Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
0ff929a9
Commit
0ff929a9
authored
Apr 16, 2020
by
clayjohn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use sky properly for ambient and reflections
parent
30ab5c9b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
24 deletions
+29
-24
rasterizer_scene_high_end_rd.cpp
.../rendering/rasterizer_rd/rasterizer_scene_high_end_rd.cpp
+25
-20
rasterizer_scene_rd.cpp
servers/rendering/rasterizer_rd/rasterizer_scene_rd.cpp
+2
-2
rasterizer_scene_rd.h
servers/rendering/rasterizer_rd/rasterizer_scene_rd.h
+2
-2
No files found.
servers/rendering/rasterizer_rd/rasterizer_scene_high_end_rd.cpp
View file @
0ff929a9
...
...
@@ -1164,7 +1164,7 @@ void RasterizerSceneHighEndRD::_setup_environment(RID p_environment, const Camer
}
else
if
(
is_environment
(
p_environment
))
{
RS
::
EnvironmentBG
env_bg
=
environment_get_background
(
p_environment
);
RS
::
EnvironmentAmbientSource
ambient_src
=
environment_get_ambient_
light_ambient_
source
(
p_environment
);
RS
::
EnvironmentAmbientSource
ambient_src
=
environment_get_ambient_source
(
p_environment
);
float
bg_energy
=
environment_get_bg_energy
(
p_environment
);
scene_state
.
ubo
.
ambient_light_color_energy
[
3
]
=
bg_energy
;
...
...
@@ -1184,7 +1184,7 @@ void RasterizerSceneHighEndRD::_setup_environment(RID p_environment, const Camer
scene_state
.
ubo
.
use_ambient_cubemap
=
false
;
}
else
{
float
energy
=
environment_get_ambient_light_
ambient_
energy
(
p_environment
);
float
energy
=
environment_get_ambient_light_energy
(
p_environment
);
Color
color
=
environment_get_ambient_light_color
(
p_environment
);
color
=
color
.
to_linear
();
scene_state
.
ubo
.
ambient_light_color_energy
[
0
]
=
color
.
r
*
energy
;
...
...
@@ -1526,7 +1526,7 @@ void RasterizerSceneHighEndRD::_setup_reflections(RID *p_reflection_probe_cull_r
Color
ambient_linear
=
storage
->
reflection_probe_get_interior_ambient
(
base_probe
).
to_linear
();
if
(
is_environment
(
p_environment
))
{
Color
env_ambient_color
=
environment_get_ambient_light_color
(
p_environment
).
to_linear
();
float
env_ambient_energy
=
environment_get_ambient_light_
ambient_
energy
(
p_environment
);
float
env_ambient_energy
=
environment_get_ambient_light_energy
(
p_environment
);
ambient_linear
=
env_ambient_color
;
ambient_linear
.
r
*=
env_ambient_energy
;
ambient_linear
.
g
*=
env_ambient_energy
;
...
...
@@ -2253,23 +2253,7 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor
clear_color
.
b
*=
bg_energy
;
}
break
;
case
RS
:
:
ENV_BG_SKY
:
{
RID
sky
=
environment_get_sky
(
p_environment
);
if
(
sky
.
is_valid
())
{
RENDER_TIMESTAMP
(
"Setup Sky"
);
CameraMatrix
projection
=
p_cam_projection
;
if
(
p_reflection_probe
.
is_valid
())
{
CameraMatrix
correction
;
correction
.
set_depth_correction
(
true
);
projection
=
correction
*
p_cam_projection
;
}
_setup_sky
(
p_environment
,
p_cam_transform
.
origin
,
screen_size
);
_update_sky
(
p_environment
,
projection
,
p_cam_transform
);
radiance_uniform_set
=
sky_get_radiance_uniform_set_rd
(
sky
,
default_shader_rd
,
RADIANCE_UNIFORM_SET
);
draw_sky
=
true
;
}
draw_sky
=
true
;
}
break
;
case
RS
:
:
ENV_BG_CANVAS
:
{
keep_color
=
true
;
...
...
@@ -2283,6 +2267,27 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor
default
:
{
}
}
// setup sky if used for ambient, reflections, or background
if
(
draw_sky
||
environment_get_reflection_source
(
p_environment
)
==
RS
::
ENV_REFLECTION_SOURCE_SKY
||
environment_get_ambient_source
(
p_environment
)
==
RS
::
ENV_AMBIENT_SOURCE_SKY
)
{
RID
sky
=
environment_get_sky
(
p_environment
);
if
(
sky
.
is_valid
())
{
RENDER_TIMESTAMP
(
"Setup Sky"
);
CameraMatrix
projection
=
p_cam_projection
;
if
(
p_reflection_probe
.
is_valid
())
{
CameraMatrix
correction
;
correction
.
set_depth_correction
(
true
);
projection
=
correction
*
p_cam_projection
;
}
_setup_sky
(
p_environment
,
p_cam_transform
.
origin
,
screen_size
);
_update_sky
(
p_environment
,
projection
,
p_cam_transform
);
radiance_uniform_set
=
sky_get_radiance_uniform_set_rd
(
sky
,
default_shader_rd
,
RADIANCE_UNIFORM_SET
);
}
else
{
// do not try to draw sky if invalid
draw_sky
=
false
;
}
}
}
else
{
clear_color
=
p_default_bg_color
;
...
...
servers/rendering/rasterizer_rd/rasterizer_scene_rd.cpp
View file @
0ff929a9
...
...
@@ -1179,12 +1179,12 @@ Color RasterizerSceneRD::environment_get_ambient_light_color(RID p_env) const {
ERR_FAIL_COND_V
(
!
env
,
Color
());
return
env
->
ambient_light
;
}
RS
::
EnvironmentAmbientSource
RasterizerSceneRD
::
environment_get_ambient_
light_ambient_
source
(
RID
p_env
)
const
{
RS
::
EnvironmentAmbientSource
RasterizerSceneRD
::
environment_get_ambient_source
(
RID
p_env
)
const
{
Environent
*
env
=
environment_owner
.
getornull
(
p_env
);
ERR_FAIL_COND_V
(
!
env
,
RS
::
ENV_AMBIENT_SOURCE_BG
);
return
env
->
ambient_source
;
}
float
RasterizerSceneRD
::
environment_get_ambient_light_
ambient_
energy
(
RID
p_env
)
const
{
float
RasterizerSceneRD
::
environment_get_ambient_light_energy
(
RID
p_env
)
const
{
Environent
*
env
=
environment_owner
.
getornull
(
p_env
);
ERR_FAIL_COND_V
(
!
env
,
0
);
return
env
->
ambient_light_energy
;
...
...
servers/rendering/rasterizer_rd/rasterizer_scene_rd.h
View file @
0ff929a9
...
...
@@ -866,8 +866,8 @@ public:
float
environment_get_bg_energy
(
RID
p_env
)
const
;
int
environment_get_canvas_max_layer
(
RID
p_env
)
const
;
Color
environment_get_ambient_light_color
(
RID
p_env
)
const
;
RS
::
EnvironmentAmbientSource
environment_get_ambient_
light_ambient_
source
(
RID
p_env
)
const
;
float
environment_get_ambient_light_
ambient_
energy
(
RID
p_env
)
const
;
RS
::
EnvironmentAmbientSource
environment_get_ambient_source
(
RID
p_env
)
const
;
float
environment_get_ambient_light_energy
(
RID
p_env
)
const
;
float
environment_get_ambient_sky_contribution
(
RID
p_env
)
const
;
RS
::
EnvironmentReflectionSource
environment_get_reflection_source
(
RID
p_env
)
const
;
Color
environment_get_ao_color
(
RID
p_env
)
const
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment