Fix GI probes not working in the ubershader
This commit is contained in:
parent
ea6ed9658d
commit
edb140839e
4 changed files with 12 additions and 5 deletions
|
@ -1855,7 +1855,10 @@ void RasterizerSceneGLES3::_setup_light(RenderList::Element *e, const Transform
|
|||
// Normally, lightmapping uses the same texturing units than the GI probes; however, in the case of the ubershader
|
||||
// that's not a good idea because some hardware/drivers (Android/Intel) may fail to render if a single texturing unit
|
||||
// is used through multiple kinds of samplers in the same shader.
|
||||
if (state.scene_shader.is_version_ubershader()) {
|
||||
// Moreover, since we don't know at this point if we are going to consume these textures from the ubershader or
|
||||
// a conditioned one, the fact that async compilation is enabled is enough for us to switch to the alternative
|
||||
// arrangement of texturing units.
|
||||
if (storage->config.async_compilation_enabled) {
|
||||
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 12);
|
||||
} else {
|
||||
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 10);
|
||||
|
@ -1871,7 +1874,7 @@ void RasterizerSceneGLES3::_setup_light(RenderList::Element *e, const Transform
|
|||
if (gi_probe_count > 1) {
|
||||
GIProbeInstance *gipi2 = gi_probe_instance_owner.getptr(ridp[1]);
|
||||
|
||||
if (state.scene_shader.is_version_ubershader()) {
|
||||
if (storage->config.async_compilation_enabled) {
|
||||
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 13);
|
||||
} else {
|
||||
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 11);
|
||||
|
|
|
@ -582,6 +582,11 @@ ShaderGLES3::Version *ShaderGLES3::get_current_version(bool &r_async_forbidden)
|
|||
strings_common.push_back("\n");
|
||||
}
|
||||
|
||||
if (is_async_compilation_supported() && get_ubershader_flags_uniform() != -1) {
|
||||
// Indicate that this shader may be used both as ubershader and conditioned during the session
|
||||
strings_common.push_back("#define UBERSHADER_COMPAT\n");
|
||||
}
|
||||
|
||||
LocalVector<CharString> flag_macros;
|
||||
bool build_ubershader = get_ubershader_flags_uniform() != -1 && (effective_version.version & VersionKey::UBERSHADER_FLAG);
|
||||
if (build_ubershader) {
|
||||
|
|
|
@ -400,7 +400,6 @@ public:
|
|||
bool is_custom_code_ready_for_render(uint32_t p_code_id);
|
||||
|
||||
uint32_t get_version() const { return new_conditional_version.version; }
|
||||
bool is_version_ubershader() const { return (new_conditional_version.version & VersionKey::UBERSHADER_FLAG); }
|
||||
_FORCE_INLINE_ bool is_version_valid() const { return version && version->compile_status == Version::COMPILE_STATUS_OK; }
|
||||
|
||||
virtual void init() = 0;
|
||||
|
|
|
@ -1649,7 +1649,7 @@ uniform mediump vec4[12] lightmap_captures;
|
|||
|
||||
#ifdef USE_GI_PROBES //ubershader-skip
|
||||
|
||||
#if !defined(IS_UBERSHADER)
|
||||
#if !defined(UBERSHADER_COMPAT)
|
||||
uniform mediump sampler3D gi_probe1; //texunit:-10
|
||||
#else
|
||||
uniform mediump sampler3D gi_probe1_uber; //texunit:-12
|
||||
|
@ -1663,7 +1663,7 @@ uniform highp float gi_probe_bias1;
|
|||
uniform highp float gi_probe_normal_bias1;
|
||||
uniform bool gi_probe_blend_ambient1;
|
||||
|
||||
#if !defined(IS_UBERSHADER)
|
||||
#if !defined(UBERSHADER_COMPAT)
|
||||
uniform mediump sampler3D gi_probe2; //texunit:-11
|
||||
#else
|
||||
uniform mediump sampler3D gi_probe2_uber; //texunit:-13
|
||||
|
|
Loading…
Reference in a new issue