Sort decals and lights based on camera origin
Also implement sort_offset for decals Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
This commit is contained in:
parent
360b61084a
commit
49bebf2bfb
15 changed files with 56 additions and 35 deletions
|
|
@ -1584,6 +1584,7 @@ void RasterizerSceneGLES3::_setup_lights(const RenderDataGLES3 *p_render_data, b
|
|||
LightData &light_data = (i < r_omni_light_count) ? scene_state.omni_lights[index] : scene_state.spot_lights[index];
|
||||
RS::LightType type = (i < r_omni_light_count) ? RS::LIGHT_OMNI : RS::LIGHT_SPOT;
|
||||
GLES3::LightInstance *li = (i < r_omni_light_count) ? scene_state.omni_light_sort[index].instance : scene_state.spot_light_sort[index].instance;
|
||||
real_t distance = (i < r_omni_light_count) ? scene_state.omni_light_sort[index].depth : scene_state.spot_light_sort[index].depth;
|
||||
RID base = li->light;
|
||||
|
||||
Transform3D light_transform = li->transform;
|
||||
|
|
@ -1612,13 +1613,11 @@ void RasterizerSceneGLES3::_setup_lights(const RenderDataGLES3 *p_render_data, b
|
|||
// Reuse fade begin, fade length and distance for shadow LOD determination later.
|
||||
float fade_begin = 0.0;
|
||||
float fade_length = 0.0;
|
||||
real_t distance = 0.0;
|
||||
|
||||
float fade = 1.0;
|
||||
if (light_storage->light_is_distance_fade_enabled(li->light)) {
|
||||
fade_begin = light_storage->light_get_distance_fade_begin(li->light);
|
||||
fade_length = light_storage->light_get_distance_fade_length(li->light);
|
||||
distance = p_render_data->cam_transform.origin.distance_to(li->transform.origin);
|
||||
|
||||
if (distance > fade_begin) {
|
||||
// Use `smoothstep()` to make opacity changes more gradual and less noticeable to the player.
|
||||
|
|
|
|||
|
|
@ -1534,18 +1534,6 @@ AABB TextureStorage::decal_get_aabb(RID p_decal) const {
|
|||
return AABB();
|
||||
}
|
||||
|
||||
/* DECAL INSTANCE API */
|
||||
|
||||
RID TextureStorage::decal_instance_create(RID p_decal) {
|
||||
return RID();
|
||||
}
|
||||
|
||||
void TextureStorage::decal_instance_free(RID p_decal_instance) {
|
||||
}
|
||||
|
||||
void TextureStorage::decal_instance_set_transform(RID p_decal, const Transform3D &p_transform) {
|
||||
}
|
||||
|
||||
/* RENDER TARGET API */
|
||||
|
||||
GLuint TextureStorage::system_fbo = 0;
|
||||
|
|
|
|||
|
|
@ -561,9 +561,10 @@ public:
|
|||
|
||||
/* DECAL INSTANCE */
|
||||
|
||||
virtual RID decal_instance_create(RID p_decal) override;
|
||||
virtual void decal_instance_free(RID p_decal_instance) override;
|
||||
virtual void decal_instance_set_transform(RID p_decal, const Transform3D &p_transform) override;
|
||||
virtual RID decal_instance_create(RID p_decal) override { return RID(); }
|
||||
virtual void decal_instance_free(RID p_decal_instance) override {}
|
||||
virtual void decal_instance_set_transform(RID p_decal, const Transform3D &p_transform) override {}
|
||||
virtual void decal_instance_set_sorting_offset(RID p_decal_instance, float p_sorting_offset) override {}
|
||||
|
||||
/* RENDER TARGET API */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue