mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 09:08:22 -05:00
102 lines
2.8 KiB
Text
102 lines
2.8 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 SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_Control;
|
|
vec2 uv_Splat0;
|
|
vec2 uv_Splat1;
|
|
vec2 uv_Splat2;
|
|
vec2 uv_Splat3;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec4 hip_pack0;
|
|
vec4 hip_pack1;
|
|
vec2 hip_pack2;
|
|
vec4 hip_screen;
|
|
vec3 hip_lmapFade;
|
|
};
|
|
struct appdata_full {
|
|
vec4 vertex;
|
|
vec4 tangent;
|
|
vec3 normal;
|
|
vec4 texcoord;
|
|
vec4 texcoord1;
|
|
vec4 color;
|
|
};
|
|
uniform vec4 _Control_ST;
|
|
uniform vec4 _ProjectionParams;
|
|
uniform vec4 _Splat0_ST;
|
|
uniform vec4 _Splat1_ST;
|
|
uniform vec4 _Splat2_ST;
|
|
uniform vec4 _Splat3_ST;
|
|
|
|
|
|
uniform vec4 unity_LightmapFade;
|
|
uniform vec4 unity_LightmapST;
|
|
void PositionFog( in vec4 v, out vec4 pos, out float fog );
|
|
vec4 ComputeScreenPos( in vec4 pos );
|
|
v2f_surf vert_surf( in appdata_full v );
|
|
void PositionFog( in vec4 v, out vec4 pos, out float fog ) {
|
|
pos = ( gl_ModelViewProjectionMatrix * v );
|
|
fog = pos.z ;
|
|
}
|
|
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_surf vert_surf( in appdata_full v ) {
|
|
v2f_surf o;
|
|
PositionFog( v.vertex, o.pos, o.fog);
|
|
o.hip_pack0.xy = ((v.texcoord.xy * _Control_ST.xy ) + _Control_ST.zw );
|
|
o.hip_pack0.zw = ((v.texcoord.xy * _Splat0_ST.xy ) + _Splat0_ST.zw );
|
|
o.hip_pack1.xy = ((v.texcoord.xy * _Splat1_ST.xy ) + _Splat1_ST.zw );
|
|
o.hip_pack1.zw = ((v.texcoord.xy * _Splat2_ST.xy ) + _Splat2_ST.zw );
|
|
o.hip_pack2.xy = ((v.texcoord.xy * _Splat3_ST.xy ) + _Splat3_ST.zw );
|
|
o.hip_screen = ComputeScreenPos( o.pos);
|
|
o.hip_lmapFade.xy = ((v.texcoord1.xy * unity_LightmapST.xy ) + unity_LightmapST.zw );
|
|
o.hip_lmapFade.z = ((( -( gl_ModelViewMatrix * v.vertex ).z ) * unity_LightmapFade.z ) + unity_LightmapFade.w );
|
|
return o;
|
|
}
|
|
attribute vec4 TANGENT;
|
|
varying vec4 xlv_FOG;
|
|
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);
|
|
xlv_FOG = vec4( xl_retval.fog, 0.0, 0.0, 0.0);
|
|
gl_TexCoord[0] = vec4( xl_retval.hip_pack0);
|
|
gl_TexCoord[1] = vec4( xl_retval.hip_pack1);
|
|
gl_TexCoord[2] = vec4( xl_retval.hip_pack2, 0.0, 0.0);
|
|
gl_TexCoord[3] = vec4( xl_retval.hip_screen);
|
|
gl_TexCoord[4] = vec4( xl_retval.hip_lmapFade, 0.0);
|
|
}
|