mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-01 11:56:58 -05:00
384 lines
8.3 KiB
Text
384 lines
8.3 KiB
Text
|
struct LeafSurfaceOutput {
|
||
|
vec3 Albedo;
|
||
|
vec3 Normal;
|
||
|
vec3 Emission;
|
||
|
vec3 Translucency;
|
||
|
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 vec4 _TranslucencyColor;
|
||
|
uniform float _Shininess;
|
||
|
uniform sampler2D _MainTex;
|
||
|
uniform sampler2D _LightTextureB0;
|
||
|
uniform samplerCube _LightTexture0;
|
||
|
uniform vec4 _LightColor0;
|
||
|
uniform sampler2D _GlossMap;
|
||
|
uniform float _Cutoff;
|
||
|
uniform sampler2D _BumpMap;
|
||
|
void xll_clip (
|
||
|
in float x_1
|
||
|
)
|
||
|
{
|
||
|
if ((x_1 < 0.0)) {
|
||
|
discard;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
float xll_saturate (
|
||
|
in float x_2
|
||
|
)
|
||
|
{
|
||
|
float tmpvar_3;
|
||
|
tmpvar_3 = clamp (x_2, 0.0, 1.0);
|
||
|
return tmpvar_3;
|
||
|
}
|
||
|
|
||
|
vec2 xll_saturate (
|
||
|
in vec2 x_4
|
||
|
)
|
||
|
{
|
||
|
vec2 tmpvar_5;
|
||
|
tmpvar_5 = clamp (x_4, 0.0, 1.0);
|
||
|
return tmpvar_5;
|
||
|
}
|
||
|
|
||
|
vec3 xll_saturate (
|
||
|
in vec3 x_6
|
||
|
)
|
||
|
{
|
||
|
vec3 tmpvar_7;
|
||
|
tmpvar_7 = clamp (x_6, 0.0, 1.0);
|
||
|
return tmpvar_7;
|
||
|
}
|
||
|
|
||
|
vec4 xll_saturate (
|
||
|
in vec4 x_8
|
||
|
)
|
||
|
{
|
||
|
vec4 tmpvar_9;
|
||
|
tmpvar_9 = clamp (x_8, 0.0, 1.0);
|
||
|
return tmpvar_9;
|
||
|
}
|
||
|
|
||
|
mat2 xll_saturate (
|
||
|
in mat2 m_10
|
||
|
)
|
||
|
{
|
||
|
vec2 tmpvar_11;
|
||
|
tmpvar_11 = clamp (m_10[0], 0.0, 1.0);
|
||
|
vec2 tmpvar_12;
|
||
|
tmpvar_12 = clamp (m_10[1], 0.0, 1.0);
|
||
|
mat2 tmpvar_13;
|
||
|
vec2 tmpvar_14;
|
||
|
tmpvar_14 = tmpvar_11;
|
||
|
tmpvar_13[0] = tmpvar_14;
|
||
|
vec2 tmpvar_15;
|
||
|
tmpvar_15 = tmpvar_12;
|
||
|
tmpvar_13[1] = tmpvar_15;
|
||
|
return tmpvar_13;
|
||
|
}
|
||
|
|
||
|
mat3 xll_saturate (
|
||
|
in mat3 m_16
|
||
|
)
|
||
|
{
|
||
|
vec3 tmpvar_17;
|
||
|
tmpvar_17 = clamp (m_16[0], 0.0, 1.0);
|
||
|
vec3 tmpvar_18;
|
||
|
tmpvar_18 = clamp (m_16[1], 0.0, 1.0);
|
||
|
vec3 tmpvar_19;
|
||
|
tmpvar_19 = clamp (m_16[2], 0.0, 1.0);
|
||
|
mat3 tmpvar_20;
|
||
|
vec3 tmpvar_21;
|
||
|
tmpvar_21 = tmpvar_17;
|
||
|
tmpvar_20[0] = tmpvar_21;
|
||
|
vec3 tmpvar_22;
|
||
|
tmpvar_22 = tmpvar_18;
|
||
|
tmpvar_20[1] = tmpvar_22;
|
||
|
vec3 tmpvar_23;
|
||
|
tmpvar_23 = tmpvar_19;
|
||
|
tmpvar_20[2] = tmpvar_23;
|
||
|
return tmpvar_20;
|
||
|
}
|
||
|
|
||
|
mat4 xll_saturate (
|
||
|
in mat4 m_24
|
||
|
)
|
||
|
{
|
||
|
vec4 tmpvar_25;
|
||
|
tmpvar_25 = clamp (m_24[0], 0.0, 1.0);
|
||
|
vec4 tmpvar_26;
|
||
|
tmpvar_26 = clamp (m_24[1], 0.0, 1.0);
|
||
|
vec4 tmpvar_27;
|
||
|
tmpvar_27 = clamp (m_24[2], 0.0, 1.0);
|
||
|
vec4 tmpvar_28;
|
||
|
tmpvar_28 = clamp (m_24[3], 0.0, 1.0);
|
||
|
mat4 tmpvar_29;
|
||
|
vec4 tmpvar_30;
|
||
|
tmpvar_30 = tmpvar_25;
|
||
|
tmpvar_29[0] = tmpvar_30;
|
||
|
vec4 tmpvar_31;
|
||
|
tmpvar_31 = tmpvar_26;
|
||
|
tmpvar_29[1] = tmpvar_31;
|
||
|
vec4 tmpvar_32;
|
||
|
tmpvar_32 = tmpvar_27;
|
||
|
tmpvar_29[2] = tmpvar_32;
|
||
|
vec4 tmpvar_33;
|
||
|
tmpvar_33 = tmpvar_28;
|
||
|
tmpvar_29[3] = tmpvar_33;
|
||
|
return tmpvar_29;
|
||
|
}
|
||
|
|
||
|
vec4 UnpackNormal (
|
||
|
in vec4 packednormal_34
|
||
|
)
|
||
|
{
|
||
|
vec4 normal_35;
|
||
|
vec2 tmpvar_36;
|
||
|
tmpvar_36 = ((packednormal_34.wy * 2.0) - 1.0);
|
||
|
normal_35.xy = tmpvar_36.xy.xy;
|
||
|
float tmpvar_37;
|
||
|
tmpvar_37 = sqrt (((1.0 - (normal_35.x * normal_35.x)) - (normal_35.y * normal_35.y)));
|
||
|
float tmpvar_38;
|
||
|
tmpvar_38 = tmpvar_37;
|
||
|
normal_35.z = vec3(tmpvar_38).z;
|
||
|
return normal_35;
|
||
|
}
|
||
|
|
||
|
void surf (
|
||
|
in Input IN_39,
|
||
|
inout LeafSurfaceOutput o_40
|
||
|
)
|
||
|
{
|
||
|
vec4 c_41;
|
||
|
vec4 tmpvar_42;
|
||
|
tmpvar_42 = texture2D (_MainTex, IN_39.uv_MainTex);
|
||
|
vec4 tmpvar_43;
|
||
|
tmpvar_43 = tmpvar_42;
|
||
|
c_41 = tmpvar_43;
|
||
|
vec3 tmpvar_44;
|
||
|
tmpvar_44 = (c_41.xyz * IN_39.color.xyz);
|
||
|
o_40.Albedo = tmpvar_44;
|
||
|
vec4 tmpvar_45;
|
||
|
tmpvar_45 = texture2D (_TranslucencyMap, IN_39.uv_MainTex);
|
||
|
vec3 tmpvar_46;
|
||
|
tmpvar_46 = _TranslucencyColor.xyz;
|
||
|
vec3 tmpvar_47;
|
||
|
tmpvar_47 = (tmpvar_45.xyz * tmpvar_46);
|
||
|
o_40.Translucency = tmpvar_47;
|
||
|
vec4 tmpvar_48;
|
||
|
tmpvar_48 = texture2D (_GlossMap, IN_39.uv_MainTex);
|
||
|
float tmpvar_49;
|
||
|
tmpvar_49 = tmpvar_48.w;
|
||
|
o_40.Gloss = tmpvar_49;
|
||
|
float tmpvar_50;
|
||
|
tmpvar_50 = (c_41.w * IN_39.color.w);
|
||
|
o_40.Alpha = tmpvar_50;
|
||
|
float tmpvar_51;
|
||
|
tmpvar_51 = _Shininess;
|
||
|
o_40.Specular = tmpvar_51;
|
||
|
vec4 tmpvar_52;
|
||
|
tmpvar_52 = texture2D (_BumpMap, IN_39.uv_MainTex);
|
||
|
vec4 tmpvar_53;
|
||
|
tmpvar_53 = UnpackNormal (tmpvar_52);
|
||
|
vec3 tmpvar_54;
|
||
|
tmpvar_54 = tmpvar_53.xyz;
|
||
|
vec3 tmpvar_55;
|
||
|
tmpvar_55 = tmpvar_54;
|
||
|
o_40.Normal = tmpvar_55;
|
||
|
}
|
||
|
|
||
|
vec4 LightingTreeLeaf (
|
||
|
in LeafSurfaceOutput s_56,
|
||
|
in vec3 lightDir_57,
|
||
|
in vec3 viewDir_58,
|
||
|
in float atten_59
|
||
|
)
|
||
|
{
|
||
|
vec4 c_60;
|
||
|
vec3 col_61;
|
||
|
vec3 translucencyColor_62;
|
||
|
float trans_63;
|
||
|
float spec_64;
|
||
|
float nh_65;
|
||
|
float diff_66;
|
||
|
vec3 h_67;
|
||
|
vec3 tmpvar_68;
|
||
|
tmpvar_68 = normalize ((lightDir_57 + viewDir_58));
|
||
|
vec3 tmpvar_69;
|
||
|
tmpvar_69 = tmpvar_68;
|
||
|
h_67 = tmpvar_69;
|
||
|
float tmpvar_70;
|
||
|
tmpvar_70 = dot (s_56.Normal, lightDir_57);
|
||
|
float tmpvar_71;
|
||
|
tmpvar_71 = tmpvar_70;
|
||
|
diff_66 = tmpvar_71;
|
||
|
float tmpvar_72;
|
||
|
tmpvar_72 = dot (s_56.Normal, h_67);
|
||
|
float tmpvar_73;
|
||
|
tmpvar_73 = max (0.0, tmpvar_72);
|
||
|
float tmpvar_74;
|
||
|
tmpvar_74 = tmpvar_73;
|
||
|
nh_65 = tmpvar_74;
|
||
|
float tmpvar_75;
|
||
|
tmpvar_75 = pow (nh_65, (s_56.Specular * 128.0));
|
||
|
float tmpvar_76;
|
||
|
tmpvar_76 = (tmpvar_75 * s_56.Gloss);
|
||
|
spec_64 = tmpvar_76;
|
||
|
float tmpvar_77;
|
||
|
tmpvar_77 = max (0.0, -(diff_66));
|
||
|
float tmpvar_78;
|
||
|
tmpvar_78 = tmpvar_77;
|
||
|
trans_63 = tmpvar_78;
|
||
|
vec3 tmpvar_79;
|
||
|
tmpvar_79 = ((s_56.Translucency * trans_63) * 2.0);
|
||
|
translucencyColor_62 = tmpvar_79;
|
||
|
float tmpvar_80;
|
||
|
tmpvar_80 = max (0.0, ((diff_66 * 0.5) + 0.5));
|
||
|
float tmpvar_81;
|
||
|
tmpvar_81 = tmpvar_80;
|
||
|
diff_66 = tmpvar_81;
|
||
|
vec3 tmpvar_82;
|
||
|
tmpvar_82 = (s_56.Albedo * (diff_66 + translucencyColor_62));
|
||
|
col_61 = tmpvar_82;
|
||
|
float tmpvar_83;
|
||
|
tmpvar_83 = ceil (trans_63);
|
||
|
float tmpvar_84;
|
||
|
tmpvar_84 = xll_saturate (tmpvar_83);
|
||
|
vec3 tmpvar_85;
|
||
|
tmpvar_85 = (col_61 + (spec_64 * (1.0 - tmpvar_84)));
|
||
|
col_61 = tmpvar_85;
|
||
|
vec3 tmpvar_86;
|
||
|
tmpvar_86 = (col_61 * _LightColor0.xyz);
|
||
|
col_61 = tmpvar_86;
|
||
|
vec3 tmpvar_87;
|
||
|
tmpvar_87 = (col_61 * (atten_59 * 2.0));
|
||
|
c_60.xyz = tmpvar_87.xyz.xyz;
|
||
|
return c_60;
|
||
|
}
|
||
|
|
||
|
vec4 frag_surf (
|
||
|
in v2f_surf IN_88
|
||
|
)
|
||
|
{
|
||
|
vec4 c_89;
|
||
|
vec3 lightDir_90;
|
||
|
LeafSurfaceOutput o_91;
|
||
|
Input surfIN_92;
|
||
|
vec2 tmpvar_93;
|
||
|
tmpvar_93 = IN_88.hip_pack0.xy;
|
||
|
surfIN_92.uv_MainTex = tmpvar_93;
|
||
|
vec4 tmpvar_94;
|
||
|
tmpvar_94 = IN_88.lop_color;
|
||
|
surfIN_92.color = tmpvar_94;
|
||
|
vec3 tmpvar_95;
|
||
|
tmpvar_95 = vec3(0.0, 0.0, 0.0);
|
||
|
o_91.Albedo = tmpvar_95;
|
||
|
vec3 tmpvar_96;
|
||
|
tmpvar_96 = vec3(0.0, 0.0, 0.0);
|
||
|
o_91.Emission = tmpvar_96;
|
||
|
float tmpvar_97;
|
||
|
tmpvar_97 = 0.0;
|
||
|
o_91.Specular = tmpvar_97;
|
||
|
float tmpvar_98;
|
||
|
tmpvar_98 = 0.0;
|
||
|
o_91.Alpha = tmpvar_98;
|
||
|
surf (surfIN_92, o_91);
|
||
|
xll_clip ((o_91.Alpha - _Cutoff));
|
||
|
vec3 tmpvar_99;
|
||
|
tmpvar_99 = IN_88.lightDir;
|
||
|
lightDir_90 = tmpvar_99;
|
||
|
vec3 tmpvar_100;
|
||
|
tmpvar_100 = normalize (lightDir_90);
|
||
|
vec3 tmpvar_101;
|
||
|
tmpvar_101 = tmpvar_100;
|
||
|
lightDir_90 = tmpvar_101;
|
||
|
vec3 tmpvar_102;
|
||
|
tmpvar_102 = IN_88.viewDir.xyz;
|
||
|
vec3 tmpvar_103;
|
||
|
tmpvar_103 = normalize (tmpvar_102);
|
||
|
float tmpvar_104;
|
||
|
tmpvar_104 = dot (IN_88._LightCoord, IN_88._LightCoord);
|
||
|
vec2 tmpvar_105;
|
||
|
tmpvar_105 = vec2(tmpvar_104);
|
||
|
vec2 tmpvar_106;
|
||
|
tmpvar_106 = tmpvar_105.xy;
|
||
|
vec4 tmpvar_107;
|
||
|
tmpvar_107 = texture2D (_LightTextureB0, tmpvar_106);
|
||
|
vec4 tmpvar_108;
|
||
|
tmpvar_108 = textureCube (_LightTexture0, IN_88._LightCoord);
|
||
|
vec4 tmpvar_109;
|
||
|
tmpvar_109 = LightingTreeLeaf (o_91, lightDir_90, tmpvar_103, (tmpvar_107.w * tmpvar_108.w));
|
||
|
vec4 tmpvar_110;
|
||
|
tmpvar_110 = tmpvar_109;
|
||
|
c_89 = tmpvar_110;
|
||
|
float tmpvar_111;
|
||
|
tmpvar_111 = o_91.Alpha;
|
||
|
c_89.w = vec4(tmpvar_111).w;
|
||
|
return c_89;
|
||
|
}
|
||
|
|
||
|
void main ()
|
||
|
{
|
||
|
v2f_surf xlt_IN_112;
|
||
|
vec4 xl_retval_113;
|
||
|
vec4 tmpvar_114;
|
||
|
tmpvar_114 = vec4(0.0, 0.0, 0.0, 0.0);
|
||
|
xlt_IN_112.pos = tmpvar_114;
|
||
|
float tmpvar_115;
|
||
|
tmpvar_115 = xlv_FOG.x;
|
||
|
xlt_IN_112.fog = tmpvar_115;
|
||
|
vec2 tmpvar_116;
|
||
|
tmpvar_116 = gl_TexCoord[0].xy;
|
||
|
vec2 tmpvar_117;
|
||
|
tmpvar_117 = tmpvar_116;
|
||
|
xlt_IN_112.hip_pack0 = tmpvar_117;
|
||
|
vec4 tmpvar_118;
|
||
|
tmpvar_118 = gl_Color.xyzw;
|
||
|
vec4 tmpvar_119;
|
||
|
tmpvar_119 = tmpvar_118;
|
||
|
xlt_IN_112.lop_color = tmpvar_119;
|
||
|
vec3 tmpvar_120;
|
||
|
tmpvar_120 = gl_TexCoord[1].xyz;
|
||
|
vec3 tmpvar_121;
|
||
|
tmpvar_121 = tmpvar_120;
|
||
|
xlt_IN_112.lightDir = tmpvar_121;
|
||
|
vec3 tmpvar_122;
|
||
|
tmpvar_122 = gl_TexCoord[2].xyz;
|
||
|
vec3 tmpvar_123;
|
||
|
tmpvar_123 = tmpvar_122;
|
||
|
xlt_IN_112.viewDir = tmpvar_123;
|
||
|
vec3 tmpvar_124;
|
||
|
tmpvar_124 = gl_TexCoord[3].xyz;
|
||
|
vec3 tmpvar_125;
|
||
|
tmpvar_125 = tmpvar_124;
|
||
|
xlt_IN_112._LightCoord = tmpvar_125;
|
||
|
vec4 tmpvar_126;
|
||
|
tmpvar_126 = frag_surf (xlt_IN_112);
|
||
|
vec4 tmpvar_127;
|
||
|
tmpvar_127 = tmpvar_126;
|
||
|
xl_retval_113 = tmpvar_127;
|
||
|
vec4 tmpvar_128;
|
||
|
tmpvar_128 = xl_retval_113.xyzw;
|
||
|
vec4 tmpvar_129;
|
||
|
tmpvar_129 = tmpvar_128;
|
||
|
gl_FragData[0] = tmpvar_129;
|
||
|
}
|
||
|
|