mirror of
https://github.com/Relintai/pandemonium_engine_minimal.git
synced 2024-12-21 16:56:50 +01:00
Removed the probe api.
This commit is contained in:
parent
38ed779965
commit
ef3511a544
@ -53,19 +53,7 @@ public:
|
||||
void light_instance_set_shadow_transform(RID p_light_instance, const Projection &p_projection, const Transform &p_transform, float p_far, float p_split, int p_pass, float p_bias_scale = 1.0) {}
|
||||
void light_instance_mark_visible(RID p_light_instance) {}
|
||||
|
||||
RID reflection_atlas_create() { return RID(); }
|
||||
void reflection_atlas_set_size(RID p_ref_atlas, int p_size) {}
|
||||
void reflection_atlas_set_subdivision(RID p_ref_atlas, int p_subdiv) {}
|
||||
|
||||
RID reflection_probe_instance_create(RID p_probe) { return RID(); }
|
||||
void reflection_probe_instance_set_transform(RID p_instance, const Transform &p_transform) {}
|
||||
void reflection_probe_release_atlas_index(RID p_instance) {}
|
||||
bool reflection_probe_instance_needs_redraw(RID p_instance) { return false; }
|
||||
bool reflection_probe_instance_has_reflection(RID p_instance) { return false; }
|
||||
bool reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) { return false; }
|
||||
bool reflection_probe_instance_postprocess_step(RID p_instance) { return true; }
|
||||
|
||||
void render_scene(const Transform &p_cam_transform, const Projection &p_cam_projection, const int p_eye, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, RID p_environment, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass) {}
|
||||
void render_scene(const Transform &p_cam_transform, const Projection &p_cam_projection, const int p_eye, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID p_environment, RID p_shadow_atlas) {}
|
||||
void render_shadow(RID p_light, RID p_shadow_atlas, int p_pass, InstanceBase **p_cull_result, int p_cull_count) {}
|
||||
|
||||
void set_scene_pass(uint64_t p_pass) {}
|
||||
@ -442,38 +430,6 @@ public:
|
||||
Color light_get_color(RID p_light) { return Color(); }
|
||||
uint64_t light_get_version(RID p_light) const { return 0; }
|
||||
|
||||
/* PROBE API */
|
||||
|
||||
RID reflection_probe_create() { return RID(); }
|
||||
|
||||
void reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) {}
|
||||
void reflection_probe_set_intensity(RID p_probe, float p_intensity) {}
|
||||
void reflection_probe_set_interior_ambient(RID p_probe, const Color &p_ambient) {}
|
||||
void reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy) {}
|
||||
void reflection_probe_set_interior_ambient_probe_contribution(RID p_probe, float p_contrib) {}
|
||||
void reflection_probe_set_max_distance(RID p_probe, float p_distance) {}
|
||||
void reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) {}
|
||||
void reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) {}
|
||||
void reflection_probe_set_as_interior(RID p_probe, bool p_enable) {}
|
||||
void reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) {}
|
||||
void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) {}
|
||||
void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) {}
|
||||
void reflection_probe_set_resolution(RID p_probe, int p_resolution) {}
|
||||
|
||||
AABB reflection_probe_get_aabb(RID p_probe) const { return AABB(); }
|
||||
RS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const { return RenderingServer::REFLECTION_PROBE_UPDATE_ONCE; }
|
||||
uint32_t reflection_probe_get_cull_mask(RID p_probe) const { return 0; }
|
||||
Vector3 reflection_probe_get_extents(RID p_probe) const { return Vector3(); }
|
||||
Vector3 reflection_probe_get_origin_offset(RID p_probe) const { return Vector3(); }
|
||||
float reflection_probe_get_origin_max_distance(RID p_probe) const { return 0.0; }
|
||||
bool reflection_probe_renders_shadows(RID p_probe) const { return false; }
|
||||
|
||||
void instance_add_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) {}
|
||||
void instance_remove_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) {}
|
||||
|
||||
void instance_add_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance) {}
|
||||
void instance_remove_dependency(RID p_base, RasterizerScene::InstanceBase *p_instance) {}
|
||||
|
||||
/* RENDER TARGET */
|
||||
|
||||
RID render_target_create() { return RID(); }
|
||||
|
@ -523,219 +523,6 @@ int RasterizerSceneGLES2::get_directional_light_shadow_size(RID p_light_intance)
|
||||
}
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
RID RasterizerSceneGLES2::reflection_atlas_create() {
|
||||
return RID();
|
||||
}
|
||||
|
||||
void RasterizerSceneGLES2::reflection_atlas_set_size(RID p_ref_atlas, int p_size) {
|
||||
}
|
||||
|
||||
void RasterizerSceneGLES2::reflection_atlas_set_subdivision(RID p_ref_atlas, int p_subdiv) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
RID RasterizerSceneGLES2::reflection_probe_instance_create(RID p_probe) {
|
||||
RasterizerStorageGLES2::ReflectionProbe *probe = storage->reflection_probe_owner.getornull(p_probe);
|
||||
ERR_FAIL_COND_V(!probe, RID());
|
||||
|
||||
ReflectionProbeInstance *rpi = memnew(ReflectionProbeInstance);
|
||||
|
||||
rpi->probe_ptr = probe;
|
||||
rpi->self = reflection_probe_instance_owner.make_rid(rpi);
|
||||
rpi->probe = p_probe;
|
||||
rpi->reflection_atlas_index = -1;
|
||||
rpi->render_step = -1;
|
||||
rpi->last_pass = 0;
|
||||
rpi->current_resolution = 0;
|
||||
rpi->dirty = true;
|
||||
|
||||
rpi->index = 0;
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
glGenFramebuffers(1, &rpi->fbo[i]);
|
||||
glGenTextures(1, &rpi->color[i]);
|
||||
}
|
||||
|
||||
glGenRenderbuffers(1, &rpi->depth);
|
||||
|
||||
rpi->cubemap = 0;
|
||||
//glGenTextures(1, &rpi->cubemap);
|
||||
|
||||
return rpi->self;
|
||||
}
|
||||
|
||||
void RasterizerSceneGLES2::reflection_probe_instance_set_transform(RID p_instance, const Transform &p_transform) {
|
||||
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
|
||||
ERR_FAIL_COND(!rpi);
|
||||
rpi->transform = p_transform;
|
||||
}
|
||||
|
||||
void RasterizerSceneGLES2::reflection_probe_release_atlas_index(RID p_instance) {
|
||||
}
|
||||
|
||||
bool RasterizerSceneGLES2::reflection_probe_instance_needs_redraw(RID p_instance) {
|
||||
const ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
|
||||
ERR_FAIL_COND_V(!rpi, false);
|
||||
|
||||
bool need_redraw = rpi->probe_ptr->resolution != rpi->current_resolution || rpi->dirty || rpi->probe_ptr->update_mode == RS::REFLECTION_PROBE_UPDATE_ALWAYS;
|
||||
rpi->dirty = false;
|
||||
return need_redraw;
|
||||
}
|
||||
|
||||
bool RasterizerSceneGLES2::reflection_probe_instance_has_reflection(RID p_instance) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RasterizerSceneGLES2::reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) {
|
||||
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
|
||||
ERR_FAIL_COND_V(!rpi, false);
|
||||
|
||||
rpi->render_step = 0;
|
||||
|
||||
if (rpi->probe_ptr->resolution != rpi->current_resolution) {
|
||||
//update cubemap if resolution changed
|
||||
int size = rpi->probe_ptr->resolution;
|
||||
|
||||
if (size > storage->config.max_viewport_dimensions[0] || size > storage->config.max_viewport_dimensions[1]) {
|
||||
WARN_PRINT_ONCE("Cannot set reflection probe resolution larger than maximum hardware supported size of (" + itos(storage->config.max_viewport_dimensions[0]) + ", " + itos(storage->config.max_viewport_dimensions[1]) + "). Setting size to maximum.");
|
||||
size = MIN(size, storage->config.max_viewport_dimensions[0]);
|
||||
size = MIN(size, storage->config.max_viewport_dimensions[1]);
|
||||
}
|
||||
|
||||
rpi->current_resolution = size;
|
||||
|
||||
GLenum internal_format = GL_RGB;
|
||||
GLenum format = GL_RGB;
|
||||
GLenum type = GL_UNSIGNED_BYTE;
|
||||
|
||||
WRAPPED_GL_ACTIVE_TEXTURE(GL_TEXTURE0);
|
||||
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, rpi->depth);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, storage->config.depth_buffer_internalformat, size, size);
|
||||
|
||||
if (rpi->cubemap != 0) {
|
||||
glDeleteTextures(1, &rpi->cubemap);
|
||||
}
|
||||
|
||||
glGenTextures(1, &rpi->cubemap);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, rpi->cubemap);
|
||||
|
||||
// Mobile hardware (PowerVR specially) prefers this approach,
|
||||
// the previous approach with manual lod levels kills the game.
|
||||
for (int i = 0; i < 6; i++) {
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, internal_format, size, size, 0, format, type, nullptr);
|
||||
}
|
||||
|
||||
glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
|
||||
|
||||
// Generate framebuffers for rendering
|
||||
for (int i = 0; i < 6; i++) {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, rpi->fbo[i]);
|
||||
glBindTexture(GL_TEXTURE_2D, rpi->color[i]);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, internal_format, size, size, 0, format, type, nullptr);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rpi->color[i], 0);
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rpi->depth);
|
||||
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
ERR_CONTINUE(status != GL_FRAMEBUFFER_COMPLETE);
|
||||
}
|
||||
|
||||
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES2::system_fbo);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RasterizerSceneGLES2::reflection_probe_instance_postprocess_step(RID p_instance) {
|
||||
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_instance);
|
||||
ERR_FAIL_COND_V(!rpi, false);
|
||||
ERR_FAIL_COND_V(rpi->current_resolution == 0, false);
|
||||
|
||||
int size = rpi->probe_ptr->resolution;
|
||||
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
for (int i = 0; i < RS::ARRAY_MAX - 1; i++) {
|
||||
glDisableVertexAttribArray(i);
|
||||
}
|
||||
}
|
||||
|
||||
WRAPPED_GL_ACTIVE_TEXTURE(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, rpi->cubemap);
|
||||
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); //use linear, no mipmaps so it does not read from what is being written to
|
||||
|
||||
//first of all, copy rendered textures to cubemap
|
||||
for (int i = 0; i < 6; i++) {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, rpi->fbo[i]);
|
||||
glViewport(0, 0, size, size);
|
||||
glCopyTexSubImage2D(_cube_side_enum[i], 0, 0, 0, 0, 0, size, size);
|
||||
}
|
||||
//do filtering
|
||||
//vdc cache
|
||||
WRAPPED_GL_ACTIVE_TEXTURE(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, storage->resources.radical_inverse_vdc_cache_tex);
|
||||
|
||||
// now render to the framebuffer, mipmap level for mipmap level
|
||||
int lod = 1;
|
||||
|
||||
size >>= 1;
|
||||
int mipmaps = 6;
|
||||
|
||||
storage->shaders.cubemap_filter.set_conditional(CubemapFilterShaderGLES2::USE_SOURCE_PANORAMA, false);
|
||||
storage->shaders.cubemap_filter.bind();
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, storage->resources.mipmap_blur_fbo);
|
||||
|
||||
//blur
|
||||
while (size >= 1) {
|
||||
WRAPPED_GL_ACTIVE_TEXTURE(GL_TEXTURE3);
|
||||
glBindTexture(GL_TEXTURE_2D, storage->resources.mipmap_blur_color);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, size, size, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, storage->resources.mipmap_blur_color, 0);
|
||||
glViewport(0, 0, size, size);
|
||||
WRAPPED_GL_ACTIVE_TEXTURE(GL_TEXTURE0);
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
storage->bind_quad_array();
|
||||
storage->shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES2::FACE_ID, i);
|
||||
float roughness = CLAMP(lod / (float)(mipmaps - 1), 0, 1);
|
||||
storage->shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES2::ROUGHNESS, roughness);
|
||||
storage->shaders.cubemap_filter.set_uniform(CubemapFilterShaderGLES2::Z_FLIP, false);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
glCopyTexSubImage2D(_cube_side_enum[i], lod, 0, 0, 0, 0, size, size);
|
||||
}
|
||||
|
||||
size >>= 1;
|
||||
|
||||
lod++;
|
||||
}
|
||||
|
||||
// restore ranges
|
||||
WRAPPED_GL_ACTIVE_TEXTURE(GL_TEXTURE0);
|
||||
glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
WRAPPED_GL_ACTIVE_TEXTURE(GL_TEXTURE3); //back to panorama
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
WRAPPED_GL_ACTIVE_TEXTURE(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, RasterizerStorageGLES2::system_fbo);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
RID RasterizerSceneGLES2::light_instance_create(RID p_light) {
|
||||
LightInstance *light_instance = memnew(LightInstance);
|
||||
|
||||
@ -947,32 +734,6 @@ void RasterizerSceneGLES2::_add_geometry_with_material(RasterizerStorageGLES2::G
|
||||
eo->use_accum_ptr = &eo->use_accum;
|
||||
}
|
||||
|
||||
int rpsize = e->instance->reflection_probe_instances.size();
|
||||
if (rpsize > 0) {
|
||||
bool first = true;
|
||||
rpsize = MIN(rpsize, 2); //more than 2 per object are not supported, this keeps it stable
|
||||
|
||||
for (int i = 0; i < rpsize; i++) {
|
||||
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(e->instance->reflection_probe_instances[i]);
|
||||
if (rpi->last_pass != render_pass) {
|
||||
continue;
|
||||
}
|
||||
if (first) {
|
||||
e->refprobe_0_index = rpi->index;
|
||||
first = false;
|
||||
} else {
|
||||
e->refprobe_1_index = rpi->index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* if (e->refprobe_0_index > e->refprobe_1_index) { //if both are valid, swap them to keep order as best as possible
|
||||
uint64_t tmp = e->refprobe_0_index;
|
||||
e->refprobe_0_index = e->refprobe_1_index;
|
||||
e->refprobe_1_index = tmp;
|
||||
}*/
|
||||
}
|
||||
|
||||
//add directional lights
|
||||
|
||||
if (p_material->shader->spatial.unshaded) {
|
||||
@ -1751,48 +1512,6 @@ void RasterizerSceneGLES2::_setup_light(LightInstance *light, ShadowAtlas *shado
|
||||
}
|
||||
}
|
||||
|
||||
void RasterizerSceneGLES2::_setup_refprobes(ReflectionProbeInstance *p_refprobe1, ReflectionProbeInstance *p_refprobe2, const Transform &p_view_transform) {
|
||||
if (p_refprobe1) {
|
||||
state.scene_shader.set_uniform(SceneShaderGLES2::REFPROBE1_USE_BOX_PROJECT, p_refprobe1->probe_ptr->box_projection);
|
||||
state.scene_shader.set_uniform(SceneShaderGLES2::REFPROBE1_BOX_EXTENTS, p_refprobe1->probe_ptr->extents);
|
||||
state.scene_shader.set_uniform(SceneShaderGLES2::REFPROBE1_BOX_OFFSET, p_refprobe1->probe_ptr->origin_offset);
|
||||
state.scene_shader.set_uniform(SceneShaderGLES2::REFPROBE1_EXTERIOR, !p_refprobe1->probe_ptr->interior);
|
||||
state.scene_shader.set_uniform(SceneShaderGLES2::REFPROBE1_INTENSITY, p_refprobe1->probe_ptr->intensity);
|
||||
|
||||
Color ambient;
|
||||
if (p_refprobe1->probe_ptr->interior) {
|
||||
ambient = p_refprobe1->probe_ptr->interior_ambient * p_refprobe1->probe_ptr->interior_ambient_energy;
|
||||
ambient.a = p_refprobe1->probe_ptr->interior_ambient_probe_contrib;
|
||||
}
|
||||
|
||||
state.scene_shader.set_uniform(SceneShaderGLES2::REFPROBE1_AMBIENT, ambient);
|
||||
|
||||
Transform proj = (p_view_transform.inverse() * p_refprobe1->transform).affine_inverse();
|
||||
|
||||
state.scene_shader.set_uniform(SceneShaderGLES2::REFPROBE1_LOCAL_MATRIX, proj);
|
||||
}
|
||||
|
||||
if (p_refprobe2) {
|
||||
state.scene_shader.set_uniform(SceneShaderGLES2::REFPROBE2_USE_BOX_PROJECT, p_refprobe2->probe_ptr->box_projection);
|
||||
state.scene_shader.set_uniform(SceneShaderGLES2::REFPROBE2_BOX_EXTENTS, p_refprobe2->probe_ptr->extents);
|
||||
state.scene_shader.set_uniform(SceneShaderGLES2::REFPROBE2_BOX_OFFSET, p_refprobe2->probe_ptr->origin_offset);
|
||||
state.scene_shader.set_uniform(SceneShaderGLES2::REFPROBE2_EXTERIOR, !p_refprobe2->probe_ptr->interior);
|
||||
state.scene_shader.set_uniform(SceneShaderGLES2::REFPROBE2_INTENSITY, p_refprobe2->probe_ptr->intensity);
|
||||
|
||||
Color ambient;
|
||||
if (p_refprobe2->probe_ptr->interior) {
|
||||
ambient = p_refprobe2->probe_ptr->interior_ambient * p_refprobe2->probe_ptr->interior_ambient_energy;
|
||||
ambient.a = p_refprobe2->probe_ptr->interior_ambient_probe_contrib;
|
||||
}
|
||||
|
||||
state.scene_shader.set_uniform(SceneShaderGLES2::REFPROBE2_AMBIENT, ambient);
|
||||
|
||||
Transform proj = (p_view_transform.inverse() * p_refprobe2->transform).affine_inverse();
|
||||
|
||||
state.scene_shader.set_uniform(SceneShaderGLES2::REFPROBE2_LOCAL_MATRIX, proj);
|
||||
}
|
||||
}
|
||||
|
||||
void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, int p_element_count, const Transform &p_view_transform, const Projection &p_projection, const int p_eye, RID p_shadow_atlas, float p_shadow_bias, float p_shadow_normal_bias, bool p_reverse_cull, bool p_alpha_pass, bool p_shadow) {
|
||||
ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas);
|
||||
|
||||
@ -1818,8 +1537,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
|
||||
bool prev_base_pass = false;
|
||||
LightInstance *prev_light = nullptr;
|
||||
bool prev_vertex_lit = false;
|
||||
ReflectionProbeInstance *prev_refprobe_1 = nullptr;
|
||||
ReflectionProbeInstance *prev_refprobe_2 = nullptr;
|
||||
|
||||
int prev_blend_mode = -2; //will always catch the first go
|
||||
|
||||
@ -1847,8 +1564,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
|
||||
bool accum_pass = *e->use_accum_ptr;
|
||||
*e->use_accum_ptr = true; //set to accum for next time this is found
|
||||
LightInstance *light = nullptr;
|
||||
ReflectionProbeInstance *refprobe_1 = nullptr;
|
||||
ReflectionProbeInstance *refprobe_2 = nullptr;
|
||||
bool rebind_light = false;
|
||||
|
||||
if (!p_shadow && material->shader) {
|
||||
@ -1949,29 +1664,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
|
||||
prev_vertex_lit = vertex_lit;
|
||||
rebind = true;
|
||||
}
|
||||
|
||||
if (!unshaded && !accum_pass && e->refprobe_0_index != RenderList::MAX_REFLECTION_PROBES) {
|
||||
ERR_FAIL_INDEX(e->refprobe_0_index, reflection_probe_count);
|
||||
refprobe_1 = reflection_probe_instances[e->refprobe_0_index];
|
||||
}
|
||||
if (!unshaded && !accum_pass && e->refprobe_1_index != RenderList::MAX_REFLECTION_PROBES) {
|
||||
ERR_FAIL_INDEX(e->refprobe_1_index, reflection_probe_count);
|
||||
refprobe_2 = reflection_probe_instances[e->refprobe_1_index];
|
||||
}
|
||||
|
||||
if (refprobe_1 != prev_refprobe_1 || refprobe_2 != prev_refprobe_2) {
|
||||
state.scene_shader.set_conditional(SceneShaderGLES2::USE_REFLECTION_PROBE1, refprobe_1 != nullptr);
|
||||
state.scene_shader.set_conditional(SceneShaderGLES2::USE_REFLECTION_PROBE2, refprobe_2 != nullptr);
|
||||
if (refprobe_1 != nullptr && refprobe_1 != prev_refprobe_1) {
|
||||
WRAPPED_GL_ACTIVE_TEXTURE(GL_TEXTURE0 + storage->config.max_texture_image_units - 5);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, refprobe_1->cubemap);
|
||||
}
|
||||
if (refprobe_2 != nullptr && refprobe_2 != prev_refprobe_2) {
|
||||
WRAPPED_GL_ACTIVE_TEXTURE(GL_TEXTURE0 + storage->config.max_texture_image_units - 6);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, refprobe_2->cubemap);
|
||||
}
|
||||
rebind = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool depth_prepass = false;
|
||||
@ -2073,8 +1765,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements,
|
||||
prev_instancing = instancing;
|
||||
prev_octahedral_compression = octahedral_compression;
|
||||
prev_light = light;
|
||||
prev_refprobe_1 = refprobe_1;
|
||||
prev_refprobe_2 = refprobe_2;
|
||||
}
|
||||
|
||||
_setup_light_type(nullptr, nullptr); //clear light stuff
|
||||
@ -2193,7 +1883,7 @@ void RasterizerSceneGLES2::_post_process(const Projection &p_cam_projection) {
|
||||
state.tonemap_shader.set_conditional(TonemapShaderGLES2::DISABLE_ALPHA, false);
|
||||
}
|
||||
|
||||
void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const Projection &p_cam_projection, const int p_eye, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, RID p_environment, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass) {
|
||||
void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const Projection &p_cam_projection, const int p_eye, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID p_shadow_atlas) {
|
||||
Transform cam_transform = p_cam_transform;
|
||||
|
||||
storage->info.render.object_count += p_cull_count;
|
||||
@ -2211,37 +1901,23 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
|
||||
reverse_cull = true;
|
||||
}
|
||||
|
||||
if (p_reflection_probe.is_valid()) {
|
||||
ReflectionProbeInstance *probe = reflection_probe_instance_owner.getornull(p_reflection_probe);
|
||||
ERR_FAIL_COND(!probe);
|
||||
state.render_no_shadows = !probe->probe_ptr->enable_shadows;
|
||||
|
||||
current_fb = probe->fbo[p_reflection_probe_pass];
|
||||
|
||||
viewport_width = probe->probe_ptr->resolution;
|
||||
viewport_height = probe->probe_ptr->resolution;
|
||||
|
||||
probe_interior = probe->probe_ptr->interior;
|
||||
|
||||
state.render_no_shadows = false;
|
||||
if (storage->frame.current_rt->multisample_active) {
|
||||
current_fb = storage->frame.current_rt->multisample_fbo;
|
||||
} else if (storage->frame.current_rt->external.fbo != 0) {
|
||||
current_fb = storage->frame.current_rt->external.fbo;
|
||||
} else {
|
||||
state.render_no_shadows = false;
|
||||
if (storage->frame.current_rt->multisample_active) {
|
||||
current_fb = storage->frame.current_rt->multisample_fbo;
|
||||
} else if (storage->frame.current_rt->external.fbo != 0) {
|
||||
current_fb = storage->frame.current_rt->external.fbo;
|
||||
} else {
|
||||
current_fb = storage->frame.current_rt->fbo;
|
||||
}
|
||||
current_fb = storage->frame.current_rt->fbo;
|
||||
}
|
||||
|
||||
viewport_width = storage->frame.current_rt->width;
|
||||
viewport_height = storage->frame.current_rt->height;
|
||||
viewport_x = storage->frame.current_rt->x;
|
||||
viewport_width = storage->frame.current_rt->width;
|
||||
viewport_height = storage->frame.current_rt->height;
|
||||
viewport_x = storage->frame.current_rt->x;
|
||||
|
||||
if (storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_DIRECT_TO_SCREEN]) {
|
||||
viewport_y = OS::get_singleton()->get_window_size().height - viewport_height - storage->frame.current_rt->y;
|
||||
} else {
|
||||
viewport_y = storage->frame.current_rt->y;
|
||||
}
|
||||
if (storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_DIRECT_TO_SCREEN]) {
|
||||
viewport_y = OS::get_singleton()->get_window_size().height - viewport_height - storage->frame.current_rt->y;
|
||||
} else {
|
||||
viewport_y = storage->frame.current_rt->y;
|
||||
}
|
||||
|
||||
state.used_screen_texture = false;
|
||||
@ -2282,22 +1958,6 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
|
||||
render_light_instance_count = 0;
|
||||
}
|
||||
|
||||
if (p_reflection_probe_cull_count) {
|
||||
reflection_probe_instances = (ReflectionProbeInstance **)alloca(sizeof(ReflectionProbeInstance *) * p_reflection_probe_cull_count);
|
||||
reflection_probe_count = p_reflection_probe_cull_count;
|
||||
for (int i = 0; i < p_reflection_probe_cull_count; i++) {
|
||||
ReflectionProbeInstance *rpi = reflection_probe_instance_owner.getornull(p_reflection_probe_cull_result[i]);
|
||||
ERR_CONTINUE(!rpi);
|
||||
rpi->last_pass = render_pass + 1; //will be incremented later
|
||||
rpi->index = i;
|
||||
reflection_probe_instances[i] = rpi;
|
||||
}
|
||||
|
||||
} else {
|
||||
reflection_probe_instances = nullptr;
|
||||
reflection_probe_count = 0;
|
||||
}
|
||||
|
||||
// render list stuff
|
||||
|
||||
render_list.clear();
|
||||
@ -2405,11 +2065,6 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
|
||||
|
||||
_render_render_list(&render_list.elements[render_list.max_elements - render_list.alpha_element_count], render_list.alpha_element_count, cam_transform, p_cam_projection, p_eye, p_shadow_atlas, 0.0, 0.0, reverse_cull, true, false);
|
||||
|
||||
if (p_reflection_probe.is_valid()) {
|
||||
// Rendering to a probe so no need for post_processing
|
||||
return;
|
||||
}
|
||||
|
||||
//post process
|
||||
_post_process(p_cam_projection);
|
||||
|
||||
@ -2762,23 +2417,6 @@ bool RasterizerSceneGLES2::free(RID p_rid) {
|
||||
shadow_atlas_owner.free(p_rid);
|
||||
memdelete(shadow_atlas);
|
||||
|
||||
} else if (reflection_probe_instance_owner.owns(p_rid)) {
|
||||
ReflectionProbeInstance *reflection_instance = reflection_probe_instance_owner.get(p_rid);
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
glDeleteFramebuffers(1, &reflection_instance->fbo[i]);
|
||||
glDeleteTextures(1, &reflection_instance->color[i]);
|
||||
}
|
||||
|
||||
if (reflection_instance->cubemap != 0) {
|
||||
glDeleteTextures(1, &reflection_instance->cubemap);
|
||||
}
|
||||
glDeleteRenderbuffers(1, &reflection_instance->depth);
|
||||
|
||||
reflection_probe_release_atlas_index(p_rid);
|
||||
reflection_probe_instance_owner.free(p_rid);
|
||||
memdelete(reflection_instance);
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -202,7 +202,6 @@ public:
|
||||
int spot_light_count;
|
||||
int omni_light_count;
|
||||
int directional_light_count;
|
||||
int reflection_probe_count;
|
||||
|
||||
bool used_sss;
|
||||
bool using_contact_shadows;
|
||||
@ -302,54 +301,6 @@ public:
|
||||
virtual int get_directional_light_shadow_size(RID p_light_intance);
|
||||
virtual void set_directional_shadow_count(int p_count);
|
||||
|
||||
/* REFLECTION PROBE ATLAS API */
|
||||
|
||||
virtual RID reflection_atlas_create();
|
||||
virtual void reflection_atlas_set_size(RID p_ref_atlas, int p_size);
|
||||
virtual void reflection_atlas_set_subdivision(RID p_ref_atlas, int p_subdiv);
|
||||
|
||||
/* REFLECTION CUBEMAPS */
|
||||
|
||||
/* REFLECTION PROBE INSTANCE */
|
||||
|
||||
struct ReflectionProbeInstance : public RID_Data {
|
||||
RasterizerStorageGLES2::ReflectionProbe *probe_ptr;
|
||||
RID probe;
|
||||
RID self;
|
||||
RID atlas;
|
||||
|
||||
int reflection_atlas_index;
|
||||
|
||||
int render_step;
|
||||
int reflection_index;
|
||||
|
||||
GLuint fbo[6];
|
||||
GLuint color[6];
|
||||
GLuint depth;
|
||||
GLuint cubemap;
|
||||
|
||||
int current_resolution;
|
||||
mutable bool dirty;
|
||||
|
||||
uint64_t last_pass;
|
||||
uint32_t index;
|
||||
|
||||
Transform transform;
|
||||
};
|
||||
|
||||
mutable RID_Owner<ReflectionProbeInstance> reflection_probe_instance_owner;
|
||||
|
||||
ReflectionProbeInstance **reflection_probe_instances;
|
||||
int reflection_probe_count;
|
||||
|
||||
virtual RID reflection_probe_instance_create(RID p_probe);
|
||||
virtual void reflection_probe_instance_set_transform(RID p_instance, const Transform &p_transform);
|
||||
virtual void reflection_probe_release_atlas_index(RID p_instance);
|
||||
virtual bool reflection_probe_instance_needs_redraw(RID p_instance);
|
||||
virtual bool reflection_probe_instance_has_reflection(RID p_instance);
|
||||
virtual bool reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas);
|
||||
virtual bool reflection_probe_instance_postprocess_step(RID p_instance);
|
||||
|
||||
/* LIGHT INSTANCE */
|
||||
|
||||
struct LightInstance : public RID_Data {
|
||||
@ -595,12 +546,11 @@ public:
|
||||
_FORCE_INLINE_ void _setup_geometry(RenderList::Element *p_element);
|
||||
_FORCE_INLINE_ void _setup_light_type(LightInstance *p_light, ShadowAtlas *shadow_atlas);
|
||||
_FORCE_INLINE_ void _setup_light(LightInstance *p_light, ShadowAtlas *shadow_atlas, const Transform &p_view_transform, bool accum_pass);
|
||||
_FORCE_INLINE_ void _setup_refprobes(ReflectionProbeInstance *p_refprobe1, ReflectionProbeInstance *p_refprobe2, const Transform &p_view_transform);
|
||||
_FORCE_INLINE_ void _render_geometry(RenderList::Element *p_element);
|
||||
|
||||
void _post_process(const Projection &p_cam_projection);
|
||||
|
||||
virtual void render_scene(const Transform &p_cam_transform, const Projection &p_cam_projection, const int p_eye, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, RID p_environment, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass);
|
||||
virtual void render_scene(const Transform &p_cam_transform, const Projection &p_cam_projection, const int p_eye, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID p_shadow_atlas);
|
||||
virtual void render_shadow(RID p_light, RID p_shadow_atlas, int p_pass, InstanceBase **p_cull_result, int p_cull_count);
|
||||
virtual bool free(RID p_rid);
|
||||
|
||||
|
@ -3794,180 +3794,6 @@ AABB RasterizerStorageGLES2::light_get_aabb(RID p_light) const {
|
||||
ERR_FAIL_V(AABB());
|
||||
}
|
||||
|
||||
/* PROBE API */
|
||||
|
||||
RID RasterizerStorageGLES2::reflection_probe_create() {
|
||||
ReflectionProbe *reflection_probe = memnew(ReflectionProbe);
|
||||
|
||||
reflection_probe->intensity = 1.0;
|
||||
reflection_probe->interior_ambient = Color();
|
||||
reflection_probe->interior_ambient_energy = 1.0;
|
||||
reflection_probe->interior_ambient_probe_contrib = 0.0;
|
||||
reflection_probe->max_distance = 0;
|
||||
reflection_probe->extents = Vector3(1, 1, 1);
|
||||
reflection_probe->origin_offset = Vector3(0, 0, 0);
|
||||
reflection_probe->interior = false;
|
||||
reflection_probe->box_projection = false;
|
||||
reflection_probe->enable_shadows = false;
|
||||
reflection_probe->cull_mask = (1 << 20) - 1;
|
||||
reflection_probe->update_mode = RS::REFLECTION_PROBE_UPDATE_ONCE;
|
||||
reflection_probe->resolution = 128;
|
||||
|
||||
return reflection_probe_owner.make_rid(reflection_probe);
|
||||
}
|
||||
|
||||
void RasterizerStorageGLES2::reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
|
||||
reflection_probe->update_mode = p_mode;
|
||||
reflection_probe->instance_change_notify(true, false);
|
||||
}
|
||||
|
||||
void RasterizerStorageGLES2::reflection_probe_set_intensity(RID p_probe, float p_intensity) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
|
||||
reflection_probe->intensity = p_intensity;
|
||||
}
|
||||
|
||||
void RasterizerStorageGLES2::reflection_probe_set_interior_ambient(RID p_probe, const Color &p_ambient) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
|
||||
reflection_probe->interior_ambient = p_ambient;
|
||||
}
|
||||
|
||||
void RasterizerStorageGLES2::reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
|
||||
reflection_probe->interior_ambient_energy = p_energy;
|
||||
}
|
||||
|
||||
void RasterizerStorageGLES2::reflection_probe_set_interior_ambient_probe_contribution(RID p_probe, float p_contrib) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
|
||||
reflection_probe->interior_ambient_probe_contrib = p_contrib;
|
||||
}
|
||||
|
||||
void RasterizerStorageGLES2::reflection_probe_set_max_distance(RID p_probe, float p_distance) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
|
||||
reflection_probe->max_distance = p_distance;
|
||||
reflection_probe->instance_change_notify(true, false);
|
||||
}
|
||||
void RasterizerStorageGLES2::reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
|
||||
reflection_probe->extents = p_extents;
|
||||
reflection_probe->instance_change_notify(true, false);
|
||||
}
|
||||
void RasterizerStorageGLES2::reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
|
||||
reflection_probe->origin_offset = p_offset;
|
||||
reflection_probe->instance_change_notify(true, false);
|
||||
}
|
||||
|
||||
void RasterizerStorageGLES2::reflection_probe_set_as_interior(RID p_probe, bool p_enable) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
|
||||
reflection_probe->interior = p_enable;
|
||||
reflection_probe->instance_change_notify(true, false);
|
||||
}
|
||||
void RasterizerStorageGLES2::reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
|
||||
reflection_probe->box_projection = p_enable;
|
||||
}
|
||||
|
||||
void RasterizerStorageGLES2::reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
|
||||
reflection_probe->enable_shadows = p_enable;
|
||||
reflection_probe->instance_change_notify(true, false);
|
||||
}
|
||||
void RasterizerStorageGLES2::reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
|
||||
reflection_probe->cull_mask = p_layers;
|
||||
reflection_probe->instance_change_notify(true, false);
|
||||
}
|
||||
|
||||
void RasterizerStorageGLES2::reflection_probe_set_resolution(RID p_probe, int p_resolution) {
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
|
||||
ERR_FAIL_COND(!reflection_probe);
|
||||
|
||||
reflection_probe->resolution = p_resolution;
|
||||
}
|
||||
|
||||
AABB RasterizerStorageGLES2::reflection_probe_get_aabb(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, AABB());
|
||||
|
||||
AABB aabb;
|
||||
aabb.position = -reflection_probe->extents;
|
||||
aabb.size = reflection_probe->extents * 2.0;
|
||||
|
||||
return aabb;
|
||||
}
|
||||
RS::ReflectionProbeUpdateMode RasterizerStorageGLES2::reflection_probe_get_update_mode(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, RS::REFLECTION_PROBE_UPDATE_ALWAYS);
|
||||
|
||||
return reflection_probe->update_mode;
|
||||
}
|
||||
|
||||
uint32_t RasterizerStorageGLES2::reflection_probe_get_cull_mask(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, 0);
|
||||
|
||||
return reflection_probe->cull_mask;
|
||||
}
|
||||
|
||||
Vector3 RasterizerStorageGLES2::reflection_probe_get_extents(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, Vector3());
|
||||
|
||||
return reflection_probe->extents;
|
||||
}
|
||||
Vector3 RasterizerStorageGLES2::reflection_probe_get_origin_offset(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, Vector3());
|
||||
|
||||
return reflection_probe->origin_offset;
|
||||
}
|
||||
|
||||
bool RasterizerStorageGLES2::reflection_probe_renders_shadows(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, false);
|
||||
|
||||
return reflection_probe->enable_shadows;
|
||||
}
|
||||
|
||||
float RasterizerStorageGLES2::reflection_probe_get_origin_max_distance(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, 0);
|
||||
|
||||
return reflection_probe->max_distance;
|
||||
}
|
||||
|
||||
int RasterizerStorageGLES2::reflection_probe_get_resolution(RID p_probe) const {
|
||||
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
|
||||
ERR_FAIL_COND_V(!reflection_probe, 0);
|
||||
|
||||
return reflection_probe->resolution;
|
||||
}
|
||||
|
||||
////////
|
||||
|
||||
void RasterizerStorageGLES2::instance_add_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) {
|
||||
@ -3987,10 +3813,6 @@ void RasterizerStorageGLES2::instance_add_dependency(RID p_base, RasterizerScene
|
||||
inst = multimesh_owner.getornull(p_base);
|
||||
ERR_FAIL_COND(!inst);
|
||||
} break;
|
||||
case RS::INSTANCE_REFLECTION_PROBE: {
|
||||
inst = reflection_probe_owner.getornull(p_base);
|
||||
ERR_FAIL_COND(!inst);
|
||||
} break;
|
||||
case RS::INSTANCE_LIGHT: {
|
||||
inst = light_owner.getornull(p_base);
|
||||
ERR_FAIL_COND(!inst);
|
||||
@ -4015,10 +3837,6 @@ void RasterizerStorageGLES2::instance_remove_dependency(RID p_base, RasterizerSc
|
||||
inst = multimesh_owner.getornull(p_base);
|
||||
ERR_FAIL_COND(!inst);
|
||||
} break;
|
||||
case RS::INSTANCE_REFLECTION_PROBE: {
|
||||
inst = reflection_probe_owner.getornull(p_base);
|
||||
ERR_FAIL_COND(!inst);
|
||||
} break;
|
||||
case RS::INSTANCE_LIGHT: {
|
||||
inst = light_owner.getornull(p_base);
|
||||
ERR_FAIL_COND(!inst);
|
||||
@ -4925,8 +4743,6 @@ RS::InstanceType RasterizerStorageGLES2::get_base_type(RID p_rid) const {
|
||||
return RS::INSTANCE_LIGHT;
|
||||
} else if (multimesh_owner.owns(p_rid)) {
|
||||
return RS::INSTANCE_MULTIMESH;
|
||||
} else if (reflection_probe_owner.owns(p_rid)) {
|
||||
return RS::INSTANCE_REFLECTION_PROBE;
|
||||
} else {
|
||||
return RS::INSTANCE_NONE;
|
||||
}
|
||||
@ -5071,15 +4887,6 @@ bool RasterizerStorageGLES2::free(RID p_rid) {
|
||||
light_owner.free(p_rid);
|
||||
memdelete(light);
|
||||
|
||||
return true;
|
||||
} else if (reflection_probe_owner.owns(p_rid)) {
|
||||
// delete the texture
|
||||
ReflectionProbe *reflection_probe = reflection_probe_owner.get(p_rid);
|
||||
reflection_probe->instance_remove_deps();
|
||||
|
||||
reflection_probe_owner.free(p_rid);
|
||||
memdelete(reflection_probe);
|
||||
|
||||
return true;
|
||||
} else if (canvas_occluder_owner.owns(p_rid)) {
|
||||
CanvasOccluder *co = canvas_occluder_owner.get(p_rid);
|
||||
|
@ -881,53 +881,6 @@ public:
|
||||
virtual AABB light_get_aabb(RID p_light) const;
|
||||
virtual uint64_t light_get_version(RID p_light) const;
|
||||
|
||||
/* PROBE API */
|
||||
|
||||
struct ReflectionProbe : Instantiable {
|
||||
RS::ReflectionProbeUpdateMode update_mode;
|
||||
float intensity;
|
||||
Color interior_ambient;
|
||||
float interior_ambient_energy;
|
||||
float interior_ambient_probe_contrib;
|
||||
float max_distance;
|
||||
Vector3 extents;
|
||||
Vector3 origin_offset;
|
||||
bool interior;
|
||||
bool box_projection;
|
||||
bool enable_shadows;
|
||||
uint32_t cull_mask;
|
||||
int resolution;
|
||||
};
|
||||
|
||||
mutable RID_Owner<ReflectionProbe> reflection_probe_owner;
|
||||
|
||||
virtual RID reflection_probe_create();
|
||||
|
||||
virtual void reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode);
|
||||
virtual void reflection_probe_set_intensity(RID p_probe, float p_intensity);
|
||||
virtual void reflection_probe_set_interior_ambient(RID p_probe, const Color &p_ambient);
|
||||
virtual void reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy);
|
||||
virtual void reflection_probe_set_interior_ambient_probe_contribution(RID p_probe, float p_contrib);
|
||||
virtual void reflection_probe_set_max_distance(RID p_probe, float p_distance);
|
||||
virtual void reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents);
|
||||
virtual void reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset);
|
||||
virtual void reflection_probe_set_as_interior(RID p_probe, bool p_enable);
|
||||
virtual void reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable);
|
||||
virtual void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable);
|
||||
virtual void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers);
|
||||
virtual void reflection_probe_set_resolution(RID p_probe, int p_resolution);
|
||||
|
||||
virtual AABB reflection_probe_get_aabb(RID p_probe) const;
|
||||
virtual RS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const;
|
||||
virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const;
|
||||
|
||||
virtual int reflection_probe_get_resolution(RID p_probe) const;
|
||||
|
||||
virtual Vector3 reflection_probe_get_extents(RID p_probe) const;
|
||||
virtual Vector3 reflection_probe_get_origin_offset(RID p_probe) const;
|
||||
virtual float reflection_probe_get_origin_max_distance(RID p_probe) const;
|
||||
virtual bool reflection_probe_renders_shadows(RID p_probe) const;
|
||||
|
||||
/* INSTANCE */
|
||||
|
||||
virtual void instance_add_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance);
|
||||
|
@ -73,7 +73,6 @@ public:
|
||||
|
||||
Vector<RID> materials;
|
||||
Vector<RID> light_instances;
|
||||
Vector<RID> reflection_probe_instances;
|
||||
|
||||
PoolVector<float> blend_values;
|
||||
|
||||
@ -125,19 +124,7 @@ public:
|
||||
virtual void light_instance_mark_visible(RID p_light_instance) = 0;
|
||||
virtual bool light_instances_can_render_shadow_cube() const { return true; }
|
||||
|
||||
virtual RID reflection_atlas_create() = 0;
|
||||
virtual void reflection_atlas_set_size(RID p_ref_atlas, int p_size) = 0;
|
||||
virtual void reflection_atlas_set_subdivision(RID p_ref_atlas, int p_subdiv) = 0;
|
||||
|
||||
virtual RID reflection_probe_instance_create(RID p_probe) = 0;
|
||||
virtual void reflection_probe_instance_set_transform(RID p_instance, const Transform &p_transform) = 0;
|
||||
virtual void reflection_probe_release_atlas_index(RID p_instance) = 0;
|
||||
virtual bool reflection_probe_instance_needs_redraw(RID p_instance) = 0;
|
||||
virtual bool reflection_probe_instance_has_reflection(RID p_instance) = 0;
|
||||
virtual bool reflection_probe_instance_begin_render(RID p_instance, RID p_reflection_atlas) = 0;
|
||||
virtual bool reflection_probe_instance_postprocess_step(RID p_instance) = 0;
|
||||
|
||||
virtual void render_scene(const Transform &p_cam_transform, const Projection &p_cam_projection, const int p_eye, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID *p_reflection_probe_cull_result, int p_reflection_probe_cull_count, RID p_environment, RID p_shadow_atlas, RID p_reflection_atlas, RID p_reflection_probe, int p_reflection_probe_pass) = 0;
|
||||
virtual void render_scene(const Transform &p_cam_transform, const Projection &p_cam_projection, const int p_eye, bool p_cam_ortogonal, InstanceBase **p_cull_result, int p_cull_count, RID *p_light_cull_result, int p_light_cull_count, RID p_shadow_atlas) = 0;
|
||||
virtual void render_shadow(RID p_light, RID p_shadow_atlas, int p_pass, InstanceBase **p_cull_result, int p_cull_count) = 0;
|
||||
|
||||
virtual void set_scene_pass(uint64_t p_pass) = 0;
|
||||
@ -402,32 +389,6 @@ public:
|
||||
virtual Color light_get_color(RID p_light) = 0;
|
||||
virtual uint64_t light_get_version(RID p_light) const = 0;
|
||||
|
||||
/* PROBE API */
|
||||
|
||||
virtual RID reflection_probe_create() = 0;
|
||||
|
||||
virtual void reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) = 0;
|
||||
virtual void reflection_probe_set_resolution(RID p_probe, int p_resolution) = 0;
|
||||
virtual void reflection_probe_set_intensity(RID p_probe, float p_intensity) = 0;
|
||||
virtual void reflection_probe_set_interior_ambient(RID p_probe, const Color &p_ambient) = 0;
|
||||
virtual void reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy) = 0;
|
||||
virtual void reflection_probe_set_interior_ambient_probe_contribution(RID p_probe, float p_contrib) = 0;
|
||||
virtual void reflection_probe_set_max_distance(RID p_probe, float p_distance) = 0;
|
||||
virtual void reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) = 0;
|
||||
virtual void reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) = 0;
|
||||
virtual void reflection_probe_set_as_interior(RID p_probe, bool p_enable) = 0;
|
||||
virtual void reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) = 0;
|
||||
virtual void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) = 0;
|
||||
virtual void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) = 0;
|
||||
|
||||
virtual AABB reflection_probe_get_aabb(RID p_probe) const = 0;
|
||||
virtual RS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const = 0;
|
||||
virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const = 0;
|
||||
virtual Vector3 reflection_probe_get_extents(RID p_probe) const = 0;
|
||||
virtual Vector3 reflection_probe_get_origin_offset(RID p_probe) const = 0;
|
||||
virtual float reflection_probe_get_origin_max_distance(RID p_probe) const = 0;
|
||||
virtual bool reflection_probe_renders_shadows(RID p_probe) const = 0;
|
||||
|
||||
virtual void instance_add_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) = 0;
|
||||
virtual void instance_remove_skeleton(RID p_skeleton, RasterizerScene::InstanceBase *p_instance) = 0;
|
||||
|
||||
|
@ -305,24 +305,6 @@ public:
|
||||
BIND2(light_directional_set_blend_splits, RID, bool)
|
||||
BIND2(light_directional_set_shadow_depth_range_mode, RID, LightDirectionalShadowDepthRangeMode)
|
||||
|
||||
/* PROBE API */
|
||||
|
||||
BIND0R(RID, reflection_probe_create)
|
||||
|
||||
BIND2(reflection_probe_set_update_mode, RID, ReflectionProbeUpdateMode)
|
||||
BIND2(reflection_probe_set_intensity, RID, float)
|
||||
BIND2(reflection_probe_set_interior_ambient, RID, const Color &)
|
||||
BIND2(reflection_probe_set_interior_ambient_energy, RID, float)
|
||||
BIND2(reflection_probe_set_interior_ambient_probe_contribution, RID, float)
|
||||
BIND2(reflection_probe_set_max_distance, RID, float)
|
||||
BIND2(reflection_probe_set_extents, RID, const Vector3 &)
|
||||
BIND2(reflection_probe_set_origin_offset, RID, const Vector3 &)
|
||||
BIND2(reflection_probe_set_as_interior, RID, bool)
|
||||
BIND2(reflection_probe_set_enable_box_projection, RID, bool)
|
||||
BIND2(reflection_probe_set_enable_shadows, RID, bool)
|
||||
BIND2(reflection_probe_set_cull_mask, RID, uint32_t)
|
||||
BIND2(reflection_probe_set_resolution, RID, int)
|
||||
|
||||
#undef BINDBASE
|
||||
//from now on, calls forwarded to this singleton
|
||||
#define BINDBASE RSG::scene
|
||||
|
@ -319,19 +319,6 @@ void *RenderingServerScene::_instance_pair(void *p_self, SpatialPartitionID, Ins
|
||||
}
|
||||
geom->lighting_dirty = true;
|
||||
|
||||
return E; //this element should make freeing faster
|
||||
} else if (B->base_type == RS::INSTANCE_REFLECTION_PROBE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
|
||||
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(B->base_data);
|
||||
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
|
||||
|
||||
InstanceReflectionProbeData::PairInfo pinfo;
|
||||
pinfo.geometry = A;
|
||||
pinfo.L = geom->reflection_probes.push_back(B);
|
||||
|
||||
List<InstanceReflectionProbeData::PairInfo>::Element *E = reflection_probe->geometries.push_back(pinfo);
|
||||
|
||||
geom->reflection_dirty = true;
|
||||
|
||||
return E; //this element should make freeing faster
|
||||
}
|
||||
|
||||
@ -362,16 +349,6 @@ void RenderingServerScene::_instance_unpair(void *p_self, SpatialPartitionID, In
|
||||
}
|
||||
geom->lighting_dirty = true;
|
||||
|
||||
} else if (B->base_type == RS::INSTANCE_REFLECTION_PROBE && ((1 << A->base_type) & RS::INSTANCE_GEOMETRY_MASK)) {
|
||||
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(B->base_data);
|
||||
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(A->base_data);
|
||||
|
||||
List<InstanceReflectionProbeData::PairInfo>::Element *E = reinterpret_cast<List<InstanceReflectionProbeData::PairInfo>::Element *>(udata);
|
||||
|
||||
geom->reflection_probes.erase(E->get().L);
|
||||
reflection_probe->geometries.erase(E);
|
||||
|
||||
geom->reflection_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -385,13 +362,12 @@ RID RenderingServerScene::scenario_create() {
|
||||
scenario->sps->set_pair_callback(_instance_pair, this);
|
||||
scenario->sps->set_unpair_callback(_instance_unpair, this);
|
||||
|
||||
scenario->reflection_probe_shadow_atlas = RSG::scene_render->shadow_atlas_create();
|
||||
RSG::scene_render->shadow_atlas_set_size(scenario->reflection_probe_shadow_atlas, 1024); //make enough shadows for close distance, don't bother with rest
|
||||
RSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 0, 4);
|
||||
RSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 1, 4);
|
||||
RSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 2, 4);
|
||||
RSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->reflection_probe_shadow_atlas, 3, 8);
|
||||
scenario->reflection_atlas = RSG::scene_render->reflection_atlas_create();
|
||||
scenario->shadow_atlas = RSG::scene_render->shadow_atlas_create();
|
||||
RSG::scene_render->shadow_atlas_set_size(scenario->shadow_atlas, 1024); //make enough shadows for close distance, don't bother with rest
|
||||
RSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->shadow_atlas, 0, 4);
|
||||
RSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->shadow_atlas, 1, 4);
|
||||
RSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->shadow_atlas, 2, 4);
|
||||
RSG::scene_render->shadow_atlas_set_quadrant_subdivision(scenario->shadow_atlas, 3, 8);
|
||||
|
||||
return scenario_rid;
|
||||
}
|
||||
@ -434,10 +410,6 @@ void RenderingServerScene::scenario_set_fallback_environment(RID p_scenario, RID
|
||||
}
|
||||
|
||||
void RenderingServerScene::scenario_set_reflection_atlas_size(RID p_scenario, int p_size, int p_subdiv) {
|
||||
Scenario *scenario = scenario_owner.get(p_scenario);
|
||||
ERR_FAIL_COND(!scenario);
|
||||
RSG::scene_render->reflection_atlas_set_size(scenario->reflection_atlas, p_size);
|
||||
RSG::scene_render->reflection_atlas_set_subdivision(scenario->reflection_atlas, p_subdiv);
|
||||
}
|
||||
|
||||
/* INSTANCING API */
|
||||
@ -493,13 +465,6 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
|
||||
}
|
||||
RSG::scene_render->free(light->instance);
|
||||
} break;
|
||||
case RS::INSTANCE_REFLECTION_PROBE: {
|
||||
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(instance->base_data);
|
||||
RSG::scene_render->free(reflection_probe->instance);
|
||||
if (reflection_probe->update_list.in_list()) {
|
||||
reflection_probe_render_list.remove(&reflection_probe->update_list);
|
||||
}
|
||||
} break;
|
||||
default: {
|
||||
}
|
||||
}
|
||||
@ -546,13 +511,6 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) {
|
||||
instance->blend_values.resize(RSG::storage->mesh_get_blend_shape_count(p_base));
|
||||
}
|
||||
} break;
|
||||
case RS::INSTANCE_REFLECTION_PROBE: {
|
||||
InstanceReflectionProbeData *reflection_probe = memnew(InstanceReflectionProbeData);
|
||||
reflection_probe->owner = instance;
|
||||
instance->base_data = reflection_probe;
|
||||
|
||||
reflection_probe->instance = RSG::scene_render->reflection_probe_instance_create(p_base);
|
||||
} break;
|
||||
|
||||
default: {
|
||||
}
|
||||
@ -591,10 +549,6 @@ void RenderingServerScene::instance_set_scenario(RID p_instance, RID p_scenario)
|
||||
light->D = nullptr;
|
||||
}
|
||||
} break;
|
||||
case RS::INSTANCE_REFLECTION_PROBE: {
|
||||
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(instance->base_data);
|
||||
RSG::scene_render->reflection_probe_release_atlas_index(reflection_probe->instance);
|
||||
} break;
|
||||
default: {
|
||||
}
|
||||
}
|
||||
@ -1021,12 +975,6 @@ void RenderingServerScene::instance_set_visible(RID p_instance, bool p_visible)
|
||||
instance->scenario->sps->set_pairable(instance, p_visible, 1 << RS::INSTANCE_LIGHT, p_visible ? RS::INSTANCE_GEOMETRY_MASK : 0);
|
||||
}
|
||||
|
||||
} break;
|
||||
case RS::INSTANCE_REFLECTION_PROBE: {
|
||||
if (instance->spatial_partition_id && instance->scenario) {
|
||||
instance->scenario->sps->set_pairable(instance, p_visible, 1 << RS::INSTANCE_REFLECTION_PROBE, p_visible ? RS::INSTANCE_GEOMETRY_MASK : 0);
|
||||
}
|
||||
|
||||
} break;
|
||||
default: {
|
||||
// if we haven't called set_pairable, we STILL need to do a collision check
|
||||
@ -1247,13 +1195,6 @@ void RenderingServerScene::_update_instance(Instance *p_instance) {
|
||||
light->shadow_dirty = true;
|
||||
}
|
||||
|
||||
if (p_instance->base_type == RS::INSTANCE_REFLECTION_PROBE) {
|
||||
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(p_instance->base_data);
|
||||
|
||||
RSG::scene_render->reflection_probe_instance_set_transform(reflection_probe->instance, *instance_xform);
|
||||
reflection_probe->reflection_dirty = true;
|
||||
}
|
||||
|
||||
if (p_instance->aabb.has_no_surface()) {
|
||||
return;
|
||||
}
|
||||
@ -1287,7 +1228,7 @@ void RenderingServerScene::_update_instance(Instance *p_instance) {
|
||||
uint32_t pairable_mask = 0;
|
||||
bool pairable = false;
|
||||
|
||||
if (p_instance->base_type == RS::INSTANCE_LIGHT || p_instance->base_type == RS::INSTANCE_REFLECTION_PROBE) {
|
||||
if (p_instance->base_type == RS::INSTANCE_LIGHT) {
|
||||
pairable_mask = p_instance->visible ? RS::INSTANCE_GEOMETRY_MASK : 0;
|
||||
pairable = true;
|
||||
}
|
||||
@ -1335,10 +1276,6 @@ void RenderingServerScene::_update_instance_aabb(Instance *p_instance) {
|
||||
case RenderingServer::INSTANCE_LIGHT: {
|
||||
new_aabb = RSG::storage->light_get_aabb(p_instance->base);
|
||||
|
||||
} break;
|
||||
case RenderingServer::INSTANCE_REFLECTION_PROBE: {
|
||||
new_aabb = RSG::storage->reflection_probe_get_aabb(p_instance->base);
|
||||
|
||||
} break;
|
||||
default: {
|
||||
}
|
||||
@ -1889,7 +1826,7 @@ void RenderingServerScene::render_camera(RID p_camera, RID p_scenario, Size2 p_v
|
||||
Transform camera_transform = _interpolation_data.interpolation_enabled ? camera->get_transform_interpolated() : camera->transform;
|
||||
|
||||
_prepare_scene(camera_transform, camera_matrix, ortho, camera->env, camera->visible_layers, p_scenario, p_shadow_atlas, RID(), camera->previous_room_id_hint);
|
||||
_render_scene(camera_transform, camera_matrix, 0, ortho, camera->env, p_scenario, p_shadow_atlas, RID(), -1);
|
||||
_render_scene(camera_transform, camera_matrix, 0, ortho, camera->env, p_scenario, p_shadow_atlas);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1916,8 +1853,6 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
|
||||
instance_cull_count = 0;
|
||||
light_cull_count = 0;
|
||||
|
||||
reflection_probe_cull_count = 0;
|
||||
|
||||
//light_samplers_culled=0;
|
||||
|
||||
/*
|
||||
@ -1954,33 +1889,6 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
|
||||
light_cull_count++;
|
||||
}
|
||||
}
|
||||
} else if (ins->base_type == RS::INSTANCE_REFLECTION_PROBE && ins->visible) {
|
||||
if (reflection_probe_cull_count < MAX_REFLECTION_PROBES_CULLED) {
|
||||
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(ins->base_data);
|
||||
|
||||
if (p_reflection_probe != reflection_probe->instance) {
|
||||
//avoid entering The Matrix
|
||||
|
||||
if (!reflection_probe->geometries.empty()) {
|
||||
//do not add this light if no geometry is affected by it..
|
||||
|
||||
if (reflection_probe->reflection_dirty || RSG::scene_render->reflection_probe_instance_needs_redraw(reflection_probe->instance)) {
|
||||
if (!reflection_probe->update_list.in_list()) {
|
||||
reflection_probe->render_step = 0;
|
||||
reflection_probe_render_list.add_last(&reflection_probe->update_list);
|
||||
}
|
||||
|
||||
reflection_probe->reflection_dirty = false;
|
||||
}
|
||||
|
||||
if (RSG::scene_render->reflection_probe_instance_has_reflection(reflection_probe->instance)) {
|
||||
reflection_probe_instance_cull_result[reflection_probe_cull_count] = reflection_probe->instance;
|
||||
reflection_probe_cull_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (((1 << ins->base_type) & RS::INSTANCE_GEOMETRY_MASK) && ins->visible && ins->cast_shadows != RS::SHADOW_CASTING_SETTING_SHADOWS_ONLY) {
|
||||
keep = true;
|
||||
|
||||
@ -2004,19 +1912,6 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
|
||||
geom->lighting_dirty = false;
|
||||
}
|
||||
|
||||
if (geom->reflection_dirty) {
|
||||
int l = 0;
|
||||
//only called when reflection probe AABB enter/exit this geometry
|
||||
ins->reflection_probe_instances.resize(geom->reflection_probes.size());
|
||||
|
||||
for (List<Instance *>::Element *E = geom->reflection_probes.front(); E; E = E->next()) {
|
||||
InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(E->get()->base_data);
|
||||
|
||||
ins->reflection_probe_instances.write[l++] = reflection_probe->instance;
|
||||
}
|
||||
|
||||
geom->reflection_dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!keep) {
|
||||
@ -2185,7 +2080,7 @@ void RenderingServerScene::_prepare_scene(const Transform p_cam_transform, const
|
||||
}
|
||||
}
|
||||
|
||||
void RenderingServerScene::_render_scene(const Transform p_cam_transform, const Projection &p_cam_projection, const int p_eye, bool p_cam_orthogonal, RID p_force_environment, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass) {
|
||||
void RenderingServerScene::_render_scene(const Transform p_cam_transform, const Projection &p_cam_projection, const int p_eye, bool p_cam_orthogonal, RID p_force_environment, RID p_scenario, RID p_shadow_atlas) {
|
||||
Scenario *scenario = scenario_owner.getornull(p_scenario);
|
||||
|
||||
/* ENVIRONMENT */
|
||||
@ -2201,7 +2096,7 @@ void RenderingServerScene::_render_scene(const Transform p_cam_transform, const
|
||||
|
||||
/* PROCESS GEOMETRY AND DRAW SCENE */
|
||||
|
||||
RSG::scene_render->render_scene(p_cam_transform, p_cam_projection, p_eye, p_cam_orthogonal, (RasterizerScene::InstanceBase **)instance_cull_result, instance_cull_count, light_instance_cull_result, light_cull_count + directional_light_count, reflection_probe_instance_cull_result, reflection_probe_cull_count, environment, p_shadow_atlas, scenario->reflection_atlas, p_reflection_probe, p_reflection_probe_pass);
|
||||
RSG::scene_render->render_scene(p_cam_transform, p_cam_projection, p_eye, p_cam_orthogonal, (RasterizerScene::InstanceBase **)instance_cull_result, instance_cull_count, light_instance_cull_result, light_cull_count + directional_light_count, p_shadow_atlas);
|
||||
}
|
||||
|
||||
void RenderingServerScene::render_empty_scene(RID p_scenario, RID p_shadow_atlas) {
|
||||
@ -2215,7 +2110,7 @@ void RenderingServerScene::render_empty_scene(RID p_scenario, RID p_shadow_atlas
|
||||
} else {
|
||||
environment = scenario->fallback_environment;
|
||||
}
|
||||
RSG::scene_render->render_scene(Transform(), Projection(), 0, true, nullptr, 0, nullptr, 0, nullptr, 0, environment, p_shadow_atlas, scenario->reflection_atlas, RID(), 0);
|
||||
RSG::scene_render->render_scene(Transform(), Projection(), 0, true, nullptr, 0, nullptr, 0, p_shadow_atlas);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -2251,8 +2146,7 @@ bool RenderingServerScene::free(RID p_rid) {
|
||||
while (scenario->instances.first()) {
|
||||
instance_set_scenario(scenario->instances.first()->self()->self, RID());
|
||||
}
|
||||
RSG::scene_render->free(scenario->reflection_probe_shadow_atlas);
|
||||
RSG::scene_render->free(scenario->reflection_atlas);
|
||||
RSG::scene_render->free(scenario->shadow_atlas);
|
||||
scenario_owner.free(p_rid);
|
||||
memdelete(scenario);
|
||||
|
||||
|
@ -273,8 +273,7 @@ public:
|
||||
List<Instance *> directional_lights;
|
||||
RID environment;
|
||||
RID fallback_environment;
|
||||
RID reflection_probe_shadow_atlas;
|
||||
RID reflection_atlas;
|
||||
RID shadow_atlas;
|
||||
|
||||
SelfList<Instance>::List instances;
|
||||
|
||||
@ -420,12 +419,8 @@ public:
|
||||
bool can_cast_shadows;
|
||||
bool material_is_animated;
|
||||
|
||||
List<Instance *> reflection_probes;
|
||||
bool reflection_dirty;
|
||||
|
||||
InstanceGeometryData() {
|
||||
lighting_dirty = true;
|
||||
reflection_dirty = true;
|
||||
can_cast_shadows = true;
|
||||
material_is_animated = true;
|
||||
}
|
||||
@ -441,7 +436,6 @@ public:
|
||||
List<PairInfo> geometries;
|
||||
|
||||
RID instance;
|
||||
bool reflection_dirty;
|
||||
SelfList<InstanceReflectionProbeData> update_list;
|
||||
|
||||
int render_step;
|
||||
@ -449,14 +443,11 @@ public:
|
||||
|
||||
InstanceReflectionProbeData() :
|
||||
update_list(this) {
|
||||
reflection_dirty = true;
|
||||
render_step = -1;
|
||||
previous_room_id_hint = -1;
|
||||
}
|
||||
};
|
||||
|
||||
SelfList<InstanceReflectionProbeData>::List reflection_probe_render_list;
|
||||
|
||||
struct InstanceLightData : public InstanceBaseData {
|
||||
struct PairInfo {
|
||||
List<Instance *>::Element *L; //light iterator in geometry
|
||||
@ -488,8 +479,6 @@ public:
|
||||
RID light_instance_cull_result[MAX_LIGHTS_CULLED];
|
||||
int light_cull_count;
|
||||
int directional_light_count;
|
||||
RID reflection_probe_instance_cull_result[MAX_REFLECTION_PROBES_CULLED];
|
||||
int reflection_probe_cull_count;
|
||||
|
||||
RID_Owner<Instance> instance_owner;
|
||||
|
||||
@ -540,7 +529,7 @@ public:
|
||||
_FORCE_INLINE_ bool _light_instance_update_shadow(Instance *p_instance, const Transform p_cam_transform, const Projection &p_cam_projection, bool p_cam_orthogonal, RID p_shadow_atlas, Scenario *p_scenario, uint32_t p_visible_layers = 0xFFFFFF);
|
||||
|
||||
void _prepare_scene(const Transform p_cam_transform, const Projection &p_cam_projection, bool p_cam_orthogonal, RID p_force_environment, uint32_t p_visible_layers, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, int32_t &r_previous_room_id_hint);
|
||||
void _render_scene(const Transform p_cam_transform, const Projection &p_cam_projection, const int p_eye, bool p_cam_orthogonal, RID p_force_environment, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass);
|
||||
void _render_scene(const Transform p_cam_transform, const Projection &p_cam_projection, const int p_eye, bool p_cam_orthogonal, RID p_force_environment, RID p_scenario, RID p_shadow_atlas);
|
||||
void render_empty_scene(RID p_scenario, RID p_shadow_atlas);
|
||||
|
||||
void render_camera(RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas);
|
||||
|
@ -148,7 +148,6 @@ void RenderingServerWrapMT::finish() {
|
||||
directional_light_free_cached_ids();
|
||||
omni_light_free_cached_ids();
|
||||
spot_light_free_cached_ids();
|
||||
reflection_probe_free_cached_ids();
|
||||
camera_free_cached_ids();
|
||||
viewport_free_cached_ids();
|
||||
scenario_free_cached_ids();
|
||||
|
@ -231,24 +231,6 @@ public:
|
||||
FUNC2(light_directional_set_blend_splits, RID, bool)
|
||||
FUNC2(light_directional_set_shadow_depth_range_mode, RID, LightDirectionalShadowDepthRangeMode)
|
||||
|
||||
/* PROBE API */
|
||||
|
||||
FUNCRID(reflection_probe)
|
||||
|
||||
FUNC2(reflection_probe_set_update_mode, RID, ReflectionProbeUpdateMode)
|
||||
FUNC2(reflection_probe_set_intensity, RID, float)
|
||||
FUNC2(reflection_probe_set_interior_ambient, RID, const Color &)
|
||||
FUNC2(reflection_probe_set_interior_ambient_energy, RID, float)
|
||||
FUNC2(reflection_probe_set_interior_ambient_probe_contribution, RID, float)
|
||||
FUNC2(reflection_probe_set_max_distance, RID, float)
|
||||
FUNC2(reflection_probe_set_extents, RID, const Vector3 &)
|
||||
FUNC2(reflection_probe_set_origin_offset, RID, const Vector3 &)
|
||||
FUNC2(reflection_probe_set_as_interior, RID, bool)
|
||||
FUNC2(reflection_probe_set_enable_box_projection, RID, bool)
|
||||
FUNC2(reflection_probe_set_enable_shadows, RID, bool)
|
||||
FUNC2(reflection_probe_set_cull_mask, RID, uint32_t)
|
||||
FUNC2(reflection_probe_set_resolution, RID, int)
|
||||
|
||||
/* CAMERA API */
|
||||
|
||||
FUNCRID(camera)
|
||||
|
@ -1941,20 +1941,6 @@ void RenderingServer::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("light_directional_set_blend_splits", "light", "enable"), &RenderingServer::light_directional_set_blend_splits);
|
||||
ClassDB::bind_method(D_METHOD("light_directional_set_shadow_depth_range_mode", "light", "range_mode"), &RenderingServer::light_directional_set_shadow_depth_range_mode);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("reflection_probe_create"), &RenderingServer::reflection_probe_create);
|
||||
ClassDB::bind_method(D_METHOD("reflection_probe_set_update_mode", "probe", "mode"), &RenderingServer::reflection_probe_set_update_mode);
|
||||
ClassDB::bind_method(D_METHOD("reflection_probe_set_intensity", "probe", "intensity"), &RenderingServer::reflection_probe_set_intensity);
|
||||
ClassDB::bind_method(D_METHOD("reflection_probe_set_interior_ambient", "probe", "color"), &RenderingServer::reflection_probe_set_interior_ambient);
|
||||
ClassDB::bind_method(D_METHOD("reflection_probe_set_interior_ambient_energy", "probe", "energy"), &RenderingServer::reflection_probe_set_interior_ambient_energy);
|
||||
ClassDB::bind_method(D_METHOD("reflection_probe_set_interior_ambient_probe_contribution", "probe", "contrib"), &RenderingServer::reflection_probe_set_interior_ambient_probe_contribution);
|
||||
ClassDB::bind_method(D_METHOD("reflection_probe_set_max_distance", "probe", "distance"), &RenderingServer::reflection_probe_set_max_distance);
|
||||
ClassDB::bind_method(D_METHOD("reflection_probe_set_extents", "probe", "extents"), &RenderingServer::reflection_probe_set_extents);
|
||||
ClassDB::bind_method(D_METHOD("reflection_probe_set_origin_offset", "probe", "offset"), &RenderingServer::reflection_probe_set_origin_offset);
|
||||
ClassDB::bind_method(D_METHOD("reflection_probe_set_as_interior", "probe", "enable"), &RenderingServer::reflection_probe_set_as_interior);
|
||||
ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_box_projection", "probe", "enable"), &RenderingServer::reflection_probe_set_enable_box_projection);
|
||||
ClassDB::bind_method(D_METHOD("reflection_probe_set_enable_shadows", "probe", "enable"), &RenderingServer::reflection_probe_set_enable_shadows);
|
||||
ClassDB::bind_method(D_METHOD("reflection_probe_set_cull_mask", "probe", "layers"), &RenderingServer::reflection_probe_set_cull_mask);
|
||||
|
||||
#endif
|
||||
|
||||
ClassDB::bind_method(D_METHOD("camera_create"), &RenderingServer::camera_create);
|
||||
@ -2313,7 +2299,6 @@ void RenderingServer::_bind_methods() {
|
||||
BIND_ENUM_CONSTANT(INSTANCE_MESH);
|
||||
BIND_ENUM_CONSTANT(INSTANCE_MULTIMESH);
|
||||
BIND_ENUM_CONSTANT(INSTANCE_LIGHT);
|
||||
BIND_ENUM_CONSTANT(INSTANCE_REFLECTION_PROBE);
|
||||
BIND_ENUM_CONSTANT(INSTANCE_MAX);
|
||||
BIND_ENUM_CONSTANT(INSTANCE_GEOMETRY_MASK);
|
||||
|
||||
@ -2373,9 +2358,6 @@ void RenderingServer::_bind_methods() {
|
||||
BIND_ENUM_CONSTANT(MULTIMESH_INTERP_QUALITY_FAST);
|
||||
BIND_ENUM_CONSTANT(MULTIMESH_INTERP_QUALITY_HIGH);
|
||||
|
||||
BIND_ENUM_CONSTANT(REFLECTION_PROBE_UPDATE_ONCE);
|
||||
BIND_ENUM_CONSTANT(REFLECTION_PROBE_UPDATE_ALWAYS);
|
||||
|
||||
BIND_ENUM_CONSTANT(CHANGED_PRIORITY_ANY);
|
||||
BIND_ENUM_CONSTANT(CHANGED_PRIORITY_LOW);
|
||||
BIND_ENUM_CONSTANT(CHANGED_PRIORITY_HIGH);
|
||||
|
@ -464,29 +464,6 @@ public:
|
||||
|
||||
virtual void light_directional_set_shadow_depth_range_mode(RID p_light, LightDirectionalShadowDepthRangeMode p_range_mode) = 0;
|
||||
|
||||
/* PROBE API */
|
||||
|
||||
virtual RID reflection_probe_create() = 0;
|
||||
|
||||
enum ReflectionProbeUpdateMode {
|
||||
REFLECTION_PROBE_UPDATE_ONCE,
|
||||
REFLECTION_PROBE_UPDATE_ALWAYS,
|
||||
};
|
||||
|
||||
virtual void reflection_probe_set_update_mode(RID p_probe, ReflectionProbeUpdateMode p_mode) = 0;
|
||||
virtual void reflection_probe_set_intensity(RID p_probe, float p_intensity) = 0;
|
||||
virtual void reflection_probe_set_interior_ambient(RID p_probe, const Color &p_color) = 0;
|
||||
virtual void reflection_probe_set_interior_ambient_energy(RID p_probe, float p_energy) = 0;
|
||||
virtual void reflection_probe_set_interior_ambient_probe_contribution(RID p_probe, float p_contrib) = 0;
|
||||
virtual void reflection_probe_set_max_distance(RID p_probe, float p_distance) = 0;
|
||||
virtual void reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) = 0;
|
||||
virtual void reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) = 0;
|
||||
virtual void reflection_probe_set_as_interior(RID p_probe, bool p_enable) = 0;
|
||||
virtual void reflection_probe_set_enable_box_projection(RID p_probe, bool p_enable) = 0;
|
||||
virtual void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) = 0;
|
||||
virtual void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) = 0;
|
||||
virtual void reflection_probe_set_resolution(RID p_probe, int p_resolution) = 0;
|
||||
|
||||
/* CAMERA API */
|
||||
|
||||
virtual RID camera_create() = 0;
|
||||
@ -640,7 +617,6 @@ public:
|
||||
INSTANCE_MESH,
|
||||
INSTANCE_MULTIMESH,
|
||||
INSTANCE_LIGHT,
|
||||
INSTANCE_REFLECTION_PROBE,
|
||||
INSTANCE_MAX,
|
||||
|
||||
INSTANCE_GEOMETRY_MASK = (1 << INSTANCE_MESH) | (1 << INSTANCE_MULTIMESH)
|
||||
@ -971,7 +947,6 @@ VARIANT_ENUM_CAST(RenderingServer::LightOmniShadowMode);
|
||||
VARIANT_ENUM_CAST(RenderingServer::LightOmniShadowDetail);
|
||||
VARIANT_ENUM_CAST(RenderingServer::LightDirectionalShadowMode);
|
||||
VARIANT_ENUM_CAST(RenderingServer::LightDirectionalShadowDepthRangeMode);
|
||||
VARIANT_ENUM_CAST(RenderingServer::ReflectionProbeUpdateMode);
|
||||
VARIANT_ENUM_CAST(RenderingServer::InstanceFlags);
|
||||
VARIANT_ENUM_CAST(RenderingServer::ShadowCastingSetting);
|
||||
VARIANT_ENUM_CAST(RenderingServer::TextureType);
|
||||
|
Loading…
Reference in New Issue
Block a user