mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-29 11:05:36 -05:00
206 lines
4.5 KiB
Text
206 lines
4.5 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_MainTex;
|
|
vec3 worldRefl;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec2 hip_pack0;
|
|
vec3 normal;
|
|
vec3 lightDir;
|
|
vec4 _LightCoord;
|
|
};
|
|
varying vec4 xlv_FOG;
|
|
uniform vec4 _ReflectColor;
|
|
uniform sampler2D _MainTex;
|
|
uniform sampler2D _LightTextureB0;
|
|
uniform sampler2D _LightTexture0;
|
|
uniform vec4 _LightColor0;
|
|
uniform samplerCube _Cube;
|
|
uniform vec4 _Color;
|
|
void surf (
|
|
in Input IN_1,
|
|
inout SurfaceOutput o_2
|
|
)
|
|
{
|
|
vec4 reflcol_3;
|
|
vec4 c_4;
|
|
vec4 tex_5;
|
|
vec4 tmpvar_6;
|
|
tmpvar_6 = texture2D (_MainTex, IN_1.uv_MainTex);
|
|
vec4 tmpvar_7;
|
|
tmpvar_7 = tmpvar_6;
|
|
tex_5 = tmpvar_7;
|
|
vec4 tmpvar_8;
|
|
tmpvar_8 = (tex_5 * _Color);
|
|
c_4 = tmpvar_8;
|
|
vec3 tmpvar_9;
|
|
tmpvar_9 = c_4.xyz;
|
|
o_2.Albedo = tmpvar_9;
|
|
vec4 tmpvar_10;
|
|
tmpvar_10 = textureCube (_Cube, IN_1.worldRefl);
|
|
vec4 tmpvar_11;
|
|
tmpvar_11 = tmpvar_10;
|
|
reflcol_3 = tmpvar_11;
|
|
vec4 tmpvar_12;
|
|
tmpvar_12 = (reflcol_3 * tex_5.w);
|
|
reflcol_3 = tmpvar_12;
|
|
vec3 tmpvar_13;
|
|
tmpvar_13 = (reflcol_3.xyz * _ReflectColor.xyz);
|
|
o_2.Emission = tmpvar_13;
|
|
float tmpvar_14;
|
|
tmpvar_14 = (reflcol_3.w * _ReflectColor.w);
|
|
o_2.Alpha = tmpvar_14;
|
|
}
|
|
|
|
float UnitySpotCookie (
|
|
in vec4 LightCoord_15
|
|
)
|
|
{
|
|
vec4 tmpvar_16;
|
|
tmpvar_16 = texture2D (_LightTexture0, ((LightCoord_15.xy / LightCoord_15.w) + 0.5));
|
|
return tmpvar_16.w;
|
|
}
|
|
|
|
float UnitySpotAttenuate (
|
|
in vec3 LightCoord_17
|
|
)
|
|
{
|
|
float tmpvar_18;
|
|
tmpvar_18 = dot (LightCoord_17, LightCoord_17);
|
|
vec2 tmpvar_19;
|
|
tmpvar_19 = vec2(tmpvar_18);
|
|
vec2 tmpvar_20;
|
|
tmpvar_20 = tmpvar_19.xy;
|
|
vec4 tmpvar_21;
|
|
tmpvar_21 = texture2D (_LightTextureB0, tmpvar_20);
|
|
return tmpvar_21.w;
|
|
}
|
|
|
|
vec4 LightingLambert (
|
|
in SurfaceOutput s_22,
|
|
in vec3 lightDir_23,
|
|
in float atten_24
|
|
)
|
|
{
|
|
vec4 c_25;
|
|
float diff_26;
|
|
float tmpvar_27;
|
|
tmpvar_27 = dot (s_22.Normal, lightDir_23);
|
|
float tmpvar_28;
|
|
tmpvar_28 = max (0.0, tmpvar_27);
|
|
float tmpvar_29;
|
|
tmpvar_29 = tmpvar_28;
|
|
diff_26 = tmpvar_29;
|
|
vec3 tmpvar_30;
|
|
tmpvar_30 = ((s_22.Albedo * _LightColor0.xyz) * ((diff_26 * atten_24) * 2.0));
|
|
c_25.xyz = tmpvar_30.xyz.xyz;
|
|
float tmpvar_31;
|
|
tmpvar_31 = s_22.Alpha;
|
|
c_25.w = vec4(tmpvar_31).w;
|
|
return c_25;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN_32
|
|
)
|
|
{
|
|
vec4 c_33;
|
|
vec3 lightDir_34;
|
|
SurfaceOutput o_35;
|
|
Input surfIN_36;
|
|
vec2 tmpvar_37;
|
|
tmpvar_37 = IN_32.hip_pack0.xy;
|
|
surfIN_36.uv_MainTex = tmpvar_37;
|
|
vec3 tmpvar_38;
|
|
tmpvar_38 = vec3(0.0, 0.0, 0.0);
|
|
o_35.Albedo = tmpvar_38;
|
|
vec3 tmpvar_39;
|
|
tmpvar_39 = vec3(0.0, 0.0, 0.0);
|
|
o_35.Emission = tmpvar_39;
|
|
float tmpvar_40;
|
|
tmpvar_40 = 0.0;
|
|
o_35.Specular = tmpvar_40;
|
|
float tmpvar_41;
|
|
tmpvar_41 = 0.0;
|
|
o_35.Alpha = tmpvar_41;
|
|
float tmpvar_42;
|
|
tmpvar_42 = 0.0;
|
|
o_35.Gloss = tmpvar_42;
|
|
vec3 tmpvar_43;
|
|
tmpvar_43 = IN_32.normal;
|
|
o_35.Normal = tmpvar_43;
|
|
surf (surfIN_36, o_35);
|
|
vec3 tmpvar_44;
|
|
tmpvar_44 = IN_32.lightDir;
|
|
lightDir_34 = tmpvar_44;
|
|
vec3 tmpvar_45;
|
|
tmpvar_45 = normalize (lightDir_34);
|
|
vec3 tmpvar_46;
|
|
tmpvar_46 = tmpvar_45;
|
|
lightDir_34 = tmpvar_46;
|
|
float tmpvar_47;
|
|
tmpvar_47 = UnitySpotCookie (IN_32._LightCoord);
|
|
float tmpvar_48;
|
|
tmpvar_48 = UnitySpotAttenuate (IN_32._LightCoord.xyz);
|
|
vec4 tmpvar_49;
|
|
tmpvar_49 = LightingLambert (o_35, lightDir_34, ((float((IN_32._LightCoord.z > 0.0)) * tmpvar_47) * tmpvar_48));
|
|
vec4 tmpvar_50;
|
|
tmpvar_50 = tmpvar_49;
|
|
c_33 = tmpvar_50;
|
|
float tmpvar_51;
|
|
tmpvar_51 = 0.0;
|
|
c_33.w = vec4(tmpvar_51).w;
|
|
return c_33;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN_52;
|
|
vec4 xl_retval_53;
|
|
vec4 tmpvar_54;
|
|
tmpvar_54 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN_52.pos = tmpvar_54;
|
|
float tmpvar_55;
|
|
tmpvar_55 = xlv_FOG.x;
|
|
xlt_IN_52.fog = tmpvar_55;
|
|
vec2 tmpvar_56;
|
|
tmpvar_56 = gl_TexCoord[0].xy;
|
|
vec2 tmpvar_57;
|
|
tmpvar_57 = tmpvar_56;
|
|
xlt_IN_52.hip_pack0 = tmpvar_57;
|
|
vec3 tmpvar_58;
|
|
tmpvar_58 = gl_TexCoord[1].xyz;
|
|
vec3 tmpvar_59;
|
|
tmpvar_59 = tmpvar_58;
|
|
xlt_IN_52.normal = tmpvar_59;
|
|
vec3 tmpvar_60;
|
|
tmpvar_60 = gl_TexCoord[2].xyz;
|
|
vec3 tmpvar_61;
|
|
tmpvar_61 = tmpvar_60;
|
|
xlt_IN_52.lightDir = tmpvar_61;
|
|
vec4 tmpvar_62;
|
|
tmpvar_62 = gl_TexCoord[3].xyzw;
|
|
vec4 tmpvar_63;
|
|
tmpvar_63 = tmpvar_62;
|
|
xlt_IN_52._LightCoord = tmpvar_63;
|
|
vec4 tmpvar_64;
|
|
tmpvar_64 = frag_surf (xlt_IN_52);
|
|
vec4 tmpvar_65;
|
|
tmpvar_65 = tmpvar_64;
|
|
xl_retval_53 = tmpvar_65;
|
|
vec4 tmpvar_66;
|
|
tmpvar_66 = xl_retval_53.xyzw;
|
|
vec4 tmpvar_67;
|
|
tmpvar_67 = tmpvar_66;
|
|
gl_FragData[0] = tmpvar_67;
|
|
}
|
|
|