Fixes and tweaks for rendering
This commit is contained in:
@@ -553,7 +553,7 @@ public:
|
||||
/// <summary>
|
||||
/// Sets the rendering viewport and scissor rectangle.
|
||||
/// </summary>
|
||||
/// <param name="viewport">The viewport.</param>
|
||||
/// <param name="viewport">The viewport (in pixels).</param>
|
||||
API_FUNCTION() FORCE_INLINE void SetViewportAndScissors(const Viewport& viewport)
|
||||
{
|
||||
SetViewport(viewport);
|
||||
@@ -575,13 +575,13 @@ public:
|
||||
/// <summary>
|
||||
/// Sets the rendering viewport.
|
||||
/// </summary>
|
||||
/// <param name="viewport">The viewport.</param>
|
||||
/// <param name="viewport">The viewport (in pixels).</param>
|
||||
API_FUNCTION() virtual void SetViewport(API_PARAM(Ref) const Viewport& viewport) = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the scissor rectangle.
|
||||
/// </summary>
|
||||
/// <param name="scissorRect">The scissor rectangle.</param>
|
||||
/// <param name="scissorRect">The scissor rectangle (in pixels).</param>
|
||||
API_FUNCTION() virtual void SetScissor(API_PARAM(Ref) const Rectangle& scissorRect) = 0;
|
||||
|
||||
public:
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
#define GBUFFER2_FORMAT PixelFormat::R8G8B8A8_UNorm
|
||||
#define GBUFFER3_FORMAT PixelFormat::R8G8B8A8_UNorm
|
||||
|
||||
// Light accumulation buffer format (direct+indirect light, materials emissive)
|
||||
#define LIGHT_BUFFER_FORMAT PixelFormat::R11G11B10_Float
|
||||
|
||||
/// <summary>
|
||||
/// The scene rendering buffers container.
|
||||
/// </summary>
|
||||
|
||||
@@ -135,12 +135,15 @@ bool GlobalSignDistanceFieldPass::Init()
|
||||
// Check platform support
|
||||
const auto device = GPUDevice::Instance;
|
||||
_supported = device->GetFeatureLevel() >= FeatureLevel::SM5 && device->Limits.HasCompute && device->Limits.HasTypedUAVLoad
|
||||
&& FORMAT_FEATURES_ARE_NOT_SUPPORTED(device->GetFormatFeatures(GLOBAL_SDF_FORMAT).Support, FormatSupport::ShaderSample | FormatSupport::Texture3D);
|
||||
&& FORMAT_FEATURES_ARE_SUPPORTED(device->GetFormatFeatures(GLOBAL_SDF_FORMAT).Support, FormatSupport::ShaderSample | FormatSupport::Texture3D);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GlobalSignDistanceFieldPass::setupResources()
|
||||
{
|
||||
if (!_supported)
|
||||
return true;
|
||||
|
||||
// Load shader
|
||||
if (!_shader)
|
||||
{
|
||||
@@ -239,7 +242,7 @@ bool GlobalSignDistanceFieldPass::Render(RenderContext& renderContext, GPUContex
|
||||
result = sdfData.Result;
|
||||
return false;
|
||||
}
|
||||
|
||||
sdfData.LastFrameUsed = currentFrame;
|
||||
PROFILE_GPU_CPU("Global SDF");
|
||||
|
||||
// TODO: configurable via graphics settings
|
||||
@@ -251,7 +254,6 @@ bool GlobalSignDistanceFieldPass::Render(RenderContext& renderContext, GPUContex
|
||||
const float cascadesDistances[] = { distanceExtent, distanceExtent * 2.0f, distanceExtent * 4.0f, distanceExtent * 8.0f };
|
||||
|
||||
// Initialize buffers
|
||||
sdfData.LastFrameUsed = currentFrame;
|
||||
auto desc = GPUTextureDescription::New3D(resolution, resolution, resolution, GLOBAL_SDF_FORMAT, GPUTextureFlags::ShaderResource | GPUTextureFlags::UnorderedAccess, 1);
|
||||
bool updated = false;
|
||||
for (GPUTexture*& cascade : sdfData.Cascades)
|
||||
|
||||
@@ -72,6 +72,7 @@ public:
|
||||
/// <param name="output">The output buffer.</param>
|
||||
void RenderDebug(RenderContext& renderContext, GPUContext* context, GPUTexture* output);
|
||||
|
||||
// Rasterize Model SDF into the Global SDF. Call it from actor Draw() method during DrawPass::GlobalSDF.
|
||||
void RasterizeModelSDF(const ModelBase::SDFData& sdf, const Matrix& localToWorld, const BoundingBox& objectBounds);
|
||||
|
||||
private:
|
||||
|
||||
@@ -326,7 +326,7 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext)
|
||||
renderContext.List->SortDrawCalls(renderContext, false, DrawCallsListType::Distortion);
|
||||
|
||||
// Get the light accumulation buffer
|
||||
auto tempDesc = GPUTextureDescription::New2D(renderContext.Buffers->GetWidth(), renderContext.Buffers->GetHeight(), PixelFormat::R11G11B10_Float);
|
||||
auto tempDesc = GPUTextureDescription::New2D(renderContext.Buffers->GetWidth(), renderContext.Buffers->GetHeight(), LIGHT_BUFFER_FORMAT);
|
||||
auto lightBuffer = RenderTargetPool::Get(tempDesc);
|
||||
|
||||
#if USE_EDITOR
|
||||
|
||||
Reference in New Issue
Block a user