Differential D16243 Diff 58431 source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl
| #pragma BLENDER_REQUIRE(volumetric_lib.glsl) | #pragma BLENDER_REQUIRE(volumetric_lib.glsl) | ||||
| /* Based on Frosbite Unified Volumetric. | /* Based on Frosbite Unified Volumetric. | ||||
| * https://www.ea.com/frostbite/news/physically-based-unified-volumetric-rendering-in-frostbite */ | * https://www.ea.com/frostbite/news/physically-based-unified-volumetric-rendering-in-frostbite */ | ||||
| /* Step 3 : Integrate for each froxel the final amount of light | /* Step 3 : Integrate for each froxel the final amount of light | ||||
| * scattered back to the viewer and the amount of transmittance. */ | * scattered back to the viewer and the amount of transmittance. */ | ||||
| uniform sampler3D volumeScattering; /* Result of the scatter step */ | /* Globals when using OPTI */ | ||||
| uniform sampler3D volumeExtinction; | |||||
| #ifdef USE_VOLUME_OPTI | #ifdef USE_VOLUME_OPTI | ||||
| uniform layout(r11f_g11f_b10f) writeonly restrict image3D finalScattering_img; | |||||
| uniform layout(r11f_g11f_b10f) writeonly restrict image3D finalTransmittance_img; | |||||
| vec3 finalScattering; | vec3 finalScattering; | ||||
| vec3 finalTransmittance; | vec3 finalTransmittance; | ||||
| #else | |||||
| flat in int slice; | |||||
| layout(location = 0) out vec3 finalScattering; | |||||
| layout(location = 1) out vec3 finalTransmittance; | |||||
| #endif | #endif | ||||
| void main() | void main() | ||||
| { | { | ||||
| /* Start with full transmittance and no scattered light. */ | /* Start with full transmittance and no scattered light. */ | ||||
| finalScattering = vec3(0.0); | finalScattering = vec3(0.0); | ||||
| finalTransmittance = vec3(1.0); | finalTransmittance = vec3(1.0); | ||||
| Show All 12 Lines | void main() | ||||
| if (ProjectionMatrix[3][3] == 0.0) { | if (ProjectionMatrix[3][3] == 0.0) { | ||||
| prev_ray_len = length(view_cell); | prev_ray_len = length(view_cell); | ||||
| orig_ray_len = prev_ray_len / view_cell.z; | orig_ray_len = prev_ray_len / view_cell.z; | ||||
| } | } | ||||
| #ifdef USE_VOLUME_OPTI | #ifdef USE_VOLUME_OPTI | ||||
| int slice = textureSize(volumeScattering, 0).z; | int slice = textureSize(volumeScattering, 0).z; | ||||
| ivec2 texco = ivec2(gl_FragCoord.xy); | ivec2 texco = ivec2(gl_FragCoord.xy); | ||||
| #else | |||||
| int slice = volumetric_geom_iface.slice; | |||||
| #endif | #endif | ||||
| for (int i = 0; i <= slice; i++) { | for (int i = 0; i <= slice; i++) { | ||||
| ivec3 volume_cell = ivec3(ivec2(gl_FragCoord.xy), i); | ivec3 volume_cell = ivec3(ivec2(gl_FragCoord.xy), i); | ||||
| vec3 Lscat = texelFetch(volumeScattering, volume_cell, 0).rgb; | vec3 Lscat = texelFetch(volumeScattering, volume_cell, 0).rgb; | ||||
| vec3 s_extinction = texelFetch(volumeExtinction, volume_cell, 0).rgb; | vec3 s_extinction = texelFetch(volumeExtinction, volume_cell, 0).rgb; | ||||
| float cell_depth = volume_z_to_view_z((float(i) + 1.0) / tex_size.z); | float cell_depth = volume_z_to_view_z((float(i) + 1.0) / tex_size.z); | ||||
| Show All 29 Lines | |||||