mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-29 02:55:36 -05:00
304 lines
6.1 KiB
Text
304 lines
6.1 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_MainTex;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec2 hip_pack0;
|
|
vec4 hip_screen;
|
|
vec3 hip_lmapFade;
|
|
};
|
|
varying vec4 xlv_FOG;
|
|
uniform sampler2D unity_LightmapInd;
|
|
uniform sampler2D unity_Lightmap;
|
|
uniform vec4 _SpecColor;
|
|
uniform float _Shininess;
|
|
uniform sampler2D _MainTex;
|
|
uniform sampler2D _LightBuffer;
|
|
uniform float _Cutoff;
|
|
uniform vec4 _Color;
|
|
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;
|
|
}
|
|
|
|
void surf (
|
|
in Input IN_34,
|
|
inout SurfaceOutput o_35
|
|
)
|
|
{
|
|
vec4 tex_36;
|
|
vec4 tmpvar_37;
|
|
tmpvar_37 = texture2D (_MainTex, IN_34.uv_MainTex);
|
|
vec4 tmpvar_38;
|
|
tmpvar_38 = tmpvar_37;
|
|
tex_36 = tmpvar_38;
|
|
vec3 tmpvar_39;
|
|
tmpvar_39 = (tex_36.xyz * _Color.xyz);
|
|
o_35.Albedo = tmpvar_39;
|
|
float tmpvar_40;
|
|
tmpvar_40 = tex_36.w;
|
|
o_35.Gloss = tmpvar_40;
|
|
float tmpvar_41;
|
|
tmpvar_41 = (tex_36.w * _Color.w);
|
|
o_35.Alpha = tmpvar_41;
|
|
float tmpvar_42;
|
|
tmpvar_42 = _Shininess;
|
|
o_35.Specular = tmpvar_42;
|
|
}
|
|
|
|
vec4 LightingBlinnPhong_PrePass (
|
|
in SurfaceOutput s_43,
|
|
in vec4 light_44
|
|
)
|
|
{
|
|
vec4 c_45;
|
|
float spec_46;
|
|
float tmpvar_47;
|
|
tmpvar_47 = (light_44.w * s_43.Gloss);
|
|
spec_46 = tmpvar_47;
|
|
vec3 tmpvar_48;
|
|
tmpvar_48 = ((s_43.Albedo * light_44.xyz) + ((light_44.xyz * _SpecColor.xyz) * spec_46));
|
|
c_45.xyz = tmpvar_48.xyz.xyz;
|
|
float tmpvar_49;
|
|
tmpvar_49 = (s_43.Alpha + (spec_46 * _SpecColor.w));
|
|
c_45.w = vec4(tmpvar_49).w;
|
|
return c_45;
|
|
}
|
|
|
|
vec3 DecodeLightmap (
|
|
in vec4 color_50
|
|
)
|
|
{
|
|
return (2.0 * color_50.xyz);
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_51
|
|
)
|
|
{
|
|
vec4 col_52;
|
|
vec3 lm_53;
|
|
vec3 lmIndirect_54;
|
|
vec3 lmFull_55;
|
|
vec4 light_56;
|
|
SurfaceOutput o_57;
|
|
Input surfIN_58;
|
|
vec2 tmpvar_59;
|
|
tmpvar_59 = IN_51.hip_pack0.xy;
|
|
surfIN_58.uv_MainTex = tmpvar_59;
|
|
vec3 tmpvar_60;
|
|
tmpvar_60 = vec3(0.0, 0.0, 0.0);
|
|
o_57.Albedo = tmpvar_60;
|
|
vec3 tmpvar_61;
|
|
tmpvar_61 = vec3(0.0, 0.0, 0.0);
|
|
o_57.Emission = tmpvar_61;
|
|
float tmpvar_62;
|
|
tmpvar_62 = 0.0;
|
|
o_57.Specular = tmpvar_62;
|
|
float tmpvar_63;
|
|
tmpvar_63 = 0.0;
|
|
o_57.Alpha = tmpvar_63;
|
|
float tmpvar_64;
|
|
tmpvar_64 = 0.0;
|
|
o_57.Gloss = tmpvar_64;
|
|
surf (surfIN_58, o_57);
|
|
xll_clip ((o_57.Alpha - _Cutoff));
|
|
vec4 tmpvar_65;
|
|
tmpvar_65 = texture2DProj (_LightBuffer, IN_51.hip_screen);
|
|
vec4 tmpvar_66;
|
|
tmpvar_66 = tmpvar_65;
|
|
light_56 = tmpvar_66;
|
|
vec4 tmpvar_67;
|
|
tmpvar_67 = log2 (light_56);
|
|
vec4 tmpvar_68;
|
|
tmpvar_68 = -(tmpvar_67);
|
|
light_56 = tmpvar_68;
|
|
vec4 tmpvar_69;
|
|
tmpvar_69 = texture2D (unity_Lightmap, IN_51.hip_lmapFade.xy);
|
|
vec3 tmpvar_70;
|
|
tmpvar_70 = DecodeLightmap (tmpvar_69);
|
|
vec3 tmpvar_71;
|
|
tmpvar_71 = tmpvar_70;
|
|
lmFull_55 = tmpvar_71;
|
|
vec4 tmpvar_72;
|
|
tmpvar_72 = texture2D (unity_LightmapInd, IN_51.hip_lmapFade.xy);
|
|
vec3 tmpvar_73;
|
|
tmpvar_73 = DecodeLightmap (tmpvar_72);
|
|
vec3 tmpvar_74;
|
|
tmpvar_74 = tmpvar_73;
|
|
lmIndirect_54 = tmpvar_74;
|
|
float tmpvar_75;
|
|
tmpvar_75 = xll_saturate (IN_51.hip_lmapFade.z);
|
|
vec3 tmpvar_76;
|
|
tmpvar_76 = vec3(tmpvar_75);
|
|
vec3 tmpvar_77;
|
|
tmpvar_77 = mix (lmIndirect_54, lmFull_55, tmpvar_76);
|
|
vec3 tmpvar_78;
|
|
tmpvar_78 = tmpvar_77;
|
|
lm_53 = tmpvar_78;
|
|
vec3 tmpvar_79;
|
|
tmpvar_79 = (light_56.xyz + lm_53);
|
|
light_56.xyz = tmpvar_79.xyz.xyz;
|
|
vec4 tmpvar_80;
|
|
tmpvar_80 = LightingBlinnPhong_PrePass (o_57, light_56);
|
|
vec4 tmpvar_81;
|
|
tmpvar_81 = tmpvar_80;
|
|
col_52 = tmpvar_81;
|
|
return col_52;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_82;
|
|
vec4 xl_retval_83;
|
|
vec4 tmpvar_84;
|
|
tmpvar_84 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_82.pos = tmpvar_84;
|
|
float tmpvar_85;
|
|
tmpvar_85 = xlv_FOG.x;
|
|
xlt_IN_82.fog = tmpvar_85;
|
|
vec2 tmpvar_86;
|
|
tmpvar_86 = gl_TexCoord[0].xy;
|
|
vec2 tmpvar_87;
|
|
tmpvar_87 = tmpvar_86;
|
|
xlt_IN_82.hip_pack0 = tmpvar_87;
|
|
vec4 tmpvar_88;
|
|
tmpvar_88 = gl_TexCoord[1].xyzw;
|
|
vec4 tmpvar_89;
|
|
tmpvar_89 = tmpvar_88;
|
|
xlt_IN_82.hip_screen = tmpvar_89;
|
|
vec3 tmpvar_90;
|
|
tmpvar_90 = gl_TexCoord[2].xyz;
|
|
vec3 tmpvar_91;
|
|
tmpvar_91 = tmpvar_90;
|
|
xlt_IN_82.hip_lmapFade = tmpvar_91;
|
|
vec4 tmpvar_92;
|
|
tmpvar_92 = frag_surf (xlt_IN_82);
|
|
vec4 tmpvar_93;
|
|
tmpvar_93 = tmpvar_92;
|
|
xl_retval_83 = tmpvar_93;
|
|
vec4 tmpvar_94;
|
|
tmpvar_94 = xl_retval_83.xyzw;
|
|
vec4 tmpvar_95;
|
|
tmpvar_95 = tmpvar_94;
|
|
gl_FragData[0] = tmpvar_95;
|
|
}
|
|
|