mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-04 21:31:11 -05:00
160 lines
3.4 KiB
Text
160 lines
3.4 KiB
Text
|
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;
|
||
|
};
|
||
|
uniform sampler2D _MainTex;
|
||
|
uniform vec4 _Color;
|
||
|
uniform sampler2D _BumpMap;
|
||
|
vec4 UnpackNormal (
|
||
|
in vec4 packednormal_1
|
||
|
)
|
||
|
{
|
||
|
vec4 normal_2;
|
||
|
vec2 tmpvar_3;
|
||
|
tmpvar_3 = ((packednormal_1.wy * 2.0) - 1.0);
|
||
|
normal_2.xy = tmpvar_3.xy.xy;
|
||
|
float tmpvar_4;
|
||
|
tmpvar_4 = sqrt (((1.0 - (normal_2.x * normal_2.x)) - (normal_2.y * normal_2.y)));
|
||
|
float tmpvar_5;
|
||
|
tmpvar_5 = tmpvar_4;
|
||
|
normal_2.z = vec3(tmpvar_5).z;
|
||
|
return normal_2;
|
||
|
}
|
||
|
|
||
|
void surf (
|
||
|
in Input IN_6,
|
||
|
inout SurfaceOutput o_7
|
||
|
)
|
||
|
{
|
||
|
vec4 c_8;
|
||
|
vec4 tmpvar_9;
|
||
|
tmpvar_9 = texture2D (_MainTex, IN_6.uv_MainTex);
|
||
|
vec4 tmpvar_10;
|
||
|
tmpvar_10 = (tmpvar_9 * _Color);
|
||
|
c_8 = tmpvar_10;
|
||
|
vec3 tmpvar_11;
|
||
|
tmpvar_11 = c_8.xyz;
|
||
|
o_7.Albedo = tmpvar_11;
|
||
|
float tmpvar_12;
|
||
|
tmpvar_12 = c_8.w;
|
||
|
o_7.Alpha = tmpvar_12;
|
||
|
vec4 tmpvar_13;
|
||
|
tmpvar_13 = texture2D (_BumpMap, IN_6.uv_BumpMap);
|
||
|
vec4 tmpvar_14;
|
||
|
tmpvar_14 = UnpackNormal (tmpvar_13);
|
||
|
vec3 tmpvar_15;
|
||
|
tmpvar_15 = tmpvar_14.xyz;
|
||
|
vec3 tmpvar_16;
|
||
|
tmpvar_16 = tmpvar_15;
|
||
|
o_7.Normal = tmpvar_16;
|
||
|
}
|
||
|
|
||
|
vec4 frag_surf (
|
||
|
in v2f_surf IN_17
|
||
|
)
|
||
|
{
|
||
|
vec4 res_18;
|
||
|
vec3 viewN_19;
|
||
|
SurfaceOutput o_20;
|
||
|
Input surfIN_21;
|
||
|
vec2 tmpvar_22;
|
||
|
tmpvar_22 = IN_17.hip_pack0.xy;
|
||
|
surfIN_21.uv_BumpMap = tmpvar_22;
|
||
|
vec3 tmpvar_23;
|
||
|
tmpvar_23 = vec3(0.0, 0.0, 0.0);
|
||
|
o_20.Albedo = tmpvar_23;
|
||
|
vec3 tmpvar_24;
|
||
|
tmpvar_24 = vec3(0.0, 0.0, 0.0);
|
||
|
o_20.Emission = tmpvar_24;
|
||
|
float tmpvar_25;
|
||
|
tmpvar_25 = 0.0;
|
||
|
o_20.Specular = tmpvar_25;
|
||
|
float tmpvar_26;
|
||
|
tmpvar_26 = 0.0;
|
||
|
o_20.Alpha = tmpvar_26;
|
||
|
float tmpvar_27;
|
||
|
tmpvar_27 = 0.0;
|
||
|
o_20.Gloss = tmpvar_27;
|
||
|
surf (surfIN_21, o_20);
|
||
|
float tmpvar_28;
|
||
|
tmpvar_28 = dot (IN_17.TtoV0, o_20.Normal);
|
||
|
float tmpvar_29;
|
||
|
tmpvar_29 = tmpvar_28;
|
||
|
viewN_19.x = tmpvar_29;
|
||
|
float tmpvar_30;
|
||
|
tmpvar_30 = dot (IN_17.TtoV1, o_20.Normal);
|
||
|
float tmpvar_31;
|
||
|
tmpvar_31 = tmpvar_30;
|
||
|
viewN_19.y = vec2(tmpvar_31).y;
|
||
|
float tmpvar_32;
|
||
|
tmpvar_32 = dot (IN_17.TtoV2, o_20.Normal);
|
||
|
float tmpvar_33;
|
||
|
tmpvar_33 = tmpvar_32;
|
||
|
viewN_19.z = vec3(tmpvar_33).z;
|
||
|
vec3 tmpvar_34;
|
||
|
tmpvar_34 = viewN_19;
|
||
|
o_20.Normal = tmpvar_34;
|
||
|
vec3 tmpvar_35;
|
||
|
tmpvar_35 = ((o_20.Normal * vec3(0.5, 0.5, -0.5)) + 0.5);
|
||
|
res_18.xyz = tmpvar_35.xyz.xyz;
|
||
|
float tmpvar_36;
|
||
|
tmpvar_36 = o_20.Specular;
|
||
|
res_18.w = vec4(tmpvar_36).w;
|
||
|
return res_18;
|
||
|
}
|
||
|
|
||
|
void main ()
|
||
|
{
|
||
|
v2f_surf xlt_IN_37;
|
||
|
vec4 xl_retval_38;
|
||
|
vec4 tmpvar_39;
|
||
|
tmpvar_39 = vec4(0.0, 0.0, 0.0, 0.0);
|
||
|
xlt_IN_37.pos = tmpvar_39;
|
||
|
vec2 tmpvar_40;
|
||
|
tmpvar_40 = gl_TexCoord[0].xy;
|
||
|
vec2 tmpvar_41;
|
||
|
tmpvar_41 = tmpvar_40;
|
||
|
xlt_IN_37.hip_pack0 = tmpvar_41;
|
||
|
vec3 tmpvar_42;
|
||
|
tmpvar_42 = gl_TexCoord[1].xyz;
|
||
|
vec3 tmpvar_43;
|
||
|
tmpvar_43 = tmpvar_42;
|
||
|
xlt_IN_37.TtoV0 = tmpvar_43;
|
||
|
vec3 tmpvar_44;
|
||
|
tmpvar_44 = gl_TexCoord[2].xyz;
|
||
|
vec3 tmpvar_45;
|
||
|
tmpvar_45 = tmpvar_44;
|
||
|
xlt_IN_37.TtoV1 = tmpvar_45;
|
||
|
vec3 tmpvar_46;
|
||
|
tmpvar_46 = gl_TexCoord[3].xyz;
|
||
|
vec3 tmpvar_47;
|
||
|
tmpvar_47 = tmpvar_46;
|
||
|
xlt_IN_37.TtoV2 = tmpvar_47;
|
||
|
vec4 tmpvar_48;
|
||
|
tmpvar_48 = frag_surf (xlt_IN_37);
|
||
|
vec4 tmpvar_49;
|
||
|
tmpvar_49 = tmpvar_48;
|
||
|
xl_retval_38 = tmpvar_49;
|
||
|
vec4 tmpvar_50;
|
||
|
tmpvar_50 = xl_retval_38.xyzw;
|
||
|
vec4 tmpvar_51;
|
||
|
tmpvar_51 = tmpvar_50;
|
||
|
gl_FragData[0] = tmpvar_51;
|
||
|
}
|
||
|
|