mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-04 21:31:11 -05:00
215 lines
4.7 KiB
Text
215 lines
4.7 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;
|
||
|
vec3 lightDir;
|
||
|
vec3 viewDir;
|
||
|
};
|
||
|
varying vec4 xlv_FOG;
|
||
|
uniform float _Shininess;
|
||
|
uniform sampler2D _MainTex;
|
||
|
uniform vec4 _LightColor0;
|
||
|
uniform sampler2D _GlossMap;
|
||
|
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 c_8;
|
||
|
vec4 tmpvar_9;
|
||
|
tmpvar_9 = texture2D (_MainTex, IN_6.uv_MainTex);
|
||
|
vec4 tmpvar_10;
|
||
|
tmpvar_10 = tmpvar_9;
|
||
|
c_8 = tmpvar_10;
|
||
|
vec3 tmpvar_11;
|
||
|
tmpvar_11 = (c_8.xyz * IN_6.color.xyz);
|
||
|
o_7.Albedo = tmpvar_11;
|
||
|
vec4 tmpvar_12;
|
||
|
tmpvar_12 = texture2D (_GlossMap, IN_6.uv_MainTex);
|
||
|
float tmpvar_13;
|
||
|
tmpvar_13 = tmpvar_12.w;
|
||
|
o_7.Gloss = tmpvar_13;
|
||
|
float tmpvar_14;
|
||
|
tmpvar_14 = _Color.w;
|
||
|
o_7.Alpha = tmpvar_14;
|
||
|
float tmpvar_15;
|
||
|
tmpvar_15 = _Shininess;
|
||
|
o_7.Specular = tmpvar_15;
|
||
|
vec4 tmpvar_16;
|
||
|
tmpvar_16 = texture2D (_BumpMap, IN_6.uv_MainTex);
|
||
|
vec4 tmpvar_17;
|
||
|
tmpvar_17 = UnpackNormal (tmpvar_16);
|
||
|
vec3 tmpvar_18;
|
||
|
tmpvar_18 = tmpvar_17.xyz;
|
||
|
vec3 tmpvar_19;
|
||
|
tmpvar_19 = tmpvar_18;
|
||
|
o_7.Normal = tmpvar_19;
|
||
|
}
|
||
|
|
||
|
vec4 LightingTreeBark (
|
||
|
in SurfaceOutput s_20,
|
||
|
in vec3 lightDir_21,
|
||
|
in vec3 viewDir_22,
|
||
|
in float atten_23
|
||
|
)
|
||
|
{
|
||
|
vec4 c_24;
|
||
|
float spec_25;
|
||
|
float nh_26;
|
||
|
float diff_27;
|
||
|
vec3 h_28;
|
||
|
vec3 tmpvar_29;
|
||
|
tmpvar_29 = normalize ((lightDir_21 + viewDir_22));
|
||
|
vec3 tmpvar_30;
|
||
|
tmpvar_30 = tmpvar_29;
|
||
|
h_28 = tmpvar_30;
|
||
|
float tmpvar_31;
|
||
|
tmpvar_31 = dot (s_20.Normal, lightDir_21);
|
||
|
float tmpvar_32;
|
||
|
tmpvar_32 = max (0.0, tmpvar_31);
|
||
|
float tmpvar_33;
|
||
|
tmpvar_33 = tmpvar_32;
|
||
|
diff_27 = tmpvar_33;
|
||
|
float tmpvar_34;
|
||
|
tmpvar_34 = dot (s_20.Normal, h_28);
|
||
|
float tmpvar_35;
|
||
|
tmpvar_35 = max (0.0, tmpvar_34);
|
||
|
float tmpvar_36;
|
||
|
tmpvar_36 = tmpvar_35;
|
||
|
nh_26 = tmpvar_36;
|
||
|
float tmpvar_37;
|
||
|
tmpvar_37 = pow (nh_26, (s_20.Specular * 128.0));
|
||
|
float tmpvar_38;
|
||
|
tmpvar_38 = (tmpvar_37 * s_20.Gloss);
|
||
|
spec_25 = tmpvar_38;
|
||
|
vec3 tmpvar_39;
|
||
|
tmpvar_39 = ((((s_20.Albedo * _LightColor0.xyz) * diff_27) + (_LightColor0.xyz * spec_25)) * (atten_23 * 2.0));
|
||
|
c_24.xyz = tmpvar_39.xyz.xyz;
|
||
|
float tmpvar_40;
|
||
|
tmpvar_40 = (((_LightColor0.w * spec_25) * atten_23) * s_20.Alpha);
|
||
|
c_24.w = vec4(tmpvar_40).w;
|
||
|
return c_24;
|
||
|
}
|
||
|
|
||
|
vec4 frag_surf (
|
||
|
in v2f_surf IN_41
|
||
|
)
|
||
|
{
|
||
|
vec4 c_42;
|
||
|
vec3 lightDir_43;
|
||
|
SurfaceOutput o_44;
|
||
|
Input surfIN_45;
|
||
|
vec2 tmpvar_46;
|
||
|
tmpvar_46 = IN_41.hip_pack0.xy;
|
||
|
surfIN_45.uv_MainTex = tmpvar_46;
|
||
|
vec4 tmpvar_47;
|
||
|
tmpvar_47 = IN_41.lop_color;
|
||
|
surfIN_45.color = tmpvar_47;
|
||
|
vec3 tmpvar_48;
|
||
|
tmpvar_48 = vec3(0.0, 0.0, 0.0);
|
||
|
o_44.Albedo = tmpvar_48;
|
||
|
vec3 tmpvar_49;
|
||
|
tmpvar_49 = vec3(0.0, 0.0, 0.0);
|
||
|
o_44.Emission = tmpvar_49;
|
||
|
float tmpvar_50;
|
||
|
tmpvar_50 = 0.0;
|
||
|
o_44.Specular = tmpvar_50;
|
||
|
float tmpvar_51;
|
||
|
tmpvar_51 = 0.0;
|
||
|
o_44.Alpha = tmpvar_51;
|
||
|
float tmpvar_52;
|
||
|
tmpvar_52 = 0.0;
|
||
|
o_44.Gloss = tmpvar_52;
|
||
|
surf (surfIN_45, o_44);
|
||
|
vec3 tmpvar_53;
|
||
|
tmpvar_53 = IN_41.lightDir;
|
||
|
lightDir_43 = tmpvar_53;
|
||
|
vec3 tmpvar_54;
|
||
|
tmpvar_54 = IN_41.viewDir.xyz;
|
||
|
vec3 tmpvar_55;
|
||
|
tmpvar_55 = normalize (tmpvar_54);
|
||
|
vec4 tmpvar_56;
|
||
|
tmpvar_56 = LightingTreeBark (o_44, lightDir_43, tmpvar_55, 1.0);
|
||
|
vec4 tmpvar_57;
|
||
|
tmpvar_57 = tmpvar_56;
|
||
|
c_42 = tmpvar_57;
|
||
|
float tmpvar_58;
|
||
|
tmpvar_58 = 0.0;
|
||
|
c_42.w = vec4(tmpvar_58).w;
|
||
|
return c_42;
|
||
|
}
|
||
|
|
||
|
void main ()
|
||
|
{
|
||
|
v2f_surf xlt_IN_59;
|
||
|
vec4 xl_retval_60;
|
||
|
vec4 tmpvar_61;
|
||
|
tmpvar_61 = vec4(0.0, 0.0, 0.0, 0.0);
|
||
|
xlt_IN_59.pos = tmpvar_61;
|
||
|
float tmpvar_62;
|
||
|
tmpvar_62 = xlv_FOG.x;
|
||
|
xlt_IN_59.fog = tmpvar_62;
|
||
|
vec2 tmpvar_63;
|
||
|
tmpvar_63 = gl_TexCoord[0].xy;
|
||
|
vec2 tmpvar_64;
|
||
|
tmpvar_64 = tmpvar_63;
|
||
|
xlt_IN_59.hip_pack0 = tmpvar_64;
|
||
|
vec4 tmpvar_65;
|
||
|
tmpvar_65 = gl_Color.xyzw;
|
||
|
vec4 tmpvar_66;
|
||
|
tmpvar_66 = tmpvar_65;
|
||
|
xlt_IN_59.lop_color = tmpvar_66;
|
||
|
vec3 tmpvar_67;
|
||
|
tmpvar_67 = gl_TexCoord[1].xyz;
|
||
|
vec3 tmpvar_68;
|
||
|
tmpvar_68 = tmpvar_67;
|
||
|
xlt_IN_59.lightDir = tmpvar_68;
|
||
|
vec3 tmpvar_69;
|
||
|
tmpvar_69 = gl_TexCoord[2].xyz;
|
||
|
vec3 tmpvar_70;
|
||
|
tmpvar_70 = tmpvar_69;
|
||
|
xlt_IN_59.viewDir = tmpvar_70;
|
||
|
vec4 tmpvar_71;
|
||
|
tmpvar_71 = frag_surf (xlt_IN_59);
|
||
|
vec4 tmpvar_72;
|
||
|
tmpvar_72 = tmpvar_71;
|
||
|
xl_retval_60 = tmpvar_72;
|
||
|
vec4 tmpvar_73;
|
||
|
tmpvar_73 = xl_retval_60.xyzw;
|
||
|
vec4 tmpvar_74;
|
||
|
tmpvar_74 = tmpvar_73;
|
||
|
gl_FragData[0] = tmpvar_74;
|
||
|
}
|
||
|
|