mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-11 00:31:28 -05:00
64 lines
1.5 KiB
Text
64 lines
1.5 KiB
Text
|
struct v2f_vertex_lit {
|
||
|
vec2 uv;
|
||
|
vec4 diff;
|
||
|
vec4 spec;
|
||
|
};
|
||
|
struct v2f_img {
|
||
|
vec4 pos;
|
||
|
vec2 uv;
|
||
|
};
|
||
|
struct appdata_img {
|
||
|
vec4 vertex;
|
||
|
vec2 texcoord;
|
||
|
};
|
||
|
struct v2f {
|
||
|
vec4 pos;
|
||
|
vec2 uv;
|
||
|
vec3 color;
|
||
|
};
|
||
|
struct appdata_full {
|
||
|
vec4 vertex;
|
||
|
vec4 tangent;
|
||
|
vec3 normal;
|
||
|
vec4 texcoord;
|
||
|
vec4 texcoord1;
|
||
|
vec4 color;
|
||
|
};
|
||
|
uniform vec4 _TerrainTreeLightColors[4];
|
||
|
uniform vec3 _TerrainTreeLightDirections[4];
|
||
|
|
||
|
|
||
|
v2f vert( in appdata_full v );
|
||
|
v2f vert( in appdata_full v ) {
|
||
|
v2f o;
|
||
|
vec3 lightColor;
|
||
|
int i = 0;
|
||
|
vec3 lightDir;
|
||
|
float diff;
|
||
|
o.pos = ( gl_ModelViewProjectionMatrix * v.vertex );
|
||
|
o.uv = v.texcoord.xy ;
|
||
|
lightColor = gl_LightModel.ambient.xyz ;
|
||
|
for ( ; (i < 4); ( i++ )) {
|
||
|
lightDir.xyz = _TerrainTreeLightDirections[ i ];
|
||
|
diff = max( 0.000000, dot( lightDir.xyz , v.normal));
|
||
|
lightColor += vec3( (_TerrainTreeLightColors[ i ] * diff));
|
||
|
}
|
||
|
o.color = (lightColor * v.color.w );
|
||
|
return o;
|
||
|
}
|
||
|
attribute vec4 TANGENT;
|
||
|
void main() {
|
||
|
v2f xl_retval;
|
||
|
appdata_full xlt_v;
|
||
|
xlt_v.vertex = vec4( gl_Vertex);
|
||
|
xlt_v.tangent = vec4( TANGENT);
|
||
|
xlt_v.normal = vec3( gl_Normal);
|
||
|
xlt_v.texcoord = vec4( gl_MultiTexCoord0);
|
||
|
xlt_v.texcoord1 = vec4( gl_MultiTexCoord1);
|
||
|
xlt_v.color = vec4( gl_Color);
|
||
|
xl_retval = vert( xlt_v);
|
||
|
gl_Position = vec4( xl_retval.pos);
|
||
|
gl_TexCoord[0] = vec4( xl_retval.uv, 0.0, 0.0);
|
||
|
gl_TexCoord[1] = vec4( xl_retval.color, 0.0);
|
||
|
}
|