Cleanup some rendering code
This commit is contained in:
@@ -490,7 +490,6 @@ void Foliage::DrawType(RenderContext& renderContext, const FoliageType& type, Dr
|
||||
batch.DrawCall.World.SetRow4(Float4(firstInstance.InstanceOrigin, 1.0f));
|
||||
batch.DrawCall.Surface.PrevWorld = batch.DrawCall.World;
|
||||
batch.DrawCall.Surface.GeometrySize = mesh.GetBox().GetSize();
|
||||
batch.DrawCall.Surface.Skinning = nullptr;
|
||||
batch.DrawCall.WorldDeterminantSign = 1;
|
||||
|
||||
if (EnumHasAnyFlags(drawModes, DrawPass::Forward))
|
||||
|
||||
@@ -407,11 +407,7 @@ void Mesh::Draw(const RenderContext& renderContext, MaterialBase* material, cons
|
||||
drawCall.ObjectRadius = (float)_sphere.Radius * drawCall.World.GetScaleVector().GetAbsolute().MaxValue();
|
||||
drawCall.Surface.GeometrySize = _box.GetSize();
|
||||
drawCall.Surface.PrevWorld = world;
|
||||
drawCall.Surface.Lightmap = nullptr;
|
||||
drawCall.Surface.LightmapUVsArea = Rectangle::Empty;
|
||||
drawCall.Surface.Skinning = nullptr;
|
||||
drawCall.Surface.LODDitherFactor = 0.0f;
|
||||
drawCall.WorldDeterminantSign = Math::FloatSelect(world.RotDeterminant(), 1, -1);
|
||||
drawCall.WorldDeterminantSign = RenderTools::GetWorldDeterminantSign(drawCall.World);
|
||||
drawCall.PerInstanceRandom = perInstanceRandom;
|
||||
#if USE_EDITOR
|
||||
const ViewMode viewMode = renderContext.View.Mode;
|
||||
@@ -477,9 +473,8 @@ void Mesh::Draw(const RenderContext& renderContext, const DrawInfo& info, float
|
||||
drawCall.Surface.PrevWorld = info.DrawState->PrevWorld;
|
||||
drawCall.Surface.Lightmap = (info.Flags & StaticFlags::Lightmap) != StaticFlags::None ? info.Lightmap : nullptr;
|
||||
drawCall.Surface.LightmapUVsArea = info.LightmapUVs ? *info.LightmapUVs : Rectangle::Empty;
|
||||
drawCall.Surface.Skinning = nullptr;
|
||||
drawCall.Surface.LODDitherFactor = lodDitherFactor;
|
||||
drawCall.WorldDeterminantSign = Math::FloatSelect(drawCall.World.RotDeterminant(), 1, -1);
|
||||
drawCall.WorldDeterminantSign = RenderTools::GetWorldDeterminantSign(drawCall.World);
|
||||
drawCall.PerInstanceRandom = info.PerInstanceRandom;
|
||||
#if USE_EDITOR
|
||||
const ViewMode viewMode = renderContext.View.Mode;
|
||||
@@ -539,9 +534,8 @@ void Mesh::Draw(const RenderContextBatch& renderContextBatch, const DrawInfo& in
|
||||
drawCall.Surface.PrevWorld = info.DrawState->PrevWorld;
|
||||
drawCall.Surface.Lightmap = (info.Flags & StaticFlags::Lightmap) != StaticFlags::None ? info.Lightmap : nullptr;
|
||||
drawCall.Surface.LightmapUVsArea = info.LightmapUVs ? *info.LightmapUVs : Rectangle::Empty;
|
||||
drawCall.Surface.Skinning = nullptr;
|
||||
drawCall.Surface.LODDitherFactor = lodDitherFactor;
|
||||
drawCall.WorldDeterminantSign = Math::FloatSelect(drawCall.World.RotDeterminant(), 1, -1);
|
||||
drawCall.WorldDeterminantSign = RenderTools::GetWorldDeterminantSign(drawCall.World);
|
||||
drawCall.PerInstanceRandom = info.PerInstanceRandom;
|
||||
#if USE_EDITOR
|
||||
const ViewMode viewMode = renderContextBatch.GetMainContext().View.Mode;
|
||||
|
||||
@@ -249,11 +249,9 @@ void SkinnedMesh::Draw(const RenderContext& renderContext, const DrawInfo& info,
|
||||
drawCall.ObjectRadius = (float)info.Bounds.Radius; // TODO: should it be kept in sync with ObjectPosition?
|
||||
drawCall.Surface.GeometrySize = _box.GetSize();
|
||||
drawCall.Surface.PrevWorld = info.DrawState->PrevWorld;
|
||||
drawCall.Surface.Lightmap = nullptr;
|
||||
drawCall.Surface.LightmapUVsArea = Rectangle::Empty;
|
||||
drawCall.Surface.Skinning = info.Skinning;
|
||||
drawCall.Surface.LODDitherFactor = lodDitherFactor;
|
||||
drawCall.WorldDeterminantSign = Math::FloatSelect(drawCall.World.RotDeterminant(), 1, -1);
|
||||
drawCall.WorldDeterminantSign = RenderTools::GetWorldDeterminantSign(drawCall.World);
|
||||
drawCall.PerInstanceRandom = info.PerInstanceRandom;
|
||||
|
||||
// Push draw call to the render list
|
||||
@@ -292,11 +290,9 @@ void SkinnedMesh::Draw(const RenderContextBatch& renderContextBatch, const DrawI
|
||||
drawCall.ObjectRadius = (float)info.Bounds.Radius; // TODO: should it be kept in sync with ObjectPosition?
|
||||
drawCall.Surface.GeometrySize = _box.GetSize();
|
||||
drawCall.Surface.PrevWorld = info.DrawState->PrevWorld;
|
||||
drawCall.Surface.Lightmap = nullptr;
|
||||
drawCall.Surface.LightmapUVsArea = Rectangle::Empty;
|
||||
drawCall.Surface.Skinning = info.Skinning;
|
||||
drawCall.Surface.LODDitherFactor = lodDitherFactor;
|
||||
drawCall.WorldDeterminantSign = Math::FloatSelect(drawCall.World.RotDeterminant(), 1, -1);
|
||||
drawCall.WorldDeterminantSign = RenderTools::GetWorldDeterminantSign(drawCall.World);
|
||||
drawCall.PerInstanceRandom = info.PerInstanceRandom;
|
||||
|
||||
// Push draw call to the render lists
|
||||
|
||||
@@ -29,6 +29,11 @@ public:
|
||||
return mipSlice + arraySlice * mipLevels;
|
||||
}
|
||||
|
||||
FORCE_INLINE static float GetWorldDeterminantSign(const Matrix& worldMatrix)
|
||||
{
|
||||
return Math::FloatSelect(worldMatrix.RotDeterminant(), 1, -1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Computes the feature level for the given shader profile.
|
||||
/// </summary>
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
#include "Skybox.h"
|
||||
#include "Engine/Core/Math/Color.h"
|
||||
#include "Engine/Core/Types/Variant.h"
|
||||
#include "Engine/Graphics/RenderView.h"
|
||||
#include "Engine/Renderer/RenderList.h"
|
||||
#include "Engine/Serialization/Serialization.h"
|
||||
#include "Engine/Graphics/RenderView.h"
|
||||
#include "Engine/Graphics/RenderTask.h"
|
||||
#include "Engine/Graphics/RenderTools.h"
|
||||
#include "Engine/Level/Scene/SceneRendering.h"
|
||||
#include "Engine/Content/Assets/Material.h"
|
||||
#include "Engine/Content/Content.h"
|
||||
@@ -101,7 +102,7 @@ void Skybox::ApplySky(GPUContext* context, RenderContext& renderContext, const M
|
||||
drawCall.ObjectPosition = drawCall.World.GetTranslation();
|
||||
drawCall.ObjectRadius = (float)_sphere.Radius;
|
||||
drawCall.Surface.GeometrySize = _box.GetSize();
|
||||
drawCall.WorldDeterminantSign = Math::FloatSelect(world.RotDeterminant(), 1, -1);
|
||||
drawCall.WorldDeterminantSign = RenderTools::GetWorldDeterminantSign(drawCall.World);
|
||||
drawCall.PerInstanceRandom = GetPerInstanceRandom();
|
||||
MaterialBase::BindParameters bindParams(context, renderContext, drawCall);
|
||||
bindParams.BindViewData();
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "Engine/Graphics/RenderBuffers.h"
|
||||
#include "Engine/Graphics/RenderTargetPool.h"
|
||||
#include "Engine/Renderer/RenderList.h"
|
||||
#include "Engine/Graphics/RenderTools.h"
|
||||
|
||||
void QuadOverdrawPass::Render(RenderContext& renderContext, GPUContext* context, GPUTextureView* lightBuffer)
|
||||
{
|
||||
@@ -82,7 +83,7 @@ void QuadOverdrawPass::Render(RenderContext& renderContext, GPUContext* context,
|
||||
m1 *= m2;
|
||||
drawCall.World = m1;
|
||||
drawCall.ObjectPosition = drawCall.World.GetTranslation();
|
||||
drawCall.WorldDeterminantSign = Math::FloatSelect(drawCall.World.RotDeterminant(), 1, -1);
|
||||
drawCall.WorldDeterminantSign = RenderTools::GetWorldDeterminantSign(drawCall.World);
|
||||
skyMaterial->Bind(bindParams);
|
||||
skyModel->Render(context);
|
||||
}
|
||||
|
||||
@@ -691,7 +691,6 @@ void RenderList::ExecuteDrawCalls(const RenderContext& renderContext, DrawCallsL
|
||||
// Prepare instance buffer
|
||||
if (useInstancing)
|
||||
{
|
||||
PROFILE_CPU_NAMED("Build Instancing");
|
||||
int32 instancedBatchesCount = 0;
|
||||
for (int32 i = 0; i < list.Batches.Count(); i++)
|
||||
{
|
||||
@@ -707,6 +706,7 @@ void RenderList::ExecuteDrawCalls(const RenderContext& renderContext, DrawCallsL
|
||||
}
|
||||
if (instancedBatchesCount != 0)
|
||||
{
|
||||
PROFILE_CPU_NAMED("Build Instancing");
|
||||
_instanceBuffer.Clear();
|
||||
_instanceBuffer.Data.Resize(instancedBatchesCount * sizeof(InstanceData));
|
||||
auto instanceData = (InstanceData*)_instanceBuffer.Data.Get();
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "Engine/Graphics/RenderTask.h"
|
||||
#include "Engine/Graphics/Textures/GPUTexture.h"
|
||||
#include "Engine/Renderer/RenderList.h"
|
||||
#include "Engine/Graphics/RenderTools.h"
|
||||
#include "Engine/Core/Math/OrientedBoundingBox.h"
|
||||
#include "Engine/Level/Scene/Scene.h"
|
||||
#if USE_EDITOR
|
||||
@@ -121,7 +122,7 @@ void TerrainChunk::Draw(const RenderContext& renderContext) const
|
||||
drawCall.Terrain.Lightmap = nullptr;
|
||||
drawCall.Terrain.LightmapUVsArea = Rectangle::Empty;
|
||||
}
|
||||
drawCall.WorldDeterminantSign = Math::FloatSelect(drawCall.World.RotDeterminant(), 1, -1);
|
||||
drawCall.WorldDeterminantSign = RenderTools::GetWorldDeterminantSign(drawCall.World);
|
||||
drawCall.PerInstanceRandom = _perInstanceRandom;
|
||||
|
||||
// Add half-texel offset for heightmap sampling in vertex shader
|
||||
@@ -178,7 +179,7 @@ void TerrainChunk::Draw(const RenderContext& renderContext, MaterialBase* materi
|
||||
drawCall.Terrain.Lightmap = nullptr;
|
||||
drawCall.Terrain.LightmapUVsArea = Rectangle::Empty;
|
||||
}
|
||||
drawCall.WorldDeterminantSign = Math::FloatSelect(drawCall.World.RotDeterminant(), 1, -1);
|
||||
drawCall.WorldDeterminantSign = RenderTools::GetWorldDeterminantSign(drawCall.World);
|
||||
drawCall.PerInstanceRandom = _perInstanceRandom;
|
||||
|
||||
// Add half-texel offset for heightmap sampling in vertex shader
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "Engine/Content/Assets/MaterialInstance.h"
|
||||
#include "Engine/Content/Content.h"
|
||||
#include "Engine/Core/Types/Variant.h"
|
||||
#include "Engine/Graphics/RenderTools.h"
|
||||
#include "Engine/Localization/Localization.h"
|
||||
#if USE_EDITOR
|
||||
#include "Editor/Editor.h"
|
||||
@@ -369,11 +370,7 @@ void TextRender::Draw(RenderContext& renderContext)
|
||||
drawCall.ObjectRadius = (float)_sphere.Radius;
|
||||
drawCall.Surface.GeometrySize = _localBox.GetSize();
|
||||
drawCall.Surface.PrevWorld = _drawState.PrevWorld;
|
||||
drawCall.Surface.Lightmap = nullptr;
|
||||
drawCall.Surface.LightmapUVsArea = Rectangle::Empty;
|
||||
drawCall.Surface.Skinning = nullptr;
|
||||
drawCall.Surface.LODDitherFactor = 0.0f;
|
||||
drawCall.WorldDeterminantSign = Math::FloatSelect(world.RotDeterminant(), 1, -1);
|
||||
drawCall.WorldDeterminantSign = RenderTools::GetWorldDeterminantSign(drawCall.World);
|
||||
drawCall.PerInstanceRandom = GetPerInstanceRandom();
|
||||
drawCall.Geometry.IndexBuffer = _ib.GetBuffer();
|
||||
drawCall.Geometry.VertexBuffers[0] = _vb0.GetBuffer();
|
||||
|
||||
@@ -118,7 +118,7 @@ struct ModelInput
|
||||
float4 Tangent : TANGENT;
|
||||
float2 LightmapUV : TEXCOORD1;
|
||||
#if USE_VERTEX_COLOR
|
||||
half4 Color : COLOR;
|
||||
half4 Color : COLOR;
|
||||
#endif
|
||||
#if USE_INSTANCING
|
||||
float4 InstanceOrigin : ATTRIBUTE0; // .w contains PerInstanceRandom
|
||||
@@ -149,13 +149,6 @@ struct ModelInput_Skinned
|
||||
float4 Tangent : TANGENT;
|
||||
uint4 BlendIndices : BLENDINDICES;
|
||||
float4 BlendWeights : BLENDWEIGHT;
|
||||
#if USE_INSTANCING
|
||||
float4 InstanceOrigin : ATTRIBUTE0; // .w contains PerInstanceRandom
|
||||
float4 InstanceTransform1 : ATTRIBUTE1; // .w contains LODDitherFactor
|
||||
float3 InstanceTransform2 : ATTRIBUTE2;
|
||||
float3 InstanceTransform3 : ATTRIBUTE3;
|
||||
half4 InstanceLightmapArea : ATTRIBUTE4;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct Model_VS2PS
|
||||
|
||||
Reference in New Issue
Block a user