From e37d72369510e45a0895af88d47a7fdac93ceba9 Mon Sep 17 00:00:00 2001 From: clayjohn Date: Sun, 7 Apr 2019 23:18:29 -0700 Subject: [PATCH] fixes bug when setting projection matrix --- drivers/gles2/shaders/scene.glsl | 3 +++ servers/visual/shader_types.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gles2/shaders/scene.glsl b/drivers/gles2/shaders/scene.glsl index 5d21c679bad..222dcd25cb1 100644 --- a/drivers/gles2/shaders/scene.glsl +++ b/drivers/gles2/shaders/scene.glsl @@ -424,9 +424,12 @@ void main() { #endif + mat4 local_projection_matrix = projection_matrix; + mat4 modelview = camera_inverse_matrix * world_matrix; float roughness = 1.0; +#define projection_matrix local_projection_matrix #define world_transform world_matrix { diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp index 7a42bc475eb..8fd5dfc7389 100644 --- a/servers/visual/shader_types.cpp +++ b/servers/visual/shader_types.cpp @@ -76,7 +76,7 @@ ShaderTypes::ShaderTypes() { shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["CAMERA_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["PROJECTION_MATRIX"] = ShaderLanguage::TYPE_MAT4; shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["MODELVIEW_MATRIX"] = ShaderLanguage::TYPE_MAT4; - shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["INV_PROJECTION_MATRIX"] = ShaderLanguage::TYPE_MAT4; + shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["INV_PROJECTION_MATRIX"] = constt(ShaderLanguage::TYPE_MAT4); shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT); shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["VIEWPORT_SIZE"] = constt(ShaderLanguage::TYPE_VEC2); shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["OUTPUT_IS_SRGB"] = constt(ShaderLanguage::TYPE_BOOL);