Various fixes to graphics
This commit is contained in:
@@ -106,7 +106,6 @@ void TerrainMaterialShader::Bind(BindParameters& params)
|
||||
// Invert culling when scale is negative
|
||||
cullMode = cullMode == CullMode::Normal ? CullMode::Inverted : CullMode::Normal;
|
||||
}
|
||||
auto hass = _shader->HasShader("PS_QuadOverdraw");
|
||||
const PipelineStateCache* psCache = _cache.GetPS(view.Pass, useLightmap);
|
||||
ASSERT(psCache);
|
||||
GPUPipelineState* state = ((PipelineStateCache*)psCache)->GetPS(this, cullMode);
|
||||
@@ -171,6 +170,9 @@ bool TerrainMaterialShader::Load()
|
||||
psDesc.PS = _shader->GetPS("PS_GBuffer", 1);
|
||||
_cache.DefaultLightmap.Init(psDesc);
|
||||
|
||||
psDesc.StencilEnable = false;
|
||||
psDesc.StencilPassOp = StencilOperation::Keep;
|
||||
|
||||
#if GPU_ENABLE_DEVELOPMENT
|
||||
if (_shader->HasShader("PS_QuadOverdraw"))
|
||||
{
|
||||
|
||||
@@ -55,6 +55,8 @@ API_STRUCT(NoDefault) struct FLAXENGINE_API RenderContext
|
||||
|
||||
/// <summary>
|
||||
/// The high-level renderer context batch that encapsulates multiple rendering requests within a single task (eg. optimize main view scene rendering and shadow projections at once).
|
||||
/// Contains a set of context where the main (first) one is drawing the scene, while others are utility context for shadow maps (batched int oa single drawing process).
|
||||
/// All views share the same world origin.
|
||||
/// </summary>
|
||||
API_STRUCT(NoDefault) struct FLAXENGINE_API RenderContextBatch
|
||||
{
|
||||
@@ -89,11 +91,13 @@ API_STRUCT(NoDefault) struct FLAXENGINE_API RenderContextBatch
|
||||
RenderContextBatch(SceneRenderTask* task);
|
||||
RenderContextBatch(const RenderContext& context);
|
||||
|
||||
// Gets the main (first) render context which draws the scene.
|
||||
FORCE_INLINE RenderContext& GetMainContext()
|
||||
{
|
||||
return Contexts.Get()[0];
|
||||
}
|
||||
|
||||
// Gets the main (first) render context which draws the scene.
|
||||
FORCE_INLINE const RenderContext& GetMainContext() const
|
||||
{
|
||||
return Contexts.Get()[0];
|
||||
|
||||
@@ -696,6 +696,10 @@ Float2 RenderTools::GetDepthBounds(const RenderView& view, const Float3& nearPoi
|
||||
clipNearPoint /= clipNearPoint.W;
|
||||
clipFarPoint /= clipFarPoint.W;
|
||||
|
||||
// Clamp within valid depth range
|
||||
clipNearPoint.Z = Math::Saturate(clipNearPoint.Z);
|
||||
clipFarPoint.Z = Math::Saturate(clipFarPoint.Z);
|
||||
|
||||
return Float2(clipNearPoint.Z, clipFarPoint.Z);
|
||||
#else
|
||||
// Point closest the view
|
||||
|
||||
@@ -133,7 +133,7 @@ Actor::Actor(const SpawnParams& params)
|
||||
|
||||
SceneRendering* Actor::GetSceneRendering() const
|
||||
{
|
||||
return &GetScene()->Rendering;
|
||||
return _scene ? &_scene->Rendering : nullptr;
|
||||
}
|
||||
|
||||
void Actor::SetSceneInHierarchy(Scene* scene)
|
||||
|
||||
@@ -15,13 +15,14 @@
|
||||
#if !BUILD_RELEASE
|
||||
#include "Engine/Graphics/GPUDevice.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Engine/Engine.h"
|
||||
#endif
|
||||
|
||||
#if BUILD_RELEASE
|
||||
#define CHECK_SCENE_EDIT_ACCESS()
|
||||
#else
|
||||
#define CHECK_SCENE_EDIT_ACCESS() \
|
||||
if (_isRendering && IsInMainThread() && GPUDevice::Instance && GPUDevice::Instance->IsRendering()) \
|
||||
if (_isRendering && IsInMainThread() && GPUDevice::Instance && GPUDevice::Instance->IsRendering() && Engine::FatalError != FatalErrorType::None) \
|
||||
{ \
|
||||
LOG(Error, "Adding/removing actors during rendering is not supported ({}, '{}').", a->ToString(), a->GetNamePath()); \
|
||||
return; \
|
||||
|
||||
@@ -270,8 +270,6 @@ void ReflectionsPass::Render(RenderContext& renderContext, GPUTextureView* light
|
||||
int32 probesCount = renderContext.List->EnvironmentProbes.Count();
|
||||
bool renderProbes = probesCount > 0 && renderContext.List->Settings.GlobalIllumination.Reflections == ReflectionsMode::EnvironmentProbes;
|
||||
bool renderDDGI = renderContext.List->Settings.GlobalIllumination.Reflections == ReflectionsMode::DDGI;
|
||||
auto shader = _shader->GPU;
|
||||
auto cb = shader->GetCB(0);
|
||||
|
||||
// Check if no need to render reflection environment
|
||||
if (!useReflections || !(renderProbes || useSSR || renderDDGI) || checkIfSkipPass())
|
||||
@@ -291,6 +289,8 @@ void ReflectionsPass::Render(RenderContext& renderContext, GPUTextureView* light
|
||||
auto& ssrSettings = renderContext.List->Settings.ScreenSpaceReflections;
|
||||
data.SSRTexelSize = Float2(1.0f / (float)RenderTools::GetResolution(width, ssrSettings.ResolvePassResolution), 1.0f / (float)RenderTools::GetResolution(height, ssrSettings.ResolvePassResolution));
|
||||
auto depthBuffer = renderContext.Buffers->GetReadOnlyDepthBuffer();
|
||||
auto shader = _shader->GPU;
|
||||
auto cb = shader->GetCB(0);
|
||||
|
||||
auto tempDesc = GPUTextureDescription::New2D(renderContext.Buffers->GetWidth(), renderContext.Buffers->GetHeight(), PixelFormat::R11G11B10_Float);
|
||||
auto reflectionsBuffer = RenderTargetPool::Get(tempDesc);
|
||||
|
||||
@@ -149,7 +149,7 @@ float4 PS_Wireframe(float4 SvPosition : SV_Position) : SV_Target0
|
||||
{
|
||||
// Depth-based gradient
|
||||
float alpha = saturate(SvPosition.w * UNITS_TO_METERS_SCALE * 0.1f);
|
||||
#if VULKAN
|
||||
#if VULKAN || defined(WGSL)
|
||||
alpha = 1 - alpha;
|
||||
#endif
|
||||
return lerp(ColorNear, ColorFar, alpha);
|
||||
|
||||
Reference in New Issue
Block a user