Eevee-Next: World Reflective Light #108149

Merged
Jeroen Bakker merged 33 commits from Jeroen-Bakker/blender:eevee-next-world-shader into main 2023-06-29 15:25:04 +02:00
2 changed files with 14 additions and 14 deletions
Showing only changes of commit c7e6778f23 - Show all commits

View File

@ -9,27 +9,27 @@ namespace blender::eevee {
void ReflectionProbeModule::init()
{
if (cubemaps_.is_empty()) {
cubemaps_.reserve(MAX_PROBES);
cubemaps_.reserve(max_probes);
/* Initialize the world cubemap. */
ReflectionProbe world_cubemap;
world_cubemap.type = ReflectionProbe::Type::World;
world_cubemap.type = ReflectionProbe::Type::WORLD;
world_cubemap.is_dirty = true;
cubemaps_.append(world_cubemap);
cubemaps_tx_.ensure_cube_array(GPU_RGBA16F,
MAX_RESOLUTION,
MAX_PROBES,
max_resolution,
max_probes,
GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_ATTACHMENT,
NULL,
MIPMAP_LEVELS);
max_mipmap_levels);
GPU_texture_mipmap_mode(cubemaps_tx_, true, true);
}
}
void ReflectionProbeModule::sync()
{
for (int index : IndexRange(MAX_PROBES)) {
for (int index : IndexRange(max_probes)) {
ReflectionProbe &cubemap = cubemaps_[index];
if (!cubemap.needs_update()) {
continue;
@ -41,7 +41,7 @@ void ReflectionProbeModule::sync()
void ReflectionProbeModule::sync(const ReflectionProbe &cubemap)
{
if (cubemap.type == ReflectionProbe::Type::World) {
if (cubemap.type == ReflectionProbe::Type::WORLD) {
GPUMaterial *world_material = instance_.world.get_world_material();
instance_.pipelines.world.sync(world_material);
Jeroen-Bakker marked this conversation as resolved Outdated

Prefer always syncing it inside World::sync() just like the other world pipeline is doing inst_.pipelines.world.sync(gpumat);.

Prefer always syncing it inside `World::sync()` just like the other world pipeline is doing `inst_.pipelines.world.sync(gpumat);`.
}
@ -52,7 +52,7 @@ void ReflectionProbeModule::sync(const ReflectionProbe &cubemap)
void ReflectionProbeModule::set_world_dirty()
{
cubemaps_[WORLD_SLOT].is_dirty = true;
cubemaps_[world_slot].is_dirty = true;
Jeroen-Bakker marked this conversation as resolved Outdated

Reflection Probe

Reflection Probe
}
/* -------------------------------------------------------------------- */
@ -62,7 +62,7 @@ void ReflectionProbeModule::set_world_dirty()
bool ReflectionProbe::needs_update() const
{
return type != Type::Unused && is_dirty;
return type != Type::UNUSED && is_dirty;
}
/** \} */

View File

@ -35,7 +35,7 @@ class WorldPipeline;
* \{ */
class ReflectionProbe {
public:
enum Type { Unused, World };
enum Type { UNUSED, WORLD };
Jeroen-Bakker marked this conversation as resolved Outdated

Style: Uppercase enum members.

Style: Uppercase enum members.
Type type;
bool is_dirty = false;
@ -46,22 +46,22 @@ class ReflectionProbe {
class ReflectionProbeModule {
private:
/** The max number of probes to track. */
static constexpr int MAX_PROBES = 1;
static constexpr int max_probes = 1;
Jeroen-Bakker marked this conversation as resolved Outdated

Style: No uppercase

Style: No uppercase
/**
* The maximum resolution of a cubemap side.
*
* Must be a power of two; intension to be used as a cubemap atlas.
*/
static constexpr int MAX_RESOLUTION = 2048;
static constexpr int MIPMAP_LEVELS = 12;
static constexpr int max_resolution = 2048;
Jeroen-Bakker marked this conversation as resolved Outdated

I don't know if this is covered by the next patch, but this should become an option.

I don't know if this is covered by the next patch, but this should become an option.

Yes, that will be part of the reflection probe baking patch. Might even land earlier when specific parts of that patch are stable. Currently this part isn't stable to land in main yet.

Yes, that will be part of the reflection probe baking patch. Might even land earlier when specific parts of that patch are stable. Currently this part isn't stable to land in main yet.
static constexpr int max_mipmap_levels = log(max_resolution) + 1;
Jeroen-Bakker marked this conversation as resolved Outdated

Maybe derive it from MAX_RESOLUTION ? log2(MAX_RESOLUTION) + 1

Maybe derive it from `MAX_RESOLUTION` ? `log2(MAX_RESOLUTION) + 1`
/**
* Index of the probe that is used for world background.
*
* NOTE: First probe always contains the world probe.
*/
static constexpr int WORLD_SLOT = 0;
static constexpr int world_slot = 0;
Instance &instance_;