EnvironmentProbe selectable resolution
This commit is contained in:
@@ -13,6 +13,7 @@ void GraphicsSettings::Apply()
|
|||||||
Graphics::ShadowsQuality = ShadowsQuality;
|
Graphics::ShadowsQuality = ShadowsQuality;
|
||||||
Graphics::ShadowMapsQuality = ShadowMapsQuality;
|
Graphics::ShadowMapsQuality = ShadowMapsQuality;
|
||||||
Graphics::AllowCSMBlending = AllowCSMBlending;
|
Graphics::AllowCSMBlending = AllowCSMBlending;
|
||||||
|
Graphics::DefaultProbeResolution = (int32)DefaultProbeResolution;
|
||||||
Graphics::GlobalSDFQuality = GlobalSDFQuality;
|
Graphics::GlobalSDFQuality = GlobalSDFQuality;
|
||||||
Graphics::GIQuality = GIQuality;
|
Graphics::GIQuality = GIQuality;
|
||||||
Graphics::GlobalSurfaceAtlasResolution = GlobalSurfaceAtlasResolution;
|
Graphics::GlobalSurfaceAtlasResolution = GlobalSurfaceAtlasResolution;
|
||||||
|
|||||||
@@ -63,6 +63,22 @@ public:
|
|||||||
API_FIELD(Attributes="EditorOrder(1320), DefaultValue(false), EditorDisplay(\"Quality\", \"Allow CSM Blending\")")
|
API_FIELD(Attributes="EditorOrder(1320), DefaultValue(false), EditorDisplay(\"Quality\", \"Allow CSM Blending\")")
|
||||||
bool AllowCSMBlending = false;
|
bool AllowCSMBlending = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Default probes cubemap resolution.
|
||||||
|
/// </summary>
|
||||||
|
API_ENUM() enum class DefaultProbeResolutions
|
||||||
|
{
|
||||||
|
_64 = 64,
|
||||||
|
_128 = 128,
|
||||||
|
_256 = 256,
|
||||||
|
_512 = 512,
|
||||||
|
_1024 = 1024,
|
||||||
|
_2048 = 2048,
|
||||||
|
_4096 = 4096,
|
||||||
|
};
|
||||||
|
API_FIELD(Attributes = "EditorOrder(1500), DefaultValue(DefaultProbeResolutions._512), EditorDisplay(\"Quality\", \"Default Probe Resolution\")")
|
||||||
|
DefaultProbeResolutions DefaultProbeResolution = DefaultProbeResolutions::_512;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If checked, enables Global SDF rendering. This can be used in materials, shaders, and particles.
|
/// If checked, enables Global SDF rendering. This can be used in materials, shaders, and particles.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ Quality Graphics::VolumetricFogQuality = Quality::High;
|
|||||||
Quality Graphics::ShadowsQuality = Quality::Medium;
|
Quality Graphics::ShadowsQuality = Quality::Medium;
|
||||||
Quality Graphics::ShadowMapsQuality = Quality::Medium;
|
Quality Graphics::ShadowMapsQuality = Quality::Medium;
|
||||||
bool Graphics::AllowCSMBlending = false;
|
bool Graphics::AllowCSMBlending = false;
|
||||||
|
int32 Graphics::DefaultProbeResolution = 512;
|
||||||
Quality Graphics::GlobalSDFQuality = Quality::High;
|
Quality Graphics::GlobalSDFQuality = Quality::High;
|
||||||
Quality Graphics::GIQuality = Quality::High;
|
Quality Graphics::GIQuality = Quality::High;
|
||||||
int32 Graphics::GlobalSurfaceAtlasResolution = 2048;
|
int32 Graphics::GlobalSurfaceAtlasResolution = 2048;
|
||||||
|
|||||||
@@ -53,6 +53,11 @@ public:
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
API_FIELD() static bool AllowCSMBlending;
|
API_FIELD() static bool AllowCSMBlending;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Default probes cubemap resolution.
|
||||||
|
/// </summary>
|
||||||
|
API_FIELD() static int32 DefaultProbeResolution;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Global SDF quality. Controls the volume texture resolution and amount of cascades to use.
|
/// The Global SDF quality. Controls the volume texture resolution and amount of cascades to use.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "Engine/ContentImporters/AssetsImportingManager.h"
|
#include "Engine/ContentImporters/AssetsImportingManager.h"
|
||||||
#include "Engine/Serialization/Serialization.h"
|
#include "Engine/Serialization/Serialization.h"
|
||||||
#include "Engine/Level/Scene/Scene.h"
|
#include "Engine/Level/Scene/Scene.h"
|
||||||
|
#include "Engine/Graphics/Graphics.h"
|
||||||
|
|
||||||
EnvironmentProbe::EnvironmentProbe(const SpawnParams& params)
|
EnvironmentProbe::EnvironmentProbe(const SpawnParams& params)
|
||||||
: Actor(params)
|
: Actor(params)
|
||||||
@@ -80,8 +81,12 @@ void EnvironmentProbe::Bake(float timeout)
|
|||||||
|
|
||||||
void EnvironmentProbe::SetProbeData(TextureData& data)
|
void EnvironmentProbe::SetProbeData(TextureData& data)
|
||||||
{
|
{
|
||||||
|
int32 probeResolution = (int32)CubemapResolution;
|
||||||
|
// if Use Graphics Settings
|
||||||
|
if (probeResolution == 0) probeResolution = Graphics::DefaultProbeResolution;
|
||||||
|
|
||||||
// Validate input data
|
// Validate input data
|
||||||
ASSERT(data.GetArraySize() == 6 && data.Height == ENV_PROBES_RESOLUTION && data.Width == ENV_PROBES_RESOLUTION);
|
ASSERT(data.GetArraySize() == 6 && data.Height == probeResolution && data.Width == probeResolution);
|
||||||
|
|
||||||
// Check if was using custom probe
|
// Check if was using custom probe
|
||||||
if (_isUsingCustomProbe)
|
if (_isUsingCustomProbe)
|
||||||
@@ -170,6 +175,7 @@ void EnvironmentProbe::Serialize(SerializeStream& stream, const void* otherObj)
|
|||||||
SERIALIZE_GET_OTHER_OBJ(EnvironmentProbe);
|
SERIALIZE_GET_OTHER_OBJ(EnvironmentProbe);
|
||||||
|
|
||||||
SERIALIZE_MEMBER(Radius, _radius);
|
SERIALIZE_MEMBER(Radius, _radius);
|
||||||
|
SERIALIZE(CubemapResolution);
|
||||||
SERIALIZE(Brightness);
|
SERIALIZE(Brightness);
|
||||||
SERIALIZE(AutoUpdate);
|
SERIALIZE(AutoUpdate);
|
||||||
SERIALIZE(CaptureNearPlane);
|
SERIALIZE(CaptureNearPlane);
|
||||||
@@ -183,6 +189,7 @@ void EnvironmentProbe::Deserialize(DeserializeStream& stream, ISerializeModifier
|
|||||||
Actor::Deserialize(stream, modifier);
|
Actor::Deserialize(stream, modifier);
|
||||||
|
|
||||||
DESERIALIZE_MEMBER(Radius, _radius);
|
DESERIALIZE_MEMBER(Radius, _radius);
|
||||||
|
DESERIALIZE(CubemapResolution);
|
||||||
DESERIALIZE(Brightness);
|
DESERIALIZE(Brightness);
|
||||||
DESERIALIZE(AutoUpdate);
|
DESERIALIZE(AutoUpdate);
|
||||||
DESERIALIZE(CaptureNearPlane);
|
DESERIALIZE(CaptureNearPlane);
|
||||||
|
|||||||
@@ -19,6 +19,23 @@ private:
|
|||||||
AssetReference<CubeTexture> _probe;
|
AssetReference<CubeTexture> _probe;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/// <summary>
|
||||||
|
/// The reflections texture resolution.
|
||||||
|
/// </summary>
|
||||||
|
API_ENUM() enum class CubemapResolutions
|
||||||
|
{
|
||||||
|
UseGraphicsSettings = 0,
|
||||||
|
_64 = 64,
|
||||||
|
_128 = 128,
|
||||||
|
_256 = 256,
|
||||||
|
_512 = 512,
|
||||||
|
_1024 = 1024,
|
||||||
|
_2048 = 2048,
|
||||||
|
_4096 = 4096,
|
||||||
|
};
|
||||||
|
API_FIELD(Attributes = "EditorOrder(0), DefaultValue(CubemapResolutions.UseGraphicsSettings), EditorDisplay(\"Probe\")")
|
||||||
|
CubemapResolutions CubemapResolution = CubemapResolutions::UseGraphicsSettings;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The reflections brightness.
|
/// The reflections brightness.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "Engine/Graphics/Textures/TextureData.h"
|
#include "Engine/Graphics/Textures/TextureData.h"
|
||||||
#include "Engine/Graphics/RenderTask.h"
|
#include "Engine/Graphics/RenderTask.h"
|
||||||
#include "Engine/Engine/Engine.h"
|
#include "Engine/Engine/Engine.h"
|
||||||
|
#include "Engine/Graphics/Graphics.h"
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Custom task called after downloading probe texture data to save it.
|
/// Custom task called after downloading probe texture data to save it.
|
||||||
@@ -278,7 +279,15 @@ bool ProbesRenderer::Init()
|
|||||||
|
|
||||||
// Init rendering pipeline
|
// Init rendering pipeline
|
||||||
_output = GPUDevice::Instance->CreateTexture(TEXT("Output"));
|
_output = GPUDevice::Instance->CreateTexture(TEXT("Output"));
|
||||||
if (_output->Init(GPUTextureDescription::New2D(ENV_PROBES_RESOLUTION, ENV_PROBES_RESOLUTION, ENV_PROBES_FORMAT)))
|
int32 probeResolution = ENV_PROBES_RESOLUTION;
|
||||||
|
if (_current.Type == EntryType::EnvProbe)
|
||||||
|
{
|
||||||
|
auto envProbe = (EnvironmentProbe*)_current.Actor.Get();
|
||||||
|
probeResolution = (int32)envProbe->CubemapResolution;
|
||||||
|
// if Use Graphics Settings
|
||||||
|
if (probeResolution == 0) probeResolution = Graphics::DefaultProbeResolution;
|
||||||
|
}
|
||||||
|
if (_output->Init(GPUTextureDescription::New2D(probeResolution, probeResolution, ENV_PROBES_FORMAT)))
|
||||||
return true;
|
return true;
|
||||||
_task = New<SceneRenderTask>();
|
_task = New<SceneRenderTask>();
|
||||||
auto task = _task;
|
auto task = _task;
|
||||||
@@ -300,15 +309,15 @@ bool ProbesRenderer::Init()
|
|||||||
view.StaticFlagsMask = StaticFlags::ReflectionProbe;
|
view.StaticFlagsMask = StaticFlags::ReflectionProbe;
|
||||||
view.MaxShadowsQuality = Quality::Low;
|
view.MaxShadowsQuality = Quality::Low;
|
||||||
task->IsCameraCut = true;
|
task->IsCameraCut = true;
|
||||||
task->Resize(ENV_PROBES_RESOLUTION, ENV_PROBES_RESOLUTION);
|
task->Resize(probeResolution, probeResolution);
|
||||||
task->Render.Bind(onRender);
|
task->Render.Bind(onRender);
|
||||||
|
|
||||||
// Init render targets
|
// Init render targets
|
||||||
_probe = GPUDevice::Instance->CreateTexture(TEXT("ProbesUpdate.Probe"));
|
_probe = GPUDevice::Instance->CreateTexture(TEXT("ProbesUpdate.Probe"));
|
||||||
if (_probe->Init(GPUTextureDescription::NewCube(ENV_PROBES_RESOLUTION, ENV_PROBES_FORMAT, GPUTextureFlags::ShaderResource | GPUTextureFlags::RenderTarget | GPUTextureFlags::PerMipViews, 0)))
|
if (_probe->Init(GPUTextureDescription::NewCube(probeResolution, ENV_PROBES_FORMAT, GPUTextureFlags::ShaderResource | GPUTextureFlags::RenderTarget | GPUTextureFlags::PerMipViews, 0)))
|
||||||
return true;
|
return true;
|
||||||
_tmpFace = GPUDevice::Instance->CreateTexture(TEXT("ProbesUpdate.TmpFae"));
|
_tmpFace = GPUDevice::Instance->CreateTexture(TEXT("ProbesUpdate.TmpFae"));
|
||||||
if (_tmpFace->Init(GPUTextureDescription::New2D(ENV_PROBES_RESOLUTION, ENV_PROBES_RESOLUTION, 0, ENV_PROBES_FORMAT, GPUTextureFlags::ShaderResource | GPUTextureFlags::RenderTarget | GPUTextureFlags::PerMipViews)))
|
if (_tmpFace->Init(GPUTextureDescription::New2D(probeResolution, probeResolution, 0, ENV_PROBES_FORMAT, GPUTextureFlags::ShaderResource | GPUTextureFlags::RenderTarget | GPUTextureFlags::PerMipViews)))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Mark as ready
|
// Mark as ready
|
||||||
@@ -465,9 +474,13 @@ void ProbesRenderer::onRender(RenderTask* task, GPUContext* context)
|
|||||||
|
|
||||||
// Init
|
// Init
|
||||||
float customCullingNear = -1;
|
float customCullingNear = -1;
|
||||||
|
int32 probeResolution = ENV_PROBES_RESOLUTION;
|
||||||
if (_current.Type == EntryType::EnvProbe)
|
if (_current.Type == EntryType::EnvProbe)
|
||||||
{
|
{
|
||||||
auto envProbe = (EnvironmentProbe*)_current.Actor.Get();
|
auto envProbe = (EnvironmentProbe*)_current.Actor.Get();
|
||||||
|
probeResolution = (int32)envProbe->CubemapResolution;
|
||||||
|
// if Use Graphics Settings
|
||||||
|
if (probeResolution == 0) probeResolution = Graphics::DefaultProbeResolution;
|
||||||
LOG(Info, "Updating Env probe '{0}'...", envProbe->ToString());
|
LOG(Info, "Updating Env probe '{0}'...", envProbe->ToString());
|
||||||
Vector3 position = envProbe->GetPosition();
|
Vector3 position = envProbe->GetPosition();
|
||||||
float radius = envProbe->GetScaledRadius();
|
float radius = envProbe->GetScaledRadius();
|
||||||
@@ -523,7 +536,7 @@ void ProbesRenderer::onRender(RenderTask* task, GPUContext* context)
|
|||||||
{
|
{
|
||||||
PROFILE_GPU("Copy Face");
|
PROFILE_GPU("Copy Face");
|
||||||
context->SetRenderTarget(_probe->View(faceIndex));
|
context->SetRenderTarget(_probe->View(faceIndex));
|
||||||
context->SetViewportAndScissors(ENV_PROBES_RESOLUTION, ENV_PROBES_RESOLUTION);
|
context->SetViewportAndScissors(probeResolution, probeResolution);
|
||||||
auto probeFrame = _output->View();
|
auto probeFrame = _output->View();
|
||||||
if (setLowerHemisphereToBlack && faceIndex != 2)
|
if (setLowerHemisphereToBlack && faceIndex != 2)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user