Add improvements to Volumetric Fog quality and performance
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
/// <summary>
|
||||
/// Current materials shader version.
|
||||
/// </summary>
|
||||
#define MATERIAL_GRAPH_VERSION 180
|
||||
#define MATERIAL_GRAPH_VERSION 181
|
||||
|
||||
class Material;
|
||||
class GPUShader;
|
||||
|
||||
@@ -25,6 +25,8 @@ PACK_STRUCT(struct VolumeParticleMaterialShaderData {
|
||||
float VolumetricFogMaxDistance;
|
||||
int32 ParticleStride;
|
||||
int32 ParticleIndex;
|
||||
Float3 GridSliceParameters;
|
||||
float Dummy1;
|
||||
});
|
||||
|
||||
DrawPass VolumeParticleMaterialShader::GetDrawModes() const
|
||||
@@ -86,6 +88,7 @@ void VolumeParticleMaterialShader::Bind(BindParameters& params)
|
||||
materialData->VolumetricFogMaxDistance = customData->VolumetricFogMaxDistance;
|
||||
materialData->ParticleStride = drawCall.Particle.Particles->Stride;
|
||||
materialData->ParticleIndex = customData->ParticleIndex;
|
||||
materialData->GridSliceParameters = customData->GridSliceParameters;
|
||||
}
|
||||
|
||||
// Bind constants
|
||||
|
||||
@@ -630,6 +630,20 @@ void RenderTools::ComputeBoxModelDrawMatrix(const RenderView& view, const Orient
|
||||
resultIsViewInside = box.Contains(view.Position) == ContainmentType::Contains;
|
||||
}
|
||||
|
||||
float RenderTools::TemporalHalton(int32 index, int32 base)
|
||||
{
|
||||
float result = 0.0f;
|
||||
const float invBase = 1.0f / (float)base;
|
||||
float fraction = invBase;
|
||||
while (index > 0)
|
||||
{
|
||||
result += float(index % base) * fraction;
|
||||
index /= base;
|
||||
fraction *= invBase;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Float2 RenderTools::GetDepthBounds(const RenderView& view, const Float3& nearPoint, const Float3& farPoint)
|
||||
{
|
||||
// Point closest the view
|
||||
|
||||
@@ -148,6 +148,8 @@ public:
|
||||
static void ComputeSphereModelDrawMatrix(const RenderView& view, const Float3& position, float radius, Matrix& resultWorld, bool& resultIsViewInside);
|
||||
static void ComputeBoxModelDrawMatrix(const RenderView& view, const OrientedBoundingBox& box, Matrix& resultWorld, bool& resultIsViewInside);
|
||||
|
||||
static float TemporalHalton(int32 index, int32 base);
|
||||
|
||||
// Calculates depth bounds to optimize drawing with depth buffer to cover only specific range of depth. Returns min and max depth (as Float2) to pass into GPUContext::SetDepthBounds.
|
||||
static Float2 GetDepthBounds(const RenderView& view, const Float3& nearPoint, const Float3& farPoint);
|
||||
static Float2 GetDepthBounds(const RenderView& view, const BoundingSphere& bounds);
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
#include "Engine/Level/Actors/Camera.h"
|
||||
#include "Engine/Core/Math/Double4x4.h"
|
||||
#include "Engine/Renderer/RenderList.h"
|
||||
#include "Engine/Renderer/RendererPass.h"
|
||||
#include "RenderBuffers.h"
|
||||
#include "RenderTask.h"
|
||||
#include "RenderTools.h"
|
||||
|
||||
void RenderView::Prepare(RenderContext& renderContext)
|
||||
{
|
||||
@@ -29,8 +29,8 @@ void RenderView::Prepare(RenderContext& renderContext)
|
||||
|
||||
// Calculate jitter
|
||||
const float jitterSpread = renderContext.List->Settings.AntiAliasing.TAA_JitterSpread;
|
||||
const float jitterX = (RendererUtils::TemporalHalton(TaaFrameIndex + 1, 2) - 0.5f) * jitterSpread;
|
||||
const float jitterY = (RendererUtils::TemporalHalton(TaaFrameIndex + 1, 3) - 0.5f) * jitterSpread;
|
||||
const float jitterX = (RenderTools::TemporalHalton(TaaFrameIndex + 1, 2) - 0.5f) * jitterSpread;
|
||||
const float jitterY = (RenderTools::TemporalHalton(TaaFrameIndex + 1, 3) - 0.5f) * jitterSpread;
|
||||
taaJitter = Float2(jitterX * 2.0f / width, jitterY * 2.0f / height);
|
||||
|
||||
// Modify projection matrix
|
||||
|
||||
Reference in New Issue
Block a user