mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-11 00:31:28 -05:00
333 lines
7.1 KiB
Text
333 lines
7.1 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_Control;
|
|
vec2 uv_Splat0;
|
|
vec2 uv_Splat1;
|
|
vec2 uv_Splat2;
|
|
vec2 uv_Splat3;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec4 hip_pack0;
|
|
vec4 hip_pack1;
|
|
vec2 hip_pack2;
|
|
vec4 hip_screen;
|
|
vec3 hip_lmapFade;
|
|
};
|
|
uniform sampler2D _Control;
|
|
uniform sampler2D _LightBuffer;
|
|
uniform sampler2D _Splat0;
|
|
uniform sampler2D _Splat1;
|
|
uniform sampler2D _Splat2;
|
|
uniform sampler2D _Splat3;
|
|
uniform sampler2D unity_Lightmap;
|
|
uniform sampler2D unity_LightmapInd;
|
|
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;
|
|
}
|
|
|
|
void surf (
|
|
in Input IN_33,
|
|
inout SurfaceOutput o_34
|
|
)
|
|
{
|
|
vec3 col_35;
|
|
vec4 splat_control_36;
|
|
vec4 tmpvar_37;
|
|
tmpvar_37 = texture2D (_Control, IN_33.uv_Control);
|
|
vec4 tmpvar_38;
|
|
tmpvar_38 = tmpvar_37;
|
|
splat_control_36 = tmpvar_38;
|
|
vec4 tmpvar_39;
|
|
tmpvar_39 = texture2D (_Splat0, IN_33.uv_Splat0);
|
|
vec3 tmpvar_40;
|
|
tmpvar_40 = (splat_control_36.x * tmpvar_39.xyz);
|
|
col_35 = tmpvar_40;
|
|
vec4 tmpvar_41;
|
|
tmpvar_41 = texture2D (_Splat1, IN_33.uv_Splat1);
|
|
vec3 tmpvar_42;
|
|
tmpvar_42 = (col_35 + (splat_control_36.y * tmpvar_41.xyz));
|
|
col_35 = tmpvar_42;
|
|
vec4 tmpvar_43;
|
|
tmpvar_43 = texture2D (_Splat2, IN_33.uv_Splat2);
|
|
vec3 tmpvar_44;
|
|
tmpvar_44 = (col_35 + (splat_control_36.z * tmpvar_43.xyz));
|
|
col_35 = tmpvar_44;
|
|
vec4 tmpvar_45;
|
|
tmpvar_45 = texture2D (_Splat3, IN_33.uv_Splat3);
|
|
vec3 tmpvar_46;
|
|
tmpvar_46 = (col_35 + (splat_control_36.w * tmpvar_45.xyz));
|
|
col_35 = tmpvar_46;
|
|
vec3 tmpvar_47;
|
|
tmpvar_47 = col_35;
|
|
o_34.Albedo = tmpvar_47;
|
|
float tmpvar_48;
|
|
tmpvar_48 = 0.0;
|
|
o_34.Alpha = tmpvar_48;
|
|
}
|
|
|
|
vec4 LightingLambert_PrePass (
|
|
in SurfaceOutput s_49,
|
|
in vec4 light_50
|
|
)
|
|
{
|
|
vec4 c_51;
|
|
vec3 tmpvar_52;
|
|
tmpvar_52 = (s_49.Albedo * light_50.xyz);
|
|
c_51.xyz = tmpvar_52.xyz.xyz;
|
|
float tmpvar_53;
|
|
tmpvar_53 = s_49.Alpha;
|
|
c_51.w = vec4(tmpvar_53).w;
|
|
return c_51;
|
|
}
|
|
|
|
vec3 DecodeLightmap (
|
|
in vec4 color_54
|
|
)
|
|
{
|
|
return (2.0 * color_54.xyz);
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_55
|
|
)
|
|
{
|
|
vec4 col_56;
|
|
vec3 lm_57;
|
|
vec3 lmIndirect_58;
|
|
vec3 lmFull_59;
|
|
vec4 light_60;
|
|
SurfaceOutput o_61;
|
|
Input surfIN_62;
|
|
vec2 tmpvar_63;
|
|
tmpvar_63 = IN_55.hip_pack0.xy;
|
|
surfIN_62.uv_Control = tmpvar_63;
|
|
vec2 tmpvar_64;
|
|
tmpvar_64 = IN_55.hip_pack0.zw;
|
|
surfIN_62.uv_Splat0 = tmpvar_64;
|
|
vec2 tmpvar_65;
|
|
tmpvar_65 = IN_55.hip_pack1.xy;
|
|
surfIN_62.uv_Splat1 = tmpvar_65;
|
|
vec2 tmpvar_66;
|
|
tmpvar_66 = IN_55.hip_pack1.zw;
|
|
surfIN_62.uv_Splat2 = tmpvar_66;
|
|
vec2 tmpvar_67;
|
|
tmpvar_67 = IN_55.hip_pack2.xy;
|
|
surfIN_62.uv_Splat3 = tmpvar_67;
|
|
vec3 tmpvar_68;
|
|
tmpvar_68 = vec3(0.0, 0.0, 0.0);
|
|
o_61.Albedo = tmpvar_68;
|
|
vec3 tmpvar_69;
|
|
tmpvar_69 = vec3(0.0, 0.0, 0.0);
|
|
o_61.Emission = tmpvar_69;
|
|
float tmpvar_70;
|
|
tmpvar_70 = 0.0;
|
|
o_61.Specular = tmpvar_70;
|
|
float tmpvar_71;
|
|
tmpvar_71 = 0.0;
|
|
o_61.Alpha = tmpvar_71;
|
|
float tmpvar_72;
|
|
tmpvar_72 = 0.0;
|
|
o_61.Gloss = tmpvar_72;
|
|
surf (surfIN_62, o_61);
|
|
vec4 tmpvar_73;
|
|
tmpvar_73 = texture2DProj (_LightBuffer, IN_55.hip_screen);
|
|
vec4 tmpvar_74;
|
|
tmpvar_74 = tmpvar_73;
|
|
light_60 = tmpvar_74;
|
|
vec4 tmpvar_75;
|
|
tmpvar_75 = log2 (light_60);
|
|
vec4 tmpvar_76;
|
|
tmpvar_76 = -(tmpvar_75);
|
|
light_60 = tmpvar_76;
|
|
vec4 tmpvar_77;
|
|
tmpvar_77 = texture2D (unity_Lightmap, IN_55.hip_lmapFade.xy);
|
|
vec3 tmpvar_78;
|
|
tmpvar_78 = DecodeLightmap (tmpvar_77);
|
|
vec3 tmpvar_79;
|
|
tmpvar_79 = tmpvar_78;
|
|
lmFull_59 = tmpvar_79;
|
|
vec4 tmpvar_80;
|
|
tmpvar_80 = texture2D (unity_LightmapInd, IN_55.hip_lmapFade.xy);
|
|
vec3 tmpvar_81;
|
|
tmpvar_81 = DecodeLightmap (tmpvar_80);
|
|
vec3 tmpvar_82;
|
|
tmpvar_82 = tmpvar_81;
|
|
lmIndirect_58 = tmpvar_82;
|
|
float tmpvar_83;
|
|
tmpvar_83 = xll_saturate (IN_55.hip_lmapFade.z);
|
|
vec3 tmpvar_84;
|
|
tmpvar_84 = vec3(tmpvar_83);
|
|
vec3 tmpvar_85;
|
|
tmpvar_85 = mix (lmIndirect_58, lmFull_59, tmpvar_84);
|
|
vec3 tmpvar_86;
|
|
tmpvar_86 = tmpvar_85;
|
|
lm_57 = tmpvar_86;
|
|
vec3 tmpvar_87;
|
|
tmpvar_87 = (light_60.xyz + lm_57);
|
|
light_60.xyz = tmpvar_87.xyz.xyz;
|
|
vec4 tmpvar_88;
|
|
tmpvar_88 = LightingLambert_PrePass (o_61, light_60);
|
|
vec4 tmpvar_89;
|
|
tmpvar_89 = tmpvar_88;
|
|
col_56 = tmpvar_89;
|
|
return col_56;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_90;
|
|
vec4 xl_retval_91;
|
|
vec4 tmpvar_92;
|
|
tmpvar_92 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_90.pos = tmpvar_92;
|
|
float tmpvar_93;
|
|
tmpvar_93 = xlv_FOG.x;
|
|
xlt_IN_90.fog = tmpvar_93;
|
|
vec4 tmpvar_94;
|
|
tmpvar_94 = gl_TexCoord[0].xyzw;
|
|
vec4 tmpvar_95;
|
|
tmpvar_95 = tmpvar_94;
|
|
xlt_IN_90.hip_pack0 = tmpvar_95;
|
|
vec4 tmpvar_96;
|
|
tmpvar_96 = gl_TexCoord[1].xyzw;
|
|
vec4 tmpvar_97;
|
|
tmpvar_97 = tmpvar_96;
|
|
xlt_IN_90.hip_pack1 = tmpvar_97;
|
|
vec2 tmpvar_98;
|
|
tmpvar_98 = gl_TexCoord[2].xy;
|
|
vec2 tmpvar_99;
|
|
tmpvar_99 = tmpvar_98;
|
|
xlt_IN_90.hip_pack2 = tmpvar_99;
|
|
vec4 tmpvar_100;
|
|
tmpvar_100 = gl_TexCoord[3].xyzw;
|
|
vec4 tmpvar_101;
|
|
tmpvar_101 = tmpvar_100;
|
|
xlt_IN_90.hip_screen = tmpvar_101;
|
|
vec3 tmpvar_102;
|
|
tmpvar_102 = gl_TexCoord[4].xyz;
|
|
vec3 tmpvar_103;
|
|
tmpvar_103 = tmpvar_102;
|
|
xlt_IN_90.hip_lmapFade = tmpvar_103;
|
|
vec4 tmpvar_104;
|
|
tmpvar_104 = frag_surf (xlt_IN_90);
|
|
vec4 tmpvar_105;
|
|
tmpvar_105 = tmpvar_104;
|
|
xl_retval_91 = tmpvar_105;
|
|
vec4 tmpvar_106;
|
|
tmpvar_106 = xl_retval_91.xyzw;
|
|
vec4 tmpvar_107;
|
|
tmpvar_107 = tmpvar_106;
|
|
gl_FragData[0] = tmpvar_107;
|
|
}
|
|
|