mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-29 11:05:36 -05:00
301 lines
6.2 KiB
Text
301 lines
6.2 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_BumpMap;
|
|
vec3 viewDir;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec2 hip_pack0;
|
|
vec3 lightDir;
|
|
vec3 _LightCoord;
|
|
};
|
|
uniform sampler2D _BumpMap;
|
|
uniform vec4 _LightColor0;
|
|
uniform samplerCube _LightTexture0;
|
|
uniform sampler2D _LightTextureB0;
|
|
uniform sampler2D _MainTex;
|
|
uniform vec4 _RimColor;
|
|
uniform float _RimPower;
|
|
varying vec4 xlv_FOG;
|
|
float xll_saturate (
|
|
in float x_1
|
|
)
|
|
{
|
|
float tmpvar_2;
|
|
tmpvar_2 = clamp (x_1, 0.0, 1.0);
|
|
return tmpvar_2;
|
|
}
|
|
|
|
vec2 xll_saturate (
|
|
in vec2 x_3
|
|
)
|
|
{
|
|
vec2 tmpvar_4;
|
|
tmpvar_4 = clamp (x_3, 0.0, 1.0);
|
|
return tmpvar_4;
|
|
}
|
|
|
|
vec3 xll_saturate (
|
|
in vec3 x_5
|
|
)
|
|
{
|
|
vec3 tmpvar_6;
|
|
tmpvar_6 = clamp (x_5, 0.0, 1.0);
|
|
return tmpvar_6;
|
|
}
|
|
|
|
vec4 xll_saturate (
|
|
in vec4 x_7
|
|
)
|
|
{
|
|
vec4 tmpvar_8;
|
|
tmpvar_8 = clamp (x_7, 0.0, 1.0);
|
|
return tmpvar_8;
|
|
}
|
|
|
|
mat2 xll_saturate (
|
|
in mat2 m_9
|
|
)
|
|
{
|
|
vec2 tmpvar_10;
|
|
tmpvar_10 = clamp (m_9[0], 0.0, 1.0);
|
|
vec2 tmpvar_11;
|
|
tmpvar_11 = clamp (m_9[1], 0.0, 1.0);
|
|
mat2 tmpvar_12;
|
|
vec2 tmpvar_13;
|
|
tmpvar_13 = tmpvar_10;
|
|
tmpvar_12[0] = tmpvar_13;
|
|
vec2 tmpvar_14;
|
|
tmpvar_14 = tmpvar_11;
|
|
tmpvar_12[1] = tmpvar_14;
|
|
return tmpvar_12;
|
|
}
|
|
|
|
mat3 xll_saturate (
|
|
in mat3 m_15
|
|
)
|
|
{
|
|
vec3 tmpvar_16;
|
|
tmpvar_16 = clamp (m_15[0], 0.0, 1.0);
|
|
vec3 tmpvar_17;
|
|
tmpvar_17 = clamp (m_15[1], 0.0, 1.0);
|
|
vec3 tmpvar_18;
|
|
tmpvar_18 = clamp (m_15[2], 0.0, 1.0);
|
|
mat3 tmpvar_19;
|
|
vec3 tmpvar_20;
|
|
tmpvar_20 = tmpvar_16;
|
|
tmpvar_19[0] = tmpvar_20;
|
|
vec3 tmpvar_21;
|
|
tmpvar_21 = tmpvar_17;
|
|
tmpvar_19[1] = tmpvar_21;
|
|
vec3 tmpvar_22;
|
|
tmpvar_22 = tmpvar_18;
|
|
tmpvar_19[2] = tmpvar_22;
|
|
return tmpvar_19;
|
|
}
|
|
|
|
mat4 xll_saturate (
|
|
in mat4 m_23
|
|
)
|
|
{
|
|
vec4 tmpvar_24;
|
|
tmpvar_24 = clamp (m_23[0], 0.0, 1.0);
|
|
vec4 tmpvar_25;
|
|
tmpvar_25 = clamp (m_23[1], 0.0, 1.0);
|
|
vec4 tmpvar_26;
|
|
tmpvar_26 = clamp (m_23[2], 0.0, 1.0);
|
|
vec4 tmpvar_27;
|
|
tmpvar_27 = clamp (m_23[3], 0.0, 1.0);
|
|
mat4 tmpvar_28;
|
|
vec4 tmpvar_29;
|
|
tmpvar_29 = tmpvar_24;
|
|
tmpvar_28[0] = tmpvar_29;
|
|
vec4 tmpvar_30;
|
|
tmpvar_30 = tmpvar_25;
|
|
tmpvar_28[1] = tmpvar_30;
|
|
vec4 tmpvar_31;
|
|
tmpvar_31 = tmpvar_26;
|
|
tmpvar_28[2] = tmpvar_31;
|
|
vec4 tmpvar_32;
|
|
tmpvar_32 = tmpvar_27;
|
|
tmpvar_28[3] = tmpvar_32;
|
|
return tmpvar_28;
|
|
}
|
|
|
|
vec4 UnpackNormal (
|
|
in vec4 packednormal_33
|
|
)
|
|
{
|
|
vec4 normal_34;
|
|
vec2 tmpvar_35;
|
|
tmpvar_35 = ((packednormal_33.wy * 2.0) - 1.0);
|
|
normal_34.xy = tmpvar_35.xy.xy;
|
|
float tmpvar_36;
|
|
tmpvar_36 = sqrt (((1.0 - (normal_34.x * normal_34.x)) - (normal_34.y * normal_34.y)));
|
|
float tmpvar_37;
|
|
tmpvar_37 = tmpvar_36;
|
|
normal_34.z = vec3(tmpvar_37).z;
|
|
return normal_34;
|
|
}
|
|
|
|
void surf (
|
|
in Input IN_38,
|
|
inout SurfaceOutput o_39
|
|
)
|
|
{
|
|
float rim_40;
|
|
vec4 tmpvar_41;
|
|
tmpvar_41 = texture2D (_MainTex, IN_38.uv_BumpMap);
|
|
vec3 tmpvar_42;
|
|
tmpvar_42 = tmpvar_41.xyz;
|
|
o_39.Albedo = tmpvar_42;
|
|
vec4 tmpvar_43;
|
|
tmpvar_43 = texture2D (_BumpMap, IN_38.uv_BumpMap);
|
|
vec4 tmpvar_44;
|
|
tmpvar_44 = UnpackNormal (tmpvar_43);
|
|
vec3 tmpvar_45;
|
|
tmpvar_45 = tmpvar_44.xyz;
|
|
vec3 tmpvar_46;
|
|
tmpvar_46 = tmpvar_45;
|
|
o_39.Normal = tmpvar_46;
|
|
vec3 tmpvar_47;
|
|
tmpvar_47 = normalize (IN_38.viewDir);
|
|
float tmpvar_48;
|
|
tmpvar_48 = dot (tmpvar_47, o_39.Normal);
|
|
float tmpvar_49;
|
|
tmpvar_49 = xll_saturate (tmpvar_48);
|
|
float tmpvar_50;
|
|
tmpvar_50 = (1.0 - tmpvar_49);
|
|
rim_40 = tmpvar_50;
|
|
float tmpvar_51;
|
|
tmpvar_51 = pow (rim_40, _RimPower);
|
|
vec3 tmpvar_52;
|
|
tmpvar_52 = (_RimColor.xyz * tmpvar_51);
|
|
o_39.Emission = tmpvar_52;
|
|
}
|
|
|
|
vec4 LightingLambert (
|
|
in SurfaceOutput s_53,
|
|
in vec3 lightDir_54,
|
|
in float atten_55
|
|
)
|
|
{
|
|
vec4 c_56;
|
|
float diff_57;
|
|
float tmpvar_58;
|
|
tmpvar_58 = dot (s_53.Normal, lightDir_54);
|
|
float tmpvar_59;
|
|
tmpvar_59 = max (0.0, tmpvar_58);
|
|
float tmpvar_60;
|
|
tmpvar_60 = tmpvar_59;
|
|
diff_57 = tmpvar_60;
|
|
vec3 tmpvar_61;
|
|
tmpvar_61 = ((s_53.Albedo * _LightColor0.xyz) * ((diff_57 * atten_55) * 2.0));
|
|
c_56.xyz = tmpvar_61.xyz.xyz;
|
|
float tmpvar_62;
|
|
tmpvar_62 = s_53.Alpha;
|
|
c_56.w = vec4(tmpvar_62).w;
|
|
return c_56;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_63
|
|
)
|
|
{
|
|
vec4 c_64;
|
|
vec3 lightDir_65;
|
|
SurfaceOutput o_66;
|
|
Input surfIN_67;
|
|
vec2 tmpvar_68;
|
|
tmpvar_68 = IN_63.hip_pack0.xy;
|
|
surfIN_67.uv_BumpMap = tmpvar_68;
|
|
vec3 tmpvar_69;
|
|
tmpvar_69 = vec3(0.0, 0.0, 0.0);
|
|
o_66.Albedo = tmpvar_69;
|
|
vec3 tmpvar_70;
|
|
tmpvar_70 = vec3(0.0, 0.0, 0.0);
|
|
o_66.Emission = tmpvar_70;
|
|
float tmpvar_71;
|
|
tmpvar_71 = 0.0;
|
|
o_66.Specular = tmpvar_71;
|
|
float tmpvar_72;
|
|
tmpvar_72 = 0.0;
|
|
o_66.Alpha = tmpvar_72;
|
|
float tmpvar_73;
|
|
tmpvar_73 = 0.0;
|
|
o_66.Gloss = tmpvar_73;
|
|
surf (surfIN_67, o_66);
|
|
vec3 tmpvar_74;
|
|
tmpvar_74 = IN_63.lightDir;
|
|
lightDir_65 = tmpvar_74;
|
|
vec3 tmpvar_75;
|
|
tmpvar_75 = normalize (lightDir_65);
|
|
vec3 tmpvar_76;
|
|
tmpvar_76 = tmpvar_75;
|
|
lightDir_65 = tmpvar_76;
|
|
float tmpvar_77;
|
|
tmpvar_77 = dot (IN_63._LightCoord, IN_63._LightCoord);
|
|
vec2 tmpvar_78;
|
|
tmpvar_78 = vec2(tmpvar_77);
|
|
vec2 tmpvar_79;
|
|
tmpvar_79 = tmpvar_78.xy;
|
|
vec4 tmpvar_80;
|
|
tmpvar_80 = texture2D (_LightTextureB0, tmpvar_79);
|
|
vec4 tmpvar_81;
|
|
tmpvar_81 = textureCube (_LightTexture0, IN_63._LightCoord);
|
|
vec4 tmpvar_82;
|
|
tmpvar_82 = LightingLambert (o_66, lightDir_65, (tmpvar_80.w * tmpvar_81.w));
|
|
vec4 tmpvar_83;
|
|
tmpvar_83 = tmpvar_82;
|
|
c_64 = tmpvar_83;
|
|
float tmpvar_84;
|
|
tmpvar_84 = 0.0;
|
|
c_64.w = vec4(tmpvar_84).w;
|
|
return c_64;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_85;
|
|
vec4 xl_retval_86;
|
|
vec4 tmpvar_87;
|
|
tmpvar_87 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_85.pos = tmpvar_87;
|
|
float tmpvar_88;
|
|
tmpvar_88 = xlv_FOG.x;
|
|
xlt_IN_85.fog = tmpvar_88;
|
|
vec2 tmpvar_89;
|
|
tmpvar_89 = gl_TexCoord[0].xy;
|
|
vec2 tmpvar_90;
|
|
tmpvar_90 = tmpvar_89;
|
|
xlt_IN_85.hip_pack0 = tmpvar_90;
|
|
vec3 tmpvar_91;
|
|
tmpvar_91 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_92;
|
|
tmpvar_92 = tmpvar_91;
|
|
xlt_IN_85.lightDir = tmpvar_92;
|
|
vec3 tmpvar_93;
|
|
tmpvar_93 = gl_TexCoord[2].xyz;
|
|
vec3 tmpvar_94;
|
|
tmpvar_94 = tmpvar_93;
|
|
xlt_IN_85._LightCoord = tmpvar_94;
|
|
vec4 tmpvar_95;
|
|
tmpvar_95 = frag_surf (xlt_IN_85);
|
|
vec4 tmpvar_96;
|
|
tmpvar_96 = tmpvar_95;
|
|
xl_retval_86 = tmpvar_96;
|
|
vec4 tmpvar_97;
|
|
tmpvar_97 = xl_retval_86.xyzw;
|
|
vec4 tmpvar_98;
|
|
tmpvar_98 = tmpvar_97;
|
|
gl_FragData[0] = tmpvar_98;
|
|
}
|
|
|