mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-29 02:55:36 -05:00
290 lines
5.8 KiB
Text
290 lines
5.8 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
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;
|
|
vec4 hip_screen;
|
|
vec3 hip_lmapFade;
|
|
};
|
|
varying vec4 xlv_FOG;
|
|
uniform sampler2D unity_LightmapInd;
|
|
uniform sampler2D unity_Lightmap;
|
|
uniform sampler2D _MainTex;
|
|
uniform sampler2D _LightBuffer;
|
|
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
|
|
)
|
|
{
|
|
vec4 c_35;
|
|
vec4 tmpvar_36;
|
|
tmpvar_36 = texture2D (_MainTex, IN_33.uv_MainTex);
|
|
vec4 tmpvar_37;
|
|
tmpvar_37 = (tmpvar_36 * IN_33.color);
|
|
c_35 = tmpvar_37;
|
|
vec3 tmpvar_38;
|
|
tmpvar_38 = c_35.xyz;
|
|
o_34.Albedo = tmpvar_38;
|
|
float tmpvar_39;
|
|
tmpvar_39 = c_35.w;
|
|
o_34.Alpha = tmpvar_39;
|
|
}
|
|
|
|
vec4 LightingLambert_PrePass (
|
|
in SurfaceOutput s_40,
|
|
in vec4 light_41
|
|
)
|
|
{
|
|
vec4 c_42;
|
|
vec3 tmpvar_43;
|
|
tmpvar_43 = (s_40.Albedo * light_41.xyz);
|
|
c_42.xyz = tmpvar_43.xyz.xyz;
|
|
float tmpvar_44;
|
|
tmpvar_44 = s_40.Alpha;
|
|
c_42.w = vec4(tmpvar_44).w;
|
|
return c_42;
|
|
}
|
|
|
|
vec3 DecodeLightmap (
|
|
in vec4 color_45
|
|
)
|
|
{
|
|
return (2.0 * color_45.xyz);
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_46
|
|
)
|
|
{
|
|
vec4 col_47;
|
|
vec3 lm_48;
|
|
vec3 lmIndirect_49;
|
|
vec3 lmFull_50;
|
|
vec4 light_51;
|
|
SurfaceOutput o_52;
|
|
Input surfIN_53;
|
|
vec2 tmpvar_54;
|
|
tmpvar_54 = IN_46.hip_pack0.xy;
|
|
surfIN_53.uv_MainTex = tmpvar_54;
|
|
vec4 tmpvar_55;
|
|
tmpvar_55 = IN_46.lop_color;
|
|
surfIN_53.color = tmpvar_55;
|
|
vec3 tmpvar_56;
|
|
tmpvar_56 = vec3(0.0, 0.0, 0.0);
|
|
o_52.Albedo = tmpvar_56;
|
|
vec3 tmpvar_57;
|
|
tmpvar_57 = vec3(0.0, 0.0, 0.0);
|
|
o_52.Emission = tmpvar_57;
|
|
float tmpvar_58;
|
|
tmpvar_58 = 0.0;
|
|
o_52.Specular = tmpvar_58;
|
|
float tmpvar_59;
|
|
tmpvar_59 = 0.0;
|
|
o_52.Alpha = tmpvar_59;
|
|
float tmpvar_60;
|
|
tmpvar_60 = 0.0;
|
|
o_52.Gloss = tmpvar_60;
|
|
surf (surfIN_53, o_52);
|
|
vec4 tmpvar_61;
|
|
tmpvar_61 = texture2DProj (_LightBuffer, IN_46.hip_screen);
|
|
vec4 tmpvar_62;
|
|
tmpvar_62 = tmpvar_61;
|
|
light_51 = tmpvar_62;
|
|
vec4 tmpvar_63;
|
|
tmpvar_63 = log2 (light_51);
|
|
vec4 tmpvar_64;
|
|
tmpvar_64 = -(tmpvar_63);
|
|
light_51 = tmpvar_64;
|
|
vec4 tmpvar_65;
|
|
tmpvar_65 = texture2D (unity_Lightmap, IN_46.hip_lmapFade.xy);
|
|
vec3 tmpvar_66;
|
|
tmpvar_66 = DecodeLightmap (tmpvar_65);
|
|
vec3 tmpvar_67;
|
|
tmpvar_67 = tmpvar_66;
|
|
lmFull_50 = tmpvar_67;
|
|
vec4 tmpvar_68;
|
|
tmpvar_68 = texture2D (unity_LightmapInd, IN_46.hip_lmapFade.xy);
|
|
vec3 tmpvar_69;
|
|
tmpvar_69 = DecodeLightmap (tmpvar_68);
|
|
vec3 tmpvar_70;
|
|
tmpvar_70 = tmpvar_69;
|
|
lmIndirect_49 = tmpvar_70;
|
|
float tmpvar_71;
|
|
tmpvar_71 = xll_saturate (IN_46.hip_lmapFade.z);
|
|
vec3 tmpvar_72;
|
|
tmpvar_72 = vec3(tmpvar_71);
|
|
vec3 tmpvar_73;
|
|
tmpvar_73 = mix (lmIndirect_49, lmFull_50, tmpvar_72);
|
|
vec3 tmpvar_74;
|
|
tmpvar_74 = tmpvar_73;
|
|
lm_48 = tmpvar_74;
|
|
vec3 tmpvar_75;
|
|
tmpvar_75 = (light_51.xyz + lm_48);
|
|
light_51.xyz = tmpvar_75.xyz.xyz;
|
|
vec4 tmpvar_76;
|
|
tmpvar_76 = LightingLambert_PrePass (o_52, light_51);
|
|
vec4 tmpvar_77;
|
|
tmpvar_77 = tmpvar_76;
|
|
col_47 = tmpvar_77;
|
|
return col_47;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_78;
|
|
vec4 xl_retval_79;
|
|
vec4 tmpvar_80;
|
|
tmpvar_80 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_78.pos = tmpvar_80;
|
|
float tmpvar_81;
|
|
tmpvar_81 = xlv_FOG.x;
|
|
xlt_IN_78.fog = tmpvar_81;
|
|
vec2 tmpvar_82;
|
|
tmpvar_82 = gl_TexCoord[0].xy;
|
|
vec2 tmpvar_83;
|
|
tmpvar_83 = tmpvar_82;
|
|
xlt_IN_78.hip_pack0 = tmpvar_83;
|
|
vec4 tmpvar_84;
|
|
tmpvar_84 = gl_Color.xyzw;
|
|
vec4 tmpvar_85;
|
|
tmpvar_85 = tmpvar_84;
|
|
xlt_IN_78.lop_color = tmpvar_85;
|
|
vec4 tmpvar_86;
|
|
tmpvar_86 = gl_TexCoord[1].xyzw;
|
|
vec4 tmpvar_87;
|
|
tmpvar_87 = tmpvar_86;
|
|
xlt_IN_78.hip_screen = tmpvar_87;
|
|
vec3 tmpvar_88;
|
|
tmpvar_88 = gl_TexCoord[2].xyz;
|
|
vec3 tmpvar_89;
|
|
tmpvar_89 = tmpvar_88;
|
|
xlt_IN_78.hip_lmapFade = tmpvar_89;
|
|
vec4 tmpvar_90;
|
|
tmpvar_90 = frag_surf (xlt_IN_78);
|
|
vec4 tmpvar_91;
|
|
tmpvar_91 = tmpvar_90;
|
|
xl_retval_79 = tmpvar_91;
|
|
vec4 tmpvar_92;
|
|
tmpvar_92 = xl_retval_79.xyzw;
|
|
vec4 tmpvar_93;
|
|
tmpvar_93 = tmpvar_92;
|
|
gl_FragData[0] = tmpvar_93;
|
|
}
|
|
|