diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-12-04 19:20:20 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-12-04 19:21:37 +0300 |
commit | 5bd008f4ddd42d61a0e605fca8136230e7189d82 (patch) | |
tree | 98a61c1456b5f8e268e95b3a724f71787d2fbab3 /source/blender/draw/engines/eevee/shaders/irradiance_lib.glsl | |
parent | c370fffc9bd0900a30e04ac631641d43e0f217a5 (diff) |
Eevee: Irradiance Grid: Allocate needed resources instead of a static chunck.
This commit makes the irradiance pool and render target sizes depend on the number of irradiance sample in the whole ViewLayer.
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/irradiance_lib.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/irradiance_lib.glsl | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/irradiance_lib.glsl b/source/blender/draw/engines/eevee/shaders/irradiance_lib.glsl index 2555d413da9..76d20486d3d 100644 --- a/source/blender/draw/engines/eevee/shaders/irradiance_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/irradiance_lib.glsl @@ -82,9 +82,10 @@ float load_visibility_cell(int cell, vec3 L, float dist, float bias, float bleed { /* Keep in sync with diffuse_filter_probe() */ ivec2 cell_co = ivec2(irradianceVisibilitySize); - int cell_per_row = textureSize(irradianceGrid, 0).x / irradianceVisibilitySize; - cell_co.x *= (cell) % cell_per_row; - cell_co.y *= (cell) / cell_per_row; + ivec2 cell_per_row_col = textureSize(irradianceGrid, 0).xy / irradianceVisibilitySize; + cell_co.x *= (cell % cell_per_row_col.x); + cell_co.y *= (cell / cell_per_row_col.x) % cell_per_row_col.y; + float layer = 1.0 + float((cell / cell_per_row_col.x) / cell_per_row_col.y); vec2 texel_size = 1.0 / vec2(textureSize(irradianceGrid, 0).xy); vec2 co = vec2(cell_co) * texel_size; @@ -92,7 +93,7 @@ float load_visibility_cell(int cell, vec3 L, float dist, float bias, float bleed vec2 uv = mapping_octahedron(-L, vec2(1.0 / float(irradianceVisibilitySize))); uv *= vec2(irradianceVisibilitySize) * texel_size; - vec4 data = texture(irradianceGrid, vec3(co + uv, 1.0)); + vec4 data = texture(irradianceGrid, vec3(co + uv, layer)); /* Decoding compressed data */ vec2 moments = visibility_decode(data, range); |