mirror of https://github.com/axmolengine/axmol.git
Migrate cpp_tests shaders
This commit is contained in:
parent
9770aaa812
commit
c675e15a92
|
@ -0,0 +1,39 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
layout(location = 0) in vec4 v_fragmentColor;
|
||||
layout(location = 1) in vec2 v_texCoord;
|
||||
layout(binding = 0) uniform sampler2D u_normalMap;
|
||||
|
||||
layout(binding = 1) uniform sampler2D u_tex0;
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
float u_kBump;
|
||||
vec4 u_lightPosInLocalSpace;
|
||||
vec2 u_contentSize;
|
||||
vec3 u_diffuseL;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 texColor=texture(u_tex0, v_texCoord);
|
||||
vec3 normal=texture(u_normalMap, v_texCoord).rgb;
|
||||
normal=normal*2.0-1.0;
|
||||
normal.y=-normal.y;
|
||||
if(u_kBump!=1.0)
|
||||
{
|
||||
//if the vertex.z mult kBump, then the normal.z should div kBump and re-normalize
|
||||
normal=vec3(normal.x,normal.y,normal.z/u_kBump);
|
||||
normal=normalize(normal);
|
||||
}
|
||||
vec4 curPixelPosInLocalSpace=vec4(v_texCoord.x*u_contentSize.x,(1.0-v_texCoord.y)*u_contentSize.y,0.0,1.0);
|
||||
vec4 lightDir=normalize(curPixelPosInLocalSpace-u_lightPosInLocalSpace);
|
||||
vec3 posToLight=-lightDir.xyz;
|
||||
float normDotPosToLight=max(0.0,dot(normal,posToLight));
|
||||
vec4 diffuse=vec4(normDotPosToLight*u_diffuseL,1.0);
|
||||
vec4 ambient=vec4(0.5,0.5,0.5,1);
|
||||
FragColor=texColor*vec4(vec3(diffuse+ambient),diffuse.a);
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec3 OutLineColor;
|
||||
vec4 u_color;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
FragColor = vec4(OutLineColor,1.0) * u_color;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
#version 310 es
|
||||
layout(location = 0) in vec4 a_position;
|
||||
layout(location = 1) in vec3 a_normal;
|
||||
|
||||
layout(std140, binding = 0) uniform vs_ub {
|
||||
float OutlineWidth;
|
||||
mat4 u_MVPMatrix;
|
||||
};
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 pos = u_MVPMatrix * a_position;
|
||||
vec4 normalproj = u_MVPMatrix * vec4(a_normal, 0);
|
||||
normalproj = normalize(normalproj);
|
||||
pos.xy += normalproj.xy * (OutlineWidth * (pos.z * 0.5 + 0.5));
|
||||
|
||||
gl_Position = pos;
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
#version 310 es
|
||||
layout(location = 0) in vec3 a_position;
|
||||
layout(location = 1) in vec3 a_normal;
|
||||
layout(location = 2) in vec4 a_blendWeight;
|
||||
layout(location = 3) in vec4 a_blendIndex;
|
||||
|
||||
|
||||
const int SKINNING_JOINT_COUNT = 60;
|
||||
// Uniforms
|
||||
|
||||
// Varyings
|
||||
layout(location = 0) out vec2 TextureCoordOut;
|
||||
|
||||
layout(std140, binding = 0) uniform vs_ub {
|
||||
float OutlineWidth;
|
||||
vec4 u_matrixPalette[SKINNING_JOINT_COUNT * 3];
|
||||
mat4 u_MVPMatrix;
|
||||
};
|
||||
|
||||
vec4 SkinnedVec3(vec4 vec)
|
||||
{
|
||||
float blendWeight = a_blendWeight[0];
|
||||
|
||||
int matrixIndex = int (a_blendIndex[0]) * 3;
|
||||
vec4 matrixPalette1 = u_matrixPalette[matrixIndex] * blendWeight;
|
||||
vec4 matrixPalette2 = u_matrixPalette[matrixIndex + 1] * blendWeight;
|
||||
vec4 matrixPalette3 = u_matrixPalette[matrixIndex + 2] * blendWeight;
|
||||
|
||||
|
||||
blendWeight = a_blendWeight[1];
|
||||
if (blendWeight > 0.0)
|
||||
{
|
||||
matrixIndex = int(a_blendIndex[1]) * 3;
|
||||
matrixPalette1 += u_matrixPalette[matrixIndex] * blendWeight;
|
||||
matrixPalette2 += u_matrixPalette[matrixIndex + 1] * blendWeight;
|
||||
matrixPalette3 += u_matrixPalette[matrixIndex + 2] * blendWeight;
|
||||
}
|
||||
|
||||
|
||||
blendWeight = a_blendWeight[2];
|
||||
if (blendWeight > 0.0)
|
||||
{
|
||||
matrixIndex = int(a_blendIndex[2]) * 3;
|
||||
matrixPalette1 += u_matrixPalette[matrixIndex] * blendWeight;
|
||||
matrixPalette2 += u_matrixPalette[matrixIndex + 1] * blendWeight;
|
||||
matrixPalette3 += u_matrixPalette[matrixIndex + 2] * blendWeight;
|
||||
}
|
||||
|
||||
|
||||
blendWeight = a_blendWeight[3];
|
||||
if (blendWeight > 0.0)
|
||||
{
|
||||
matrixIndex = int(a_blendIndex[3]) * 3;
|
||||
matrixPalette1 += u_matrixPalette[matrixIndex] * blendWeight;
|
||||
matrixPalette2 += u_matrixPalette[matrixIndex + 1] * blendWeight;
|
||||
matrixPalette3 += u_matrixPalette[matrixIndex + 2] * blendWeight;
|
||||
}
|
||||
|
||||
|
||||
vec4 _skinnedPosition;
|
||||
vec4 postion = vec;
|
||||
_skinnedPosition.x = dot(postion, matrixPalette1);
|
||||
_skinnedPosition.y = dot(postion, matrixPalette2);
|
||||
_skinnedPosition.z = dot(postion, matrixPalette3);
|
||||
_skinnedPosition.w = postion.w;
|
||||
|
||||
return _skinnedPosition;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 pos = u_MVPMatrix * SkinnedVec3(vec4(a_position,1.0));
|
||||
|
||||
vec4 normalproj = u_MVPMatrix * vec4(SkinnedVec3(vec4(a_normal,0.0)).xyz, 0);
|
||||
normalproj = normalize(normalproj);
|
||||
pos.xy += normalproj.xy * (OutlineWidth * (pos.z * 0.5 + 0.5));
|
||||
|
||||
gl_Position = pos;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
layout(location = 0) in vec4 v_fragmentColor;
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = v_fragmentColor;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
#version 310 es
|
||||
layout(location = 0) in vec4 a_position;
|
||||
layout(location = 1) in vec4 a_color;
|
||||
|
||||
layout(location = 0) out vec4 v_fragmentColor;
|
||||
|
||||
|
||||
layout(std140, binding = 0) uniform vs_ub {
|
||||
mat4 u_MVPMatrix;
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_MVPMatrix * a_position;
|
||||
v_fragmentColor = a_color;
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
#define MAX_DIRECTIONAL_LIGHT_NUM 1
|
||||
|
||||
#define MAX_POINT_LIGHT_NUM 1
|
||||
|
||||
#define MAX_SPOT_LIGHT_NUM 1
|
||||
|
||||
#if (MAX_DIRECTIONAL_LIGHT_NUM > 0)
|
||||
#endif
|
||||
#if (MAX_POINT_LIGHT_NUM > 0)
|
||||
#endif
|
||||
#if (MAX_SPOT_LIGHT_NUM > 0)
|
||||
#endif
|
||||
|
||||
|
||||
layout(location = 0) in vec2 TextureCoordOut;
|
||||
#if MAX_POINT_LIGHT_NUM
|
||||
layout(location = 1) in vec3 v_vertexToPointLightDirection[MAX_POINT_LIGHT_NUM];
|
||||
#if MAX_SPOT_LIGHT_NUM
|
||||
layout(location = 2) in vec3 v_vertexToSpotLightDirection[MAX_SPOT_LIGHT_NUM];
|
||||
#endif
|
||||
#if ((MAX_DIRECTIONAL_LIGHT_NUM > 0) || (MAX_POINT_LIGHT_NUM > 0) || (MAX_SPOT_LIGHT_NUM > 0))
|
||||
layout(location = 3) in vec3 v_normal;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
layout(binding = 0) uniform sampler2D u_sampler0;
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
#if (MAX_DIRECTIONAL_LIGHT_NUM > 0)
|
||||
vec3 u_DirLightSourceColor[MAX_DIRECTIONAL_LIGHT_NUM];
|
||||
vec3 u_DirLightSourceDirection[MAX_DIRECTIONAL_LIGHT_NUM];
|
||||
#endif
|
||||
#if (MAX_POINT_LIGHT_NUM > 0)
|
||||
vec3 u_PointLightSourceColor[MAX_POINT_LIGHT_NUM];
|
||||
float u_PointLightSourceRangeInverse[MAX_POINT_LIGHT_NUM];
|
||||
#endif
|
||||
#if (MAX_SPOT_LIGHT_NUM > 0)
|
||||
vec3 u_SpotLightSourceColor[MAX_SPOT_LIGHT_NUM];
|
||||
vec3 u_SpotLightSourceDirection[MAX_SPOT_LIGHT_NUM];
|
||||
float u_SpotLightSourceInnerAngleCos[MAX_SPOT_LIGHT_NUM];
|
||||
float u_SpotLightSourceOuterAngleCos[MAX_SPOT_LIGHT_NUM];
|
||||
float u_SpotLightSourceRangeInverse[MAX_SPOT_LIGHT_NUM];
|
||||
#endif
|
||||
vec3 u_AmbientLightSourceColor;
|
||||
vec4 u_color;
|
||||
};
|
||||
|
||||
vec3 computeLighting(vec3 normalVector, vec3 lightDirection, vec3 lightColor, float attenuation)
|
||||
{
|
||||
float diffuse = max(dot(normalVector, lightDirection), 0.0);
|
||||
vec3 diffuseColor = lightColor * diffuse * attenuation;
|
||||
|
||||
return diffuseColor;
|
||||
}
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
#if ((MAX_DIRECTIONAL_LIGHT_NUM > 0) || (MAX_POINT_LIGHT_NUM > 0) || (MAX_SPOT_LIGHT_NUM > 0))
|
||||
vec3 normal = normalize(v_normal);
|
||||
#endif
|
||||
|
||||
vec4 combinedColor = vec4(u_AmbientLightSourceColor, 1.0);
|
||||
|
||||
// Directional light contribution
|
||||
#if (MAX_DIRECTIONAL_LIGHT_NUM > 0)
|
||||
for (int i = 0; i < MAX_DIRECTIONAL_LIGHT_NUM; ++i)
|
||||
{
|
||||
vec3 lightDirection = normalize(u_DirLightSourceDirection[i] * 2.0);
|
||||
combinedColor.xyz += computeLighting(normal, -lightDirection, u_DirLightSourceColor[i], 1.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Point light contribution
|
||||
#if (MAX_POINT_LIGHT_NUM > 0)
|
||||
for (int i = 0; i < MAX_POINT_LIGHT_NUM; ++i)
|
||||
{
|
||||
vec3 ldir = v_vertexToPointLightDirection[i] * u_PointLightSourceRangeInverse[i];
|
||||
float attenuation = clamp(1.0 - dot(ldir, ldir), 0.0, 1.0);
|
||||
combinedColor.xyz += computeLighting(normal, normalize(v_vertexToPointLightDirection[i]), u_PointLightSourceColor[i], attenuation);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Spot light contribution
|
||||
#if (MAX_SPOT_LIGHT_NUM > 0)
|
||||
for (int i = 0; i < MAX_SPOT_LIGHT_NUM; ++i)
|
||||
{
|
||||
// Compute range attenuation
|
||||
vec3 ldir = v_vertexToSpotLightDirection[i] * u_SpotLightSourceRangeInverse[i];
|
||||
float attenuation = clamp(1.0 - dot(ldir, ldir), 0.0, 1.0);
|
||||
vec3 vertexToSpotLightDirection = normalize(v_vertexToSpotLightDirection[i]);
|
||||
|
||||
vec3 spotLightDirection = normalize(u_SpotLightSourceDirection[i] * 2.0);
|
||||
|
||||
// "-lightDirection" is used because light direction points in opposite direction to spot direction.
|
||||
float spotCurrentAngleCos = dot(spotLightDirection, -vertexToSpotLightDirection);
|
||||
|
||||
// Apply spot attenuation
|
||||
attenuation *= smoothstep(u_SpotLightSourceOuterAngleCos[i], u_SpotLightSourceInnerAngleCos[i], spotCurrentAngleCos);
|
||||
attenuation = clamp(attenuation, 0.0, 1.0);
|
||||
combinedColor.xyz += computeLighting(normal, vertexToSpotLightDirection, u_SpotLightSourceColor[i], attenuation);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ((MAX_DIRECTIONAL_LIGHT_NUM > 0) || (MAX_POINT_LIGHT_NUM > 0) || (MAX_SPOT_LIGHT_NUM > 0))
|
||||
FragColor = texture(u_sampler0, TextureCoordOut) * u_color * combinedColor;
|
||||
#else
|
||||
FragColor = texture(u_sampler0, TextureCoordOut) * u_color;
|
||||
#endif
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
layout(location = 0) in vec2 TextureCoordOut;
|
||||
layout(binding = 0) uniform sampler2D u_sampler0;
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec4 u_color;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
FragColor = texture(u_sampler0, TextureCoordOut) * u_color;
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
layout(location = 0) in vec3 v_reflect;
|
||||
layout(binding = 0) uniform samplerCube u_cubeTex;
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec4 u_color;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
FragColor = texture(u_cubeTex, v_reflect) * u_color;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#version 310 es
|
||||
layout(location = 0) in vec4 a_position;
|
||||
layout(location = 1) in vec3 a_normal;
|
||||
|
||||
layout(location = 0) out vec3 v_reflect;
|
||||
//uniforms
|
||||
|
||||
layout(std140, binding = 0) uniform vs_ub {
|
||||
mat4 u_MVPMatrix;
|
||||
mat4 u_MVMatrix;
|
||||
mat3 u_NormalMatrix;
|
||||
};
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = u_MVPMatrix * a_position;
|
||||
|
||||
// compute reflect
|
||||
vec4 positionWorldViewSpace = u_MVMatrix * a_position;
|
||||
vec3 vEyeVertex = normalize(positionWorldViewSpace.xyz);
|
||||
|
||||
vec3 v_normalVector = u_NormalMatrix * a_normal;
|
||||
v_reflect = normalize(reflect(-vEyeVertex, v_normalVector));
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
layout(location = 0) in vec2 v_texture_coord;
|
||||
|
||||
layout(binding = 0) uniform sampler2D u_sampler0;
|
||||
layout(binding = 1) uniform sampler2D u_sampler1;
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec4 u_color;
|
||||
float offset;
|
||||
float duration;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 color = duration*vec4(0,0.8,0.4,1.0);
|
||||
//blend two texture
|
||||
FragColor = u_color*texture(u_sampler0, vec2(v_texture_coord.x- 2.0 * offset,v_texture_coord.y)) * vec4(0.3,0.3,0.3,1)+texture(u_sampler1,vec2(v_texture_coord.x-offset,v_texture_coord.y)).r*color;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
#version 310 es
|
||||
layout(location = 0) in vec4 a_position;
|
||||
layout(location = 1) in vec2 a_texCoord;
|
||||
layout(location = 0) out vec2 v_texture_coord;
|
||||
|
||||
layout(std140, binding = 0) uniform vs_ub {
|
||||
float offset;
|
||||
mat4 u_MVPMatrix;
|
||||
};
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = u_MVPMatrix * a_position;
|
||||
v_texture_coord = a_texCoord;
|
||||
v_texture_coord.y = (1.0 - v_texture_coord.y);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
layout(location = 0) in vec2 TextureCoordOut;
|
||||
|
||||
layout(binding = 0) uniform sampler2D u_tex0;
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec4 u_color;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
FragColor = texture(u_tex0, TextureCoordOut) * u_color;
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
#version 310 es
|
||||
layout(location = 0) in vec4 a_position;
|
||||
layout(location = 1) in vec2 a_texCoord;
|
||||
|
||||
layout(location = 0) out vec2 TextureCoordOut;
|
||||
|
||||
|
||||
layout(std140, binding = 0) uniform vs_ub {
|
||||
mat4 u_MVPMatrix;
|
||||
};
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = u_MVPMatrix * a_position;
|
||||
TextureCoordOut = a_texCoord;
|
||||
TextureCoordOut.y = 1.0 - TextureCoordOut.y;
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
layout(location = 0) in vec4 v_fragmentColor;
|
||||
layout(location = 1) in vec2 v_texCoord;
|
||||
|
||||
layout(binding = 0) uniform sampler2D u_tex0;
|
||||
|
||||
const float blurSize = 1.0/512.0;
|
||||
const float intensity = 0.35;
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec2 resolution;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 sum = vec4(0);
|
||||
vec2 texcoord = v_texCoord.xy;
|
||||
int j;
|
||||
int i;
|
||||
|
||||
//thank you! http://www.gamerendering.com/2008/10/11/gaussian-blur-filter-shader/ for the
|
||||
//blur tutorial
|
||||
// blur in y (vertical)
|
||||
// take nine samples, with the distance blurSize between them
|
||||
sum += texture(u_tex0, vec2(texcoord.x - 4.0*blurSize, texcoord.y)) * 0.05;
|
||||
sum += texture(u_tex0, vec2(texcoord.x - 3.0*blurSize, texcoord.y)) * 0.09;
|
||||
sum += texture(u_tex0, vec2(texcoord.x - 2.0*blurSize, texcoord.y)) * 0.12;
|
||||
sum += texture(u_tex0, vec2(texcoord.x - blurSize, texcoord.y)) * 0.15;
|
||||
sum += texture(u_tex0, vec2(texcoord.x, texcoord.y)) * 0.16;
|
||||
sum += texture(u_tex0, vec2(texcoord.x + blurSize, texcoord.y)) * 0.15;
|
||||
sum += texture(u_tex0, vec2(texcoord.x + 2.0*blurSize, texcoord.y)) * 0.12;
|
||||
sum += texture(u_tex0, vec2(texcoord.x + 3.0*blurSize, texcoord.y)) * 0.09;
|
||||
sum += texture(u_tex0, vec2(texcoord.x + 4.0*blurSize, texcoord.y)) * 0.05;
|
||||
|
||||
// blur in y (vertical)
|
||||
// take nine samples, with the distance blurSize between them
|
||||
sum += texture(u_tex0, vec2(texcoord.x, texcoord.y - 4.0*blurSize)) * 0.05;
|
||||
sum += texture(u_tex0, vec2(texcoord.x, texcoord.y - 3.0*blurSize)) * 0.09;
|
||||
sum += texture(u_tex0, vec2(texcoord.x, texcoord.y - 2.0*blurSize)) * 0.12;
|
||||
sum += texture(u_tex0, vec2(texcoord.x, texcoord.y - blurSize)) * 0.15;
|
||||
sum += texture(u_tex0, vec2(texcoord.x, texcoord.y)) * 0.16;
|
||||
sum += texture(u_tex0, vec2(texcoord.x, texcoord.y + blurSize)) * 0.15;
|
||||
sum += texture(u_tex0, vec2(texcoord.x, texcoord.y + 2.0*blurSize)) * 0.12;
|
||||
sum += texture(u_tex0, vec2(texcoord.x, texcoord.y + 3.0*blurSize)) * 0.09;
|
||||
sum += texture(u_tex0, vec2(texcoord.x, texcoord.y + 4.0*blurSize)) * 0.05;
|
||||
|
||||
//increase blur with intensity!
|
||||
FragColor = sum*intensity + texture(u_tex0, texcoord);
|
||||
return;
|
||||
/*if(sin(iGlobalTime) > 0.0)
|
||||
FragColor = sum * sin(iGlobalTime)+ texture(iChannel0, texcoord);
|
||||
else
|
||||
FragColor = sum * -sin(iGlobalTime)+ texture(iChannel0, texcoord);
|
||||
*/
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
layout(location = 0) in vec4 v_fragmentColor;
|
||||
layout(location = 1) in vec2 v_texCoord;
|
||||
|
||||
|
||||
layout(binding = 0) uniform sampler2D u_tex0;
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec2 resolution;
|
||||
float blurRadius;
|
||||
float sampleNum;
|
||||
};
|
||||
|
||||
vec4 blur(vec2);
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 col = blur(v_texCoord); //* v_fragmentColor.rgb;
|
||||
FragColor = vec4(col) * v_fragmentColor;
|
||||
}
|
||||
|
||||
vec4 blur(vec2 p)
|
||||
{
|
||||
if (blurRadius > 0.0 && sampleNum > 1.0)
|
||||
{
|
||||
vec4 col = vec4(0);
|
||||
vec2 unit = 1.0 / resolution.xy;
|
||||
|
||||
float r = blurRadius;
|
||||
float sampleStep = r / sampleNum;
|
||||
|
||||
float count = 0.0;
|
||||
|
||||
for(float x = -r; x < r; x += sampleStep)
|
||||
{
|
||||
for(float y = -r; y < r; y += sampleStep)
|
||||
{
|
||||
float weight = (r - abs(x)) * (r - abs(y));
|
||||
col += texture(u_tex0, p + vec2(x * unit.x, y * unit.y)) * weight;
|
||||
count += weight;
|
||||
}
|
||||
}
|
||||
|
||||
return col / count;
|
||||
}
|
||||
|
||||
return texture(u_tex0, p);
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
layout(location = 0) in vec4 v_fragmentColor;
|
||||
layout(location = 1) in vec2 v_texCoord;
|
||||
|
||||
|
||||
layout(binding = 0) uniform sampler2D u_tex0;
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec2 resolution;
|
||||
};
|
||||
|
||||
vec4 blur(vec2);
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 col = blur(v_texCoord); //* v_fragmentColor.rgb;
|
||||
FragColor = vec4(col) * v_fragmentColor;
|
||||
}
|
||||
|
||||
vec4 blur(vec2 p)
|
||||
{
|
||||
vec4 col = vec4(0);
|
||||
vec2 unit = 1.0 / resolution.xy;
|
||||
|
||||
float count = 0.0;
|
||||
|
||||
for(float x = -4.0; x <= 4.0; x += 2.0)
|
||||
{
|
||||
for(float y = -4.0; y <= 4.0; y += 2.0)
|
||||
{
|
||||
float weight = (4.0 - abs(x)) * (4.0 - abs(y));
|
||||
col += texture(u_tex0, p + vec2(x * unit.x, y * unit.y)) * weight;
|
||||
count += weight;
|
||||
}
|
||||
}
|
||||
|
||||
return col / count;
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
layout(location = 0) in vec4 v_fragmentColor;
|
||||
layout(location = 1) in vec2 v_texCoord;
|
||||
|
||||
|
||||
layout(binding = 0) uniform sampler2D u_tex0;
|
||||
|
||||
#define FILTER_SIZE 3
|
||||
#define COLOR_LEVELS 7.0
|
||||
#define EDGE_FILTER_SIZE 3
|
||||
#define EDGE_THRESHOLD 0.05
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec2 resolution;
|
||||
};
|
||||
|
||||
vec4 edgeFilter(in int px, in int py)
|
||||
{
|
||||
vec4 color = vec4(0.0);
|
||||
|
||||
for (int y = -EDGE_FILTER_SIZE; y <= EDGE_FILTER_SIZE; ++y)
|
||||
{
|
||||
for (int x = -EDGE_FILTER_SIZE; x <= EDGE_FILTER_SIZE; ++x)
|
||||
{
|
||||
color += texture(u_tex0, v_texCoord + vec2(px + x, py + y) / resolution.xy);
|
||||
}
|
||||
}
|
||||
|
||||
color /= float((2 * EDGE_FILTER_SIZE + 1) * (2 * EDGE_FILTER_SIZE + 1));
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
// Shade
|
||||
vec4 color = vec4(0.0);
|
||||
|
||||
for (int y = -FILTER_SIZE; y <= FILTER_SIZE; ++y)
|
||||
{
|
||||
for (int x = -FILTER_SIZE; x <= FILTER_SIZE; ++x)
|
||||
{
|
||||
color += texture(u_tex0, v_texCoord + vec2(x, y) / resolution.xy);
|
||||
}
|
||||
}
|
||||
|
||||
color /= float((2 * FILTER_SIZE + 1) * (2 * FILTER_SIZE + 1));
|
||||
|
||||
for (int c = 0; c < 3; ++c)
|
||||
{
|
||||
color[c] = floor(COLOR_LEVELS * color[c]) / COLOR_LEVELS;
|
||||
}
|
||||
|
||||
// Highlight edges
|
||||
vec4 sum = abs(edgeFilter(0, 1) - edgeFilter(0, -1));
|
||||
sum += abs(edgeFilter(1, 0) - edgeFilter(-1, 0));
|
||||
sum /= 2.0;
|
||||
|
||||
if (length(sum) > EDGE_THRESHOLD)
|
||||
{
|
||||
color.rgb = vec3(0.0);
|
||||
}
|
||||
|
||||
FragColor = color;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
// http://www.cocos2d-iphone.org
|
||||
|
||||
|
||||
layout(location = 0) in vec2 v_texCoord;
|
||||
layout(binding = 0) uniform sampler2D u_tex0;
|
||||
|
||||
vec4 getColorByCoord(int y){
|
||||
if(y < 5){
|
||||
if(y == 0){
|
||||
return vec4(1,0,0,1);
|
||||
} else if(y == 1){
|
||||
return vec4(0,1,0,1);
|
||||
} else if(y == 2){
|
||||
return vec4(0,0,1,1);
|
||||
} else if(y == 3){
|
||||
return vec4(0,1,1,1);
|
||||
} else{
|
||||
return vec4(1,0,1,1);
|
||||
}
|
||||
} else {
|
||||
if(y == 5){
|
||||
return vec4(1,1,0,1);
|
||||
} else if(y == 6){
|
||||
return vec4(1,1,1,1);
|
||||
} else if(y == 7){
|
||||
return vec4(1,0.5,0,1);
|
||||
} else if(y == 8){
|
||||
return vec4(1,0.5,0.5,1);
|
||||
}else {
|
||||
return vec4(0.5,0.5,1,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void) {
|
||||
// inline to prevent "float" loss and keep using lowp
|
||||
//int y = int( mod(( (gl_FragCoord.y+gl_FragCoord.x)*mod(AX_Time[0],5.0)) / 10.0, 10.0 ) );
|
||||
//int y = int( mod( AX_Time[3] + (gl_FragCoord.y + gl_FragCoord.x) / 10.0, 10.0 ) );
|
||||
int y = int( mod(gl_FragCoord.y / 10.0, 10.0 ) );
|
||||
FragColor = getColorByCoord(y) * texture(u_tex0, v_texCoord);
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
#version 310 es
|
||||
// http://www.cocos2d-iphone.org
|
||||
|
||||
layout(location = 0) in vec4 a_position;
|
||||
layout(location = 1) in vec2 a_texCoord;
|
||||
|
||||
layout(location = 0) out vec2 v_texCoord;
|
||||
|
||||
|
||||
layout(std140, binding = 0) uniform vs_ub {
|
||||
mat4 u_PMatrix;
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_PMatrix * a_position;
|
||||
v_texCoord = a_texCoord;
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
layout(location = 0) in vec4 v_fragmentColor;
|
||||
layout(location = 1) in vec2 v_texCoord;
|
||||
|
||||
layout(binding = 0) uniform sampler2D u_tex0;
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec2 resolution;
|
||||
};
|
||||
|
||||
float lookup(vec2 p, float dx, float dy)
|
||||
{
|
||||
vec2 uv = p.xy + vec2(dx , dy ) / resolution.xy;
|
||||
vec4 c = texture(u_tex0, uv.xy);
|
||||
return 0.2126*c.r + 0.7152*c.g + 0.0722*c.b;
|
||||
}
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 p = v_texCoord.xy;
|
||||
// simple sobel edge detection
|
||||
float gx = 0.0;
|
||||
gx += -1.0 * lookup(p, -1.0, -1.0);
|
||||
gx += -2.0 * lookup(p, -1.0, 0.0);
|
||||
gx += -1.0 * lookup(p, -1.0, 1.0);
|
||||
gx += 1.0 * lookup(p, 1.0, -1.0);
|
||||
gx += 2.0 * lookup(p, 1.0, 0.0);
|
||||
gx += 1.0 * lookup(p, 1.0, 1.0);
|
||||
|
||||
float gy = 0.0;
|
||||
gy += -1.0 * lookup(p, -1.0, -1.0);
|
||||
gy += -2.0 * lookup(p, 0.0, -1.0);
|
||||
gy += -1.0 * lookup(p, 1.0, -1.0);
|
||||
gy += 1.0 * lookup(p, -1.0, 1.0);
|
||||
gy += 2.0 * lookup(p, 0.0, 1.0);
|
||||
gy += 1.0 * lookup(p, 1.0, 1.0);
|
||||
|
||||
float g = gx*gx + gy*gy;
|
||||
|
||||
FragColor.xyz = vec3(1.-g);
|
||||
FragColor.w = 1.;
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
// Shader from http://www.iquilezles.org/apps/shadertoy/
|
||||
|
||||
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec2 center;
|
||||
vec2 resolution;
|
||||
vec2 u_screenSize;
|
||||
vec4 u_Time;
|
||||
};
|
||||
|
||||
//float u( float x ) { return 0.5+0.5*sign(x); }
|
||||
float u( float x ) { return (x>0.0)?1.0:0.0; }
|
||||
//float u( float x ) { return abs(x)/x; }
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
float time = u_Time[1];
|
||||
#ifdef METAL
|
||||
vec2 fragCoord = vec2(gl_FragCoord.x, u_screenSize.y - gl_FragCoord.y);
|
||||
#else
|
||||
vec2 fragCoord = gl_FragCoord.xy;
|
||||
#endif
|
||||
vec2 p = 2.0 * (fragCoord - center.xy) / resolution.xy;
|
||||
|
||||
float a = atan(p.x,p.y);
|
||||
float r = length(p)*.75;
|
||||
|
||||
float w = cos(3.1415927*time-r*2.0);
|
||||
float h = 0.5+0.5*cos(12.0*a-w*7.0+r*8.0);
|
||||
float d = 0.25+0.75*pow(h,1.0*r)*(0.7+0.3*w);
|
||||
|
||||
float rd = 1.0-r/d;
|
||||
float col = 0.0;
|
||||
if(rd > 0.0)
|
||||
col = u( d-r ) * sqrt(rd)*r*2.5;
|
||||
col *= 1.25+0.25*cos((12.0*a-w*7.0+r*8.0)/2.0);
|
||||
col *= 1.0 - 0.35*(0.5+0.5*sin(r*30.0))*(0.5+0.5*cos(12.0*a-w*7.0+r*8.0));
|
||||
FragColor = vec4(
|
||||
col,
|
||||
col-h*0.5+r*.2 + 0.35*h*(1.0-r),
|
||||
col-h*r + 0.1*h*(1.0-r),
|
||||
1.0);
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
layout(location = 0) in vec4 v_fragmentColor;
|
||||
layout(location = 1) in vec2 v_texCoord;
|
||||
|
||||
layout(binding = 0) uniform sampler2D u_tex0;
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 c = texture(u_tex0, v_texCoord);
|
||||
FragColor.xyz = vec3(0.2126*c.r + 0.7152*c.g + 0.0722*c.b);
|
||||
FragColor.w = c.w;
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
// Shader from http://www.iquilezles.org/apps/shadertoy/
|
||||
|
||||
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec2 center;
|
||||
vec2 resolution;
|
||||
vec2 u_screenSize;
|
||||
vec4 u_Time;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
float time = u_Time[1];
|
||||
#ifdef METAL
|
||||
vec2 fragCoord = vec2(gl_FragCoord.x, u_screenSize.y - gl_FragCoord.y);
|
||||
#else
|
||||
vec2 fragCoord = gl_FragCoord.xy;
|
||||
#endif
|
||||
vec2 p = 2.0 * (fragCoord - center.xy) / resolution.xy;
|
||||
|
||||
// animate
|
||||
float tt = mod(time,2.0)/2.0;
|
||||
float ss = pow(tt,.2)*0.5 + 0.5;
|
||||
ss -= ss*0.2*sin(tt*6.2831*5.0)*exp(-tt*6.0);
|
||||
p *= vec2(0.5,1.5) + ss*vec2(0.5,-0.5);
|
||||
|
||||
|
||||
float a = atan(p.x,p.y)/3.141593;
|
||||
float r = length(p);
|
||||
|
||||
// shape
|
||||
float h = abs(a);
|
||||
float d = (13.0*h - 22.0*h*h + 10.0*h*h*h)/(6.0-5.0*h);
|
||||
|
||||
// color
|
||||
float f = step(r,d) * pow(1.0-r/d,0.25);
|
||||
|
||||
FragColor = vec4(f,0.0,0.0,1.0);
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
// http://www.cocos2d-iphone.org
|
||||
|
||||
|
||||
layout(location = 0) in vec2 v_texCoord;
|
||||
|
||||
layout(binding = 0) uniform sampler2D u_tex0;
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec2 u_screenSize;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 optColor;
|
||||
#ifdef METAL
|
||||
float fragCoordY = u_screenSize.y - gl_FragCoord.y;
|
||||
#else
|
||||
float fragCoordY = gl_FragCoord.y;
|
||||
#endif
|
||||
int y = int( mod(fragCoordY / 3.0, 10.0 ) );
|
||||
if(y == 0) optColor = vec4(1,0,0,1);
|
||||
else if(y == 1) optColor = vec4(0,1,0,1);
|
||||
else if(y == 2) optColor = vec4(0,0,1,1);
|
||||
else if(y == 3) optColor = vec4(0,1,1,1);
|
||||
else if(y == 4) optColor = vec4(1,0,1,1);
|
||||
else if(y == 5) optColor = vec4(1,1,0,1);
|
||||
else if(y == 6) optColor = vec4(1,1,1,1);
|
||||
else if(y == 7) optColor = vec4(1,0.5,0,1);
|
||||
else if(y == 8) optColor = vec4(1,0.5,0.5,1);
|
||||
else if(y == 9) optColor = vec4(0.5,0.5,1,1);
|
||||
|
||||
// inline to prevent "float" loss and keep using lowp
|
||||
FragColor = optColor * texture(u_tex0, v_texCoord);
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
// Shader from http://www.iquilezles.org/apps/shadertoy/
|
||||
|
||||
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec2 center;
|
||||
vec2 resolution;
|
||||
vec2 u_screenSize;
|
||||
vec4 u_Time;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
float time = u_Time[1];
|
||||
#ifdef METAL
|
||||
vec2 fragCoord = vec2(gl_FragCoord.x, u_screenSize.y - gl_FragCoord.y);
|
||||
#else
|
||||
vec2 fragCoord = gl_FragCoord.xy;
|
||||
#endif
|
||||
vec2 p = 2.0 * (fragCoord - center.xy) / resolution.xy;
|
||||
vec2 cc = vec2( cos(.25*time), sin(.25*time*1.423) );
|
||||
|
||||
float dmin = 1000.0;
|
||||
vec2 z = p*vec2(1.33,1.0);
|
||||
for( int i=0; i<64; i++ )
|
||||
{
|
||||
z = cc + vec2( z.x*z.x - z.y*z.y, 2.0*z.x*z.y );
|
||||
float m2 = dot(z,z);
|
||||
if( m2>100.0 ) break;
|
||||
dmin=min(dmin,m2);
|
||||
}
|
||||
|
||||
float color = sqrt(sqrt(dmin))*0.7;
|
||||
FragColor = vec4(color,color,color,1.0);
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
layout(location = 0) in vec4 v_fragmentColor;
|
||||
layout(location = 1) in vec2 v_texCoord;
|
||||
|
||||
|
||||
|
||||
layout(binding = 0) uniform sampler2D u_tex0;
|
||||
|
||||
/*by musk License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
|
||||
|
||||
Trying to get some interesting looking lens flares.
|
||||
|
||||
13/08/13:
|
||||
published
|
||||
|
||||
muuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuusk!*/
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec2 resolution;
|
||||
vec2 textureResolution;
|
||||
vec4 u_Time;
|
||||
};
|
||||
|
||||
float noise(float t)
|
||||
{
|
||||
return texture(u_tex0,vec2(t,.0)/textureResolution.xy).x;
|
||||
}
|
||||
float noise(vec2 t)
|
||||
{
|
||||
return texture(u_tex0,t/textureResolution.xy).x;
|
||||
}
|
||||
|
||||
vec3 lensflare(vec2 uv,vec2 pos)
|
||||
{
|
||||
vec2 main = uv-pos;
|
||||
vec2 uvd = uv*(length(uv));
|
||||
|
||||
float ang = atan(main.x,main.y);
|
||||
float dist=length(main); dist = pow(dist,.1);
|
||||
float n = noise(vec2(ang*16.0,dist*32.0));
|
||||
|
||||
float f0 = 1.0/(length(uv-pos)*16.0+1.0);
|
||||
|
||||
f0 = f0+f0*(sin(noise((pos.x+pos.y)*2.2+ang*4.0+5.954)*16.0)*.1+dist*.1+.8);
|
||||
|
||||
float f1 = max(0.01-pow(length(uv+1.2*pos),1.9),.0)*7.0;
|
||||
|
||||
float f2 = max(1.0/(1.0+32.0*pow(length(uvd+0.8*pos),2.0)),.0)*00.25;
|
||||
float f22 = max(1.0/(1.0+32.0*pow(length(uvd+0.85*pos),2.0)),.0)*00.23;
|
||||
float f23 = max(1.0/(1.0+32.0*pow(length(uvd+0.9*pos),2.0)),.0)*00.21;
|
||||
|
||||
vec2 uvx = mix(uv,uvd,-0.5);
|
||||
|
||||
float f4 = max(0.01-pow(length(uvx+0.4*pos),2.4),.0)*6.0;
|
||||
float f42 = max(0.01-pow(length(uvx+0.45*pos),2.4),.0)*5.0;
|
||||
float f43 = max(0.01-pow(length(uvx+0.5*pos),2.4),.0)*3.0;
|
||||
|
||||
uvx = mix(uv,uvd,-.4);
|
||||
|
||||
float f5 = max(0.01-pow(length(uvx+0.2*pos),5.5),.0)*2.0;
|
||||
float f52 = max(0.01-pow(length(uvx+0.4*pos),5.5),.0)*2.0;
|
||||
float f53 = max(0.01-pow(length(uvx+0.6*pos),5.5),.0)*2.0;
|
||||
|
||||
uvx = mix(uv,uvd,-0.5);
|
||||
|
||||
float f6 = max(0.01-pow(length(uvx-0.3*pos),1.6),.0)*6.0;
|
||||
float f62 = max(0.01-pow(length(uvx-0.325*pos),1.6),.0)*3.0;
|
||||
float f63 = max(0.01-pow(length(uvx-0.35*pos),1.6),.0)*5.0;
|
||||
|
||||
vec3 c = vec3(.0);
|
||||
|
||||
c.r+=f2+f4+f5+f6; c.g+=f22+f42+f52+f62; c.b+=f23+f43+f53+f63;
|
||||
c = c*1.3 - vec3(length(uvd)*.05);
|
||||
c+=vec3(f0);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
vec3 cc(vec3 color, float factor,float factor2) // color modifier
|
||||
{
|
||||
float w = color.x+color.y+color.z;
|
||||
return mix(color,vec3(w)*factor,w*factor2);
|
||||
}
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 uv = v_texCoord - 0.5;
|
||||
uv.x *= resolution.x/resolution.y; //fix aspect ratio
|
||||
// vec3 mouse = vec3(iMouse.xy/iResolution.xy - 0.5,iMouse.z-.5);
|
||||
// mouse.x *= iResolution.x/iResolution.y; //fix aspect ratio
|
||||
// if (iMouse.z<.5)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
vec3 mouse;
|
||||
mouse.z = 0.5;
|
||||
mouse.x=sin(u_Time[1])*.5;
|
||||
mouse.y=sin(u_Time[1]*.913)*.5;
|
||||
|
||||
vec3 color = vec3(1.4,1.2,1.0)*lensflare(uv,mouse.xy);
|
||||
color -= noise(v_texCoord * resolution)*.015;
|
||||
color = cc(color,.5,.1);
|
||||
FragColor = vec4(color,1.0);
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
// Shader from http://www.iquilezles.org/apps/shadertoy/
|
||||
|
||||
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec2 center;
|
||||
vec2 resolution;
|
||||
vec2 u_screenSize;
|
||||
vec4 u_Time;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
#ifdef METAL
|
||||
vec2 fragCoord = vec2(gl_FragCoord.x, u_screenSize.y - gl_FragCoord.y);
|
||||
#else
|
||||
vec2 fragCoord = gl_FragCoord.xy;
|
||||
#endif
|
||||
vec2 p = 2.0 * (fragCoord - center.xy) / resolution.xy;
|
||||
p.x *= resolution.x/resolution.y;
|
||||
|
||||
float zoo = .62+.38*sin(.1*u_Time[1]);
|
||||
float coa = cos( 0.1*(1.0-zoo)*u_Time[1] );
|
||||
float sia = sin( 0.1*(1.0-zoo)*u_Time[1] );
|
||||
zoo = pow( zoo,8.0);
|
||||
vec2 xy = vec2( p.x*coa-p.y*sia, p.x*sia+p.y*coa);
|
||||
vec2 cc = vec2(-.745,.186) + xy*zoo;
|
||||
|
||||
vec2 z = vec2(0.0);
|
||||
vec2 z2 = z*z;
|
||||
float m2;
|
||||
float co = 0.0;
|
||||
|
||||
for( int i=0; i<256; i++ )
|
||||
{
|
||||
z = cc + vec2( z.x*z.x - z.y*z.y, 2.0*z.x*z.y );
|
||||
m2 = dot(z,z);
|
||||
if( m2>1024.0 ) break;
|
||||
co += 1.0;
|
||||
}
|
||||
co = co + 1.0 - log2(.5*log2(m2));
|
||||
|
||||
co = sqrt(co/256.0);
|
||||
FragColor = vec4( .5+.5*cos(6.2831*co+0.0),
|
||||
.5+.5*cos(6.2831*co+0.4),
|
||||
.5+.5*cos(6.2831*co+0.7),
|
||||
1.0 );
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
// Shader from http://www.iquilezles.org/apps/shadertoy/
|
||||
|
||||
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec2 center;
|
||||
vec2 resolution;
|
||||
vec4 u_Time;
|
||||
vec2 u_screenSize;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
#ifdef METAL
|
||||
vec2 fragCoord = vec2(gl_FragCoord.x, u_screenSize.y - gl_FragCoord.y);
|
||||
#else
|
||||
vec2 fragCoord = gl_FragCoord.xy;
|
||||
#endif
|
||||
vec2 p = 2.0 * (fragCoord - center.xy) / resolution.xy;
|
||||
float a = u_Time[1]*40.0;
|
||||
float d,e,f,g=1.0/40.0,h,i,r,q;
|
||||
e=400.0*(p.x*0.5+0.5);
|
||||
f=400.0*(p.y*0.5+0.5);
|
||||
i=200.0+sin(e*g+a/150.0)*20.0;
|
||||
d=200.0+cos(f*g/2.0)*18.0+cos(e*g)*7.0;
|
||||
r=sqrt(pow(i-e,2.0)+pow(d-f,2.0));
|
||||
q=f/r;
|
||||
e=(r*cos(q))-a/2.0;f=(r*sin(q))-a/2.0;
|
||||
d=sin(e*g)*176.0+sin(e*g)*164.0+r;
|
||||
h=((f+d)+a/2.0)*g;
|
||||
i=cos(h+r*p.x/1.3)*(e+e+a)+cos(q*g*6.0)*(r+h/3.0);
|
||||
h=sin(f*g)*144.0-sin(e*g)*212.0*p.x;
|
||||
h=(h+(f-e)*q+sin(r-(a+h)/7.0)*10.0+i/4.0)*g;
|
||||
i+=cos(h*2.3*sin(a/350.0-q))*184.0*sin(q-(r*4.3+a/12.0)*g)+tan(r*g+h)*184.0*cos(r*g+h);
|
||||
i=mod(i/5.6,256.0)/64.0;
|
||||
if(i<0.0) i+=4.0;
|
||||
if(i>=2.0) i=4.0-i;
|
||||
d=r/350.0;
|
||||
d+=sin(d*d*8.0)*0.52;
|
||||
f=(sin(a*g)+1.0)/2.0;
|
||||
FragColor=vec4(vec3(f*i/1.6,i/2.0+d/13.0,i)*d*p.x+vec3(i/1.3+d/8.0,i/2.0+d/18.0,i)*d*(1.0-p.x),1.0);
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
|
||||
layout(location = 0) in vec4 v_fragmentColor;
|
||||
layout(location = 1) in vec2 v_texCoord;
|
||||
|
||||
layout(binding = 0) uniform sampler2D u_tex0;
|
||||
layout(binding = 1) uniform sampler2D u_tex1;
|
||||
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
float u_interpolate;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main() {
|
||||
vec4 color1 = texture(u_tex0, v_texCoord);
|
||||
vec4 color2 = texture(u_tex1, v_texCoord);
|
||||
FragColor = v_fragmentColor * mix( color1, color2, u_interpolate);
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
#version 310 es
|
||||
|
||||
layout(location = 0) in vec4 a_position;
|
||||
layout(location = 1) in vec2 a_texCoord;
|
||||
layout(location = 2) in vec4 a_color;
|
||||
|
||||
layout(location = 0) out vec4 v_fragmentColor;
|
||||
layout(location = 1) out vec2 v_texCoord;
|
||||
|
||||
|
||||
layout(std140, binding = 0) uniform vs_ub {
|
||||
mat4 u_MVPMatrix;
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_MVPMatrix * a_position;
|
||||
v_fragmentColor = a_color;
|
||||
v_texCoord = a_texCoord;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
// Shader taken from: http://webglsamples.googlecode.com/hg/electricflower/electricflower.html
|
||||
|
||||
|
||||
layout(location = 0) in vec4 v_fragmentColor;
|
||||
layout(location = 1) in vec2 v_texCoord;
|
||||
|
||||
layout(binding = 0) uniform sampler2D u_tex0;
|
||||
|
||||
const float intensity = 0.05;
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec2 resolution;
|
||||
vec4 u_Time;
|
||||
vec2 u_screenSize;
|
||||
};
|
||||
|
||||
vec3 noise(vec2 uv)
|
||||
{
|
||||
vec2 p = abs(sin(uv * 13.0 + uv.x * u_Time[1] * sin(uv.y)));
|
||||
|
||||
return vec3(sin (0.2 * u_Time[1] + sin(p * 0.5) * u_Time[1] / cos(50.0)) * 10.0,0.3+0.5 * abs(sin(u_Time[1] * tan(5.0))));
|
||||
|
||||
}
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
#ifdef METAL
|
||||
vec2 fragCoord = vec2(gl_FragCoord.x, u_screenSize.y - gl_FragCoord.y);
|
||||
#else
|
||||
vec2 fragCoord = gl_FragCoord.xy;
|
||||
#endif
|
||||
FragColor.xyz = intensity * noise(fragCoord / sin(resolution.xy * u_Time[1] * 0.01)) + (1. - intensity) *
|
||||
texture(u_tex0,v_texCoord.xy).xyz;
|
||||
FragColor.w = 1.;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
layout(location = 0) in vec4 v_fragmentColor;
|
||||
layout(location = 1) in vec2 v_texCoord;
|
||||
|
||||
layout(binding = 0) uniform sampler2D u_tex0;
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
FragColor = texture(u_tex0, v_texCoord);
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
/*
|
||||
Created by guanghui on 4/8/14.
|
||||
http://www.idevgames.com/forums/thread-3010.html
|
||||
*/
|
||||
|
||||
layout(location = 0) in vec2 v_texCoord;
|
||||
layout(location = 1) in vec4 v_fragmentColor;
|
||||
|
||||
|
||||
layout(binding = 0) uniform sampler2D u_tex0;
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec3 u_outlineColor;
|
||||
float u_threshold;
|
||||
float u_radius;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
float radius = u_radius;
|
||||
vec4 accum = vec4(0.0);
|
||||
vec4 normal = vec4(0.0);
|
||||
|
||||
normal = texture(u_tex0, vec2(v_texCoord.x, v_texCoord.y));
|
||||
|
||||
accum += texture(u_tex0, vec2(v_texCoord.x - radius, v_texCoord.y - radius));
|
||||
accum += texture(u_tex0, vec2(v_texCoord.x + radius, v_texCoord.y - radius));
|
||||
accum += texture(u_tex0, vec2(v_texCoord.x + radius, v_texCoord.y + radius));
|
||||
accum += texture(u_tex0, vec2(v_texCoord.x - radius, v_texCoord.y + radius));
|
||||
|
||||
accum *= u_threshold;
|
||||
accum.rgb = u_outlineColor * accum.a;
|
||||
accum.a = 1.0;
|
||||
|
||||
normal = ( accum * (1.0 - normal.a)) + (normal * normal.a);
|
||||
|
||||
FragColor = v_fragmentColor * normal;
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
// Shader from http://www.iquilezles.org/apps/shadertoy/
|
||||
|
||||
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec2 center;
|
||||
vec2 resolution;
|
||||
vec2 u_screenSize;
|
||||
vec4 u_Time;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
#ifdef METAL
|
||||
float fragCoordY = u_screenSize.y - gl_FragCoord.y;
|
||||
#else
|
||||
float fragCoordY = gl_FragCoord.y;
|
||||
#endif
|
||||
float time = u_Time[1];
|
||||
float x = gl_FragCoord.x - (center.x - resolution.x / 2.0);
|
||||
float y = fragCoordY - (center.y - resolution.y / 2.0);
|
||||
float mov0 = x+y+cos(sin(time)*2.)*100.+sin(x/100.)*1000.;
|
||||
float mov1 = y / resolution.y / 0.2 + time;
|
||||
float mov2 = x / resolution.x / 0.2;
|
||||
float c1 = abs(sin(mov1+time)/2.+mov2/2.-mov1-mov2+time);
|
||||
float c2 = abs(sin(c1+sin(mov0/1000.+time)+sin(y/40.+time)+sin((x+y)/100.)*3.));
|
||||
float c3 = abs(sin(c2+cos(mov1+mov2+c2)+cos(mov2)+sin(x/1000.)));
|
||||
FragColor = vec4( c1,c2,c3,1.0);
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
layout(location = 0) in vec4 v_fragmentColor;
|
||||
layout(location = 1) in vec2 v_texCoord;
|
||||
|
||||
layout(binding = 0) uniform sampler2D u_tex0;
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 c = texture(u_tex0, v_texCoord);
|
||||
vec4 final = c;
|
||||
final.r = (c.r * 0.393) + (c.g * 0.769) + (c.b * 0.189);
|
||||
final.g = (c.r * 0.349) + (c.g * 0.686) + (c.b * 0.168);
|
||||
final.b = (c.r * 0.272) + (c.g * 0.534) + (c.b * 0.131);
|
||||
|
||||
FragColor = final;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
#version 310 es
|
||||
layout(location = 0) in vec4 a_position;
|
||||
layout(location = 1) in vec2 a_texCoord;
|
||||
layout(location = 2) in vec4 a_color;
|
||||
|
||||
layout(location = 0) out vec4 v_fragmentColor;
|
||||
layout(location = 1) out vec2 v_texCoord;
|
||||
|
||||
|
||||
layout(std140, binding = 0) uniform vs_ub {
|
||||
mat4 u_MVPMatrix;
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_MVPMatrix * a_position;
|
||||
v_fragmentColor = a_color;
|
||||
v_texCoord = a_texCoord;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
// Shader from here: http://www.iquilezles.org/
|
||||
|
||||
|
||||
layout(binding = 0) uniform sampler2D tex0;
|
||||
layout(binding = 1) uniform sampler2D tex1;
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec2 resolution;
|
||||
vec2 u_screenSize;
|
||||
vec4 u_Time;
|
||||
vec4 u_CosTime;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
#ifdef METAL
|
||||
vec2 fragCoord = vec2(gl_FragCoord.x, u_screenSize.y - gl_FragCoord.y);
|
||||
#else
|
||||
vec2 fragCoord = gl_FragCoord.xy;
|
||||
#endif
|
||||
float time = u_Time[1];
|
||||
vec2 p = -1.0 + 2.0 * fragCoord / resolution.xy;
|
||||
vec2 uv;
|
||||
|
||||
float a = atan(p.y,p.x);
|
||||
float r = sqrt(dot(p,p));
|
||||
|
||||
uv.x = r - u_Time[2];
|
||||
uv.y = sin(a*10.0 + 2.0)*u_CosTime[0];
|
||||
|
||||
vec3 col = (.5+.5*uv.y)*texture(tex0,uv).xyz;
|
||||
|
||||
FragColor = vec4(col,1.0);
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
layout(location = 0) in vec2 v_texture_coord;
|
||||
layout(location = 1) in float v_fogFactor;
|
||||
|
||||
|
||||
layout(binding = 0) uniform sampler2D u_tex0;
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec4 u_fogColor;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main (void)
|
||||
{
|
||||
vec4 finalColor = texture(u_tex0, v_texture_coord);
|
||||
FragColor = mix(u_fogColor, finalColor, v_fogFactor ); //out put finalColor
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
#version 310 es
|
||||
layout(location = 0) in vec4 a_position;
|
||||
layout(location = 1) in vec2 a_texCoord;
|
||||
layout(location = 0) out float v_fogFactor; //weight for fog
|
||||
layout(location = 1) out vec2 v_texture_coord;
|
||||
|
||||
|
||||
|
||||
layout(std140, binding = 0) uniform vs_ub {
|
||||
float u_fogDensity;// For exp and exp2 equation
|
||||
float u_fogStart; // This is only for linear fog
|
||||
float u_fogEnd; // This is only for linear fog
|
||||
int u_fogEquation; // 0 = linear, 1 = exp, 2 = exp2
|
||||
mat4 u_MVPMatrix;
|
||||
};
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = u_MVPMatrix * a_position;
|
||||
v_texture_coord = a_texCoord;
|
||||
|
||||
float fogFragCoord = abs(gl_Position.z); //get fog distance
|
||||
|
||||
|
||||
if(u_fogEquation == 0)
|
||||
v_fogFactor = (u_fogEnd-fogFragCoord )/(u_fogEnd-u_fogStart); //linear fog
|
||||
else if(u_fogEquation == 1)
|
||||
v_fogFactor = exp(-u_fogDensity*fogFragCoord ); //exp fog
|
||||
else if(u_fogEquation == 2)
|
||||
v_fogFactor = exp(-pow(u_fogDensity*fogFragCoord , 2.0)); //exp2 fog
|
||||
|
||||
|
||||
v_fogFactor = clamp(v_fogFactor, 0.0, 1.0); //clamp 0 to 1
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
#version 310 es
|
||||
|
||||
#define MAX_POINT_LIGHT_NUM 1
|
||||
#define MAX_SPOT_LIGHT_NUM 1
|
||||
#define MAX_DIRECTIONAL_LIGHT_NUM 1
|
||||
|
||||
#if (MAX_POINT_LIGHT_NUM > 0)
|
||||
#endif
|
||||
#if (MAX_SPOT_LIGHT_NUM > 0)
|
||||
#endif
|
||||
|
||||
layout(location = 0) in vec4 a_position;
|
||||
layout(location = 1) in vec2 a_texCoord;
|
||||
layout(location = 2) in vec3 a_normal;
|
||||
layout(location = 0) out vec2 TextureCoordOut;
|
||||
|
||||
#if MAX_POINT_LIGHT_NUM
|
||||
layout(location = 1) out vec3 v_vertexToPointLightDirection[MAX_POINT_LIGHT_NUM];
|
||||
#endif
|
||||
#if MAX_SPOT_LIGHT_NUM
|
||||
layout(location = 2) out vec3 v_vertexToSpotLightDirection[MAX_SPOT_LIGHT_NUM];
|
||||
#endif
|
||||
#if ((MAX_DIRECTIONAL_LIGHT_NUM > 0) || (MAX_POINT_LIGHT_NUM > 0) || (MAX_SPOT_LIGHT_NUM > 0))
|
||||
layout(location = 3) out vec3 v_normal;
|
||||
#endif
|
||||
|
||||
layout(std140, binding = 0) uniform vs_ub {
|
||||
#if (MAX_POINT_LIGHT_NUM > 0)
|
||||
vec3 u_PointLightSourcePosition[MAX_POINT_LIGHT_NUM];
|
||||
#endif
|
||||
#if (MAX_SPOT_LIGHT_NUM > 0)
|
||||
vec3 u_SpotLightSourcePosition[MAX_SPOT_LIGHT_NUM];
|
||||
#endif
|
||||
mat4 u_MVMatrix;
|
||||
mat4 u_PMatrix;
|
||||
mat3 u_NormalMatrix;
|
||||
};
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 ePosition = u_MVMatrix * a_position;
|
||||
#if (MAX_POINT_LIGHT_NUM > 0)
|
||||
for (int i = 0; i < MAX_POINT_LIGHT_NUM; ++i)
|
||||
{
|
||||
v_vertexToPointLightDirection[i] = u_PointLightSourcePosition[i].xyz - ePosition.xyz;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (MAX_SPOT_LIGHT_NUM > 0)
|
||||
for (int i = 0; i < MAX_SPOT_LIGHT_NUM; ++i)
|
||||
{
|
||||
v_vertexToSpotLightDirection[i] = u_SpotLightSourcePosition[i] - ePosition.xyz;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ((MAX_DIRECTIONAL_LIGHT_NUM > 0) || (MAX_POINT_LIGHT_NUM > 0) || (MAX_SPOT_LIGHT_NUM > 0))
|
||||
v_normal = u_NormalMatrix * a_normal;
|
||||
#endif
|
||||
|
||||
TextureCoordOut = a_texCoord;
|
||||
TextureCoordOut.y = 1.0 - TextureCoordOut.y;
|
||||
gl_Position = u_PMatrix * ePosition;
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
#version 310 es
|
||||
layout(location = 0) in vec3 a_position;
|
||||
|
||||
layout(location = 1) in vec4 a_blendWeight;
|
||||
layout(location = 2) in vec4 a_blendIndex;
|
||||
|
||||
layout(location = 3) in vec2 a_texCoord;
|
||||
|
||||
const int SKINNING_JOINT_COUNT = 60;
|
||||
// Uniforms
|
||||
|
||||
// Varyings
|
||||
layout(location = 0) out vec2 TextureCoordOut;
|
||||
|
||||
layout(std140, binding = 0) uniform vs_ub {
|
||||
vec4 u_matrixPalette[SKINNING_JOINT_COUNT * 3];
|
||||
mat4 u_MVPMatrix;
|
||||
};
|
||||
|
||||
vec4 getPosition()
|
||||
{
|
||||
float blendWeight = a_blendWeight[0];
|
||||
|
||||
int matrixIndex = int (a_blendIndex[0]) * 3;
|
||||
vec4 matrixPalette1 = u_matrixPalette[matrixIndex] * blendWeight;
|
||||
vec4 matrixPalette2 = u_matrixPalette[matrixIndex + 1] * blendWeight;
|
||||
vec4 matrixPalette3 = u_matrixPalette[matrixIndex + 2] * blendWeight;
|
||||
|
||||
|
||||
blendWeight = a_blendWeight[1];
|
||||
if (blendWeight > 0.0)
|
||||
{
|
||||
matrixIndex = int(a_blendIndex[1]) * 3;
|
||||
matrixPalette1 += u_matrixPalette[matrixIndex] * blendWeight;
|
||||
matrixPalette2 += u_matrixPalette[matrixIndex + 1] * blendWeight;
|
||||
matrixPalette3 += u_matrixPalette[matrixIndex + 2] * blendWeight;
|
||||
|
||||
blendWeight = a_blendWeight[2];
|
||||
if (blendWeight > 0.0)
|
||||
{
|
||||
matrixIndex = int(a_blendIndex[2]) * 3;
|
||||
matrixPalette1 += u_matrixPalette[matrixIndex] * blendWeight;
|
||||
matrixPalette2 += u_matrixPalette[matrixIndex + 1] * blendWeight;
|
||||
matrixPalette3 += u_matrixPalette[matrixIndex + 2] * blendWeight;
|
||||
|
||||
blendWeight = a_blendWeight[3];
|
||||
if (blendWeight > 0.0)
|
||||
{
|
||||
matrixIndex = int(a_blendIndex[3]) * 3;
|
||||
matrixPalette1 += u_matrixPalette[matrixIndex] * blendWeight;
|
||||
matrixPalette2 += u_matrixPalette[matrixIndex + 1] * blendWeight;
|
||||
matrixPalette3 += u_matrixPalette[matrixIndex + 2] * blendWeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vec4 _skinnedPosition;
|
||||
vec4 postion = vec4(a_position, 1.0);
|
||||
_skinnedPosition.x = dot(postion, matrixPalette1);
|
||||
_skinnedPosition.y = dot(postion, matrixPalette2);
|
||||
_skinnedPosition.z = dot(postion, matrixPalette3);
|
||||
_skinnedPosition.w = postion.w;
|
||||
|
||||
return _skinnedPosition;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 position = getPosition();
|
||||
gl_Position = u_MVPMatrix * position;
|
||||
|
||||
TextureCoordOut = a_texCoord;
|
||||
TextureCoordOut.y = 1.0 - TextureCoordOut.y;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
#version 310 es
|
||||
|
||||
|
||||
layout(location = 0) in vec4 a_position;
|
||||
layout(location = 1) in vec2 a_texCoord;
|
||||
|
||||
layout(location = 0) out vec2 TextureCoordOut;
|
||||
|
||||
layout(std140, binding = 0) uniform vs_ub {
|
||||
mat4 u_MVPMatrix;
|
||||
};
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = u_MVPMatrix * a_position;
|
||||
TextureCoordOut = a_texCoord;
|
||||
TextureCoordOut.y = 1.0 - TextureCoordOut.y;
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
|
||||
//vec2 iCenter = center;
|
||||
//uniform float iChannelTime[4]; // channel playback time (in seconds)
|
||||
//uniform vec3 iChannelResolution[4]; // channel resolution (in pixels)
|
||||
vec4 iMouse = vec4(0,0,0,0); // mouse pixel coords. xy: current (if MLB down),
|
||||
|
||||
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec2 center;
|
||||
vec2 resolution;
|
||||
vec2 u_screenSize;
|
||||
vec4 u_Time;
|
||||
};
|
||||
|
||||
float snoise(vec3 uv, float res)
|
||||
{
|
||||
const vec3 s = vec3(1e0, 1e2, 1e4);
|
||||
|
||||
uv *= res;
|
||||
|
||||
vec3 uv0 = floor(mod(uv, res))*s;
|
||||
vec3 uv1 = floor(mod(uv+vec3(1.), res))*s;
|
||||
|
||||
vec3 f = fract(uv); f = f*f*(3.0-2.0*f);
|
||||
|
||||
vec4 v = vec4(uv0.x+uv0.y+uv0.z, uv1.x+uv0.y+uv0.z,
|
||||
uv0.x+uv1.y+uv0.z, uv1.x+uv1.y+uv0.z);
|
||||
|
||||
vec4 r = fract(sin(v*1e-3)*1e5);
|
||||
float r0 = mix(mix(r.x, r.y, f.x), mix(r.z, r.w, f.x), f.y);
|
||||
|
||||
r = fract(sin((v + uv1.z - uv0.z)*1e-3)*1e5);
|
||||
float r1 = mix(mix(r.x, r.y, f.x), mix(r.z, r.w, f.x), f.y);
|
||||
|
||||
return mix(r0, r1, f.z)*2.-1.;
|
||||
}
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
#ifdef METAL
|
||||
vec2 fragCoord = vec2(gl_FragCoord.x, u_screenSize.y - gl_FragCoord.y);
|
||||
#else
|
||||
vec2 fragCoord = gl_FragCoord.xy;
|
||||
#endif
|
||||
vec2 iResolution = resolution; // viewport resolution (in pixels)
|
||||
float iGlobalTime = u_Time[1]; // shader playback time (in seconds)
|
||||
|
||||
//vec2 p = -.5 + fragCoord.xy / iResolution.xy;
|
||||
|
||||
vec2 p = (fragCoord.xy - center.xy) / iResolution.xy;
|
||||
p.x *= iResolution.x/iResolution.y;
|
||||
|
||||
float color = 3.0 - (3.*length(2.*p));
|
||||
|
||||
vec3 coord = vec3(atan(p.x,p.y)/6.2832+.5, length(p)*.4, .5);
|
||||
|
||||
for(int i = 1; i <= 3; i++)
|
||||
{
|
||||
float power = pow(2.0, float(i));
|
||||
color += (1.5 / power) * snoise(coord + vec3(0.,-iGlobalTime*.05, iGlobalTime*.01), power*16.);
|
||||
}
|
||||
FragColor = vec4( color, pow(max(color,0.),2.)*0.4, pow(max(color,0.),3.)*0.15 , 1.0);
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
|
||||
//uniform float iChannelTime[4]; // channel playback time (in seconds)
|
||||
//uniform vec3 iChannelResolution[4]; // channel resolution (in pixels)
|
||||
vec4 iMouse = vec4(0,0,0,0); // mouse pixel coords. xy: current (if MLB down), zw: click
|
||||
layout(binding = 0) //uniform sampler2D iChannel0; // input channel. XX = 2D/Cube
|
||||
|
||||
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec2 center;
|
||||
vec2 resolution;
|
||||
vec2 u_screenSize;
|
||||
vec4 u_Time;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
#ifdef METAL
|
||||
vec2 fragCoord = vec2(gl_FragCoord.x, u_screenSize.y - gl_FragCoord.y);
|
||||
#else
|
||||
vec2 fragCoord = gl_FragCoord.xy;
|
||||
#endif
|
||||
vec2 iResolution = resolution; // viewport resolution (in pixels)
|
||||
float iGlobalTime = u_Time[1]; // shader playback time (in seconds)
|
||||
|
||||
float pointRadius = 0.06;
|
||||
float linkSize = 0.04;
|
||||
float noiseStrength = 0.08; // range: 0-1
|
||||
|
||||
float minDimension = min(iResolution.x, iResolution.y);
|
||||
vec2 bounds = vec2(iResolution.x / minDimension, iResolution.y / minDimension);
|
||||
//vec2 uv = fragCoord.xy / minDimension;
|
||||
vec2 uv = (2. * fragCoord.xy - center.xy) / iResolution.xy;
|
||||
|
||||
vec3 pointR = vec3(0.0, 0.0, 1.0);
|
||||
vec3 pointG = vec3(0.0, 0.0, 1.0);
|
||||
vec3 pointB = vec3(0.0, 0.0, 1.0);
|
||||
|
||||
// Make the points orbit round the origin in 3 dimensions.
|
||||
// Coefficients are arbitrary to give different behaviours.
|
||||
// The Z coordinate should always be >0.0, as it's used directly to
|
||||
// multiply the radius to give the impression of depth.
|
||||
pointR.x += 0.32 * sin(1.32 * iGlobalTime);
|
||||
pointR.y += 0.3 * sin(1.03 * iGlobalTime);
|
||||
pointR.z += 0.4 * sin(1.32 * iGlobalTime);
|
||||
|
||||
pointG.x += 0.31 * sin(0.92 * iGlobalTime);
|
||||
pointG.y += 0.29 * sin(0.99 * iGlobalTime);
|
||||
pointG.z += 0.38 * sin(1.24 * iGlobalTime);
|
||||
|
||||
pointB.x += 0.33 * sin(1.245 * iGlobalTime);
|
||||
pointB.y += 0.3 * sin(1.41 * iGlobalTime);
|
||||
pointB.z += 0.41 * sin(1.11 * iGlobalTime);
|
||||
|
||||
// Centre the points in the display
|
||||
vec2 midUV = vec2(bounds.x * 0.5, bounds.y * 0.5);
|
||||
pointR.xy += midUV;
|
||||
pointG.xy += midUV;
|
||||
pointB.xy += midUV;
|
||||
|
||||
// Calculate the vectors from the current fragment to the coloured points
|
||||
vec2 vecToR = pointR.xy - uv;
|
||||
vec2 vecToG = pointG.xy - uv;
|
||||
vec2 vecToB = pointB.xy - uv;
|
||||
|
||||
vec2 dirToR = normalize(vecToR.xy);
|
||||
vec2 dirToG = normalize(vecToG.xy);
|
||||
vec2 dirToB = normalize(vecToB.xy);
|
||||
|
||||
float distToR = length(vecToR);
|
||||
float distToG = length(vecToG);
|
||||
float distToB = length(vecToB);
|
||||
|
||||
// Calculate the dot product between vectors from the current fragment to each pair
|
||||
// of adjacent coloured points. This helps us determine how close the current fragment
|
||||
// is to a link between points.
|
||||
float dotRG = dot(dirToR, dirToG);
|
||||
float dotGB = dot(dirToG, dirToB);
|
||||
float dotBR = dot(dirToB, dirToR);
|
||||
|
||||
// Start with a bright coloured dot around each point
|
||||
FragColor.x = 1.0 - smoothstep(distToR, 0.0, pointRadius * pointR.z);
|
||||
FragColor.y = 1.0 - smoothstep(distToG, 0.0, pointRadius * pointG.z);
|
||||
FragColor.z = 1.0 - smoothstep(distToB, 0.0, pointRadius * pointB.z);
|
||||
FragColor.w = 1.0;
|
||||
|
||||
// We want to show a coloured link between adjacent points.
|
||||
// Determine the strength of each link at the current fragment.
|
||||
// This tends towards 1.0 as the vectors to each point tend towards opposite directions.
|
||||
float linkStrengthRG = 1.0 - smoothstep(dotRG, -1.01, -1.0 + (linkSize * pointR.z * pointG.z));
|
||||
float linkStrengthGB = 1.0 - smoothstep(dotGB, -1.01, -1.0 + (linkSize * pointG.z * pointB.z));
|
||||
float linkStrengthBR = 1.0 - smoothstep(dotBR, -1.01, -1.0 + (linkSize * pointB.z * pointR.z));
|
||||
|
||||
// If the current fragment is in a link, we need to know how much the
|
||||
// linked points contribute of their colour.
|
||||
float sumDistRG = distToR + distToG;
|
||||
float sumDistGB = distToG + distToB;
|
||||
float sumDistBR = distToB + distToR;
|
||||
|
||||
float contribRonRG = 1.0 - (distToR / sumDistRG);
|
||||
float contribRonBR = 1.0 - (distToR / sumDistBR);
|
||||
|
||||
float contribGonRG = 1.0 - (distToG / sumDistRG);
|
||||
float contribGonGB = 1.0 - (distToG / sumDistGB);
|
||||
|
||||
float contribBonGB = 1.0 - (distToB / sumDistGB);
|
||||
float contribBonBR = 1.0 - (distToB / sumDistBR);
|
||||
|
||||
// Additively blend the link colours into the fragment.
|
||||
FragColor.x += (linkStrengthRG * contribRonRG) + (linkStrengthBR * contribRonBR);
|
||||
FragColor.y += (linkStrengthGB * contribGonGB) + (linkStrengthRG * contribGonRG);
|
||||
FragColor.z += (linkStrengthBR * contribBonBR) + (linkStrengthGB * contribBonGB);
|
||||
|
||||
// Use an underlying texture to provide some noise
|
||||
float noiseMin = 1.0 - noiseStrength;
|
||||
FragColor.xyz *= (1.0 - noiseStrength) + (noiseStrength * 0.);
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
//uniform float iChannelTime[4]; // channel playback time (in seconds)
|
||||
//uniform vec3 iChannelResolution[4]; // channel resolution (in pixels)
|
||||
vec4 iMouse = vec4(0,0,0,0); // mouse pixel coords. xy: current (if MLB down), zw: click
|
||||
layout(binding = 0) //uniform sampler2D iChannel0; // input channel. XX = 2D/Cube
|
||||
|
||||
/*by musk License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
|
||||
|
||||
Trying to get some interesting looking lens flares.
|
||||
|
||||
13/08/13:
|
||||
published
|
||||
|
||||
muuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuusk!*/
|
||||
|
||||
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec2 center;
|
||||
vec2 resolution;
|
||||
vec2 u_screenSize;
|
||||
vec4 u_Time;
|
||||
};
|
||||
|
||||
float noise(float t)
|
||||
{
|
||||
return 0.;
|
||||
}
|
||||
float noise(vec2 t)
|
||||
{
|
||||
return 0.;
|
||||
}
|
||||
|
||||
vec3 lensflare(vec2 uv,vec2 pos)
|
||||
{
|
||||
vec2 main = uv-pos;
|
||||
vec2 uvd = uv*(length(uv));
|
||||
|
||||
float ang = atan(main.x,main.y);
|
||||
float dist=length(main); dist = pow(dist,.1);
|
||||
float n = noise(vec2(ang*16.0,dist*32.0));
|
||||
|
||||
float f0 = 1.0/(length(uv-pos)*16.0+1.0);
|
||||
|
||||
f0 = f0+f0*(sin(noise((pos.x+pos.y)*2.2+ang*4.0+5.954)*16.0)*.1+dist*.1+.8);
|
||||
|
||||
float f1 = max(0.01-pow(length(uv+1.2*pos),1.9),.0)*7.0;
|
||||
|
||||
float f2 = max(1.0/(1.0+32.0*pow(length(uvd+0.8*pos),2.0)),.0)*00.25;
|
||||
float f22 = max(1.0/(1.0+32.0*pow(length(uvd+0.85*pos),2.0)),.0)*00.23;
|
||||
float f23 = max(1.0/(1.0+32.0*pow(length(uvd+0.9*pos),2.0)),.0)*00.21;
|
||||
|
||||
vec2 uvx = mix(uv,uvd,-0.5);
|
||||
|
||||
float f4 = max(0.01-pow(length(uvx+0.4*pos),2.4),.0)*6.0;
|
||||
float f42 = max(0.01-pow(length(uvx+0.45*pos),2.4),.0)*5.0;
|
||||
float f43 = max(0.01-pow(length(uvx+0.5*pos),2.4),.0)*3.0;
|
||||
|
||||
uvx = mix(uv,uvd,-.4);
|
||||
|
||||
float f5 = max(0.01-pow(length(uvx+0.2*pos),5.5),.0)*2.0;
|
||||
float f52 = max(0.01-pow(length(uvx+0.4*pos),5.5),.0)*2.0;
|
||||
float f53 = max(0.01-pow(length(uvx+0.6*pos),5.5),.0)*2.0;
|
||||
|
||||
uvx = mix(uv,uvd,-0.5);
|
||||
|
||||
float f6 = max(0.01-pow(length(uvx-0.3*pos),1.6),.0)*6.0;
|
||||
float f62 = max(0.01-pow(length(uvx-0.325*pos),1.6),.0)*3.0;
|
||||
float f63 = max(0.01-pow(length(uvx-0.35*pos),1.6),.0)*5.0;
|
||||
|
||||
vec3 c = vec3(.0);
|
||||
|
||||
c.r+=f2+f4+f5+f6; c.g+=f22+f42+f52+f62; c.b+=f23+f43+f53+f63;
|
||||
c = c*1.3 - vec3(length(uvd)*.05);
|
||||
c+=vec3(f0);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
vec3 cc(vec3 color, float factor,float factor2) // color modifier
|
||||
{
|
||||
float w = color.x+color.y+color.z;
|
||||
return mix(color,vec3(w)*factor,w*factor2);
|
||||
}
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
#ifdef METAL
|
||||
vec2 fragCoord = vec2(gl_FragCoord.x, u_screenSize.y - gl_FragCoord.y);
|
||||
#else
|
||||
vec2 fragCoord = gl_FragCoord.xy;
|
||||
#endif
|
||||
vec2 iResolution = resolution; // viewport resolution (in pixels)
|
||||
float iGlobalTime = u_Time[1]; // shader playback time (in seconds)
|
||||
|
||||
//vec2 uv = gl_FragCoord.xy / iResolution.xy - 0.5;
|
||||
vec2 uv = (fragCoord.xy - center.xy) / iResolution.xy;
|
||||
uv.x *= iResolution.x/iResolution.y; //fix aspect ratio
|
||||
vec3 mouse = vec3(iMouse.xy/iResolution.xy - 0.5,iMouse.z-.5);
|
||||
mouse.x *= iResolution.x/iResolution.y; //fix aspect ratio
|
||||
if (iMouse.z<.5)
|
||||
{
|
||||
mouse.x=sin(iGlobalTime)*.5;
|
||||
mouse.y=sin(iGlobalTime*.913)*.5;
|
||||
}
|
||||
|
||||
vec3 color = vec3(1.4,1.2,1.0)*lensflare(uv,mouse.xy);
|
||||
color -= noise(fragCoord.xy)*.015;
|
||||
color = cc(color,.5,.1);
|
||||
FragColor = vec4(color,1.0);
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
layout(location = 0) in vec2 v_texture_coord;
|
||||
layout(location = 1) in vec4 v_position;
|
||||
layout(binding = 0) uniform sampler2D u_sampler0;
|
||||
layout(binding = 1) uniform sampler2D u_sampler1;
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec3 u_target_pos;
|
||||
vec4 u_color;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
|
||||
float Radius = 4.0;//project range
|
||||
vec3 UVector = vec3(1.0, 0.0, 0.0)/(2.0 * Radius);
|
||||
vec3 VVector = vec3(0.0, 0.0, -1.0)/(-2.0 * Radius);
|
||||
vec2 coord;
|
||||
coord.x = dot(v_position.xyz - u_target_pos, UVector) + 0.5;
|
||||
coord.y = dot(v_position.xyz - u_target_pos, VVector) + 0.5;
|
||||
|
||||
FragColor = u_color*texture(u_sampler0,v_texture_coord)*texture(u_sampler1,coord);
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
#version 310 es
|
||||
layout(location = 0) in vec4 a_position;
|
||||
layout(location = 1) in vec2 a_texCoord;
|
||||
layout(location = 0) out vec2 v_texture_coord;
|
||||
layout(location = 1) out vec4 v_position;
|
||||
|
||||
|
||||
layout(std140, binding = 0) uniform vs_ub {
|
||||
mat4 u_model_matrix;
|
||||
mat4 u_MVPMatrix;
|
||||
};
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = u_MVPMatrix * a_position;
|
||||
v_texture_coord = a_texCoord;
|
||||
v_texture_coord.y = (1.0 - v_texture_coord.y);
|
||||
v_position = u_model_matrix * a_position;
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
#version 310 es
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
layout(location = 0) in vec2 v_texture_coord;
|
||||
layout(binding = 0) uniform sampler2D u_sampler0;
|
||||
layout(location = 1) in vec3 v_normal;
|
||||
layout(std140, binding = 0) uniform fs_ub {
|
||||
vec4 u_color;
|
||||
};
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec3 light_direction = vec3(1,-1,-1);
|
||||
light_direction = normalize(light_direction);
|
||||
vec3 light_color = vec3(1,1,1);
|
||||
vec3 normal = normalize(v_normal);
|
||||
float diffuse_factor = dot(normal,-light_direction);
|
||||
vec4 diffuse_color = texture(u_sampler0,v_texture_coord);
|
||||
|
||||
if (diffuse_factor > 0.95) diffuse_factor=1.0;
|
||||
else if (diffuse_factor > 0.75) diffuse_factor = 0.8;
|
||||
else if (diffuse_factor > 0.50) diffuse_factor = 0.6;
|
||||
else diffuse_factor = 0.4;
|
||||
|
||||
light_color = light_color * diffuse_factor;
|
||||
FragColor = vec4(light_color,1.0) * diffuse_color * u_color;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#version 310 es
|
||||
layout(location = 0) in vec4 a_position;
|
||||
layout(location = 1) in vec2 a_texCoord;
|
||||
layout(location = 2) in vec3 a_normal;
|
||||
layout(location = 0) out vec2 v_texture_coord;
|
||||
layout(location = 1) out vec3 v_normal;
|
||||
|
||||
|
||||
layout(std140, binding = 0) uniform vs_ub {
|
||||
mat4 u_MVPMatrix;
|
||||
mat3 u_NormalMatrix;
|
||||
};
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = u_MVPMatrix * a_position;
|
||||
v_texture_coord = a_texCoord;
|
||||
v_texture_coord.y = (1.0 - v_texture_coord.y);
|
||||
v_normal = u_NormalMatrix *a_normal;
|
||||
}
|
Loading…
Reference in New Issue