mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 09:08:22 -05:00
243 lines
5.6 KiB
Text
243 lines
5.6 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_MainTex;
|
|
vec4 color;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec2 hip_pack0;
|
|
vec4 lop_color;
|
|
vec3 lightDir;
|
|
vec3 viewDir;
|
|
vec3 _LightCoord;
|
|
};
|
|
varying vec4 xlv_FOG;
|
|
uniform sampler2D _TranslucencyMap;
|
|
uniform sampler2D _MainTex;
|
|
uniform sampler2D _LightTextureB0;
|
|
uniform samplerCube _LightTexture0;
|
|
uniform vec4 _LightColor0;
|
|
uniform sampler2D _BumpSpecMap;
|
|
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 norspc_8;
|
|
vec4 trngls_9;
|
|
vec4 c_10;
|
|
vec4 tmpvar_11;
|
|
tmpvar_11 = texture2D (_MainTex, IN_6.uv_MainTex);
|
|
vec4 tmpvar_12;
|
|
tmpvar_12 = tmpvar_11;
|
|
c_10 = tmpvar_12;
|
|
vec3 tmpvar_13;
|
|
tmpvar_13 = (c_10.xyz * IN_6.color.xyz);
|
|
o_7.Albedo = tmpvar_13;
|
|
vec4 tmpvar_14;
|
|
tmpvar_14 = texture2D (_TranslucencyMap, IN_6.uv_MainTex);
|
|
vec4 tmpvar_15;
|
|
tmpvar_15 = tmpvar_14;
|
|
trngls_9 = tmpvar_15;
|
|
float tmpvar_16;
|
|
tmpvar_16 = trngls_9.w;
|
|
o_7.Gloss = tmpvar_16;
|
|
float tmpvar_17;
|
|
tmpvar_17 = IN_6.color.w;
|
|
o_7.Alpha = tmpvar_17;
|
|
vec4 tmpvar_18;
|
|
tmpvar_18 = texture2D (_BumpSpecMap, IN_6.uv_MainTex);
|
|
vec4 tmpvar_19;
|
|
tmpvar_19 = tmpvar_18;
|
|
norspc_8 = tmpvar_19;
|
|
float tmpvar_20;
|
|
tmpvar_20 = norspc_8.x;
|
|
o_7.Specular = tmpvar_20;
|
|
vec4 tmpvar_21;
|
|
tmpvar_21 = UnpackNormal (norspc_8);
|
|
vec3 tmpvar_22;
|
|
tmpvar_22 = tmpvar_21.xyz;
|
|
vec3 tmpvar_23;
|
|
tmpvar_23 = tmpvar_22;
|
|
o_7.Normal = tmpvar_23;
|
|
}
|
|
|
|
vec4 LightingTreeBark (
|
|
in SurfaceOutput s_24,
|
|
in vec3 lightDir_25,
|
|
in vec3 viewDir_26,
|
|
in float atten_27
|
|
)
|
|
{
|
|
vec4 c_28;
|
|
float spec_29;
|
|
float nh_30;
|
|
float diff_31;
|
|
vec3 h_32;
|
|
vec3 tmpvar_33;
|
|
tmpvar_33 = normalize ((lightDir_25 + viewDir_26));
|
|
vec3 tmpvar_34;
|
|
tmpvar_34 = tmpvar_33;
|
|
h_32 = tmpvar_34;
|
|
float tmpvar_35;
|
|
tmpvar_35 = dot (s_24.Normal, lightDir_25);
|
|
float tmpvar_36;
|
|
tmpvar_36 = max (0.0, tmpvar_35);
|
|
float tmpvar_37;
|
|
tmpvar_37 = tmpvar_36;
|
|
diff_31 = tmpvar_37;
|
|
float tmpvar_38;
|
|
tmpvar_38 = dot (s_24.Normal, h_32);
|
|
float tmpvar_39;
|
|
tmpvar_39 = max (0.0, tmpvar_38);
|
|
float tmpvar_40;
|
|
tmpvar_40 = tmpvar_39;
|
|
nh_30 = tmpvar_40;
|
|
float tmpvar_41;
|
|
tmpvar_41 = pow (nh_30, (s_24.Specular * 128.0));
|
|
float tmpvar_42;
|
|
tmpvar_42 = (tmpvar_41 * s_24.Gloss);
|
|
spec_29 = tmpvar_42;
|
|
vec3 tmpvar_43;
|
|
tmpvar_43 = ((((s_24.Albedo * _LightColor0.xyz) * diff_31) + (_LightColor0.xyz * spec_29)) * (atten_27 * 2.0));
|
|
c_28.xyz = tmpvar_43.xyz.xyz;
|
|
float tmpvar_44;
|
|
tmpvar_44 = (((_LightColor0.w * spec_29) * atten_27) * s_24.Alpha);
|
|
c_28.w = vec4(tmpvar_44).w;
|
|
return c_28;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_45
|
|
)
|
|
{
|
|
vec4 c_46;
|
|
vec3 lightDir_47;
|
|
SurfaceOutput o_48;
|
|
Input surfIN_49;
|
|
vec2 tmpvar_50;
|
|
tmpvar_50 = IN_45.hip_pack0.xy;
|
|
surfIN_49.uv_MainTex = tmpvar_50;
|
|
vec4 tmpvar_51;
|
|
tmpvar_51 = IN_45.lop_color;
|
|
surfIN_49.color = tmpvar_51;
|
|
vec3 tmpvar_52;
|
|
tmpvar_52 = vec3(0.0, 0.0, 0.0);
|
|
o_48.Albedo = tmpvar_52;
|
|
vec3 tmpvar_53;
|
|
tmpvar_53 = vec3(0.0, 0.0, 0.0);
|
|
o_48.Emission = tmpvar_53;
|
|
float tmpvar_54;
|
|
tmpvar_54 = 0.0;
|
|
o_48.Specular = tmpvar_54;
|
|
float tmpvar_55;
|
|
tmpvar_55 = 0.0;
|
|
o_48.Alpha = tmpvar_55;
|
|
float tmpvar_56;
|
|
tmpvar_56 = 0.0;
|
|
o_48.Gloss = tmpvar_56;
|
|
surf (surfIN_49, o_48);
|
|
vec3 tmpvar_57;
|
|
tmpvar_57 = IN_45.lightDir;
|
|
lightDir_47 = tmpvar_57;
|
|
vec3 tmpvar_58;
|
|
tmpvar_58 = normalize (lightDir_47);
|
|
vec3 tmpvar_59;
|
|
tmpvar_59 = tmpvar_58;
|
|
lightDir_47 = tmpvar_59;
|
|
vec3 tmpvar_60;
|
|
tmpvar_60 = IN_45.viewDir.xyz;
|
|
vec3 tmpvar_61;
|
|
tmpvar_61 = normalize (tmpvar_60);
|
|
float tmpvar_62;
|
|
tmpvar_62 = dot (IN_45._LightCoord, IN_45._LightCoord);
|
|
vec2 tmpvar_63;
|
|
tmpvar_63 = vec2(tmpvar_62);
|
|
vec2 tmpvar_64;
|
|
tmpvar_64 = tmpvar_63.xy;
|
|
vec4 tmpvar_65;
|
|
tmpvar_65 = texture2D (_LightTextureB0, tmpvar_64);
|
|
vec4 tmpvar_66;
|
|
tmpvar_66 = textureCube (_LightTexture0, IN_45._LightCoord);
|
|
vec4 tmpvar_67;
|
|
tmpvar_67 = LightingTreeBark (o_48, lightDir_47, tmpvar_61, (tmpvar_65.w * tmpvar_66.w));
|
|
vec4 tmpvar_68;
|
|
tmpvar_68 = tmpvar_67;
|
|
c_46 = tmpvar_68;
|
|
float tmpvar_69;
|
|
tmpvar_69 = 0.0;
|
|
c_46.w = vec4(tmpvar_69).w;
|
|
return c_46;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_70;
|
|
vec4 xl_retval_71;
|
|
vec4 tmpvar_72;
|
|
tmpvar_72 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_70.pos = tmpvar_72;
|
|
float tmpvar_73;
|
|
tmpvar_73 = xlv_FOG.x;
|
|
xlt_IN_70.fog = tmpvar_73;
|
|
vec2 tmpvar_74;
|
|
tmpvar_74 = gl_TexCoord[0].xy;
|
|
vec2 tmpvar_75;
|
|
tmpvar_75 = tmpvar_74;
|
|
xlt_IN_70.hip_pack0 = tmpvar_75;
|
|
vec4 tmpvar_76;
|
|
tmpvar_76 = gl_Color.xyzw;
|
|
vec4 tmpvar_77;
|
|
tmpvar_77 = tmpvar_76;
|
|
xlt_IN_70.lop_color = tmpvar_77;
|
|
vec3 tmpvar_78;
|
|
tmpvar_78 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_79;
|
|
tmpvar_79 = tmpvar_78;
|
|
xlt_IN_70.lightDir = tmpvar_79;
|
|
vec3 tmpvar_80;
|
|
tmpvar_80 = gl_TexCoord[2].xyz;
|
|
vec3 tmpvar_81;
|
|
tmpvar_81 = tmpvar_80;
|
|
xlt_IN_70.viewDir = tmpvar_81;
|
|
vec3 tmpvar_82;
|
|
tmpvar_82 = gl_TexCoord[3].xyz;
|
|
vec3 tmpvar_83;
|
|
tmpvar_83 = tmpvar_82;
|
|
xlt_IN_70._LightCoord = tmpvar_83;
|
|
vec4 tmpvar_84;
|
|
tmpvar_84 = frag_surf (xlt_IN_70);
|
|
vec4 tmpvar_85;
|
|
tmpvar_85 = tmpvar_84;
|
|
xl_retval_71 = tmpvar_85;
|
|
vec4 tmpvar_86;
|
|
tmpvar_86 = xl_retval_71.xyzw;
|
|
vec4 tmpvar_87;
|
|
tmpvar_87 = tmpvar_86;
|
|
gl_FragData[0] = tmpvar_87;
|
|
}
|
|
|