mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 09:08:22 -05:00
57 lines
1.4 KiB
Text
57 lines
1.4 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[4];
|
||
|
};
|
||
|
uniform vec4 _MainTex_TexelSize;
|
||
|
|
||
|
|
||
|
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;
|
||
|
vec4 uv;
|
||
|
float offX;
|
||
|
float offY;
|
||
|
o.pos = ( gl_ModelViewProjectionMatrix * v.vertex );
|
||
|
uv.xy = MultiplyUV( gl_TextureMatrix[0], v.texcoord);
|
||
|
uv.zw = vec2( 0.000000);
|
||
|
offX = _MainTex_TexelSize.x ;
|
||
|
offY = _MainTex_TexelSize.y ;
|
||
|
o.uv[ 0 ] = (uv + vec4( ( -offX ), ( -offY ), 0.000000, 1.00000));
|
||
|
o.uv[ 1 ] = (uv + vec4( offX, ( -offY ), 0.000000, 1.00000));
|
||
|
o.uv[ 2 ] = (uv + vec4( offX, offY, 0.000000, 1.00000));
|
||
|
o.uv[ 3 ] = (uv + vec4( ( -offX ), offY, 0.000000, 1.00000));
|
||
|
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]);
|
||
|
gl_TexCoord[1] = vec4( xl_retval.uv[1]);
|
||
|
gl_TexCoord[2] = vec4( xl_retval.uv[2]);
|
||
|
gl_TexCoord[3] = vec4( xl_retval.uv[3]);
|
||
|
}
|