Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-07-10 16:02:25 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-07-10 16:31:34 +0300
commit1a43e081873415754950766edaddad220adf67bc (patch)
tree6a4e61b2337606daf442973d9f82e1d56b906a98 /source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl
parent97f90d48a02eef89949532b166f57ea178ee5a87 (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_cube_display_vert.glsl')
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl49
1 files changed, 33 insertions, 16 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl
index b0a6cbe1707..b327878b63d 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl
@@ -1,26 +1,43 @@
-in vec3 pos;
+/* XXX TODO fix code duplication */
+struct CubeData {
+ vec4 position_type;
+ vec4 attenuation_fac_type;
+ mat4 influencemat;
+ mat4 parallaxmat;
+};
-/* Instance attrib */
-in int probe_id;
-in vec3 probe_location;
-in float sphere_size;
+layout(std140) uniform probe_block {
+ CubeData probes_data[MAX_PROBE];
+};
+
+uniform float sphere_size;
+uniform vec3 screen_vecs[2];
flat out int pid;
-out vec3 worldNormal;
-out vec3 worldPosition;
+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()
{
- pid = probe_id;
+ pid = 1 + (gl_VertexID / 6); /* +1 for the world */
+ int vert_id = gl_VertexID % 6;
+
+ quadCoord = pos[vert_id];
- /* While this is not performant, we do this to
- * match the object mode engine instancing shader. */
- mat4 offsetmat = mat4(1.0); /* Identity */
- offsetmat[3].xyz = probe_location;
+ vec3 ws_location = probes_data[pid].position_type.xyz;
+ vec3 screen_pos = screen_vecs[0] * quadCoord.x + screen_vecs[1] * quadCoord.y;
+ ws_location += screen_pos * sphere_size;
- vec4 wpos = offsetmat * vec4(pos * sphere_size, 1.0);
- worldPosition = wpos.xyz;
- gl_Position = ViewProjectionMatrix * wpos;
- worldNormal = normalize(pos);
+ gl_Position = ViewProjectionMatrix * vec4(ws_location, 1.0);
+ gl_Position.z += 0.0001; /* Small bias to let the icon draw without zfighting */
}