Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/shaders/shadow_accum_frag.glsl
| Show All 33 Lines | void main() | ||||
| * From http://terathon.com/gdc07_lengyel.pdf (slide 26) */ | * From http://terathon.com/gdc07_lengyel.pdf (slide 26) */ | ||||
| tracing_depth -= mix(2.4e-7, 4.8e-7, depth); | tracing_depth -= mix(2.4e-7, 4.8e-7, depth); | ||||
| /* Convert to view Z. */ | /* Convert to view Z. */ | ||||
| tracing_depth = get_view_z_from_depth(tracing_depth); | tracing_depth = get_view_z_from_depth(tracing_depth); | ||||
| vec3 viewPosition = get_view_space_from_depth(uvs, depth); | vec3 viewPosition = get_view_space_from_depth(uvs, depth); | ||||
| vec3 worldPosition = transform_point(ViewMatrixInverse, viewPosition); | vec3 worldPosition = transform_point(ViewMatrixInverse, viewPosition); | ||||
| vec3 true_normal = normalize(cross(dFdx(viewPosition), dFdy(viewPosition))); | vec3 true_normal = safe_normalize(cross(dFdx(viewPosition), dFdy(viewPosition))); | ||||
| for (int i = 0; i < MAX_LIGHT && i < laNumLight; i++) { | for (int i = 0; i < MAX_LIGHT && i < laNumLight; i++) { | ||||
| LightData ld = lights_data[i]; | LightData ld = lights_data[i]; | ||||
| vec4 l_vector; /* Non-Normalized Light Vector with length in last component. */ | vec4 l_vector; /* Non-Normalized Light Vector with length in last component. */ | ||||
| l_vector.xyz = ld.l_position - worldPosition; | l_vector.xyz = ld.l_position - worldPosition; | ||||
| l_vector.w = length(l_vector.xyz); | l_vector.w = length(l_vector.xyz); | ||||
| float l_vis = light_shadowing( | float l_vis = light_shadowing(ld, worldPosition, 1.0); | ||||
| ld, worldPosition, viewPosition, tracing_depth, true_normal, rand.x, true, 1.0); | |||||
| l_vis *= light_contact_shadows( | |||||
| ld, worldPosition, viewPosition, tracing_depth, true_normal, rand.x, 1.0); | |||||
| accum_light += l_vis; | accum_light += l_vis; | ||||
| } | } | ||||
| fragColor.r = accum_light / float(laNumLight); | fragColor.r = accum_light / float(laNumLight); | ||||
| } | } | ||||