mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-11 00:31:28 -05:00
238 lines
5.4 KiB
Text
238 lines
5.4 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;
|
||
|
vec3 _LightCoord;
|
||
|
};
|
||
|
varying vec4 xlv_FOG;
|
||
|
uniform float _Shininess;
|
||
|
uniform sampler2D _MainTex;
|
||
|
uniform sampler2D _LightTextureB0;
|
||
|
uniform samplerCube _LightTexture0;
|
||
|
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 = normalize (lightDir_43);
|
||
|
vec3 tmpvar_55;
|
||
|
tmpvar_55 = tmpvar_54;
|
||
|
lightDir_43 = tmpvar_55;
|
||
|
vec3 tmpvar_56;
|
||
|
tmpvar_56 = IN_41.viewDir.xyz;
|
||
|
vec3 tmpvar_57;
|
||
|
tmpvar_57 = normalize (tmpvar_56);
|
||
|
float tmpvar_58;
|
||
|
tmpvar_58 = dot (IN_41._LightCoord, IN_41._LightCoord);
|
||
|
vec2 tmpvar_59;
|
||
|
tmpvar_59 = vec2(tmpvar_58);
|
||
|
vec2 tmpvar_60;
|
||
|
tmpvar_60 = tmpvar_59.xy;
|
||
|
vec4 tmpvar_61;
|
||
|
tmpvar_61 = texture2D (_LightTextureB0, tmpvar_60);
|
||
|
vec4 tmpvar_62;
|
||
|
tmpvar_62 = textureCube (_LightTexture0, IN_41._LightCoord);
|
||
|
vec4 tmpvar_63;
|
||
|
tmpvar_63 = LightingTreeBark (o_44, lightDir_43, tmpvar_57, (tmpvar_61.w * tmpvar_62.w));
|
||
|
vec4 tmpvar_64;
|
||
|
tmpvar_64 = tmpvar_63;
|
||
|
c_42 = tmpvar_64;
|
||
|
float tmpvar_65;
|
||
|
tmpvar_65 = 0.0;
|
||
|
c_42.w = vec4(tmpvar_65).w;
|
||
|
return c_42;
|
||
|
}
|
||
|
|
||
|
void main ()
|
||
|
{
|
||
|
v2f_surf xlt_IN_66;
|
||
|
vec4 xl_retval_67;
|
||
|
vec4 tmpvar_68;
|
||
|
tmpvar_68 = vec4(0.0, 0.0, 0.0, 0.0);
|
||
|
xlt_IN_66.pos = tmpvar_68;
|
||
|
float tmpvar_69;
|
||
|
tmpvar_69 = xlv_FOG.x;
|
||
|
xlt_IN_66.fog = tmpvar_69;
|
||
|
vec2 tmpvar_70;
|
||
|
tmpvar_70 = gl_TexCoord[0].xy;
|
||
|
vec2 tmpvar_71;
|
||
|
tmpvar_71 = tmpvar_70;
|
||
|
xlt_IN_66.hip_pack0 = tmpvar_71;
|
||
|
vec4 tmpvar_72;
|
||
|
tmpvar_72 = gl_Color.xyzw;
|
||
|
vec4 tmpvar_73;
|
||
|
tmpvar_73 = tmpvar_72;
|
||
|
xlt_IN_66.lop_color = tmpvar_73;
|
||
|
vec3 tmpvar_74;
|
||
|
tmpvar_74 = gl_TexCoord[1].xyz;
|
||
|
vec3 tmpvar_75;
|
||
|
tmpvar_75 = tmpvar_74;
|
||
|
xlt_IN_66.lightDir = tmpvar_75;
|
||
|
vec3 tmpvar_76;
|
||
|
tmpvar_76 = gl_TexCoord[2].xyz;
|
||
|
vec3 tmpvar_77;
|
||
|
tmpvar_77 = tmpvar_76;
|
||
|
xlt_IN_66.viewDir = tmpvar_77;
|
||
|
vec3 tmpvar_78;
|
||
|
tmpvar_78 = gl_TexCoord[3].xyz;
|
||
|
vec3 tmpvar_79;
|
||
|
tmpvar_79 = tmpvar_78;
|
||
|
xlt_IN_66._LightCoord = tmpvar_79;
|
||
|
vec4 tmpvar_80;
|
||
|
tmpvar_80 = frag_surf (xlt_IN_66);
|
||
|
vec4 tmpvar_81;
|
||
|
tmpvar_81 = tmpvar_80;
|
||
|
xl_retval_67 = tmpvar_81;
|
||
|
vec4 tmpvar_82;
|
||
|
tmpvar_82 = xl_retval_67.xyzw;
|
||
|
vec4 tmpvar_83;
|
||
|
tmpvar_83 = tmpvar_82;
|
||
|
gl_FragData[0] = tmpvar_83;
|
||
|
}
|
||
|
|