mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-01 11:56:58 -05:00
250 lines
5.7 KiB
Text
250 lines
5.7 KiB
Text
|
struct SurfaceOutput {
|
||
|
vec3 Albedo;
|
||
|
vec3 Normal;
|
||
|
vec3 Emission;
|
||
|
float Specular;
|
||
|
float Gloss;
|
||
|
float Alpha;
|
||
|
};
|
||
|
struct Input {
|
||
|
vec2 uv_MainTex;
|
||
|
vec2 uv_BumpMap;
|
||
|
vec3 worldRefl;
|
||
|
};
|
||
|
struct v2f_surf {
|
||
|
vec4 pos;
|
||
|
float fog;
|
||
|
vec4 hip_pack0;
|
||
|
vec3 lightDir;
|
||
|
vec3 viewDir;
|
||
|
vec3 _LightCoord;
|
||
|
};
|
||
|
varying vec4 xlv_FOG;
|
||
|
uniform vec4 _SpecColor;
|
||
|
uniform float _Shininess;
|
||
|
uniform vec4 _ReflectColor;
|
||
|
uniform sampler2D _MainTex;
|
||
|
uniform sampler2D _LightTexture0;
|
||
|
uniform vec4 _LightColor0;
|
||
|
uniform samplerCube _Cube;
|
||
|
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 reflcol_8;
|
||
|
vec3 worldRefl_9;
|
||
|
vec4 c_10;
|
||
|
vec4 tex_11;
|
||
|
vec4 tmpvar_12;
|
||
|
tmpvar_12 = texture2D (_MainTex, IN_6.uv_MainTex);
|
||
|
vec4 tmpvar_13;
|
||
|
tmpvar_13 = tmpvar_12;
|
||
|
tex_11 = tmpvar_13;
|
||
|
vec4 tmpvar_14;
|
||
|
tmpvar_14 = (tex_11 * _Color);
|
||
|
c_10 = tmpvar_14;
|
||
|
vec3 tmpvar_15;
|
||
|
tmpvar_15 = c_10.xyz;
|
||
|
o_7.Albedo = tmpvar_15;
|
||
|
float tmpvar_16;
|
||
|
tmpvar_16 = tex_11.w;
|
||
|
o_7.Gloss = tmpvar_16;
|
||
|
float tmpvar_17;
|
||
|
tmpvar_17 = _Shininess;
|
||
|
o_7.Specular = tmpvar_17;
|
||
|
vec4 tmpvar_18;
|
||
|
tmpvar_18 = texture2D (_BumpMap, IN_6.uv_BumpMap);
|
||
|
vec4 tmpvar_19;
|
||
|
tmpvar_19 = UnpackNormal (tmpvar_18);
|
||
|
vec3 tmpvar_20;
|
||
|
tmpvar_20 = tmpvar_19.xyz;
|
||
|
vec3 tmpvar_21;
|
||
|
tmpvar_21 = tmpvar_20;
|
||
|
o_7.Normal = tmpvar_21;
|
||
|
vec3 tmpvar_22;
|
||
|
tmpvar_22 = IN_6.worldRefl;
|
||
|
worldRefl_9 = tmpvar_22;
|
||
|
vec4 tmpvar_23;
|
||
|
tmpvar_23 = textureCube (_Cube, worldRefl_9);
|
||
|
vec4 tmpvar_24;
|
||
|
tmpvar_24 = tmpvar_23;
|
||
|
reflcol_8 = tmpvar_24;
|
||
|
vec4 tmpvar_25;
|
||
|
tmpvar_25 = (reflcol_8 * tex_11.w);
|
||
|
reflcol_8 = tmpvar_25;
|
||
|
vec3 tmpvar_26;
|
||
|
tmpvar_26 = (reflcol_8.xyz * _ReflectColor.xyz);
|
||
|
o_7.Emission = tmpvar_26;
|
||
|
float tmpvar_27;
|
||
|
tmpvar_27 = (reflcol_8.w * _ReflectColor.w);
|
||
|
o_7.Alpha = tmpvar_27;
|
||
|
}
|
||
|
|
||
|
vec4 LightingBlinnPhong (
|
||
|
in SurfaceOutput s_28,
|
||
|
in vec3 lightDir_29,
|
||
|
in vec3 viewDir_30,
|
||
|
in float atten_31
|
||
|
)
|
||
|
{
|
||
|
vec4 c_32;
|
||
|
float spec_33;
|
||
|
float nh_34;
|
||
|
float diff_35;
|
||
|
vec3 h_36;
|
||
|
vec3 tmpvar_37;
|
||
|
tmpvar_37 = normalize ((lightDir_29 + viewDir_30));
|
||
|
vec3 tmpvar_38;
|
||
|
tmpvar_38 = tmpvar_37;
|
||
|
h_36 = tmpvar_38;
|
||
|
float tmpvar_39;
|
||
|
tmpvar_39 = dot (s_28.Normal, lightDir_29);
|
||
|
float tmpvar_40;
|
||
|
tmpvar_40 = max (0.0, tmpvar_39);
|
||
|
float tmpvar_41;
|
||
|
tmpvar_41 = tmpvar_40;
|
||
|
diff_35 = tmpvar_41;
|
||
|
float tmpvar_42;
|
||
|
tmpvar_42 = dot (s_28.Normal, h_36);
|
||
|
float tmpvar_43;
|
||
|
tmpvar_43 = max (0.0, tmpvar_42);
|
||
|
float tmpvar_44;
|
||
|
tmpvar_44 = tmpvar_43;
|
||
|
nh_34 = tmpvar_44;
|
||
|
float tmpvar_45;
|
||
|
tmpvar_45 = pow (nh_34, (s_28.Specular * 128.0));
|
||
|
float tmpvar_46;
|
||
|
tmpvar_46 = (tmpvar_45 * s_28.Gloss);
|
||
|
spec_33 = tmpvar_46;
|
||
|
vec3 tmpvar_47;
|
||
|
tmpvar_47 = ((((s_28.Albedo * _LightColor0.xyz) * diff_35) + ((_LightColor0.xyz * _SpecColor.xyz) * spec_33)) * (atten_31 * 2.0));
|
||
|
c_32.xyz = tmpvar_47.xyz.xyz;
|
||
|
float tmpvar_48;
|
||
|
tmpvar_48 = (s_28.Alpha + (((_LightColor0.w * _SpecColor.w) * spec_33) * atten_31));
|
||
|
c_32.w = vec4(tmpvar_48).w;
|
||
|
return c_32;
|
||
|
}
|
||
|
|
||
|
vec4 frag_surf (
|
||
|
in v2f_surf IN_49
|
||
|
)
|
||
|
{
|
||
|
vec4 c_50;
|
||
|
vec3 lightDir_51;
|
||
|
SurfaceOutput o_52;
|
||
|
Input surfIN_53;
|
||
|
vec2 tmpvar_54;
|
||
|
tmpvar_54 = IN_49.hip_pack0.xy;
|
||
|
surfIN_53.uv_MainTex = tmpvar_54;
|
||
|
vec2 tmpvar_55;
|
||
|
tmpvar_55 = IN_49.hip_pack0.zw;
|
||
|
surfIN_53.uv_BumpMap = tmpvar_55;
|
||
|
vec3 tmpvar_56;
|
||
|
tmpvar_56 = vec3(0.0, 0.0, 0.0);
|
||
|
o_52.Albedo = tmpvar_56;
|
||
|
vec3 tmpvar_57;
|
||
|
tmpvar_57 = vec3(0.0, 0.0, 0.0);
|
||
|
o_52.Emission = tmpvar_57;
|
||
|
float tmpvar_58;
|
||
|
tmpvar_58 = 0.0;
|
||
|
o_52.Specular = tmpvar_58;
|
||
|
float tmpvar_59;
|
||
|
tmpvar_59 = 0.0;
|
||
|
o_52.Alpha = tmpvar_59;
|
||
|
float tmpvar_60;
|
||
|
tmpvar_60 = 0.0;
|
||
|
o_52.Gloss = tmpvar_60;
|
||
|
surf (surfIN_53, o_52);
|
||
|
vec3 tmpvar_61;
|
||
|
tmpvar_61 = IN_49.lightDir;
|
||
|
lightDir_51 = tmpvar_61;
|
||
|
vec3 tmpvar_62;
|
||
|
tmpvar_62 = normalize (lightDir_51);
|
||
|
vec3 tmpvar_63;
|
||
|
tmpvar_63 = tmpvar_62;
|
||
|
lightDir_51 = tmpvar_63;
|
||
|
vec3 tmpvar_64;
|
||
|
tmpvar_64 = IN_49.viewDir.xyz;
|
||
|
vec3 tmpvar_65;
|
||
|
tmpvar_65 = normalize (tmpvar_64);
|
||
|
float tmpvar_66;
|
||
|
tmpvar_66 = dot (IN_49._LightCoord, IN_49._LightCoord);
|
||
|
vec2 tmpvar_67;
|
||
|
tmpvar_67 = vec2(tmpvar_66);
|
||
|
vec2 tmpvar_68;
|
||
|
tmpvar_68 = tmpvar_67.xy;
|
||
|
vec4 tmpvar_69;
|
||
|
tmpvar_69 = texture2D (_LightTexture0, tmpvar_68);
|
||
|
vec4 tmpvar_70;
|
||
|
tmpvar_70 = LightingBlinnPhong (o_52, lightDir_51, tmpvar_65, tmpvar_69.w);
|
||
|
vec4 tmpvar_71;
|
||
|
tmpvar_71 = tmpvar_70;
|
||
|
c_50 = tmpvar_71;
|
||
|
float tmpvar_72;
|
||
|
tmpvar_72 = 0.0;
|
||
|
c_50.w = vec4(tmpvar_72).w;
|
||
|
return c_50;
|
||
|
}
|
||
|
|
||
|
void main ()
|
||
|
{
|
||
|
v2f_surf xlt_IN_73;
|
||
|
vec4 xl_retval_74;
|
||
|
vec4 tmpvar_75;
|
||
|
tmpvar_75 = vec4(0.0, 0.0, 0.0, 0.0);
|
||
|
xlt_IN_73.pos = tmpvar_75;
|
||
|
float tmpvar_76;
|
||
|
tmpvar_76 = xlv_FOG.x;
|
||
|
xlt_IN_73.fog = tmpvar_76;
|
||
|
vec4 tmpvar_77;
|
||
|
tmpvar_77 = gl_TexCoord[0].xyzw;
|
||
|
vec4 tmpvar_78;
|
||
|
tmpvar_78 = tmpvar_77;
|
||
|
xlt_IN_73.hip_pack0 = tmpvar_78;
|
||
|
vec3 tmpvar_79;
|
||
|
tmpvar_79 = gl_TexCoord[1].xyz;
|
||
|
vec3 tmpvar_80;
|
||
|
tmpvar_80 = tmpvar_79;
|
||
|
xlt_IN_73.lightDir = tmpvar_80;
|
||
|
vec3 tmpvar_81;
|
||
|
tmpvar_81 = gl_TexCoord[2].xyz;
|
||
|
vec3 tmpvar_82;
|
||
|
tmpvar_82 = tmpvar_81;
|
||
|
xlt_IN_73.viewDir = tmpvar_82;
|
||
|
vec3 tmpvar_83;
|
||
|
tmpvar_83 = gl_TexCoord[3].xyz;
|
||
|
vec3 tmpvar_84;
|
||
|
tmpvar_84 = tmpvar_83;
|
||
|
xlt_IN_73._LightCoord = tmpvar_84;
|
||
|
vec4 tmpvar_85;
|
||
|
tmpvar_85 = frag_surf (xlt_IN_73);
|
||
|
vec4 tmpvar_86;
|
||
|
tmpvar_86 = tmpvar_85;
|
||
|
xl_retval_74 = tmpvar_86;
|
||
|
vec4 tmpvar_87;
|
||
|
tmpvar_87 = xl_retval_74.xyzw;
|
||
|
vec4 tmpvar_88;
|
||
|
tmpvar_88 = tmpvar_87;
|
||
|
gl_FragData[0] = tmpvar_88;
|
||
|
}
|
||
|
|