mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
381 lines
8.4 KiB
Text
381 lines
8.4 KiB
Text
struct LeafSurfaceOutput {
|
|
mediump vec3 Albedo;
|
|
mediump vec3 Normal;
|
|
mediump vec3 Emission;
|
|
mediump float Translucency;
|
|
mediump float ShadowOffset;
|
|
mediump float Specular;
|
|
mediump float Gloss;
|
|
mediump float Alpha;
|
|
};
|
|
struct Input {
|
|
highp vec2 uv_MainTex;
|
|
highp vec4 color;
|
|
};
|
|
struct v2f_surf {
|
|
highp vec4 pos;
|
|
highp vec2 hip_pack0;
|
|
highp vec4 lop_color;
|
|
highp vec3 lightDir;
|
|
highp vec3 viewDir;
|
|
highp vec2 _LightCoord;
|
|
};
|
|
varying highp vec2 xlv_TEXCOORD3;
|
|
varying highp vec3 xlv_TEXCOORD2;
|
|
varying highp vec3 xlv_TEXCOORD1;
|
|
varying highp vec4 xlv_COLOR0;
|
|
varying highp vec2 xlv_TEXCOORD0;
|
|
uniform mediump float _TranslucencyViewDependency;
|
|
uniform sampler2D _TranslucencyMap;
|
|
uniform mediump vec3 _TranslucencyColor;
|
|
uniform mediump float _ShadowStrength;
|
|
uniform sampler2D _MainTex;
|
|
uniform sampler2D _LightTexture0;
|
|
uniform highp vec4 _LightColor0;
|
|
uniform highp float _Cutoff;
|
|
uniform highp vec4 _Color;
|
|
uniform sampler2D _BumpSpecMap;
|
|
void xll_clip (
|
|
in float x
|
|
)
|
|
{
|
|
if ((x < 0.0)) {
|
|
discard;
|
|
};
|
|
}
|
|
|
|
float xll_saturate (
|
|
in float x
|
|
)
|
|
{
|
|
float tmpvar_1;
|
|
tmpvar_1 = clamp (x, 0.0, 1.0);
|
|
return tmpvar_1;
|
|
}
|
|
|
|
vec2 xll_saturate (
|
|
in vec2 x
|
|
)
|
|
{
|
|
vec2 tmpvar_1;
|
|
tmpvar_1 = clamp (x, 0.0, 1.0);
|
|
return tmpvar_1;
|
|
}
|
|
|
|
vec3 xll_saturate (
|
|
in vec3 x
|
|
)
|
|
{
|
|
vec3 tmpvar_1;
|
|
tmpvar_1 = clamp (x, 0.0, 1.0);
|
|
return tmpvar_1;
|
|
}
|
|
|
|
vec4 xll_saturate (
|
|
in vec4 x
|
|
)
|
|
{
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = clamp (x, 0.0, 1.0);
|
|
return tmpvar_1;
|
|
}
|
|
|
|
mat2 xll_saturate (
|
|
in mat2 m
|
|
)
|
|
{
|
|
vec2 tmpvar_1;
|
|
tmpvar_1 = clamp (m[0], 0.0, 1.0);
|
|
vec2 tmpvar_2;
|
|
tmpvar_2 = clamp (m[1], 0.0, 1.0);
|
|
mat2 tmpvar_3;
|
|
vec2 tmpvar_4;
|
|
tmpvar_4 = tmpvar_1;
|
|
tmpvar_3[0] = tmpvar_4;
|
|
vec2 tmpvar_5;
|
|
tmpvar_5 = tmpvar_2;
|
|
tmpvar_3[1] = tmpvar_5;
|
|
return tmpvar_3;
|
|
}
|
|
|
|
mat3 xll_saturate (
|
|
in mat3 m
|
|
)
|
|
{
|
|
vec3 tmpvar_1;
|
|
tmpvar_1 = clamp (m[0], 0.0, 1.0);
|
|
vec3 tmpvar_2;
|
|
tmpvar_2 = clamp (m[1], 0.0, 1.0);
|
|
vec3 tmpvar_3;
|
|
tmpvar_3 = clamp (m[2], 0.0, 1.0);
|
|
mat3 tmpvar_4;
|
|
vec3 tmpvar_5;
|
|
tmpvar_5 = tmpvar_1;
|
|
tmpvar_4[0] = tmpvar_5;
|
|
vec3 tmpvar_6;
|
|
tmpvar_6 = tmpvar_2;
|
|
tmpvar_4[1] = tmpvar_6;
|
|
vec3 tmpvar_7;
|
|
tmpvar_7 = tmpvar_3;
|
|
tmpvar_4[2] = tmpvar_7;
|
|
return tmpvar_4;
|
|
}
|
|
|
|
mat4 xll_saturate (
|
|
in mat4 m
|
|
)
|
|
{
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = clamp (m[0], 0.0, 1.0);
|
|
vec4 tmpvar_2;
|
|
tmpvar_2 = clamp (m[1], 0.0, 1.0);
|
|
vec4 tmpvar_3;
|
|
tmpvar_3 = clamp (m[2], 0.0, 1.0);
|
|
vec4 tmpvar_4;
|
|
tmpvar_4 = clamp (m[3], 0.0, 1.0);
|
|
mat4 tmpvar_5;
|
|
vec4 tmpvar_6;
|
|
tmpvar_6 = tmpvar_1;
|
|
tmpvar_5[0] = tmpvar_6;
|
|
vec4 tmpvar_7;
|
|
tmpvar_7 = tmpvar_2;
|
|
tmpvar_5[1] = tmpvar_7;
|
|
vec4 tmpvar_8;
|
|
tmpvar_8 = tmpvar_3;
|
|
tmpvar_5[2] = tmpvar_8;
|
|
vec4 tmpvar_9;
|
|
tmpvar_9 = tmpvar_4;
|
|
tmpvar_5[3] = tmpvar_9;
|
|
return tmpvar_5;
|
|
}
|
|
|
|
mediump vec4 UnpackNormal (
|
|
in mediump vec4 packednormal
|
|
)
|
|
{
|
|
mediump vec4 normal;
|
|
mediump vec2 tmpvar_1;
|
|
tmpvar_1 = ((packednormal.wy * 2.0) - 1.0);
|
|
normal.xy = tmpvar_1.xy.xy;
|
|
mediump float tmpvar_2;
|
|
tmpvar_2 = sqrt (((1.0 - (normal.x * normal.x)) - (normal.y * normal.y)));
|
|
mediump float tmpvar_3;
|
|
tmpvar_3 = tmpvar_2;
|
|
normal.z = vec3(tmpvar_3).z;
|
|
return normal;
|
|
}
|
|
|
|
void surf (
|
|
in Input IN,
|
|
inout LeafSurfaceOutput o
|
|
)
|
|
{
|
|
mediump vec4 norspc;
|
|
mediump vec4 trngls;
|
|
mediump vec4 c;
|
|
lowp vec4 tmpvar_1;
|
|
tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex);
|
|
lowp vec4 tmpvar_2;
|
|
tmpvar_2 = tmpvar_1;
|
|
c = tmpvar_2;
|
|
highp vec3 tmpvar_3;
|
|
tmpvar_3 = ((c.xyz * _Color.xyz) * IN.color.w);
|
|
o.Albedo = tmpvar_3;
|
|
lowp vec4 tmpvar_4;
|
|
tmpvar_4 = texture2D (_TranslucencyMap, IN.uv_MainTex);
|
|
lowp vec4 tmpvar_5;
|
|
tmpvar_5 = tmpvar_4;
|
|
trngls = tmpvar_5;
|
|
mediump float tmpvar_6;
|
|
tmpvar_6 = trngls.z;
|
|
o.Translucency = tmpvar_6;
|
|
highp float tmpvar_7;
|
|
tmpvar_7 = (trngls.w * _Color.x);
|
|
o.Gloss = tmpvar_7;
|
|
mediump float tmpvar_8;
|
|
tmpvar_8 = c.w;
|
|
o.Alpha = tmpvar_8;
|
|
lowp vec4 tmpvar_9;
|
|
tmpvar_9 = texture2D (_BumpSpecMap, IN.uv_MainTex);
|
|
lowp vec4 tmpvar_10;
|
|
tmpvar_10 = tmpvar_9;
|
|
norspc = tmpvar_10;
|
|
mediump float tmpvar_11;
|
|
tmpvar_11 = norspc.x;
|
|
o.Specular = tmpvar_11;
|
|
mediump float tmpvar_12;
|
|
tmpvar_12 = norspc.z;
|
|
o.ShadowOffset = tmpvar_12;
|
|
mediump vec4 tmpvar_13;
|
|
tmpvar_13 = UnpackNormal (norspc);
|
|
mediump vec3 tmpvar_14;
|
|
tmpvar_14 = tmpvar_13.xyz;
|
|
mediump vec3 tmpvar_15;
|
|
tmpvar_15 = tmpvar_14;
|
|
o.Normal = tmpvar_15;
|
|
}
|
|
|
|
mediump vec4 LightingTreeLeaf (
|
|
in LeafSurfaceOutput s,
|
|
in mediump vec3 lightDir,
|
|
in mediump vec3 viewDir,
|
|
in mediump float atten
|
|
)
|
|
{
|
|
mediump vec4 c;
|
|
mediump vec3 translucencyColor;
|
|
mediump float backContrib;
|
|
mediump float spec;
|
|
mediump float nh;
|
|
mediump float nl;
|
|
mediump vec3 h;
|
|
mediump vec3 tmpvar_1;
|
|
tmpvar_1 = normalize ((lightDir + viewDir));
|
|
mediump vec3 tmpvar_2;
|
|
tmpvar_2 = tmpvar_1;
|
|
h = tmpvar_2;
|
|
mediump float tmpvar_3;
|
|
tmpvar_3 = dot (s.Normal, lightDir);
|
|
mediump float tmpvar_4;
|
|
tmpvar_4 = tmpvar_3;
|
|
nl = tmpvar_4;
|
|
mediump float tmpvar_5;
|
|
tmpvar_5 = dot (s.Normal, h);
|
|
mediump float tmpvar_6;
|
|
tmpvar_6 = max (0.0, tmpvar_5);
|
|
mediump float tmpvar_7;
|
|
tmpvar_7 = tmpvar_6;
|
|
nh = tmpvar_7;
|
|
mediump float tmpvar_8;
|
|
tmpvar_8 = pow (nh, (s.Specular * 128.0));
|
|
mediump float tmpvar_9;
|
|
tmpvar_9 = (tmpvar_8 * s.Gloss);
|
|
spec = tmpvar_9;
|
|
mediump float tmpvar_10;
|
|
tmpvar_10 = dot (viewDir, -(lightDir));
|
|
float tmpvar_11;
|
|
tmpvar_11 = xll_saturate (tmpvar_10);
|
|
float tmpvar_12;
|
|
tmpvar_12 = tmpvar_11;
|
|
backContrib = tmpvar_12;
|
|
float tmpvar_13;
|
|
tmpvar_13 = xll_saturate (-(nl));
|
|
mediump float tmpvar_14;
|
|
tmpvar_14 = mix (tmpvar_13, backContrib, _TranslucencyViewDependency);
|
|
mediump float tmpvar_15;
|
|
tmpvar_15 = tmpvar_14;
|
|
backContrib = tmpvar_15;
|
|
mediump vec3 tmpvar_16;
|
|
tmpvar_16 = ((backContrib * s.Translucency) * _TranslucencyColor);
|
|
translucencyColor = tmpvar_16;
|
|
mediump float tmpvar_17;
|
|
tmpvar_17 = max (0.0, ((nl * 0.6) + 0.4));
|
|
mediump float tmpvar_18;
|
|
tmpvar_18 = tmpvar_17;
|
|
nl = tmpvar_18;
|
|
mediump vec3 tmpvar_19;
|
|
tmpvar_19 = (s.Albedo * ((translucencyColor * 2.0) + nl));
|
|
c.xyz = tmpvar_19.xyz.xyz;
|
|
highp vec3 tmpvar_20;
|
|
tmpvar_20 = ((c.xyz * _LightColor0.xyz) + spec);
|
|
c.xyz = tmpvar_20.xyz.xyz;
|
|
mediump float tmpvar_21;
|
|
tmpvar_21 = mix (2.0, (atten * 2.0), _ShadowStrength);
|
|
mediump vec3 tmpvar_22;
|
|
tmpvar_22 = (c.xyz * tmpvar_21);
|
|
c.xyz = tmpvar_22.xyz.xyz;
|
|
return c;
|
|
}
|
|
|
|
mediump vec4 xlat_main (
|
|
in v2f_surf IN
|
|
)
|
|
{
|
|
mediump vec4 c;
|
|
mediump vec3 lightDir;
|
|
LeafSurfaceOutput o;
|
|
Input surfIN;
|
|
highp vec2 tmpvar_1;
|
|
tmpvar_1 = IN.hip_pack0.xy;
|
|
surfIN.uv_MainTex = tmpvar_1;
|
|
highp vec4 tmpvar_2;
|
|
tmpvar_2 = IN.lop_color;
|
|
surfIN.color = tmpvar_2;
|
|
vec3 tmpvar_3;
|
|
tmpvar_3 = vec3(0.0, 0.0, 0.0);
|
|
o.Albedo = tmpvar_3;
|
|
vec3 tmpvar_4;
|
|
tmpvar_4 = vec3(0.0, 0.0, 0.0);
|
|
o.Emission = tmpvar_4;
|
|
float tmpvar_5;
|
|
tmpvar_5 = 0.0;
|
|
o.Specular = tmpvar_5;
|
|
float tmpvar_6;
|
|
tmpvar_6 = 0.0;
|
|
o.Alpha = tmpvar_6;
|
|
surf (surfIN, o);
|
|
xll_clip ((o.Alpha - _Cutoff));
|
|
highp vec3 tmpvar_7;
|
|
tmpvar_7 = IN.lightDir;
|
|
lightDir = tmpvar_7;
|
|
highp vec3 tmpvar_8;
|
|
tmpvar_8 = IN.viewDir.xyz;
|
|
highp vec3 tmpvar_9;
|
|
tmpvar_9 = normalize (tmpvar_8);
|
|
lowp vec4 tmpvar_10;
|
|
tmpvar_10 = texture2D (_LightTexture0, IN._LightCoord);
|
|
mediump vec4 tmpvar_11;
|
|
tmpvar_11 = LightingTreeLeaf (o, lightDir, tmpvar_9, (tmpvar_10.w * 1.0));
|
|
mediump vec4 tmpvar_12;
|
|
tmpvar_12 = tmpvar_11;
|
|
c = tmpvar_12;
|
|
mediump float tmpvar_13;
|
|
tmpvar_13 = o.Alpha;
|
|
c.w = vec4(tmpvar_13).w;
|
|
return c;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN;
|
|
mediump vec4 xl_retval;
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN.pos = tmpvar_1;
|
|
highp vec2 tmpvar_2;
|
|
tmpvar_2 = xlv_TEXCOORD0.xy;
|
|
highp vec2 tmpvar_3;
|
|
tmpvar_3 = tmpvar_2;
|
|
xlt_IN.hip_pack0 = tmpvar_3;
|
|
highp vec4 tmpvar_4;
|
|
tmpvar_4 = xlv_COLOR0.xyzw;
|
|
highp vec4 tmpvar_5;
|
|
tmpvar_5 = tmpvar_4;
|
|
xlt_IN.lop_color = tmpvar_5;
|
|
highp vec3 tmpvar_6;
|
|
tmpvar_6 = xlv_TEXCOORD1.xyz;
|
|
highp vec3 tmpvar_7;
|
|
tmpvar_7 = tmpvar_6;
|
|
xlt_IN.lightDir = tmpvar_7;
|
|
highp vec3 tmpvar_8;
|
|
tmpvar_8 = xlv_TEXCOORD2.xyz;
|
|
highp vec3 tmpvar_9;
|
|
tmpvar_9 = tmpvar_8;
|
|
xlt_IN.viewDir = tmpvar_9;
|
|
highp vec2 tmpvar_10;
|
|
tmpvar_10 = xlv_TEXCOORD3.xy;
|
|
highp vec2 tmpvar_11;
|
|
tmpvar_11 = tmpvar_10;
|
|
xlt_IN._LightCoord = tmpvar_11;
|
|
mediump vec4 tmpvar_12;
|
|
tmpvar_12 = xlat_main (xlt_IN);
|
|
mediump vec4 tmpvar_13;
|
|
tmpvar_13 = tmpvar_12;
|
|
xl_retval = tmpvar_13;
|
|
mediump vec4 tmpvar_14;
|
|
tmpvar_14 = xl_retval.xyzw;
|
|
mediump vec4 tmpvar_15;
|
|
tmpvar_15 = tmpvar_14;
|
|
gl_FragData[0] = tmpvar_15;
|
|
}
|
|
|