bgfx/3rdparty/glsl-optimizer/tests/vertex/uniforms-arrays-inES3.txt

55 lines
1.9 KiB
Text
Raw Normal View History

2014-10-11 15:32:43 -04:00
#version 300 es
#define gl_Vertex _glesVertex
in highp vec4 _glesVertex;
#define gl_Normal _glesNormal
in mediump vec3 _glesNormal;
#define gl_MultiTexCoord0 _glesMultiTexCoord0
in highp vec4 _glesMultiTexCoord0;
struct v2f {
highp vec4 pos;
lowp vec4 color;
highp vec2 uv;
};
uniform mediump vec4 unity_LightColor[8];
uniform highp vec4 unity_LightPosition[8];
uniform mediump vec4 unity_LightAtten[8];
uniform highp mat4 glstate_matrix_mvp;
uniform highp mat4 glstate_matrix_modelview0;
uniform highp mat4 glstate_matrix_invtrans_modelview0;
uniform highp vec4 glstate_lightmodel_ambient;
uniform mediump vec4 _Color;
highp vec3 ShadeLights( in highp vec3 vertex, in highp vec3 normal ) {
highp vec3 viewpos = (glstate_matrix_modelview0 * vec4( vertex, 1.0)).xyz;
highp vec3 viewN = (mat3( glstate_matrix_invtrans_modelview0) * normal);
highp vec3 lightColor = glstate_lightmodel_ambient.xyz;
highp int i = 0;
for ( ; (i < 4); (i++))
{
highp vec3 toLight = (unity_LightPosition[i].xyz - (viewpos.xyz * unity_LightPosition[i].w));
highp float lengthSq = dot( toLight, toLight);
highp float atten = (1.0 / (1.0 + (lengthSq * unity_LightAtten[i].z)));
highp float diff = max( 0.0, dot( viewN, normalize(toLight)));
lightColor += (unity_LightColor[i].xyz * (diff * atten));
}
return (lightColor * vec3( _Color));
}
v2f vert( in highp vec3 v, in highp vec3 n, in highp vec2 uv ) {
v2f o;
o.pos = (glstate_matrix_mvp * vec4(v, 1.0));
o.color = vec4( (ShadeLights(v, n) * 2.0), 1.0);
o.uv = uv;
return o;
}
out lowp vec4 xlv_COLOR0;
out highp vec2 xlv_TEXCOORD0;
void main() {
v2f xl_retval;
xl_retval = vert( vec3(gl_Vertex), vec3(gl_Normal), vec2(gl_MultiTexCoord0));
gl_Position = vec4(xl_retval.pos);
xlv_COLOR0 = vec4(xl_retval.color);
xlv_TEXCOORD0 = vec2(xl_retval.uv);
}