mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-11 00:31:28 -05:00
69 lines
2.4 KiB
Text
69 lines
2.4 KiB
Text
|
uniform vec4 unity_LightmapFade;
|
||
|
uniform vec4 _ZBufferParams;
|
||
|
uniform mat4 _ViewToCookie;
|
||
|
uniform mat4 _View2Shadow;
|
||
|
uniform samplerCube _ShadowMapTexture;
|
||
|
uniform vec4 _ProjectionParams;
|
||
|
uniform sampler2D _LightTextureB0;
|
||
|
uniform samplerCube _LightTexture0;
|
||
|
uniform vec4 _LightShadowData;
|
||
|
uniform vec4 _LightPositionRange;
|
||
|
uniform vec4 _LightPos;
|
||
|
uniform vec4 _LightColor;
|
||
|
uniform sampler2D _CameraNormalsTexture;
|
||
|
uniform sampler2D _CameraDepthTexture;
|
||
|
void main ()
|
||
|
{
|
||
|
vec4 tmpvar_1;
|
||
|
tmpvar_1 = gl_TexCoord[0];
|
||
|
vec3 tmpvar_2;
|
||
|
tmpvar_2 = gl_TexCoord[1].xyz;
|
||
|
vec4 res_3;
|
||
|
float atten_4;
|
||
|
vec3 lightDir_5;
|
||
|
vec3 normal_6;
|
||
|
vec2 tmpvar_7;
|
||
|
tmpvar_7 = (tmpvar_1.xy / tmpvar_1.w);
|
||
|
vec4 tmpvar_8;
|
||
|
tmpvar_8 = texture2D (_CameraNormalsTexture, tmpvar_7);
|
||
|
normal_6 = normalize(((tmpvar_8.xyz * 2.0) - 1.0));
|
||
|
vec3 tmpvar_9;
|
||
|
tmpvar_9 = ((tmpvar_2 * (_ProjectionParams.z / tmpvar_2.z)) * (1.0/(((_ZBufferParams.x * texture2D (_CameraDepthTexture, tmpvar_7).x) + _ZBufferParams.y))));
|
||
|
vec3 tmpvar_10;
|
||
|
tmpvar_10 = (_LightPos.xyz - tmpvar_9);
|
||
|
lightDir_5 = normalize(tmpvar_10);
|
||
|
atten_4 = texture2D (_LightTextureB0, vec2((dot (tmpvar_10, tmpvar_10) * _LightPos.w))).w;
|
||
|
vec3 vec_11;
|
||
|
vec_11 = -(tmpvar_10);
|
||
|
mat3 tmpvar_12;
|
||
|
tmpvar_12[0] = _View2Shadow[0].xyz;
|
||
|
tmpvar_12[1] = _View2Shadow[1].xyz;
|
||
|
tmpvar_12[2] = _View2Shadow[2].xyz;
|
||
|
vec3 tmpvar_13;
|
||
|
tmpvar_13 = (tmpvar_12 * vec_11);
|
||
|
vec_11 = tmpvar_13;
|
||
|
float tmpvar_14;
|
||
|
tmpvar_14 = ((sqrt(dot (tmpvar_13, tmpvar_13)) * _LightPositionRange.w) * 0.97);
|
||
|
float tmpvar_15;
|
||
|
tmpvar_15 = dot (textureCube (_ShadowMapTexture, tmpvar_13), vec4(1.0, 0.00392157, 1.53787e-05, 6.22737e-09));
|
||
|
float tmpvar_16;
|
||
|
if ((tmpvar_15 < tmpvar_14)) {
|
||
|
tmpvar_16 = _LightShadowData.x;
|
||
|
} else {
|
||
|
tmpvar_16 = 1.0;
|
||
|
};
|
||
|
vec4 tmpvar_17;
|
||
|
tmpvar_17.w = 1.0;
|
||
|
tmpvar_17.xyz = tmpvar_9;
|
||
|
float tmpvar_18;
|
||
|
tmpvar_18 = ((atten_4 * tmpvar_16) * textureCube (_LightTexture0, (_ViewToCookie * tmpvar_17).xyz).w);
|
||
|
atten_4 = tmpvar_18;
|
||
|
res_3.xyz = (_LightColor.xyz * (max (0.0, dot (lightDir_5, normal_6)) * tmpvar_18));
|
||
|
res_3.w = ((pow (max (0.0, dot (normalize((lightDir_5 - normalize(tmpvar_9))), normal_6)), (tmpvar_8.w * 128.0)) * clamp (tmpvar_18, 0.0, 1.0)) * dot (_LightColor.xyz, vec3(0.22, 0.707, 0.071)));
|
||
|
vec4 tmpvar_19;
|
||
|
tmpvar_19 = (res_3 * clamp ((1.0 - ((tmpvar_9.z * unity_LightmapFade.z) + unity_LightmapFade.w)), 0.0, 1.0));
|
||
|
res_3 = tmpvar_19;
|
||
|
gl_FragData[0] = exp2(-(tmpvar_19));
|
||
|
}
|
||
|
|