mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-29 19:15:37 -05:00
51 lines
1.2 KiB
Text
51 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;
|
||
|
vec2 uv;
|
||
|
vec2 uvg;
|
||
|
vec2 uvs;
|
||
|
};
|
||
|
uniform vec4 _GrainOffsetScale;
|
||
|
uniform vec4 _ScratchOffsetScale;
|
||
|
|
||
|
|
||
|
vec2 MultiplyUV( in mat4 mat, in vec2 inUV );
|
||
|
v2f vert( in appdata_img v );
|
||
|
vec2 MultiplyUV( in mat4 mat, in vec2 inUV ) {
|
||
|
vec4 temp;
|
||
|
temp = vec4( inUV.x , inUV.y , 0.000000, 0.000000);
|
||
|
temp = ( mat * temp );
|
||
|
return temp.xy ;
|
||
|
}
|
||
|
v2f vert( in appdata_img v ) {
|
||
|
v2f o;
|
||
|
o.pos = ( gl_ModelViewProjectionMatrix * v.vertex );
|
||
|
o.uv = MultiplyUV( gl_TextureMatrix[0], v.texcoord);
|
||
|
o.uvg = ((v.texcoord.xy * _GrainOffsetScale.zw ) + _GrainOffsetScale.xy );
|
||
|
o.uvs = ((v.texcoord.xy * _ScratchOffsetScale.zw ) + _ScratchOffsetScale.xy );
|
||
|
return o;
|
||
|
}
|
||
|
void main() {
|
||
|
v2f xl_retval;
|
||
|
appdata_img xlt_v;
|
||
|
xlt_v.vertex = vec4( gl_Vertex);
|
||
|
xlt_v.texcoord = vec2( gl_MultiTexCoord0);
|
||
|
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.uvg, 0.0, 0.0);
|
||
|
gl_TexCoord[2] = vec4( xl_retval.uvs, 0.0, 0.0);
|
||
|
}
|