mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-11 08:41:31 -05:00
77 lines
2.1 KiB
Text
77 lines
2.1 KiB
Text
mat3 xll_constructMat3( mat4 m) {
|
|
return mat3( vec3( m[0]), vec3( m[1]), vec3( m[2]));
|
|
}
|
|
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 SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_MainTex;
|
|
vec2 uv_BumpMap;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
vec2 hip_pack0;
|
|
vec3 TtoV0;
|
|
vec3 TtoV1;
|
|
vec3 TtoV2;
|
|
};
|
|
struct appdata_full {
|
|
vec4 vertex;
|
|
vec4 tangent;
|
|
vec3 normal;
|
|
vec4 texcoord;
|
|
vec4 texcoord1;
|
|
vec4 color;
|
|
};
|
|
uniform vec4 _BumpMap_ST;
|
|
|
|
|
|
v2f_surf vert_surf( in appdata_full v );
|
|
v2f_surf vert_surf( in appdata_full v ) {
|
|
v2f_surf o;
|
|
vec3 binormal;
|
|
mat3 rotation;
|
|
o.pos = ( gl_ModelViewProjectionMatrix * v.vertex );
|
|
o.hip_pack0.xy = ((v.texcoord.xy * _BumpMap_ST.xy ) + _BumpMap_ST.zw );
|
|
binormal = (cross( v.normal, v.tangent.xyz ) * v.tangent.w );
|
|
rotation = mat3( v.tangent.x , binormal.x , v.normal.x , v.tangent.y , binormal.y , v.normal.y , v.tangent.z , binormal.z , v.normal.z );
|
|
o.TtoV0 = ( rotation * xll_constructMat3( gl_ModelViewMatrixInverseTranspose)[ 0 ].xyz );
|
|
o.TtoV1 = ( rotation * xll_constructMat3( gl_ModelViewMatrixInverseTranspose)[ 1 ].xyz );
|
|
o.TtoV2 = ( rotation * xll_constructMat3( gl_ModelViewMatrixInverseTranspose)[ 2 ].xyz );
|
|
return o;
|
|
}
|
|
attribute vec4 TANGENT;
|
|
void main() {
|
|
v2f_surf 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_surf( xlt_v);
|
|
gl_Position = vec4( xl_retval.pos);
|
|
gl_TexCoord[0] = vec4( xl_retval.hip_pack0, 0.0, 0.0);
|
|
gl_TexCoord[1] = vec4( xl_retval.TtoV0, 0.0);
|
|
gl_TexCoord[2] = vec4( xl_retval.TtoV1, 0.0);
|
|
gl_TexCoord[3] = vec4( xl_retval.TtoV2, 0.0);
|
|
}
|