You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-15 13:51:40 +00:00
Add multiview/stereoscopic rendering support to the clustered forward renderer
This commit is contained in:
@@ -99,6 +99,18 @@ layout(location = 8) out float dp_clip;
|
||||
|
||||
layout(location = 9) out flat uint instance_index_interp;
|
||||
|
||||
#ifdef USE_MULTIVIEW
|
||||
#ifdef has_VK_KHR_multiview
|
||||
#define ViewIndex gl_ViewIndex
|
||||
#else // has_VK_KHR_multiview
|
||||
// !BAS! This needs to become an input once we implement our fallback!
|
||||
#define ViewIndex 0
|
||||
#endif // has_VK_KHR_multiview
|
||||
#else // USE_MULTIVIEW
|
||||
// Set to zero, not supported in non stereo
|
||||
#define ViewIndex 0
|
||||
#endif //USE_MULTIVIEW
|
||||
|
||||
invariant gl_Position;
|
||||
|
||||
#GLOBALS
|
||||
@@ -244,7 +256,13 @@ void main() {
|
||||
vec4 position;
|
||||
#endif
|
||||
|
||||
#ifdef USE_MULTIVIEW
|
||||
mat4 projection_matrix = scene_data.projection_matrix_view[ViewIndex];
|
||||
mat4 inv_projection_matrix = scene_data.inv_projection_matrix_view[ViewIndex];
|
||||
#else
|
||||
mat4 projection_matrix = scene_data.projection_matrix;
|
||||
mat4 inv_projection_matrix = scene_data.inv_projection_matrix;
|
||||
#endif //USE_MULTIVIEW
|
||||
|
||||
//using world coordinates
|
||||
#if !defined(SKIP_TRANSFORM_USED) && defined(VERTEX_WORLD_COORDS_USED)
|
||||
@@ -421,10 +439,26 @@ layout(location = 8) in float dp_clip;
|
||||
|
||||
layout(location = 9) in flat uint instance_index_interp;
|
||||
|
||||
#ifdef USE_MULTIVIEW
|
||||
#ifdef has_VK_KHR_multiview
|
||||
#define ViewIndex gl_ViewIndex
|
||||
#else // has_VK_KHR_multiview
|
||||
// !BAS! This needs to become an input once we implement our fallback!
|
||||
#define ViewIndex 0
|
||||
#endif // has_VK_KHR_multiview
|
||||
#else // USE_MULTIVIEW
|
||||
// Set to zero, not supported in non stereo
|
||||
#define ViewIndex 0
|
||||
#endif //USE_MULTIVIEW
|
||||
|
||||
//defines to keep compatibility with vertex
|
||||
|
||||
#define world_matrix instances.data[instance_index].transform
|
||||
#ifdef USE_MULTIVIEW
|
||||
#define projection_matrix scene_data.projection_matrix_view[ViewIndex]
|
||||
#else
|
||||
#define projection_matrix scene_data.projection_matrix
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_SSS) && defined(ENABLE_TRANSMITTANCE)
|
||||
//both required for transmittance to be enabled
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define ROUGHNESS_MAX_LOD 5
|
||||
|
||||
#define MAX_VOXEL_GI_INSTANCES 8
|
||||
#define MAX_VIEWS 2
|
||||
|
||||
#if defined(has_GL_KHR_shader_subgroup_ballot) && defined(has_GL_KHR_shader_subgroup_arithmetic)
|
||||
|
||||
@@ -12,6 +13,10 @@
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(USE_MULTIVIEW) && defined(has_VK_KHR_multiview)
|
||||
#extension GL_EXT_multiview : enable
|
||||
#endif
|
||||
|
||||
#include "cluster_data_inc.glsl"
|
||||
#include "decal_data_inc.glsl"
|
||||
|
||||
@@ -169,10 +174,13 @@ sdfgi;
|
||||
layout(set = 1, binding = 0, std140) uniform SceneData {
|
||||
mat4 projection_matrix;
|
||||
mat4 inv_projection_matrix;
|
||||
|
||||
mat4 camera_matrix;
|
||||
mat4 inv_camera_matrix;
|
||||
|
||||
// only used for multiview
|
||||
mat4 projection_matrix_view[MAX_VIEWS];
|
||||
mat4 inv_projection_matrix_view[MAX_VIEWS];
|
||||
|
||||
vec2 viewport_size;
|
||||
vec2 screen_pixel_size;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user