mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 17:18:12 -05:00
124 lines
4.3 KiB
Text
124 lines
4.3 KiB
Text
uniform sampler2D _CameraDepthTexture;
|
|
uniform sampler2D _CameraNormalsTexture;
|
|
uniform mat4 _CameraToWorld;
|
|
uniform vec4 _LightColor;
|
|
uniform mat4 _LightMatrix0;
|
|
uniform vec4 _LightPos;
|
|
uniform vec4 _LightPositionRange;
|
|
uniform vec4 _LightShadowData;
|
|
uniform samplerCube _LightTexture0;
|
|
uniform sampler2D _LightTextureB0;
|
|
uniform vec4 _ProjectionParams;
|
|
uniform samplerCube _ShadowMapTexture;
|
|
uniform vec3 _WorldSpaceCameraPos;
|
|
uniform vec4 _ZBufferParams;
|
|
uniform vec4 unity_LightmapFade;
|
|
varying vec4 xlv_TEXCOORD0;
|
|
varying vec3 xlv_TEXCOORD1;
|
|
void main ()
|
|
{
|
|
vec4 res_1;
|
|
float atten_2;
|
|
vec3 lightDir_3;
|
|
vec3 tolight_4;
|
|
vec3 wpos_5;
|
|
vec3 normal_6;
|
|
vec2 uv_7;
|
|
uv_7 = (xlv_TEXCOORD0.xy / xlv_TEXCOORD0.w);
|
|
vec4 tmpvar_8;
|
|
tmpvar_8 = texture2D (_CameraNormalsTexture, uv_7);
|
|
normal_6 = ((tmpvar_8.xyz * 2.0) - 1.0);
|
|
normal_6 = normalize(normal_6);
|
|
vec4 tmpvar_9;
|
|
tmpvar_9.w = 1.0;
|
|
tmpvar_9.xyz = ((xlv_TEXCOORD1 * (_ProjectionParams.z / xlv_TEXCOORD1.z)) * (1.0/((
|
|
(_ZBufferParams.x * texture2D (_CameraDepthTexture, uv_7).x)
|
|
+ _ZBufferParams.y))));
|
|
wpos_5 = (_CameraToWorld * tmpvar_9).xyz;
|
|
tolight_4 = (wpos_5 - _LightPos.xyz);
|
|
lightDir_3 = -(normalize(tolight_4));
|
|
atten_2 = texture2D (_LightTextureB0, vec2((dot (tolight_4, tolight_4) * _LightPos.w))).w;
|
|
float mydist_10;
|
|
mydist_10 = (sqrt(dot (tolight_4, tolight_4)) * _LightPositionRange.w);
|
|
mydist_10 = (mydist_10 * 0.97);
|
|
vec4 shadowVals_11;
|
|
shadowVals_11.x = dot (textureCube (_ShadowMapTexture, (tolight_4 + vec3(0.0078125, 0.0078125, 0.0078125))), vec4(1.0, 0.00392157, 1.53787e-05, 6.22737e-09));
|
|
shadowVals_11.y = dot (textureCube (_ShadowMapTexture, (tolight_4 + vec3(-0.0078125, -0.0078125, 0.0078125))), vec4(1.0, 0.00392157, 1.53787e-05, 6.22737e-09));
|
|
shadowVals_11.z = dot (textureCube (_ShadowMapTexture, (tolight_4 + vec3(-0.0078125, 0.0078125, -0.0078125))), vec4(1.0, 0.00392157, 1.53787e-05, 6.22737e-09));
|
|
shadowVals_11.w = dot (textureCube (_ShadowMapTexture, (tolight_4 + vec3(0.0078125, -0.0078125, -0.0078125))), vec4(1.0, 0.00392157, 1.53787e-05, 6.22737e-09));
|
|
bvec4 tmpvar_12;
|
|
tmpvar_12 = lessThan (shadowVals_11, vec4(mydist_10));
|
|
vec4 tmpvar_13;
|
|
tmpvar_13 = _LightShadowData.xxxx;
|
|
float tmpvar_14;
|
|
if (tmpvar_12.x) {
|
|
tmpvar_14 = tmpvar_13.x;
|
|
} else {
|
|
tmpvar_14 = 1.0;
|
|
};
|
|
float tmpvar_15;
|
|
if (tmpvar_12.y) {
|
|
tmpvar_15 = tmpvar_13.y;
|
|
} else {
|
|
tmpvar_15 = 1.0;
|
|
};
|
|
float tmpvar_16;
|
|
if (tmpvar_12.z) {
|
|
tmpvar_16 = tmpvar_13.z;
|
|
} else {
|
|
tmpvar_16 = 1.0;
|
|
};
|
|
float tmpvar_17;
|
|
if (tmpvar_12.w) {
|
|
tmpvar_17 = tmpvar_13.w;
|
|
} else {
|
|
tmpvar_17 = 1.0;
|
|
};
|
|
vec4 tmpvar_18;
|
|
tmpvar_18.x = tmpvar_14;
|
|
tmpvar_18.y = tmpvar_15;
|
|
tmpvar_18.z = tmpvar_16;
|
|
tmpvar_18.w = tmpvar_17;
|
|
atten_2 = (atten_2 * dot (tmpvar_18, vec4(0.25, 0.25, 0.25, 0.25)));
|
|
vec4 tmpvar_19;
|
|
tmpvar_19.w = 1.0;
|
|
tmpvar_19.xyz = wpos_5;
|
|
atten_2 = (atten_2 * textureCube (_LightTexture0, (_LightMatrix0 * tmpvar_19).xyz).w);
|
|
res_1.xyz = (_LightColor.xyz * (max (0.0,
|
|
dot (lightDir_3, normal_6)
|
|
) * atten_2));
|
|
res_1.w = ((pow (
|
|
max (0.0, dot (normalize((lightDir_3 -
|
|
normalize((wpos_5 - _WorldSpaceCameraPos))
|
|
)), normal_6))
|
|
,
|
|
(tmpvar_8.w * 128.0)
|
|
) * clamp (atten_2, 0.0, 1.0)) * dot (_LightColor.xyz, vec3(0.22, 0.707, 0.071)));
|
|
res_1 = (res_1 * clamp ((1.0 -
|
|
((tmpvar_9.z * unity_LightmapFade.z) + unity_LightmapFade.w)
|
|
), 0.0, 1.0));
|
|
gl_FragData[0] = exp2(-(res_1));
|
|
}
|
|
|
|
|
|
// stats: 62 alu 8 tex 4 flow
|
|
// inputs: 2
|
|
// #0: xlv_TEXCOORD0 (high float) 4x1 [-1]
|
|
// #1: xlv_TEXCOORD1 (high float) 3x1 [-1]
|
|
// uniforms: 10 (total size: 0)
|
|
// #0: _CameraToWorld (high float) 4x4 [-1]
|
|
// #1: _LightColor (high float) 4x1 [-1]
|
|
// #2: _LightMatrix0 (high float) 4x4 [-1]
|
|
// #3: _LightPos (high float) 4x1 [-1]
|
|
// #4: _LightPositionRange (high float) 4x1 [-1]
|
|
// #5: _LightShadowData (high float) 4x1 [-1]
|
|
// #6: _ProjectionParams (high float) 4x1 [-1]
|
|
// #7: _WorldSpaceCameraPos (high float) 3x1 [-1]
|
|
// #8: _ZBufferParams (high float) 4x1 [-1]
|
|
// #9: unity_LightmapFade (high float) 4x1 [-1]
|
|
// textures: 5
|
|
// #0: _CameraDepthTexture (high 2d) 0x0 [-1]
|
|
// #1: _CameraNormalsTexture (high 2d) 0x0 [-1]
|
|
// #2: _LightTexture0 (high cube) 0x0 [-1]
|
|
// #3: _LightTextureB0 (high 2d) 0x0 [-1]
|
|
// #4: _ShadowMapTexture (high cube) 0x0 [-1]
|