-Fix prepass state not being reset, closes #26348

-Send zero values for shader if no default exists
This commit is contained in:
Juan Linietsky 2019-03-01 19:27:12 -03:00
parent 78fcbb80c5
commit 7bad1706c2
2 changed files with 135 additions and 0 deletions

View file

@ -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) {

View file

@ -966,6 +966,140 @@ void ShaderGLES2::use_material(void *p_material) {
// Not implemented in GLES2
} break;
case ShaderLanguage::TYPE_VOID: {
// Nothing to do?
} break;
default: {
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;