diff options
author | Bastiaan Olij <mux213@gmail.com> | 2023-02-01 12:33:22 +1100 |
---|---|---|
committer | Bastiaan Olij <mux213@gmail.com> | 2023-02-01 12:39:13 +1100 |
commit | 8c77aea9ab245b4c685ba03670613a50efdbd1ea (patch) | |
tree | 43dd5b01eb085d7c8571b870b0e76a8d4e3e0842 /drivers | |
parent | 0810ecaafdbee3ea747219e6ab3a8de5d2216a09 (diff) |
Expose EYE_OFFSET to gdshader code
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gles3/shaders/scene.glsl | 6 | ||||
-rw-r--r-- | drivers/gles3/storage/material_storage.cpp | 1 |
2 files changed, 6 insertions, 1 deletions
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index f977c8ceaf..0b389b0478 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -268,9 +268,11 @@ void main() { #ifdef USE_MULTIVIEW mat4 projection_matrix = multiview_data.projection_matrix_view[ViewIndex]; mat4 inv_projection_matrix = multiview_data.inv_projection_matrix_view[ViewIndex]; + vec3 eye_offset = multiview_data.eye_offset[ViewIndex].xyz; #else mat4 projection_matrix = scene_data.projection_matrix; mat4 inv_projection_matrix = scene_data.inv_projection_matrix; + vec3 eye_offset = vec3(0.0, 0.0, 0.0); #endif //USE_MULTIVIEW #ifdef USE_INSTANCING @@ -930,10 +932,12 @@ void main() { //lay out everything, whatever is unused is optimized away anyway vec3 vertex = vertex_interp; #ifdef USE_MULTIVIEW - vec3 view = -normalize(vertex_interp - multiview_data.eye_offset[ViewIndex].xyz); + vec3 eye_offset = multiview_data.eye_offset[ViewIndex].xyz; + vec3 view = -normalize(vertex_interp - eye_offset); mat4 projection_matrix = multiview_data.projection_matrix_view[ViewIndex]; mat4 inv_projection_matrix = multiview_data.inv_projection_matrix_view[ViewIndex]; #else + vec3 eye_offset = vec3(0.0, 0.0, 0.0); vec3 view = -normalize(vertex_interp); mat4 projection_matrix = scene_data.projection_matrix; mat4 inv_projection_matrix = scene_data.inv_projection_matrix; diff --git a/drivers/gles3/storage/material_storage.cpp b/drivers/gles3/storage/material_storage.cpp index 4fb780b665..aa8df606cf 100644 --- a/drivers/gles3/storage/material_storage.cpp +++ b/drivers/gles3/storage/material_storage.cpp @@ -1639,6 +1639,7 @@ MaterialStorage::MaterialStorage() { actions.renames["VIEW_INDEX"] = "ViewIndex"; actions.renames["VIEW_MONO_LEFT"] = "uint(0)"; actions.renames["VIEW_RIGHT"] = "uint(1)"; + actions.renames["EYE_OFFSET"] = "eye_offset"; //for light actions.renames["VIEW"] = "view"; |