summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <juan@godotengine.org>2019-03-01 19:27:12 -0300
committerJuan Linietsky <juan@godotengine.org>2019-03-01 19:28:24 -0300
commit7bad1706c2fe71aac6d02b5a445a3faeb1e44d76 (patch)
treeb99802bb42a9d22e1b09ea7df64c25b9c510c008
parent78fcbb80c53ca29a00386087d05ca9abb1b7659b (diff)
-Fix prepass state not being reset, closes #26348
-Send zero values for shader if no default exists
-rw-r--r--drivers/gles2/rasterizer_scene_gles2.cpp1
-rw-r--r--drivers/gles2/shader_gles2.cpp134
2 files changed, 135 insertions, 0 deletions
diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp
index e6f46776c0..e0eec74700 100644
--- a/drivers/gles2/rasterizer_scene_gles2.cpp
+++ b/drivers/gles2/rasterizer_scene_gles2.cpp
@@ -2523,6 +2523,7 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
state.scene_shader.set_conditional(SceneShaderGLES2::FOG_DEPTH_ENABLED, false);
state.scene_shader.set_conditional(SceneShaderGLES2::FOG_HEIGHT_ENABLED, false);
state.scene_shader.set_conditional(SceneShaderGLES2::USE_RADIANCE_MAP, false);
+ state.scene_shader.set_conditional(SceneShaderGLES2::USE_DEPTH_PREPASS, false);
}
void RasterizerSceneGLES2::_draw_sky(RasterizerStorageGLES2::Sky *p_sky, const CameraMatrix &p_projection, const Transform &p_transform, bool p_vflip, float p_custom_fov, float p_energy, const Basis &p_sky_orientation) {
diff --git a/drivers/gles2/shader_gles2.cpp b/drivers/gles2/shader_gles2.cpp
index 6856035470..ee96db99fe 100644
--- a/drivers/gles2/shader_gles2.cpp
+++ b/drivers/gles2/shader_gles2.cpp
@@ -973,6 +973,140 @@ void ShaderGLES2::use_material(void *p_material) {
ERR_PRINT("type missing, bug?");
} break;
}
+ } else { //zero
+
+ switch (E->get().type) {
+ case ShaderLanguage::TYPE_BOOL: {
+ glUniform1i(location, GL_FALSE);
+ } break;
+
+ case ShaderLanguage::TYPE_BVEC2: {
+ glUniform2i(location, GL_FALSE, GL_FALSE);
+ } break;
+
+ case ShaderLanguage::TYPE_BVEC3: {
+ glUniform3i(location, GL_FALSE, GL_FALSE, GL_FALSE);
+ } break;
+
+ case ShaderLanguage::TYPE_BVEC4: {
+ glUniform4i(location, GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
+ } break;
+
+ case ShaderLanguage::TYPE_INT: {
+ glUniform1i(location, 0);
+ } break;
+
+ case ShaderLanguage::TYPE_IVEC2: {
+ glUniform2i(location, 0, 0);
+ } break;
+
+ case ShaderLanguage::TYPE_IVEC3: {
+ glUniform3i(location, 0, 0, 0);
+ } break;
+
+ case ShaderLanguage::TYPE_IVEC4: {
+ glUniform4i(location, 0, 0, 0, 0);
+ } break;
+
+ case ShaderLanguage::TYPE_UINT: {
+ glUniform1i(location, 0);
+ } break;
+
+ case ShaderLanguage::TYPE_UVEC2: {
+ glUniform2i(location, 0, 0);
+ } break;
+
+ case ShaderLanguage::TYPE_UVEC3: {
+ glUniform3i(location, 0, 0, 0);
+ } break;
+
+ case ShaderLanguage::TYPE_UVEC4: {
+ glUniform4i(location, 0, 0, 0, 0);
+ } break;
+
+ case ShaderLanguage::TYPE_FLOAT: {
+ glUniform1f(location, 0);
+ } break;
+
+ case ShaderLanguage::TYPE_VEC2: {
+ glUniform2f(location, 0, 0);
+ } break;
+
+ case ShaderLanguage::TYPE_VEC3: {
+ glUniform3f(location, 0, 0, 0);
+ } break;
+
+ case ShaderLanguage::TYPE_VEC4: {
+ glUniform4f(location, 0, 0, 0, 0);
+ } break;
+
+ case ShaderLanguage::TYPE_MAT2: {
+ GLfloat mat[4]{ 0, 0, 0, 0 };
+
+ glUniformMatrix2fv(location, 1, GL_FALSE, mat);
+ } break;
+
+ case ShaderLanguage::TYPE_MAT3: {
+ GLfloat mat[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+
+ glUniformMatrix3fv(location, 1, GL_FALSE, mat);
+
+ } break;
+
+ case ShaderLanguage::TYPE_MAT4: {
+ GLfloat mat[16] = { 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0 };
+
+ glUniformMatrix4fv(location, 1, GL_FALSE, mat);
+
+ } break;
+
+ case ShaderLanguage::TYPE_SAMPLER2D: {
+
+ } break;
+
+ case ShaderLanguage::TYPE_ISAMPLER2D: {
+
+ } break;
+
+ case ShaderLanguage::TYPE_USAMPLER2D: {
+
+ } break;
+
+ case ShaderLanguage::TYPE_SAMPLERCUBE: {
+
+ } break;
+
+ case ShaderLanguage::TYPE_SAMPLER2DARRAY:
+ case ShaderLanguage::TYPE_ISAMPLER2DARRAY:
+ case ShaderLanguage::TYPE_USAMPLER2DARRAY:
+ case ShaderLanguage::TYPE_SAMPLER3D:
+ case ShaderLanguage::TYPE_ISAMPLER3D:
+ case ShaderLanguage::TYPE_USAMPLER3D: {
+ // Not implemented in GLES2
+ } break;
+
+ case ShaderLanguage::TYPE_VOID: {
+ // Nothing to do?
+ } break;
+ default: {
+ ERR_PRINT("type missing, bug?");
+ } break;
+ }
}
}
}