mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-12 01:01:30 -05:00
52 lines
1.2 KiB
Text
52 lines
1.2 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;
|
|
vec4 uv;
|
|
vec3 ray;
|
|
};
|
|
struct appdata {
|
|
vec4 vertex;
|
|
vec3 texcoord;
|
|
};
|
|
uniform vec4 _ProjectionParams;
|
|
|
|
|
|
vec4 ComputeScreenPos( in vec4 pos );
|
|
v2f vert( in appdata v );
|
|
vec4 ComputeScreenPos( in vec4 pos ) {
|
|
vec4 o;
|
|
o = (pos * 0.500000);
|
|
o.xy = (vec2( o.x , (o.y * _ProjectionParams.x )) + o.w );
|
|
o.zw = pos.zw ;
|
|
return o;
|
|
}
|
|
v2f vert( in appdata v ) {
|
|
v2f o;
|
|
o.pos = ( gl_ModelViewProjectionMatrix * v.vertex );
|
|
o.uv = ComputeScreenPos( o.pos);
|
|
o.ray = (( gl_ModelViewMatrix * v.vertex ).xyz * vec3( -1.00000, -1.00000, 1.00000));
|
|
o.ray = mix( o.ray, v.texcoord, vec3( float( (v.texcoord.z != 0.000000) )));
|
|
return o;
|
|
}
|
|
void main() {
|
|
v2f xl_retval;
|
|
appdata xlt_v;
|
|
xlt_v.vertex = vec4( gl_Vertex);
|
|
xlt_v.texcoord = vec3( gl_MultiTexCoord0);
|
|
xl_retval = vert( xlt_v);
|
|
gl_Position = vec4( xl_retval.pos);
|
|
gl_TexCoord[0] = vec4( xl_retval.uv);
|
|
gl_TexCoord[1] = vec4( xl_retval.ray, 0.0);
|
|
}
|