mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-01 11:56:58 -05:00
157 lines
5.1 KiB
Text
157 lines
5.1 KiB
Text
varying highp vec3 xlv_TEXCOORD1;
|
|
varying highp vec4 xlv_TEXCOORD0;
|
|
uniform highp vec4 unity_LightmapFade;
|
|
uniform highp vec4 _ZBufferParams;
|
|
uniform highp vec3 _WorldSpaceCameraPos;
|
|
uniform samplerCube _ShadowMapTexture;
|
|
uniform highp vec4 _ProjectionParams;
|
|
uniform sampler2D _LightTextureB0;
|
|
uniform samplerCube _LightTexture0;
|
|
uniform highp vec4 _LightShadowData;
|
|
uniform highp vec4 _LightPositionRange;
|
|
uniform highp vec4 _LightPos;
|
|
uniform highp mat4 _LightMatrix0;
|
|
uniform highp vec4 _LightColor;
|
|
uniform highp mat4 _CameraToWorld;
|
|
uniform sampler2D _CameraNormalsTexture;
|
|
uniform sampler2D _CameraDepthTexture;
|
|
void main ()
|
|
{
|
|
mediump vec4 res;
|
|
highp float spec;
|
|
mediump vec3 h;
|
|
highp float atten;
|
|
mediump vec3 lightDir;
|
|
highp float depth;
|
|
mediump vec3 normal;
|
|
mediump vec4 nspec;
|
|
highp vec2 tmpvar_1;
|
|
tmpvar_1 = (xlv_TEXCOORD0.xy / xlv_TEXCOORD0.w);
|
|
lowp vec4 tmpvar_2;
|
|
tmpvar_2 = texture2D (_CameraNormalsTexture, tmpvar_1);
|
|
nspec = tmpvar_2;
|
|
normal = normalize (((nspec.xyz * 2.0) - 1.0));
|
|
lowp float tmpvar_3;
|
|
tmpvar_3 = texture2D (_CameraDepthTexture, tmpvar_1).x;
|
|
depth = tmpvar_3;
|
|
highp float tmpvar_4;
|
|
tmpvar_4 = (1.0/(((_ZBufferParams.x * depth) + _ZBufferParams.y)));
|
|
depth = tmpvar_4;
|
|
highp vec4 tmpvar_5;
|
|
tmpvar_5.w = 1.0;
|
|
tmpvar_5.xyz = ((xlv_TEXCOORD1 * (_ProjectionParams.z / xlv_TEXCOORD1.z)) * tmpvar_4);
|
|
highp vec3 tmpvar_6;
|
|
tmpvar_6 = (_CameraToWorld * tmpvar_5).xyz;
|
|
highp vec3 tmpvar_7;
|
|
tmpvar_7 = (tmpvar_6 - _LightPos.xyz);
|
|
highp vec3 tmpvar_8;
|
|
tmpvar_8 = -(normalize (tmpvar_7));
|
|
lightDir = tmpvar_8;
|
|
highp vec2 tmpvar_9;
|
|
tmpvar_9 = vec2((dot (tmpvar_7, tmpvar_7) * _LightPos.w));
|
|
lowp float tmpvar_10;
|
|
tmpvar_10 = texture2D (_LightTextureB0, tmpvar_9).w;
|
|
atten = tmpvar_10;
|
|
mediump vec4 shadows;
|
|
highp vec4 shadowVals;
|
|
highp vec3 vec_i0_i0;
|
|
vec_i0_i0 = (tmpvar_7 + vec3(0.0078125, 0.0078125, 0.0078125));
|
|
highp vec4 packDist;
|
|
lowp vec4 tmpvar_11;
|
|
tmpvar_11 = textureCube (_ShadowMapTexture, vec_i0_i0);
|
|
packDist = tmpvar_11;
|
|
shadowVals.x = dot (packDist, vec4(1.0, 0.00392157, 1.53787e-05, 0.0));
|
|
highp vec3 vec_i0_i1;
|
|
vec_i0_i1 = (tmpvar_7 + vec3(-0.0078125, -0.0078125, 0.0078125));
|
|
highp vec4 packDist_i0;
|
|
lowp vec4 tmpvar_12;
|
|
tmpvar_12 = textureCube (_ShadowMapTexture, vec_i0_i1);
|
|
packDist_i0 = tmpvar_12;
|
|
shadowVals.y = dot (packDist_i0, vec4(1.0, 0.00392157, 1.53787e-05, 0.0));
|
|
highp vec3 vec_i0_i1_i2;
|
|
vec_i0_i1_i2 = (tmpvar_7 + vec3(-0.0078125, 0.0078125, -0.0078125));
|
|
highp vec4 packDist_i0_i1;
|
|
lowp vec4 tmpvar_13;
|
|
tmpvar_13 = textureCube (_ShadowMapTexture, vec_i0_i1_i2);
|
|
packDist_i0_i1 = tmpvar_13;
|
|
shadowVals.z = dot (packDist_i0_i1, vec4(1.0, 0.00392157, 1.53787e-05, 0.0));
|
|
highp vec3 vec_i0_i1_i2_i3;
|
|
vec_i0_i1_i2_i3 = (tmpvar_7 + vec3(0.0078125, -0.0078125, -0.0078125));
|
|
highp vec4 packDist_i0_i1_i2;
|
|
lowp vec4 tmpvar_14;
|
|
tmpvar_14 = textureCube (_ShadowMapTexture, vec_i0_i1_i2_i3);
|
|
packDist_i0_i1_i2 = tmpvar_14;
|
|
shadowVals.w = dot (packDist_i0_i1_i2, vec4(1.0, 0.00392157, 1.53787e-05, 0.0));
|
|
highp vec4 tmpvar_15;
|
|
tmpvar_15 = vec4(((length (tmpvar_7) * _LightPositionRange.w) * 0.97));
|
|
bvec4 tmpvar_16;
|
|
tmpvar_16 = lessThan (shadowVals, tmpvar_15);
|
|
highp float tmpvar_17;
|
|
if (tmpvar_16.x) {
|
|
tmpvar_17 = _LightShadowData.x;
|
|
} else {
|
|
tmpvar_17 = 1.0;
|
|
};
|
|
highp float tmpvar_18;
|
|
if (tmpvar_16.y) {
|
|
tmpvar_18 = _LightShadowData.x;
|
|
} else {
|
|
tmpvar_18 = 1.0;
|
|
};
|
|
highp float tmpvar_19;
|
|
if (tmpvar_16.z) {
|
|
tmpvar_19 = _LightShadowData.x;
|
|
} else {
|
|
tmpvar_19 = 1.0;
|
|
};
|
|
highp float tmpvar_20;
|
|
if (tmpvar_16.w) {
|
|
tmpvar_20 = _LightShadowData.x;
|
|
} else {
|
|
tmpvar_20 = 1.0;
|
|
};
|
|
highp vec4 tmpvar_21;
|
|
tmpvar_21.x = tmpvar_17;
|
|
tmpvar_21.y = tmpvar_18;
|
|
tmpvar_21.z = tmpvar_19;
|
|
tmpvar_21.w = tmpvar_20;
|
|
shadows = tmpvar_21;
|
|
mediump float tmpvar_22;
|
|
tmpvar_22 = dot (shadows, vec4(0.25, 0.25, 0.25, 0.25));
|
|
highp vec4 tmpvar_23;
|
|
tmpvar_23.w = 1.0;
|
|
tmpvar_23.xyz = tmpvar_6;
|
|
lowp vec4 tmpvar_24;
|
|
tmpvar_24 = textureCube (_LightTexture0, (_LightMatrix0 * tmpvar_23).xyz);
|
|
highp float tmpvar_25;
|
|
tmpvar_25 = ((atten * tmpvar_22) * tmpvar_24.w);
|
|
atten = tmpvar_25;
|
|
mediump float tmpvar_26;
|
|
tmpvar_26 = max (0.0, dot (lightDir, normal));
|
|
highp vec3 tmpvar_27;
|
|
tmpvar_27 = normalize ((lightDir - normalize ((tmpvar_6 - _WorldSpaceCameraPos))));
|
|
h = tmpvar_27;
|
|
mediump float tmpvar_28;
|
|
tmpvar_28 = pow (max (0.0, dot (h, normal)), (nspec.w * 128.0));
|
|
spec = tmpvar_28;
|
|
highp float tmpvar_29;
|
|
tmpvar_29 = (spec * clamp (tmpvar_25, 0.0, 1.0));
|
|
spec = tmpvar_29;
|
|
highp vec3 tmpvar_30;
|
|
tmpvar_30 = (_LightColor.xyz * (tmpvar_26 * tmpvar_25));
|
|
res.xyz = tmpvar_30;
|
|
mediump vec3 c;
|
|
c = _LightColor.xyz;
|
|
mediump float tmpvar_31;
|
|
tmpvar_31 = dot (c, vec3(0.22, 0.707, 0.071));
|
|
highp float tmpvar_32;
|
|
tmpvar_32 = (tmpvar_29 * tmpvar_31);
|
|
res.w = tmpvar_32;
|
|
highp float tmpvar_33;
|
|
tmpvar_33 = clamp ((1.0 - ((tmpvar_5.z * unity_LightmapFade.z) + unity_LightmapFade.w)), 0.0, 1.0);
|
|
mediump vec4 tmpvar_34;
|
|
tmpvar_34 = (res * tmpvar_33);
|
|
res = tmpvar_34;
|
|
gl_FragData[0] = exp2 (-(tmpvar_34));
|
|
}
|
|
|