mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-01 11:56:58 -05:00
386 lines
8.3 KiB
Text
386 lines
8.3 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;
|
|
vec3 TtoW0;
|
|
vec3 TtoW1;
|
|
vec3 TtoW2;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec4 hip_pack0;
|
|
vec4 hip_screen;
|
|
vec4 TtoW0;
|
|
vec4 TtoW1;
|
|
vec4 TtoW2;
|
|
vec3 hip_lmapFade;
|
|
};
|
|
varying vec4 xlv_FOG;
|
|
uniform sampler2D unity_LightmapInd;
|
|
uniform sampler2D unity_Lightmap;
|
|
uniform vec4 _ReflectColor;
|
|
uniform sampler2D _MainTex;
|
|
uniform sampler2D _LightBuffer;
|
|
uniform samplerCube _Cube;
|
|
uniform vec4 _Color;
|
|
uniform sampler2D _BumpMap;
|
|
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
|
|
)
|
|
{
|
|
vec4 reflcol_40;
|
|
vec3 worldRefl_41;
|
|
vec4 c_42;
|
|
vec4 tex_43;
|
|
vec4 tmpvar_44;
|
|
tmpvar_44 = texture2D (_MainTex, IN_38.uv_MainTex);
|
|
vec4 tmpvar_45;
|
|
tmpvar_45 = tmpvar_44;
|
|
tex_43 = tmpvar_45;
|
|
vec4 tmpvar_46;
|
|
tmpvar_46 = (tex_43 * _Color);
|
|
c_42 = tmpvar_46;
|
|
vec3 tmpvar_47;
|
|
tmpvar_47 = c_42.xyz;
|
|
o_39.Albedo = tmpvar_47;
|
|
vec4 tmpvar_48;
|
|
tmpvar_48 = texture2D (_BumpMap, IN_38.uv_BumpMap);
|
|
vec4 tmpvar_49;
|
|
tmpvar_49 = UnpackNormal (tmpvar_48);
|
|
vec3 tmpvar_50;
|
|
tmpvar_50 = tmpvar_49.xyz;
|
|
vec3 tmpvar_51;
|
|
tmpvar_51 = tmpvar_50;
|
|
o_39.Normal = tmpvar_51;
|
|
float tmpvar_52;
|
|
tmpvar_52 = dot (IN_38.TtoW0, o_39.Normal);
|
|
float tmpvar_53;
|
|
tmpvar_53 = dot (IN_38.TtoW1, o_39.Normal);
|
|
float tmpvar_54;
|
|
tmpvar_54 = dot (IN_38.TtoW2, o_39.Normal);
|
|
vec3 tmpvar_55;
|
|
tmpvar_55.x = tmpvar_52;
|
|
tmpvar_55.y = tmpvar_53;
|
|
tmpvar_55.z = tmpvar_54;
|
|
vec3 tmpvar_56;
|
|
tmpvar_56 = reflect (IN_38.worldRefl, tmpvar_55);
|
|
vec3 tmpvar_57;
|
|
tmpvar_57 = tmpvar_56;
|
|
worldRefl_41 = tmpvar_57;
|
|
vec4 tmpvar_58;
|
|
tmpvar_58 = textureCube (_Cube, worldRefl_41);
|
|
vec4 tmpvar_59;
|
|
tmpvar_59 = tmpvar_58;
|
|
reflcol_40 = tmpvar_59;
|
|
vec4 tmpvar_60;
|
|
tmpvar_60 = (reflcol_40 * tex_43.w);
|
|
reflcol_40 = tmpvar_60;
|
|
vec3 tmpvar_61;
|
|
tmpvar_61 = (reflcol_40.xyz * _ReflectColor.xyz);
|
|
o_39.Emission = tmpvar_61;
|
|
float tmpvar_62;
|
|
tmpvar_62 = (reflcol_40.w * _ReflectColor.w);
|
|
o_39.Alpha = tmpvar_62;
|
|
}
|
|
|
|
vec4 LightingLambert_PrePass (
|
|
in SurfaceOutput s_63,
|
|
in vec4 light_64
|
|
)
|
|
{
|
|
vec4 c_65;
|
|
vec3 tmpvar_66;
|
|
tmpvar_66 = (s_63.Albedo * light_64.xyz);
|
|
c_65.xyz = tmpvar_66.xyz.xyz;
|
|
float tmpvar_67;
|
|
tmpvar_67 = s_63.Alpha;
|
|
c_65.w = vec4(tmpvar_67).w;
|
|
return c_65;
|
|
}
|
|
|
|
vec3 DecodeLightmap (
|
|
in vec4 color_68
|
|
)
|
|
{
|
|
return (2.0 * color_68.xyz);
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_69
|
|
)
|
|
{
|
|
vec4 col_70;
|
|
vec3 lm_71;
|
|
vec3 lmIndirect_72;
|
|
vec3 lmFull_73;
|
|
vec4 light_74;
|
|
SurfaceOutput o_75;
|
|
Input surfIN_76;
|
|
vec2 tmpvar_77;
|
|
tmpvar_77 = IN_69.hip_pack0.xy;
|
|
surfIN_76.uv_MainTex = tmpvar_77;
|
|
vec2 tmpvar_78;
|
|
tmpvar_78 = IN_69.hip_pack0.zw;
|
|
surfIN_76.uv_BumpMap = tmpvar_78;
|
|
vec3 tmpvar_79;
|
|
tmpvar_79.x = IN_69.TtoW0.w;
|
|
tmpvar_79.y = IN_69.TtoW1.w;
|
|
tmpvar_79.z = IN_69.TtoW2.w;
|
|
vec3 tmpvar_80;
|
|
tmpvar_80 = tmpvar_79;
|
|
surfIN_76.worldRefl = tmpvar_80;
|
|
vec3 tmpvar_81;
|
|
tmpvar_81 = IN_69.TtoW0.xyz;
|
|
surfIN_76.TtoW0 = tmpvar_81;
|
|
vec3 tmpvar_82;
|
|
tmpvar_82 = IN_69.TtoW1.xyz;
|
|
surfIN_76.TtoW1 = tmpvar_82;
|
|
vec3 tmpvar_83;
|
|
tmpvar_83 = IN_69.TtoW2.xyz;
|
|
surfIN_76.TtoW2 = tmpvar_83;
|
|
vec3 tmpvar_84;
|
|
tmpvar_84 = vec3(0.0, 0.0, 0.0);
|
|
o_75.Albedo = tmpvar_84;
|
|
vec3 tmpvar_85;
|
|
tmpvar_85 = vec3(0.0, 0.0, 0.0);
|
|
o_75.Emission = tmpvar_85;
|
|
float tmpvar_86;
|
|
tmpvar_86 = 0.0;
|
|
o_75.Specular = tmpvar_86;
|
|
float tmpvar_87;
|
|
tmpvar_87 = 0.0;
|
|
o_75.Alpha = tmpvar_87;
|
|
float tmpvar_88;
|
|
tmpvar_88 = 0.0;
|
|
o_75.Gloss = tmpvar_88;
|
|
surf (surfIN_76, o_75);
|
|
vec4 tmpvar_89;
|
|
tmpvar_89 = texture2DProj (_LightBuffer, IN_69.hip_screen);
|
|
vec4 tmpvar_90;
|
|
tmpvar_90 = tmpvar_89;
|
|
light_74 = tmpvar_90;
|
|
vec4 tmpvar_91;
|
|
tmpvar_91 = log2 (light_74);
|
|
vec4 tmpvar_92;
|
|
tmpvar_92 = -(tmpvar_91);
|
|
light_74 = tmpvar_92;
|
|
vec4 tmpvar_93;
|
|
tmpvar_93 = texture2D (unity_Lightmap, IN_69.hip_lmapFade.xy);
|
|
vec3 tmpvar_94;
|
|
tmpvar_94 = DecodeLightmap (tmpvar_93);
|
|
vec3 tmpvar_95;
|
|
tmpvar_95 = tmpvar_94;
|
|
lmFull_73 = tmpvar_95;
|
|
vec4 tmpvar_96;
|
|
tmpvar_96 = texture2D (unity_LightmapInd, IN_69.hip_lmapFade.xy);
|
|
vec3 tmpvar_97;
|
|
tmpvar_97 = DecodeLightmap (tmpvar_96);
|
|
vec3 tmpvar_98;
|
|
tmpvar_98 = tmpvar_97;
|
|
lmIndirect_72 = tmpvar_98;
|
|
float tmpvar_99;
|
|
tmpvar_99 = xll_saturate (IN_69.hip_lmapFade.z);
|
|
vec3 tmpvar_100;
|
|
tmpvar_100 = vec3(tmpvar_99);
|
|
vec3 tmpvar_101;
|
|
tmpvar_101 = mix (lmIndirect_72, lmFull_73, tmpvar_100);
|
|
vec3 tmpvar_102;
|
|
tmpvar_102 = tmpvar_101;
|
|
lm_71 = tmpvar_102;
|
|
vec3 tmpvar_103;
|
|
tmpvar_103 = (light_74.xyz + lm_71);
|
|
light_74.xyz = tmpvar_103.xyz.xyz;
|
|
vec4 tmpvar_104;
|
|
tmpvar_104 = LightingLambert_PrePass (o_75, light_74);
|
|
vec4 tmpvar_105;
|
|
tmpvar_105 = tmpvar_104;
|
|
col_70 = tmpvar_105;
|
|
vec3 tmpvar_106;
|
|
tmpvar_106 = (col_70.xyz + o_75.Emission);
|
|
col_70.xyz = tmpvar_106.xyz.xyz;
|
|
return col_70;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_107;
|
|
vec4 xl_retval_108;
|
|
vec4 tmpvar_109;
|
|
tmpvar_109 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_107.pos = tmpvar_109;
|
|
float tmpvar_110;
|
|
tmpvar_110 = xlv_FOG.x;
|
|
xlt_IN_107.fog = tmpvar_110;
|
|
vec4 tmpvar_111;
|
|
tmpvar_111 = gl_TexCoord[0].xyzw;
|
|
vec4 tmpvar_112;
|
|
tmpvar_112 = tmpvar_111;
|
|
xlt_IN_107.hip_pack0 = tmpvar_112;
|
|
vec4 tmpvar_113;
|
|
tmpvar_113 = gl_TexCoord[1].xyzw;
|
|
vec4 tmpvar_114;
|
|
tmpvar_114 = tmpvar_113;
|
|
xlt_IN_107.hip_screen = tmpvar_114;
|
|
vec4 tmpvar_115;
|
|
tmpvar_115 = gl_TexCoord[2].xyzw;
|
|
vec4 tmpvar_116;
|
|
tmpvar_116 = tmpvar_115;
|
|
xlt_IN_107.TtoW0 = tmpvar_116;
|
|
vec4 tmpvar_117;
|
|
tmpvar_117 = gl_TexCoord[3].xyzw;
|
|
vec4 tmpvar_118;
|
|
tmpvar_118 = tmpvar_117;
|
|
xlt_IN_107.TtoW1 = tmpvar_118;
|
|
vec4 tmpvar_119;
|
|
tmpvar_119 = gl_TexCoord[4].xyzw;
|
|
vec4 tmpvar_120;
|
|
tmpvar_120 = tmpvar_119;
|
|
xlt_IN_107.TtoW2 = tmpvar_120;
|
|
vec3 tmpvar_121;
|
|
tmpvar_121 = gl_TexCoord[5].xyz;
|
|
vec3 tmpvar_122;
|
|
tmpvar_122 = tmpvar_121;
|
|
xlt_IN_107.hip_lmapFade = tmpvar_122;
|
|
vec4 tmpvar_123;
|
|
tmpvar_123 = frag_surf (xlt_IN_107);
|
|
vec4 tmpvar_124;
|
|
tmpvar_124 = tmpvar_123;
|
|
xl_retval_108 = tmpvar_124;
|
|
vec4 tmpvar_125;
|
|
tmpvar_125 = xl_retval_108.xyzw;
|
|
vec4 tmpvar_126;
|
|
tmpvar_126 = tmpvar_125;
|
|
gl_FragData[0] = tmpvar_126;
|
|
}
|
|
|