diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-07-10 16:02:25 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-07-10 16:31:34 +0300 |
commit | 1a43e081873415754950766edaddad220adf67bc (patch) | |
tree | 6a4e61b2337606daf442973d9f82e1d56b906a98 /source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl | |
parent | 97f90d48a02eef89949532b166f57ea178ee5a87 (diff) |
Eevee: LightCache: Initial Implementation
This separate probe rendering from viewport rendering, making possible to
run the baking in another thread (non blocking and faster).
The baked lighting is saved in the blend file. Nothing needs to be
recomputed on load.
There is a few missing bits / bugs:
- Cache cannot be saved to disk as a separate file, it is saved in the DNA
for now making file larger and memory usage higher.
- Auto update only cubemaps does update the grids (bug).
- Probes cannot be updated individually (considered as dynamic).
- Light Cache cannot be (re)generated during render.
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl index a017a791e41..7a92b55e530 100644 --- a/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl +++ b/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl @@ -1,6 +1,4 @@ -in vec3 pos; - uniform float sphere_size; uniform int offset; uniform ivec3 grid_resolution; @@ -8,25 +6,44 @@ uniform vec3 corner; uniform vec3 increment_x; uniform vec3 increment_y; uniform vec3 increment_z; +uniform vec3 screen_vecs[2]; flat out int cellOffset; -out vec3 worldNormal; +out vec2 quadCoord; + +const vec2 pos[6] = vec2[6]( + vec2(-1.0, -1.0), + vec2( 1.0, -1.0), + vec2(-1.0, 1.0), + + vec2( 1.0, -1.0), + vec2( 1.0, 1.0), + vec2(-1.0, 1.0) +); void main() { + int cell_id = gl_VertexID / 6; + int vert_id = gl_VertexID % 6; + vec3 ls_cell_location; /* Keep in sync with update_irradiance_probe */ - ls_cell_location.z = float(gl_InstanceID % grid_resolution.z); - ls_cell_location.y = float((gl_InstanceID / grid_resolution.z) % grid_resolution.y); - ls_cell_location.x = float(gl_InstanceID / (grid_resolution.z * grid_resolution.y)); + ls_cell_location.z = float(cell_id % grid_resolution.z); + ls_cell_location.y = float((cell_id / grid_resolution.z) % grid_resolution.y); + ls_cell_location.x = float(cell_id / (grid_resolution.z * grid_resolution.y)); - cellOffset = offset + gl_InstanceID; + cellOffset = offset + cell_id; vec3 ws_cell_location = corner + (increment_x * ls_cell_location.x + increment_y * ls_cell_location.y + increment_z * ls_cell_location.z); - gl_Position = ViewProjectionMatrix * vec4(pos * 0.02 * sphere_size + ws_cell_location, 1.0); - worldNormal = normalize(pos); + + quadCoord = pos[vert_id]; + vec3 screen_pos = screen_vecs[0] * quadCoord.x + screen_vecs[1] * quadCoord.y; + ws_cell_location += screen_pos * sphere_size; + + gl_Position = ViewProjectionMatrix * vec4(ws_cell_location , 1.0); + gl_Position.z += 0.0001; /* Small bias to let the icon draw without zfighting */ } |