Merge pull request #71455 from BastiaanOlij/fix_stereo_screen_depth
Make screen texture and depth texture work in Multiview
This commit is contained in:
commit
4b0363312e
15 changed files with 103 additions and 23 deletions
|
|
@ -192,7 +192,7 @@ void ShaderGLES3::_build_variant_code(StringBuilder &builder, uint32_t p_variant
|
|||
builder.append("#define ViewIndex gl_ViewID_OVR\n");
|
||||
builder.append("#define MAX_VIEWS 2\n");
|
||||
builder.append("#else\n");
|
||||
builder.append("#define ViewIndex 0\n");
|
||||
builder.append("#define ViewIndex uint(0)\n");
|
||||
builder.append("#define MAX_VIEWS 1\n");
|
||||
builder.append("#endif\n");
|
||||
|
||||
|
|
|
|||
|
|
@ -565,9 +565,15 @@ uniform highp samplerCubeShadow positional_shadow; // texunit:-4
|
|||
#ifdef USE_MULTIVIEW
|
||||
uniform highp sampler2DArray depth_buffer; // texunit:-6
|
||||
uniform highp sampler2DArray color_buffer; // texunit:-5
|
||||
vec3 multiview_uv(vec2 uv) {
|
||||
return vec3(uv, ViewIndex);
|
||||
}
|
||||
#else
|
||||
uniform highp sampler2D depth_buffer; // texunit:-6
|
||||
uniform highp sampler2D color_buffer; // texunit:-5
|
||||
vec2 multiview_uv(vec2 uv) {
|
||||
return uv;
|
||||
}
|
||||
#endif
|
||||
|
||||
uniform highp mat4 world_transform;
|
||||
|
|
@ -925,8 +931,12 @@ void main() {
|
|||
vec3 vertex = vertex_interp;
|
||||
#ifdef USE_MULTIVIEW
|
||||
vec3 view = -normalize(vertex_interp - multiview_data.eye_offset[ViewIndex].xyz);
|
||||
mat4 projection_matrix = multiview_data.projection_matrix_view[ViewIndex];
|
||||
mat4 inv_projection_matrix = multiview_data.inv_projection_matrix_view[ViewIndex];
|
||||
#else
|
||||
vec3 view = -normalize(vertex_interp);
|
||||
mat4 projection_matrix = scene_data.projection_matrix;
|
||||
mat4 inv_projection_matrix = scene_data.inv_projection_matrix;
|
||||
#endif
|
||||
highp mat4 model_matrix = world_transform;
|
||||
vec3 albedo = vec3(1.0);
|
||||
|
|
|
|||
|
|
@ -1635,8 +1635,8 @@ MaterialStorage::MaterialStorage() {
|
|||
actions.renames["NODE_POSITION_VIEW"] = "(model_matrix * scene_data.view_matrix)[3].xyz";
|
||||
|
||||
actions.renames["VIEW_INDEX"] = "ViewIndex";
|
||||
actions.renames["VIEW_MONO_LEFT"] = "0";
|
||||
actions.renames["VIEW_RIGHT"] = "1";
|
||||
actions.renames["VIEW_MONO_LEFT"] = "uint(0)";
|
||||
actions.renames["VIEW_RIGHT"] = "uint(1)";
|
||||
|
||||
//for light
|
||||
actions.renames["VIEW"] = "view";
|
||||
|
|
@ -1718,6 +1718,8 @@ MaterialStorage::MaterialStorage() {
|
|||
actions.default_filter = ShaderLanguage::FILTER_LINEAR_MIPMAP;
|
||||
actions.default_repeat = ShaderLanguage::REPEAT_ENABLE;
|
||||
|
||||
actions.check_multiview_samplers = true;
|
||||
|
||||
shaders.compiler_scene.initialize(actions);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue