mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-04 21:31:11 -05:00
254 lines
5.8 KiB
Text
254 lines
5.8 KiB
Text
|
struct SurfaceOutput {
|
||
|
vec3 Albedo;
|
||
|
vec3 Normal;
|
||
|
vec3 Emission;
|
||
|
float Specular;
|
||
|
float Gloss;
|
||
|
float Alpha;
|
||
|
};
|
||
|
struct Input {
|
||
|
vec2 uv_MainTex;
|
||
|
vec2 uv_BumpMap;
|
||
|
vec3 worldRefl;
|
||
|
vec3 TtoW0;
|
||
|
vec3 TtoW1;
|
||
|
vec3 TtoW2;
|
||
|
};
|
||
|
struct v2f_surf {
|
||
|
vec4 pos;
|
||
|
float fog;
|
||
|
vec4 hip_pack0;
|
||
|
vec4 hip_screen;
|
||
|
vec4 TtoW0;
|
||
|
vec4 TtoW1;
|
||
|
vec4 TtoW2;
|
||
|
};
|
||
|
varying vec4 xlv_FOG;
|
||
|
uniform vec4 unity_Ambient;
|
||
|
uniform vec4 _SpecColor;
|
||
|
uniform float _Shininess;
|
||
|
uniform vec4 _ReflectColor;
|
||
|
uniform sampler2D _MainTex;
|
||
|
uniform sampler2D _LightBuffer;
|
||
|
uniform samplerCube _Cube;
|
||
|
uniform vec4 _Color;
|
||
|
uniform sampler2D _BumpMap;
|
||
|
vec4 UnpackNormal (
|
||
|
in vec4 packednormal_1
|
||
|
)
|
||
|
{
|
||
|
vec4 normal_2;
|
||
|
vec2 tmpvar_3;
|
||
|
tmpvar_3 = ((packednormal_1.wy * 2.0) - 1.0);
|
||
|
normal_2.xy = tmpvar_3.xy.xy;
|
||
|
float tmpvar_4;
|
||
|
tmpvar_4 = sqrt (((1.0 - (normal_2.x * normal_2.x)) - (normal_2.y * normal_2.y)));
|
||
|
float tmpvar_5;
|
||
|
tmpvar_5 = tmpvar_4;
|
||
|
normal_2.z = vec3(tmpvar_5).z;
|
||
|
return normal_2;
|
||
|
}
|
||
|
|
||
|
void surf (
|
||
|
in Input IN_6,
|
||
|
inout SurfaceOutput o_7
|
||
|
)
|
||
|
{
|
||
|
vec4 reflcol_8;
|
||
|
vec3 worldRefl_9;
|
||
|
vec4 c_10;
|
||
|
vec4 tex_11;
|
||
|
vec4 tmpvar_12;
|
||
|
tmpvar_12 = texture2D (_MainTex, IN_6.uv_MainTex);
|
||
|
vec4 tmpvar_13;
|
||
|
tmpvar_13 = tmpvar_12;
|
||
|
tex_11 = tmpvar_13;
|
||
|
vec4 tmpvar_14;
|
||
|
tmpvar_14 = (tex_11 * _Color);
|
||
|
c_10 = tmpvar_14;
|
||
|
vec3 tmpvar_15;
|
||
|
tmpvar_15 = c_10.xyz;
|
||
|
o_7.Albedo = tmpvar_15;
|
||
|
float tmpvar_16;
|
||
|
tmpvar_16 = tex_11.w;
|
||
|
o_7.Gloss = tmpvar_16;
|
||
|
float tmpvar_17;
|
||
|
tmpvar_17 = _Shininess;
|
||
|
o_7.Specular = tmpvar_17;
|
||
|
vec4 tmpvar_18;
|
||
|
tmpvar_18 = texture2D (_BumpMap, IN_6.uv_BumpMap);
|
||
|
vec4 tmpvar_19;
|
||
|
tmpvar_19 = UnpackNormal (tmpvar_18);
|
||
|
vec3 tmpvar_20;
|
||
|
tmpvar_20 = tmpvar_19.xyz;
|
||
|
vec3 tmpvar_21;
|
||
|
tmpvar_21 = tmpvar_20;
|
||
|
o_7.Normal = tmpvar_21;
|
||
|
float tmpvar_22;
|
||
|
tmpvar_22 = dot (IN_6.TtoW0, o_7.Normal);
|
||
|
float tmpvar_23;
|
||
|
tmpvar_23 = dot (IN_6.TtoW1, o_7.Normal);
|
||
|
float tmpvar_24;
|
||
|
tmpvar_24 = dot (IN_6.TtoW2, o_7.Normal);
|
||
|
vec3 tmpvar_25;
|
||
|
tmpvar_25.x = tmpvar_22;
|
||
|
tmpvar_25.y = tmpvar_23;
|
||
|
tmpvar_25.z = tmpvar_24;
|
||
|
vec3 tmpvar_26;
|
||
|
tmpvar_26 = reflect (IN_6.worldRefl, tmpvar_25);
|
||
|
vec3 tmpvar_27;
|
||
|
tmpvar_27 = tmpvar_26;
|
||
|
worldRefl_9 = tmpvar_27;
|
||
|
vec4 tmpvar_28;
|
||
|
tmpvar_28 = textureCube (_Cube, worldRefl_9);
|
||
|
vec4 tmpvar_29;
|
||
|
tmpvar_29 = tmpvar_28;
|
||
|
reflcol_8 = tmpvar_29;
|
||
|
vec4 tmpvar_30;
|
||
|
tmpvar_30 = (reflcol_8 * tex_11.w);
|
||
|
reflcol_8 = tmpvar_30;
|
||
|
vec3 tmpvar_31;
|
||
|
tmpvar_31 = (reflcol_8.xyz * _ReflectColor.xyz);
|
||
|
o_7.Emission = tmpvar_31;
|
||
|
float tmpvar_32;
|
||
|
tmpvar_32 = (reflcol_8.w * _ReflectColor.w);
|
||
|
o_7.Alpha = tmpvar_32;
|
||
|
}
|
||
|
|
||
|
vec4 LightingBlinnPhong_PrePass (
|
||
|
in SurfaceOutput s_33,
|
||
|
in vec4 light_34
|
||
|
)
|
||
|
{
|
||
|
vec4 c_35;
|
||
|
float spec_36;
|
||
|
float tmpvar_37;
|
||
|
tmpvar_37 = (light_34.w * s_33.Gloss);
|
||
|
spec_36 = tmpvar_37;
|
||
|
vec3 tmpvar_38;
|
||
|
tmpvar_38 = ((s_33.Albedo * light_34.xyz) + ((light_34.xyz * _SpecColor.xyz) * spec_36));
|
||
|
c_35.xyz = tmpvar_38.xyz.xyz;
|
||
|
float tmpvar_39;
|
||
|
tmpvar_39 = (s_33.Alpha + (spec_36 * _SpecColor.w));
|
||
|
c_35.w = vec4(tmpvar_39).w;
|
||
|
return c_35;
|
||
|
}
|
||
|
|
||
|
vec4 frag_surf (
|
||
|
in v2f_surf IN_40
|
||
|
)
|
||
|
{
|
||
|
vec4 col_41;
|
||
|
vec4 light_42;
|
||
|
SurfaceOutput o_43;
|
||
|
Input surfIN_44;
|
||
|
vec2 tmpvar_45;
|
||
|
tmpvar_45 = IN_40.hip_pack0.xy;
|
||
|
surfIN_44.uv_MainTex = tmpvar_45;
|
||
|
vec2 tmpvar_46;
|
||
|
tmpvar_46 = IN_40.hip_pack0.zw;
|
||
|
surfIN_44.uv_BumpMap = tmpvar_46;
|
||
|
vec3 tmpvar_47;
|
||
|
tmpvar_47.x = IN_40.TtoW0.w;
|
||
|
tmpvar_47.y = IN_40.TtoW1.w;
|
||
|
tmpvar_47.z = IN_40.TtoW2.w;
|
||
|
vec3 tmpvar_48;
|
||
|
tmpvar_48 = tmpvar_47;
|
||
|
surfIN_44.worldRefl = tmpvar_48;
|
||
|
vec3 tmpvar_49;
|
||
|
tmpvar_49 = IN_40.TtoW0.xyz;
|
||
|
surfIN_44.TtoW0 = tmpvar_49;
|
||
|
vec3 tmpvar_50;
|
||
|
tmpvar_50 = IN_40.TtoW1.xyz;
|
||
|
surfIN_44.TtoW1 = tmpvar_50;
|
||
|
vec3 tmpvar_51;
|
||
|
tmpvar_51 = IN_40.TtoW2.xyz;
|
||
|
surfIN_44.TtoW2 = tmpvar_51;
|
||
|
vec3 tmpvar_52;
|
||
|
tmpvar_52 = vec3(0.0, 0.0, 0.0);
|
||
|
o_43.Albedo = tmpvar_52;
|
||
|
vec3 tmpvar_53;
|
||
|
tmpvar_53 = vec3(0.0, 0.0, 0.0);
|
||
|
o_43.Emission = tmpvar_53;
|
||
|
float tmpvar_54;
|
||
|
tmpvar_54 = 0.0;
|
||
|
o_43.Specular = tmpvar_54;
|
||
|
float tmpvar_55;
|
||
|
tmpvar_55 = 0.0;
|
||
|
o_43.Alpha = tmpvar_55;
|
||
|
float tmpvar_56;
|
||
|
tmpvar_56 = 0.0;
|
||
|
o_43.Gloss = tmpvar_56;
|
||
|
surf (surfIN_44, o_43);
|
||
|
vec4 tmpvar_57;
|
||
|
tmpvar_57 = texture2DProj (_LightBuffer, IN_40.hip_screen);
|
||
|
vec4 tmpvar_58;
|
||
|
tmpvar_58 = tmpvar_57;
|
||
|
light_42 = tmpvar_58;
|
||
|
vec4 tmpvar_59;
|
||
|
tmpvar_59 = log2 (light_42);
|
||
|
vec4 tmpvar_60;
|
||
|
tmpvar_60 = -(tmpvar_59);
|
||
|
light_42 = tmpvar_60;
|
||
|
vec3 tmpvar_61;
|
||
|
tmpvar_61 = (light_42.xyz + unity_Ambient.xyz);
|
||
|
light_42.xyz = tmpvar_61.xyz.xyz;
|
||
|
vec4 tmpvar_62;
|
||
|
tmpvar_62 = LightingBlinnPhong_PrePass (o_43, light_42);
|
||
|
vec4 tmpvar_63;
|
||
|
tmpvar_63 = tmpvar_62;
|
||
|
col_41 = tmpvar_63;
|
||
|
vec3 tmpvar_64;
|
||
|
tmpvar_64 = (col_41.xyz + o_43.Emission);
|
||
|
col_41.xyz = tmpvar_64.xyz.xyz;
|
||
|
return col_41;
|
||
|
}
|
||
|
|
||
|
void main ()
|
||
|
{
|
||
|
v2f_surf xlt_IN_65;
|
||
|
vec4 xl_retval_66;
|
||
|
vec4 tmpvar_67;
|
||
|
tmpvar_67 = vec4(0.0, 0.0, 0.0, 0.0);
|
||
|
xlt_IN_65.pos = tmpvar_67;
|
||
|
float tmpvar_68;
|
||
|
tmpvar_68 = xlv_FOG.x;
|
||
|
xlt_IN_65.fog = tmpvar_68;
|
||
|
vec4 tmpvar_69;
|
||
|
tmpvar_69 = gl_TexCoord[0].xyzw;
|
||
|
vec4 tmpvar_70;
|
||
|
tmpvar_70 = tmpvar_69;
|
||
|
xlt_IN_65.hip_pack0 = tmpvar_70;
|
||
|
vec4 tmpvar_71;
|
||
|
tmpvar_71 = gl_TexCoord[1].xyzw;
|
||
|
vec4 tmpvar_72;
|
||
|
tmpvar_72 = tmpvar_71;
|
||
|
xlt_IN_65.hip_screen = tmpvar_72;
|
||
|
vec4 tmpvar_73;
|
||
|
tmpvar_73 = gl_TexCoord[2].xyzw;
|
||
|
vec4 tmpvar_74;
|
||
|
tmpvar_74 = tmpvar_73;
|
||
|
xlt_IN_65.TtoW0 = tmpvar_74;
|
||
|
vec4 tmpvar_75;
|
||
|
tmpvar_75 = gl_TexCoord[3].xyzw;
|
||
|
vec4 tmpvar_76;
|
||
|
tmpvar_76 = tmpvar_75;
|
||
|
xlt_IN_65.TtoW1 = tmpvar_76;
|
||
|
vec4 tmpvar_77;
|
||
|
tmpvar_77 = gl_TexCoord[4].xyzw;
|
||
|
vec4 tmpvar_78;
|
||
|
tmpvar_78 = tmpvar_77;
|
||
|
xlt_IN_65.TtoW2 = tmpvar_78;
|
||
|
vec4 tmpvar_79;
|
||
|
tmpvar_79 = frag_surf (xlt_IN_65);
|
||
|
vec4 tmpvar_80;
|
||
|
tmpvar_80 = tmpvar_79;
|
||
|
xl_retval_66 = tmpvar_80;
|
||
|
vec4 tmpvar_81;
|
||
|
tmpvar_81 = xl_retval_66.xyzw;
|
||
|
vec4 tmpvar_82;
|
||
|
tmpvar_82 = tmpvar_81;
|
||
|
gl_FragData[0] = tmpvar_82;
|
||
|
}
|
||
|
|