mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 00:58:30 -05:00
226 lines
5.1 KiB
Text
226 lines
5.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;
|
|
vec3 normal;
|
|
vec3 lightDir;
|
|
vec3 viewDir;
|
|
vec4 _LightCoord;
|
|
};
|
|
varying vec4 xlv_FOG;
|
|
uniform vec4 _SpecColor;
|
|
uniform float _Shininess;
|
|
uniform sampler2D _MainTex;
|
|
uniform sampler2D _LightTextureB0;
|
|
uniform sampler2D _LightTexture0;
|
|
uniform vec4 _LightColor0;
|
|
uniform vec4 _Color;
|
|
void surf (
|
|
in Input IN_1,
|
|
inout SurfaceOutput o_2
|
|
)
|
|
{
|
|
vec4 tex_3;
|
|
vec4 tmpvar_4;
|
|
tmpvar_4 = texture2D (_MainTex, IN_1.uv_MainTex);
|
|
vec4 tmpvar_5;
|
|
tmpvar_5 = tmpvar_4;
|
|
tex_3 = tmpvar_5;
|
|
vec3 tmpvar_6;
|
|
tmpvar_6 = (tex_3.xyz * _Color.xyz);
|
|
o_2.Albedo = tmpvar_6;
|
|
float tmpvar_7;
|
|
tmpvar_7 = tex_3.w;
|
|
o_2.Gloss = tmpvar_7;
|
|
float tmpvar_8;
|
|
tmpvar_8 = (tex_3.w * _Color.w);
|
|
o_2.Alpha = tmpvar_8;
|
|
float tmpvar_9;
|
|
tmpvar_9 = _Shininess;
|
|
o_2.Specular = tmpvar_9;
|
|
}
|
|
|
|
float UnitySpotCookie (
|
|
in vec4 LightCoord_10
|
|
)
|
|
{
|
|
vec4 tmpvar_11;
|
|
tmpvar_11 = texture2D (_LightTexture0, ((LightCoord_10.xy / LightCoord_10.w) + 0.5));
|
|
return tmpvar_11.w;
|
|
}
|
|
|
|
float UnitySpotAttenuate (
|
|
in vec3 LightCoord_12
|
|
)
|
|
{
|
|
float tmpvar_13;
|
|
tmpvar_13 = dot (LightCoord_12, LightCoord_12);
|
|
vec2 tmpvar_14;
|
|
tmpvar_14 = vec2(tmpvar_13);
|
|
vec2 tmpvar_15;
|
|
tmpvar_15 = tmpvar_14.xy;
|
|
vec4 tmpvar_16;
|
|
tmpvar_16 = texture2D (_LightTextureB0, tmpvar_15);
|
|
return tmpvar_16.w;
|
|
}
|
|
|
|
vec4 LightingBlinnPhong (
|
|
in SurfaceOutput s_17,
|
|
in vec3 lightDir_18,
|
|
in vec3 viewDir_19,
|
|
in float atten_20
|
|
)
|
|
{
|
|
vec4 c_21;
|
|
float spec_22;
|
|
float nh_23;
|
|
float diff_24;
|
|
vec3 h_25;
|
|
vec3 tmpvar_26;
|
|
tmpvar_26 = normalize ((lightDir_18 + viewDir_19));
|
|
vec3 tmpvar_27;
|
|
tmpvar_27 = tmpvar_26;
|
|
h_25 = tmpvar_27;
|
|
float tmpvar_28;
|
|
tmpvar_28 = dot (s_17.Normal, lightDir_18);
|
|
float tmpvar_29;
|
|
tmpvar_29 = max (0.0, tmpvar_28);
|
|
float tmpvar_30;
|
|
tmpvar_30 = tmpvar_29;
|
|
diff_24 = tmpvar_30;
|
|
float tmpvar_31;
|
|
tmpvar_31 = dot (s_17.Normal, h_25);
|
|
float tmpvar_32;
|
|
tmpvar_32 = max (0.0, tmpvar_31);
|
|
float tmpvar_33;
|
|
tmpvar_33 = tmpvar_32;
|
|
nh_23 = tmpvar_33;
|
|
float tmpvar_34;
|
|
tmpvar_34 = pow (nh_23, (s_17.Specular * 128.0));
|
|
float tmpvar_35;
|
|
tmpvar_35 = (tmpvar_34 * s_17.Gloss);
|
|
spec_22 = tmpvar_35;
|
|
vec3 tmpvar_36;
|
|
tmpvar_36 = ((((s_17.Albedo * _LightColor0.xyz) * diff_24) + ((_LightColor0.xyz * _SpecColor.xyz) * spec_22)) * (atten_20 * 2.0));
|
|
c_21.xyz = tmpvar_36.xyz.xyz;
|
|
float tmpvar_37;
|
|
tmpvar_37 = (s_17.Alpha + (((_LightColor0.w * _SpecColor.w) * spec_22) * atten_20));
|
|
c_21.w = vec4(tmpvar_37).w;
|
|
return c_21;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_38
|
|
)
|
|
{
|
|
vec4 c_39;
|
|
vec3 lightDir_40;
|
|
SurfaceOutput o_41;
|
|
Input surfIN_42;
|
|
vec2 tmpvar_43;
|
|
tmpvar_43 = IN_38.hip_pack0.xy;
|
|
surfIN_42.uv_MainTex = tmpvar_43;
|
|
vec3 tmpvar_44;
|
|
tmpvar_44 = vec3(0.0, 0.0, 0.0);
|
|
o_41.Albedo = tmpvar_44;
|
|
vec3 tmpvar_45;
|
|
tmpvar_45 = vec3(0.0, 0.0, 0.0);
|
|
o_41.Emission = tmpvar_45;
|
|
float tmpvar_46;
|
|
tmpvar_46 = 0.0;
|
|
o_41.Specular = tmpvar_46;
|
|
float tmpvar_47;
|
|
tmpvar_47 = 0.0;
|
|
o_41.Alpha = tmpvar_47;
|
|
float tmpvar_48;
|
|
tmpvar_48 = 0.0;
|
|
o_41.Gloss = tmpvar_48;
|
|
vec3 tmpvar_49;
|
|
tmpvar_49 = IN_38.normal;
|
|
o_41.Normal = tmpvar_49;
|
|
surf (surfIN_42, o_41);
|
|
vec3 tmpvar_50;
|
|
tmpvar_50 = IN_38.lightDir;
|
|
lightDir_40 = tmpvar_50;
|
|
vec3 tmpvar_51;
|
|
tmpvar_51 = normalize (lightDir_40);
|
|
vec3 tmpvar_52;
|
|
tmpvar_52 = tmpvar_51;
|
|
lightDir_40 = tmpvar_52;
|
|
vec3 tmpvar_53;
|
|
tmpvar_53 = IN_38.viewDir.xyz;
|
|
vec3 tmpvar_54;
|
|
tmpvar_54 = normalize (tmpvar_53);
|
|
float tmpvar_55;
|
|
tmpvar_55 = UnitySpotCookie (IN_38._LightCoord);
|
|
float tmpvar_56;
|
|
tmpvar_56 = UnitySpotAttenuate (IN_38._LightCoord.xyz);
|
|
vec4 tmpvar_57;
|
|
tmpvar_57 = LightingBlinnPhong (o_41, lightDir_40, tmpvar_54, ((float((IN_38._LightCoord.z > 0.0)) * tmpvar_55) * tmpvar_56));
|
|
vec4 tmpvar_58;
|
|
tmpvar_58 = tmpvar_57;
|
|
c_39 = tmpvar_58;
|
|
float tmpvar_59;
|
|
tmpvar_59 = 0.0;
|
|
c_39.w = vec4(tmpvar_59).w;
|
|
return c_39;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_60;
|
|
vec4 xl_retval_61;
|
|
vec4 tmpvar_62;
|
|
tmpvar_62 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_60.pos = tmpvar_62;
|
|
float tmpvar_63;
|
|
tmpvar_63 = xlv_FOG.x;
|
|
xlt_IN_60.fog = tmpvar_63;
|
|
vec2 tmpvar_64;
|
|
tmpvar_64 = gl_TexCoord[0].xy;
|
|
vec2 tmpvar_65;
|
|
tmpvar_65 = tmpvar_64;
|
|
xlt_IN_60.hip_pack0 = tmpvar_65;
|
|
vec3 tmpvar_66;
|
|
tmpvar_66 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_67;
|
|
tmpvar_67 = tmpvar_66;
|
|
xlt_IN_60.normal = tmpvar_67;
|
|
vec3 tmpvar_68;
|
|
tmpvar_68 = gl_TexCoord[2].xyz;
|
|
vec3 tmpvar_69;
|
|
tmpvar_69 = tmpvar_68;
|
|
xlt_IN_60.lightDir = tmpvar_69;
|
|
vec3 tmpvar_70;
|
|
tmpvar_70 = gl_TexCoord[3].xyz;
|
|
vec3 tmpvar_71;
|
|
tmpvar_71 = tmpvar_70;
|
|
xlt_IN_60.viewDir = tmpvar_71;
|
|
vec4 tmpvar_72;
|
|
tmpvar_72 = gl_TexCoord[4].xyzw;
|
|
vec4 tmpvar_73;
|
|
tmpvar_73 = tmpvar_72;
|
|
xlt_IN_60._LightCoord = tmpvar_73;
|
|
vec4 tmpvar_74;
|
|
tmpvar_74 = frag_surf (xlt_IN_60);
|
|
vec4 tmpvar_75;
|
|
tmpvar_75 = tmpvar_74;
|
|
xl_retval_61 = tmpvar_75;
|
|
vec4 tmpvar_76;
|
|
tmpvar_76 = xl_retval_61.xyzw;
|
|
vec4 tmpvar_77;
|
|
tmpvar_77 = tmpvar_76;
|
|
gl_FragData[0] = tmpvar_77;
|
|
}
|
|
|