mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-29 19:15:37 -05:00
82 lines
2.2 KiB
Text
82 lines
2.2 KiB
Text
|
#version 300 es
|
||
|
out mediump vec4 _fragData;
|
||
|
void xll_clip(float x) {
|
||
|
if ( x<0.0 ) discard;
|
||
|
}
|
||
|
struct v2f {
|
||
|
highp vec4 pos;
|
||
|
highp vec2 uv;
|
||
|
highp vec3 color;
|
||
|
highp vec3 backContrib;
|
||
|
highp vec3 nl;
|
||
|
highp vec3 nh;
|
||
|
};
|
||
|
uniform lowp vec4 UNITY_LIGHTMODEL_AMBIENT;
|
||
|
uniform sampler2D _BumpSpecMap;
|
||
|
uniform lowp float _Cutoff;
|
||
|
uniform sampler2D _MainTex;
|
||
|
uniform lowp vec4 _SpecColor;
|
||
|
uniform highp vec4 _TerrainTreeLightColors[4];
|
||
|
uniform lowp vec3 _TranslucencyColor;
|
||
|
uniform sampler2D _TranslucencyMap;
|
||
|
lowp vec4 xlat_main( in v2f i );
|
||
|
lowp vec4 xlat_main( in v2f i ) {
|
||
|
lowp vec4 col;
|
||
|
lowp vec3 albedo;
|
||
|
mediump float specular;
|
||
|
lowp vec4 trngls;
|
||
|
mediump float gloss;
|
||
|
mediump vec3 light;
|
||
|
mediump vec3 backContribs;
|
||
|
highp int j = 0;
|
||
|
mediump vec3 lightColor;
|
||
|
mediump vec3 translucencyColor;
|
||
|
mediump float nl;
|
||
|
mediump float nh;
|
||
|
mediump float spec;
|
||
|
lowp vec4 c;
|
||
|
col = texture2D( _MainTex, i.uv);
|
||
|
xll_clip((col.w - _Cutoff));
|
||
|
#line 35
|
||
|
albedo = (col.xyz * i.color);
|
||
|
specular = (texture2D( _BumpSpecMap, i.uv).x * 128.000);
|
||
|
#line 39
|
||
|
trngls = texture2D( _TranslucencyMap, i.uv);
|
||
|
gloss = trngls.w;
|
||
|
light = (vec3( UNITY_LIGHTMODEL_AMBIENT) * albedo);
|
||
|
#line 44
|
||
|
backContribs = (i.backContrib * trngls.z);
|
||
|
for ( ; (j < 3); (j++)) {
|
||
|
#line 48
|
||
|
lightColor = _TerrainTreeLightColors[j].xyz;
|
||
|
translucencyColor = (backContribs[j] * _TranslucencyColor);
|
||
|
nl = i.nl[j];
|
||
|
#line 52
|
||
|
nh = i.nh[j];
|
||
|
spec = (pow( nh, specular) * gloss);
|
||
|
light += (((albedo * (translucencyColor + nl)) + (_SpecColor.xyz * spec)) * lightColor);
|
||
|
}
|
||
|
#line 58
|
||
|
c.xyz = (light * 2.00000);
|
||
|
c.w = 1.00000;
|
||
|
return c;
|
||
|
}
|
||
|
in highp vec4 xlv_SV_POSITION;
|
||
|
in highp vec2 xlv_TEXCOORD0;
|
||
|
in highp vec3 xlv_TEXCOORD1;
|
||
|
in highp vec3 xlv_TEXCOORD2;
|
||
|
in highp vec3 xlv_TEXCOORD3;
|
||
|
in highp vec3 xlv_TEXCOORD4;
|
||
|
void main() {
|
||
|
lowp vec4 xl_retval;
|
||
|
v2f xlt_i;
|
||
|
xlt_i.pos = vec4( xlv_SV_POSITION);
|
||
|
xlt_i.uv = vec2( xlv_TEXCOORD0);
|
||
|
xlt_i.color = vec3( xlv_TEXCOORD1);
|
||
|
xlt_i.backContrib = vec3( xlv_TEXCOORD2);
|
||
|
xlt_i.nl = vec3( xlv_TEXCOORD3);
|
||
|
xlt_i.nh = vec3( xlv_TEXCOORD4);
|
||
|
xl_retval = xlat_main( xlt_i);
|
||
|
_fragData = vec4( xl_retval);
|
||
|
}
|