mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 09:08:22 -05:00
363 lines
7.6 KiB
Text
363 lines
7.6 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 viewDir;
|
||
|
};
|
||
|
struct v2f_surf {
|
||
|
vec4 pos;
|
||
|
float fog;
|
||
|
vec4 hip_pack0;
|
||
|
vec3 viewDir;
|
||
|
vec4 hip_screen;
|
||
|
vec3 hip_lmapFade;
|
||
|
};
|
||
|
varying vec4 xlv_FOG;
|
||
|
uniform sampler2D unity_LightmapInd;
|
||
|
uniform sampler2D unity_Lightmap;
|
||
|
uniform sampler2D _ParallaxMap;
|
||
|
uniform float _Parallax;
|
||
|
uniform sampler2D _MainTex;
|
||
|
uniform sampler2D _LightBuffer;
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
vec2 ParallaxOffset (
|
||
|
in float h_38,
|
||
|
in float height_39,
|
||
|
in vec3 viewDir_40
|
||
|
)
|
||
|
{
|
||
|
vec3 v_41;
|
||
|
float tmpvar_42;
|
||
|
tmpvar_42 = ((h_38 * height_39) - (height_39 / 2.0));
|
||
|
h_38 = tmpvar_42;
|
||
|
vec3 tmpvar_43;
|
||
|
tmpvar_43 = normalize (viewDir_40);
|
||
|
vec3 tmpvar_44;
|
||
|
tmpvar_44 = tmpvar_43;
|
||
|
v_41 = tmpvar_44;
|
||
|
float tmpvar_45;
|
||
|
tmpvar_45 = (v_41.z + 0.42);
|
||
|
v_41.z = vec3(tmpvar_45).z;
|
||
|
return (h_38 * (v_41.xy / v_41.z));
|
||
|
}
|
||
|
|
||
|
void surf (
|
||
|
in Input IN_46,
|
||
|
inout SurfaceOutput o_47
|
||
|
)
|
||
|
{
|
||
|
vec4 c_48;
|
||
|
vec2 offset_49;
|
||
|
float h_50;
|
||
|
vec4 tmpvar_51;
|
||
|
tmpvar_51 = texture2D (_ParallaxMap, IN_46.uv_BumpMap);
|
||
|
float tmpvar_52;
|
||
|
tmpvar_52 = tmpvar_51.w;
|
||
|
h_50 = tmpvar_52;
|
||
|
vec2 tmpvar_53;
|
||
|
tmpvar_53 = ParallaxOffset (h_50, _Parallax, IN_46.viewDir);
|
||
|
vec2 tmpvar_54;
|
||
|
tmpvar_54 = tmpvar_53;
|
||
|
offset_49 = tmpvar_54;
|
||
|
vec2 tmpvar_55;
|
||
|
tmpvar_55 = (IN_46.uv_MainTex + offset_49);
|
||
|
IN_46.uv_MainTex = tmpvar_55;
|
||
|
vec2 tmpvar_56;
|
||
|
tmpvar_56 = (IN_46.uv_BumpMap + offset_49);
|
||
|
IN_46.uv_BumpMap = tmpvar_56;
|
||
|
vec4 tmpvar_57;
|
||
|
tmpvar_57 = texture2D (_MainTex, IN_46.uv_MainTex);
|
||
|
vec4 tmpvar_58;
|
||
|
tmpvar_58 = (tmpvar_57 * _Color);
|
||
|
c_48 = tmpvar_58;
|
||
|
vec3 tmpvar_59;
|
||
|
tmpvar_59 = c_48.xyz;
|
||
|
o_47.Albedo = tmpvar_59;
|
||
|
float tmpvar_60;
|
||
|
tmpvar_60 = c_48.w;
|
||
|
o_47.Alpha = tmpvar_60;
|
||
|
vec4 tmpvar_61;
|
||
|
tmpvar_61 = texture2D (_BumpMap, IN_46.uv_BumpMap);
|
||
|
vec4 tmpvar_62;
|
||
|
tmpvar_62 = UnpackNormal (tmpvar_61);
|
||
|
vec3 tmpvar_63;
|
||
|
tmpvar_63 = tmpvar_62.xyz;
|
||
|
vec3 tmpvar_64;
|
||
|
tmpvar_64 = tmpvar_63;
|
||
|
o_47.Normal = tmpvar_64;
|
||
|
}
|
||
|
|
||
|
vec4 LightingLambert_PrePass (
|
||
|
in SurfaceOutput s_65,
|
||
|
in vec4 light_66
|
||
|
)
|
||
|
{
|
||
|
vec4 c_67;
|
||
|
vec3 tmpvar_68;
|
||
|
tmpvar_68 = (s_65.Albedo * light_66.xyz);
|
||
|
c_67.xyz = tmpvar_68.xyz.xyz;
|
||
|
float tmpvar_69;
|
||
|
tmpvar_69 = s_65.Alpha;
|
||
|
c_67.w = vec4(tmpvar_69).w;
|
||
|
return c_67;
|
||
|
}
|
||
|
|
||
|
vec3 DecodeLightmap (
|
||
|
in vec4 color_70
|
||
|
)
|
||
|
{
|
||
|
return (2.0 * color_70.xyz);
|
||
|
}
|
||
|
|
||
|
vec4 frag_surf (
|
||
|
in v2f_surf IN_71
|
||
|
)
|
||
|
{
|
||
|
vec4 col_72;
|
||
|
vec3 lm_73;
|
||
|
vec3 lmIndirect_74;
|
||
|
vec3 lmFull_75;
|
||
|
vec4 light_76;
|
||
|
SurfaceOutput o_77;
|
||
|
Input surfIN_78;
|
||
|
vec2 tmpvar_79;
|
||
|
tmpvar_79 = IN_71.hip_pack0.xy;
|
||
|
surfIN_78.uv_MainTex = tmpvar_79;
|
||
|
vec2 tmpvar_80;
|
||
|
tmpvar_80 = IN_71.hip_pack0.zw;
|
||
|
surfIN_78.uv_BumpMap = tmpvar_80;
|
||
|
vec3 tmpvar_81;
|
||
|
tmpvar_81 = IN_71.viewDir;
|
||
|
surfIN_78.viewDir = tmpvar_81;
|
||
|
vec3 tmpvar_82;
|
||
|
tmpvar_82 = vec3(0.0, 0.0, 0.0);
|
||
|
o_77.Albedo = tmpvar_82;
|
||
|
vec3 tmpvar_83;
|
||
|
tmpvar_83 = vec3(0.0, 0.0, 0.0);
|
||
|
o_77.Emission = tmpvar_83;
|
||
|
float tmpvar_84;
|
||
|
tmpvar_84 = 0.0;
|
||
|
o_77.Specular = tmpvar_84;
|
||
|
float tmpvar_85;
|
||
|
tmpvar_85 = 0.0;
|
||
|
o_77.Alpha = tmpvar_85;
|
||
|
float tmpvar_86;
|
||
|
tmpvar_86 = 0.0;
|
||
|
o_77.Gloss = tmpvar_86;
|
||
|
surf (surfIN_78, o_77);
|
||
|
vec4 tmpvar_87;
|
||
|
tmpvar_87 = texture2DProj (_LightBuffer, IN_71.hip_screen);
|
||
|
vec4 tmpvar_88;
|
||
|
tmpvar_88 = tmpvar_87;
|
||
|
light_76 = tmpvar_88;
|
||
|
vec4 tmpvar_89;
|
||
|
tmpvar_89 = log2 (light_76);
|
||
|
vec4 tmpvar_90;
|
||
|
tmpvar_90 = -(tmpvar_89);
|
||
|
light_76 = tmpvar_90;
|
||
|
vec4 tmpvar_91;
|
||
|
tmpvar_91 = texture2D (unity_Lightmap, IN_71.hip_lmapFade.xy);
|
||
|
vec3 tmpvar_92;
|
||
|
tmpvar_92 = DecodeLightmap (tmpvar_91);
|
||
|
vec3 tmpvar_93;
|
||
|
tmpvar_93 = tmpvar_92;
|
||
|
lmFull_75 = tmpvar_93;
|
||
|
vec4 tmpvar_94;
|
||
|
tmpvar_94 = texture2D (unity_LightmapInd, IN_71.hip_lmapFade.xy);
|
||
|
vec3 tmpvar_95;
|
||
|
tmpvar_95 = DecodeLightmap (tmpvar_94);
|
||
|
vec3 tmpvar_96;
|
||
|
tmpvar_96 = tmpvar_95;
|
||
|
lmIndirect_74 = tmpvar_96;
|
||
|
float tmpvar_97;
|
||
|
tmpvar_97 = xll_saturate (IN_71.hip_lmapFade.z);
|
||
|
vec3 tmpvar_98;
|
||
|
tmpvar_98 = vec3(tmpvar_97);
|
||
|
vec3 tmpvar_99;
|
||
|
tmpvar_99 = mix (lmIndirect_74, lmFull_75, tmpvar_98);
|
||
|
vec3 tmpvar_100;
|
||
|
tmpvar_100 = tmpvar_99;
|
||
|
lm_73 = tmpvar_100;
|
||
|
vec3 tmpvar_101;
|
||
|
tmpvar_101 = (light_76.xyz + lm_73);
|
||
|
light_76.xyz = tmpvar_101.xyz.xyz;
|
||
|
vec4 tmpvar_102;
|
||
|
tmpvar_102 = LightingLambert_PrePass (o_77, light_76);
|
||
|
vec4 tmpvar_103;
|
||
|
tmpvar_103 = tmpvar_102;
|
||
|
col_72 = tmpvar_103;
|
||
|
return col_72;
|
||
|
}
|
||
|
|
||
|
void main ()
|
||
|
{
|
||
|
v2f_surf xlt_IN_104;
|
||
|
vec4 xl_retval_105;
|
||
|
vec4 tmpvar_106;
|
||
|
tmpvar_106 = vec4(0.0, 0.0, 0.0, 0.0);
|
||
|
xlt_IN_104.pos = tmpvar_106;
|
||
|
float tmpvar_107;
|
||
|
tmpvar_107 = xlv_FOG.x;
|
||
|
xlt_IN_104.fog = tmpvar_107;
|
||
|
vec4 tmpvar_108;
|
||
|
tmpvar_108 = gl_TexCoord[0].xyzw;
|
||
|
vec4 tmpvar_109;
|
||
|
tmpvar_109 = tmpvar_108;
|
||
|
xlt_IN_104.hip_pack0 = tmpvar_109;
|
||
|
vec3 tmpvar_110;
|
||
|
tmpvar_110 = gl_TexCoord[1].xyz;
|
||
|
vec3 tmpvar_111;
|
||
|
tmpvar_111 = tmpvar_110;
|
||
|
xlt_IN_104.viewDir = tmpvar_111;
|
||
|
vec4 tmpvar_112;
|
||
|
tmpvar_112 = gl_TexCoord[2].xyzw;
|
||
|
vec4 tmpvar_113;
|
||
|
tmpvar_113 = tmpvar_112;
|
||
|
xlt_IN_104.hip_screen = tmpvar_113;
|
||
|
vec3 tmpvar_114;
|
||
|
tmpvar_114 = gl_TexCoord[3].xyz;
|
||
|
vec3 tmpvar_115;
|
||
|
tmpvar_115 = tmpvar_114;
|
||
|
xlt_IN_104.hip_lmapFade = tmpvar_115;
|
||
|
vec4 tmpvar_116;
|
||
|
tmpvar_116 = frag_surf (xlt_IN_104);
|
||
|
vec4 tmpvar_117;
|
||
|
tmpvar_117 = tmpvar_116;
|
||
|
xl_retval_105 = tmpvar_117;
|
||
|
vec4 tmpvar_118;
|
||
|
tmpvar_118 = xl_retval_105.xyzw;
|
||
|
vec4 tmpvar_119;
|
||
|
tmpvar_119 = tmpvar_118;
|
||
|
gl_FragData[0] = tmpvar_119;
|
||
|
}
|
||
|
|