mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-01 11:56:58 -05:00
137 lines
2.5 KiB
Text
137 lines
2.5 KiB
Text
struct SurfaceOutput {
|
|
vec3 Albedo;
|
|
vec3 Normal;
|
|
vec3 Emission;
|
|
float Specular;
|
|
float Gloss;
|
|
float Alpha;
|
|
};
|
|
struct Input {
|
|
vec2 uv_MainTex;
|
|
};
|
|
struct v2f_surf {
|
|
vec4 pos;
|
|
vec3 vec;
|
|
vec2 hip_pack0;
|
|
};
|
|
uniform sampler2D _MainTex;
|
|
uniform vec4 _LightPositionRange;
|
|
uniform float _Cutoff;
|
|
uniform vec4 _Color;
|
|
void xll_clip (
|
|
in float x
|
|
)
|
|
{
|
|
if ((x < 0.0)) {
|
|
discard;
|
|
};
|
|
}
|
|
|
|
void surf (
|
|
in Input IN,
|
|
inout SurfaceOutput o
|
|
)
|
|
{
|
|
vec4 c;
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = texture2D (_MainTex, IN.uv_MainTex);
|
|
vec4 tmpvar_2;
|
|
tmpvar_2 = (tmpvar_1 * _Color);
|
|
c = tmpvar_2;
|
|
vec3 tmpvar_3;
|
|
tmpvar_3 = c.xyz;
|
|
o.Albedo = tmpvar_3;
|
|
float tmpvar_4;
|
|
tmpvar_4 = c.w;
|
|
o.Alpha = tmpvar_4;
|
|
}
|
|
|
|
vec4 EncodeFloatRGBA (
|
|
in float v
|
|
)
|
|
{
|
|
vec4 enc;
|
|
float kEncodeBit;
|
|
vec4 kEncodeMul;
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = vec4(1.0, 255.0, 65025.0, 160580992.0);
|
|
kEncodeMul = tmpvar_1;
|
|
float tmpvar_2;
|
|
tmpvar_2 = 0.00392157;
|
|
kEncodeBit = tmpvar_2;
|
|
vec4 tmpvar_3;
|
|
tmpvar_3 = (kEncodeMul * v);
|
|
enc = tmpvar_3;
|
|
vec4 tmpvar_4;
|
|
tmpvar_4 = fract (enc);
|
|
vec4 tmpvar_5;
|
|
tmpvar_5 = tmpvar_4;
|
|
enc = tmpvar_5;
|
|
vec4 tmpvar_6;
|
|
tmpvar_6 = (enc - (enc.yzww * kEncodeBit));
|
|
enc = tmpvar_6;
|
|
return enc;
|
|
}
|
|
|
|
vec4 frag_surf (
|
|
in v2f_surf IN
|
|
)
|
|
{
|
|
SurfaceOutput o;
|
|
Input surfIN;
|
|
vec2 tmpvar_1;
|
|
tmpvar_1 = IN.hip_pack0.xy;
|
|
surfIN.uv_MainTex = tmpvar_1;
|
|
vec3 tmpvar_2;
|
|
tmpvar_2 = vec3(0.0, 0.0, 0.0);
|
|
o.Albedo = tmpvar_2;
|
|
vec3 tmpvar_3;
|
|
tmpvar_3 = vec3(0.0, 0.0, 0.0);
|
|
o.Emission = tmpvar_3;
|
|
float tmpvar_4;
|
|
tmpvar_4 = 0.0;
|
|
o.Specular = tmpvar_4;
|
|
float tmpvar_5;
|
|
tmpvar_5 = 0.0;
|
|
o.Alpha = tmpvar_5;
|
|
float tmpvar_6;
|
|
tmpvar_6 = 0.0;
|
|
o.Gloss = tmpvar_6;
|
|
surf (surfIN, o);
|
|
xll_clip ((o.Alpha - _Cutoff));
|
|
float tmpvar_7;
|
|
tmpvar_7 = length (IN.vec);
|
|
vec4 tmpvar_8;
|
|
tmpvar_8 = EncodeFloatRGBA ((tmpvar_7 * _LightPositionRange.w));
|
|
return tmpvar_8;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
v2f_surf xlt_IN;
|
|
vec4 xl_retval;
|
|
vec4 tmpvar_1;
|
|
tmpvar_1 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
xlt_IN.pos = tmpvar_1;
|
|
vec3 tmpvar_2;
|
|
tmpvar_2 = gl_TexCoord[0].xyz;
|
|
vec3 tmpvar_3;
|
|
tmpvar_3 = tmpvar_2;
|
|
xlt_IN.vec = tmpvar_3;
|
|
vec2 tmpvar_4;
|
|
tmpvar_4 = gl_TexCoord[1].xy;
|
|
vec2 tmpvar_5;
|
|
tmpvar_5 = tmpvar_4;
|
|
xlt_IN.hip_pack0 = tmpvar_5;
|
|
vec4 tmpvar_6;
|
|
tmpvar_6 = frag_surf (xlt_IN);
|
|
vec4 tmpvar_7;
|
|
tmpvar_7 = tmpvar_6;
|
|
xl_retval = tmpvar_7;
|
|
vec4 tmpvar_8;
|
|
tmpvar_8 = xl_retval.xyzw;
|
|
vec4 tmpvar_9;
|
|
tmpvar_9 = tmpvar_8;
|
|
gl_FragData[0] = tmpvar_9;
|
|
}
|
|
|