From a214c14a4d7daf84fa32951246f641fbef4f449a Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sat, 28 Jan 2023 17:03:18 +0100 Subject: [PATCH 01/23] Add Sort Order to animated models too --- Source/Engine/Graphics/Models/Mesh.h | 74 ------------- Source/Engine/Graphics/Models/MeshBase.h | 101 +++++++++++++++++- Source/Engine/Graphics/Models/SkinnedMesh.cpp | 26 ++--- Source/Engine/Graphics/Models/SkinnedMesh.h | 61 ----------- Source/Engine/Level/Actors/AnimatedModel.cpp | 4 + Source/Engine/Level/Actors/AnimatedModel.h | 6 ++ 6 files changed, 120 insertions(+), 152 deletions(-) diff --git a/Source/Engine/Graphics/Models/Mesh.h b/Source/Engine/Graphics/Models/Mesh.h index 09c04ab34..ee16c16e3 100644 --- a/Source/Engine/Graphics/Models/Mesh.h +++ b/Source/Engine/Graphics/Models/Mesh.h @@ -6,14 +6,11 @@ #include "ModelInstanceEntry.h" #include "Config.h" #include "Types.h" -#include "Engine/Level/Types.h" #if USE_PRECISE_MESH_INTERSECTS #include "CollisionProxy.h" #endif -struct GeometryDrawStateData; class Lightmap; -class GPUBuffer; /// /// Represents part of the model that is made of vertices and can be rendered using custom material and transformation. @@ -275,77 +272,6 @@ public: /// The draw call. void GetDrawCallGeometry(DrawCall& drawCall) const; - /// - /// Model instance drawing packed data. - /// - struct DrawInfo - { - /// - /// The instance buffer to use during model rendering. - /// - ModelInstanceEntries* Buffer; - - /// - /// The world transformation of the model. - /// - Matrix* World; - - /// - /// The instance drawing state data container. Used for LOD transition handling and previous world transformation matrix updating. - /// - GeometryDrawStateData* DrawState; - - /// - /// The lightmap. - /// - const Lightmap* Lightmap; - - /// - /// The lightmap UVs. - /// - const Rectangle* LightmapUVs; - - /// - /// The model instance vertex colors buffers (per-lod all meshes packed in a single allocation, array length equal to model lods count). - /// - GPUBuffer** VertexColors; - - /// - /// The object static flags. - /// - StaticFlags Flags; - - /// - /// The object draw modes. - /// - DrawPass DrawModes; - - /// - /// The bounds of the model (used to select a proper LOD during rendering). - /// - BoundingSphere Bounds; - - /// - /// The per-instance random value. - /// - float PerInstanceRandom; - - /// - /// The LOD bias value. - /// - char LODBias; - - /// - /// The forced LOD to use. Value -1 disables this feature. - /// - char ForcedLOD; - - /// - /// The object sorting key. - /// - int16 SortOrder; - }; - /// /// Draws the mesh. Binds vertex and index buffers and invokes the draw call. /// diff --git a/Source/Engine/Graphics/Models/MeshBase.h b/Source/Engine/Graphics/Models/MeshBase.h index 8f2c80e20..0d07ec4ec 100644 --- a/Source/Engine/Graphics/Models/MeshBase.h +++ b/Source/Engine/Graphics/Models/MeshBase.h @@ -5,12 +5,20 @@ #include "Engine/Core/Math/BoundingBox.h" #include "Engine/Core/Math/BoundingSphere.h" #include "Engine/Core/Types/DataContainer.h" +#include "Engine/Graphics/Enums.h" #include "Engine/Graphics/Models/Types.h" +#include "Engine/Level/Types.h" #include "Engine/Scripting/ScriptingObject.h" +struct GeometryDrawStateData; +struct RenderContext; +struct RenderContextBatch; class Task; class ModelBase; -struct RenderContextBatch; +class Lightmap; +class GPUBuffer; +class SkinnedMeshDrawData; +class BlendShapesInstance; /// /// Base class for model resources meshes. @@ -143,4 +151,95 @@ public: /// The amount of items inside the result buffer. /// True if failed, otherwise false virtual bool DownloadDataCPU(MeshBufferType type, BytesContainer& result, int32& count) const = 0; + +public: + /// + /// Model instance drawing packed data. + /// + struct DrawInfo + { + /// + /// The instance buffer to use during model rendering + /// + ModelInstanceEntries* Buffer; + + /// + /// The world transformation of the model. + /// + Matrix* World; + + /// + /// The instance drawing state data container. Used for LOD transition handling and previous world transformation matrix updating. + /// + GeometryDrawStateData* DrawState; + + union + { + struct + { + /// + /// The skinning. + /// + SkinnedMeshDrawData* Skinning; + + /// + /// The blend shapes. + /// + BlendShapesInstance* BlendShapes; + }; + + struct + { + /// + /// The lightmap. + /// + const Lightmap* Lightmap; + + /// + /// The lightmap UVs. + /// + const Rectangle* LightmapUVs; + }; + }; + + /// + /// The model instance vertex colors buffers (per-lod all meshes packed in a single allocation, array length equal to model lods count). + /// + GPUBuffer** VertexColors; + + /// + /// The object static flags. + /// + StaticFlags Flags; + + /// + /// The object draw modes. + /// + DrawPass DrawModes; + + /// + /// The bounds of the model (used to select a proper LOD during rendering). + /// + BoundingSphere Bounds; + + /// + /// The per-instance random value. + /// + float PerInstanceRandom; + + /// + /// The LOD bias value. + /// + char LODBias; + + /// + /// The forced LOD to use. Value -1 disables this feature. + /// + char ForcedLOD; + + /// + /// The object sorting key. + /// + int16 SortOrder; + }; }; diff --git a/Source/Engine/Graphics/Models/SkinnedMesh.cpp b/Source/Engine/Graphics/Models/SkinnedMesh.cpp index 979d9e250..89db8ff8b 100644 --- a/Source/Engine/Graphics/Models/SkinnedMesh.cpp +++ b/Source/Engine/Graphics/Models/SkinnedMesh.cpp @@ -119,28 +119,22 @@ bool SkinnedMesh::UpdateMesh(uint32 vertexCount, uint32 triangleCount, VB0Skinne bool SkinnedMesh::Intersects(const Ray& ray, const Matrix& world, Real& distance, Vector3& normal) const { // Transform points - Vector3 min, max; - Vector3::Transform(_box.Minimum, world, min); - Vector3::Transform(_box.Maximum, world, max); + BoundingBox transformedBox; + Vector3::Transform(_box.Minimum, world, transformedBox.Minimum); + Vector3::Transform(_box.Maximum, world, transformedBox.Maximum); - // Get transformed box - BoundingBox transformedBox(min, max); - - // Test ray on a box + // Test ray on a transformed box return transformedBox.Intersects(ray, distance, normal); } bool SkinnedMesh::Intersects(const Ray& ray, const Transform& transform, Real& distance, Vector3& normal) const { // Transform points - Vector3 min, max; - transform.LocalToWorld(_box.Minimum, min); - transform.LocalToWorld(_box.Maximum, max); + BoundingBox transformedBox; + transform.LocalToWorld(_box.Minimum, transformedBox.Minimum); + transform.LocalToWorld(_box.Maximum, transformedBox.Maximum); - // Get transformed box - BoundingBox transformedBox(min, max); - - // Test ray on a box + // Test ray on a transformed box return transformedBox.Intersects(ray, distance, normal); } @@ -216,7 +210,7 @@ void SkinnedMesh::Draw(const RenderContext& renderContext, const DrawInfo& info, drawCall.PerInstanceRandom = info.PerInstanceRandom; // Push draw call to the render list - renderContext.List->AddDrawCall(renderContext, drawModes, StaticFlags::None, drawCall, entry.ReceiveDecals); + renderContext.List->AddDrawCall(renderContext, drawModes, StaticFlags::None, drawCall, entry.ReceiveDecals, info.SortOrder); } void SkinnedMesh::Draw(const RenderContextBatch& renderContextBatch, const DrawInfo& info, float lodDitherFactor) const @@ -279,7 +273,7 @@ void SkinnedMesh::Draw(const RenderContextBatch& renderContextBatch, const DrawI const auto shadowsMode = entry.ShadowsMode & slot.ShadowsMode; const auto drawModes = info.DrawModes & material->GetDrawModes(); if (drawModes != DrawPass::None) - renderContextBatch.GetMainContext().List->AddDrawCall(renderContextBatch, drawModes, StaticFlags::None, shadowsMode, info.Bounds, drawCall, entry.ReceiveDecals); + renderContextBatch.GetMainContext().List->AddDrawCall(renderContextBatch, drawModes, StaticFlags::None, shadowsMode, info.Bounds, drawCall, entry.ReceiveDecals, info.SortOrder); } bool SkinnedMesh::DownloadDataGPU(MeshBufferType type, BytesContainer& result) const diff --git a/Source/Engine/Graphics/Models/SkinnedMesh.h b/Source/Engine/Graphics/Models/SkinnedMesh.h index c4893c8ac..8bf957554 100644 --- a/Source/Engine/Graphics/Models/SkinnedMesh.h +++ b/Source/Engine/Graphics/Models/SkinnedMesh.h @@ -6,11 +6,6 @@ #include "Types.h" #include "BlendShape.h" -struct GeometryDrawStateData; -struct RenderContext; -class GPUBuffer; -class SkinnedMeshDrawData; - /// /// Represents part of the skinned model that is made of vertices and can be rendered using custom material, transformation and skeleton bones hierarchy. /// @@ -170,62 +165,6 @@ public: } public: - /// - /// Model instance drawing packed data. - /// - struct DrawInfo - { - /// - /// The instance buffer to use during model rendering - /// - ModelInstanceEntries* Buffer; - - /// - /// The skinning. - /// - SkinnedMeshDrawData* Skinning; - - /// - /// The blend shapes. - /// - BlendShapesInstance* BlendShapes; - - /// - /// The world transformation of the model. - /// - Matrix* World; - - /// - /// The instance drawing state data container. Used for LOD transition handling and previous world transformation matrix updating. - /// - GeometryDrawStateData* DrawState; - - /// - /// The object draw modes. - /// - DrawPass DrawModes; - - /// - /// The bounds of the model (used to select a proper LOD during rendering). - /// - BoundingSphere Bounds; - - /// - /// The per-instance random value. - /// - float PerInstanceRandom; - - /// - /// The LOD bias value. - /// - char LODBias; - - /// - /// The forced LOD to use. Value -1 disables this feature. - /// - char ForcedLOD; - }; - /// /// Draws the mesh. Binds vertex and index buffers and invokes the draw call. /// diff --git a/Source/Engine/Level/Actors/AnimatedModel.cpp b/Source/Engine/Level/Actors/AnimatedModel.cpp index ecaed39cb..9605119a3 100644 --- a/Source/Engine/Level/Actors/AnimatedModel.cpp +++ b/Source/Engine/Level/Actors/AnimatedModel.cpp @@ -737,6 +737,7 @@ void AnimatedModel::Draw(RenderContext& renderContext) draw.PerInstanceRandom = GetPerInstanceRandom(); draw.LODBias = LODBias; draw.ForcedLOD = ForcedLOD; + draw.SortOrder = SortOrder; SkinnedModel->Draw(renderContext, draw); } @@ -777,6 +778,7 @@ void AnimatedModel::Draw(RenderContextBatch& renderContextBatch) draw.PerInstanceRandom = GetPerInstanceRandom(); draw.LODBias = LODBias; draw.ForcedLOD = ForcedLOD; + draw.SortOrder = SortOrder; PRAGMA_DISABLE_DEPRECATION_WARNINGS if (ShadowsMode != ShadowsCastingMode::All) @@ -851,6 +853,7 @@ void AnimatedModel::Serialize(SerializeStream& stream, const void* otherObj) SERIALIZE(CustomBounds); SERIALIZE(LODBias); SERIALIZE(ForcedLOD); + SERIALIZE(SortOrder); SERIALIZE(DrawModes); PRAGMA_DISABLE_DEPRECATION_WARNINGS SERIALIZE(ShadowsMode); @@ -877,6 +880,7 @@ void AnimatedModel::Deserialize(DeserializeStream& stream, ISerializeModifier* m DESERIALIZE(CustomBounds); DESERIALIZE(LODBias); DESERIALIZE(ForcedLOD); + DESERIALIZE(SortOrder); DESERIALIZE(DrawModes); PRAGMA_DISABLE_DEPRECATION_WARNINGS DESERIALIZE(ShadowsMode); diff --git a/Source/Engine/Level/Actors/AnimatedModel.h b/Source/Engine/Level/Actors/AnimatedModel.h index f8cb18907..3c578d244 100644 --- a/Source/Engine/Level/Actors/AnimatedModel.h +++ b/Source/Engine/Level/Actors/AnimatedModel.h @@ -138,6 +138,12 @@ public: API_FIELD(Attributes="EditorOrder(100), DefaultValue(DrawPass.Default), EditorDisplay(\"Skinned Model\")") DrawPass DrawModes = DrawPass::Default; + /// + /// The object sort order key used when sorting drawable objects during rendering. Use lower values to draw object before others, higher values are rendered later (on top). Can be use to control transparency drawing. + /// + API_FIELD(Attributes="EditorDisplay(\"Skinned Model\"), EditorOrder(110), DefaultValue(0)") + int16 SortOrder = 0; + /// /// The shadows casting mode. /// [Deprecated on 26.10.2022, expires on 26.10.2024] From a219a3d2eb15c3a697fbff3d4f7ec043e252ba95 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 29 Jan 2023 22:09:51 +0100 Subject: [PATCH 02/23] Add **Depth Offset to materials** --- .../Features/DeferredShading.hlsl | 10 +++++++++- .../Features/ForwardShading.hlsl | 17 +++++++++++++---- Content/Editor/MaterialTemplates/Surface.shader | 13 +++++++++++-- Source/Editor/Surface/Archetypes/Material.cs | 10 +++++++++- Source/Engine/Content/Assets/Material.cpp | 4 ++++ Source/Engine/Graphics/Materials/MaterialInfo.h | 5 +++++ .../Engine/Graphics/Materials/MaterialShader.h | 2 +- .../MaterialGenerator.Layer.cpp | 2 ++ .../MaterialGenerator.Layers.cpp | 6 ++++++ .../MaterialGenerator/MaterialGenerator.cpp | 1 + .../Tools/MaterialGenerator/MaterialGenerator.h | 6 +++++- .../Tools/MaterialGenerator/MaterialLayer.cpp | 7 +++++-- Source/Shaders/MaterialCommon.hlsl | 3 ++- 13 files changed, 73 insertions(+), 13 deletions(-) diff --git a/Content/Editor/MaterialTemplates/Features/DeferredShading.hlsl b/Content/Editor/MaterialTemplates/Features/DeferredShading.hlsl index 556cc99a1..64cecd4f8 100644 --- a/Content/Editor/MaterialTemplates/Features/DeferredShading.hlsl +++ b/Content/Editor/MaterialTemplates/Features/DeferredShading.hlsl @@ -22,6 +22,9 @@ void PS_GBuffer( #if USE_GBUFFER_CUSTOM_DATA ,out float4 RT3 : SV_Target4 #endif +#endif +#if USE_DEPTH_OFFSET + ,out float Depth : SV_Depth #endif ) { @@ -36,11 +39,16 @@ void PS_GBuffer( MaterialInput materialInput = GetMaterialInput(input); Material material = GetMaterialPS(materialInput); + // Depth offset +#if USE_DEPTH_OFFSET + Depth = (materialInput.SvPosition.z * materialInput.SvPosition.w) / (materialInput.SvPosition.w + material.DepthOffset); +#endif + // Masking #if MATERIAL_MASKED clip(material.Mask - MATERIAL_MASK_THRESHOLD); #endif - + #if USE_LIGHTMAP float3 diffuseColor = GetDiffuseColor(material.Color, material.Metalness); float3 specularColor = GetSpecularColor(material.Color, material.Specular, material.Metalness); diff --git a/Content/Editor/MaterialTemplates/Features/ForwardShading.hlsl b/Content/Editor/MaterialTemplates/Features/ForwardShading.hlsl index d395a8bd1..68278f949 100644 --- a/Content/Editor/MaterialTemplates/Features/ForwardShading.hlsl +++ b/Content/Editor/MaterialTemplates/Features/ForwardShading.hlsl @@ -33,9 +33,15 @@ DECLARE_LIGHTSHADOWDATA_ACCESS(DirectionalLightShadow); // Pixel Shader function for Forward Pass META_PS(USE_FORWARD, FEATURE_LEVEL_ES2) -float4 PS_Forward(PixelInput input) : SV_Target0 +void PS_Forward( + in PixelInput input + ,out float4 output : SV_Target0 +#if USE_DEPTH_OFFSET + ,out float Depth : SV_Depth +#endif + ) { - float4 output = 0; + output = 0; #if USE_DITHERED_LOD_TRANSITION // LOD masking @@ -45,6 +51,11 @@ float4 PS_Forward(PixelInput input) : SV_Target0 // Get material parameters MaterialInput materialInput = GetMaterialInput(input); Material material = GetMaterialPS(materialInput); + + // Depth offset +#if USE_DEPTH_OFFSET + Depth = (materialInput.SvPosition.z * materialInput.SvPosition.w) / (materialInput.SvPosition.w + material.DepthOffset); +#endif // Masking #if MATERIAL_MASKED @@ -148,6 +159,4 @@ float4 PS_Forward(PixelInput input) : SV_Target0 #endif #endif - - return output; } diff --git a/Content/Editor/MaterialTemplates/Surface.shader b/Content/Editor/MaterialTemplates/Surface.shader index 0e7c948a1..3e93ddbb6 100644 --- a/Content/Editor/MaterialTemplates/Surface.shader +++ b/Content/Editor/MaterialTemplates/Surface.shader @@ -587,14 +587,18 @@ void ClipLODTransition(PixelInput input) // Pixel Shader function for Depth Pass META_PS(true, FEATURE_LEVEL_ES2) -void PS_Depth(PixelInput input) +void PS_Depth(PixelInput input +#if USE_DEPTH_OFFSET + ,out float Depth : SV_Depth +#endif + ) { #if USE_DITHERED_LOD_TRANSITION // LOD masking ClipLODTransition(input); #endif -#if MATERIAL_MASKED || MATERIAL_BLEND != MATERIAL_BLEND_OPAQUE +#if MATERIAL_MASKED || MATERIAL_BLEND != MATERIAL_BLEND_OPAQUE || USE_DEPTH_OFFSET // Get material parameters MaterialInput materialInput = GetMaterialInput(input); Material material = GetMaterialPS(materialInput); @@ -606,6 +610,11 @@ void PS_Depth(PixelInput input) #if MATERIAL_BLEND != MATERIAL_BLEND_OPAQUE clip(material.Opacity - MATERIAL_OPACITY_THRESHOLD); #endif + + // Depth offset +#if USE_DEPTH_OFFSET + Depth = (materialInput.SvPosition.z * materialInput.SvPosition.w) / (materialInput.SvPosition.w + material.DepthOffset); +#endif #endif } diff --git a/Source/Editor/Surface/Archetypes/Material.cs b/Source/Editor/Surface/Archetypes/Material.cs index 1a797c67d..5182dba50 100644 --- a/Source/Editor/Surface/Archetypes/Material.cs +++ b/Source/Editor/Surface/Archetypes/Material.cs @@ -40,6 +40,7 @@ namespace FlaxEditor.Surface.Archetypes TessellationMultiplier = 12, WorldDisplacement = 13, SubsurfaceColor = 14, + DepthOffset = 15, }; /// @@ -85,6 +86,7 @@ namespace FlaxEditor.Surface.Archetypes GetBox(MaterialNodeBoxes.TessellationMultiplier).Enabled = false; GetBox(MaterialNodeBoxes.WorldDisplacement).Enabled = false; GetBox(MaterialNodeBoxes.SubsurfaceColor).Enabled = false; + GetBox(MaterialNodeBoxes.DepthOffset).Enabled = false; return; } @@ -116,6 +118,7 @@ namespace FlaxEditor.Surface.Archetypes GetBox(MaterialNodeBoxes.TessellationMultiplier).Enabled = withTess; GetBox(MaterialNodeBoxes.WorldDisplacement).Enabled = withTess; GetBox(MaterialNodeBoxes.SubsurfaceColor).Enabled = info.ShadingModel == MaterialShadingModel.Subsurface || info.ShadingModel == MaterialShadingModel.Foliage; + GetBox(MaterialNodeBoxes.DepthOffset).Enabled = true; break; } case MaterialDomain.PostProcess: @@ -134,6 +137,7 @@ namespace FlaxEditor.Surface.Archetypes GetBox(MaterialNodeBoxes.TessellationMultiplier).Enabled = false; GetBox(MaterialNodeBoxes.WorldDisplacement).Enabled = false; GetBox(MaterialNodeBoxes.SubsurfaceColor).Enabled = false; + GetBox(MaterialNodeBoxes.DepthOffset).Enabled = false; break; } case MaterialDomain.Decal: @@ -154,6 +158,7 @@ namespace FlaxEditor.Surface.Archetypes GetBox(MaterialNodeBoxes.TessellationMultiplier).Enabled = false; GetBox(MaterialNodeBoxes.WorldDisplacement).Enabled = false; GetBox(MaterialNodeBoxes.SubsurfaceColor).Enabled = false; + GetBox(MaterialNodeBoxes.DepthOffset).Enabled = false; break; } case MaterialDomain.GUI: @@ -172,6 +177,7 @@ namespace FlaxEditor.Surface.Archetypes GetBox(MaterialNodeBoxes.TessellationMultiplier).Enabled = false; GetBox(MaterialNodeBoxes.WorldDisplacement).Enabled = false; GetBox(MaterialNodeBoxes.SubsurfaceColor).Enabled = false; + GetBox(MaterialNodeBoxes.DepthOffset).Enabled = false; break; } case MaterialDomain.VolumeParticle: @@ -190,6 +196,7 @@ namespace FlaxEditor.Surface.Archetypes GetBox(MaterialNodeBoxes.TessellationMultiplier).Enabled = false; GetBox(MaterialNodeBoxes.WorldDisplacement).Enabled = false; GetBox(MaterialNodeBoxes.SubsurfaceColor).Enabled = false; + GetBox(MaterialNodeBoxes.DepthOffset).Enabled = false; break; } default: throw new ArgumentOutOfRangeException(); @@ -281,7 +288,7 @@ namespace FlaxEditor.Surface.Archetypes Title = "Material", Description = "Main material node", Flags = NodeFlags.MaterialGraph | NodeFlags.NoRemove | NodeFlags.NoSpawnViaGUI | NodeFlags.NoSpawnViaPaste | NodeFlags.NoCloseButton, - Size = new Float2(150, 300), + Size = new Float2(150, 320), Elements = new[] { NodeElementArchetype.Factory.Input(0, "", true, typeof(void), 0), @@ -299,6 +306,7 @@ namespace FlaxEditor.Surface.Archetypes NodeElementArchetype.Factory.Input(12, "Tessellation Multiplier", true, typeof(float), 12), NodeElementArchetype.Factory.Input(13, "World Displacement", true, typeof(Float3), 13), NodeElementArchetype.Factory.Input(14, "Subsurface Color", true, typeof(Float3), 14), + NodeElementArchetype.Factory.Input(15, "Depth Offset", true, typeof(float), 15), } }, new NodeArchetype diff --git a/Source/Engine/Content/Assets/Material.cpp b/Source/Engine/Content/Assets/Material.cpp index 76ed34b80..fb2313ff7 100644 --- a/Source/Engine/Content/Assets/Material.cpp +++ b/Source/Engine/Content/Assets/Material.cpp @@ -426,6 +426,9 @@ void Material::InitCompilationOptions(ShaderCompilationOptions& options) info.BlendMode != MaterialBlendMode::Opaque && EnumHasAnyFlags(info.UsageFlags, MaterialUsageFlags::UseRefraction) && (info.FeaturesFlags & MaterialFeaturesFlags::DisableDistortion) == MaterialFeaturesFlags::None; + const bool useDepthOffset = + (info.Domain == MaterialDomain::Surface) && + EnumHasAnyFlags(info.UsageFlags, MaterialUsageFlags::UseDepthOffset); // @formatter:off static const char* Numbers[] = @@ -496,6 +499,7 @@ void Material::InitCompilationOptions(ShaderCompilationOptions& options) options.Macros.Add({ "USE_FORWARD", Numbers[useForward ? 1 : 0] }); options.Macros.Add({ "USE_DEFERRED", Numbers[isSurfaceOrTerrainOrDeformable && info.BlendMode == MaterialBlendMode::Opaque ? 1 : 0] }); options.Macros.Add({ "USE_DISTORTION", Numbers[useDistortion ? 1 : 0] }); + options.Macros.Add({ "USE_DEPTH_OFFSET", Numbers[useDepthOffset ? 1 : 0] }); #endif } diff --git a/Source/Engine/Graphics/Materials/MaterialInfo.h b/Source/Engine/Graphics/Materials/MaterialInfo.h index 86fab4548..11eb8c14f 100644 --- a/Source/Engine/Graphics/Materials/MaterialInfo.h +++ b/Source/Engine/Graphics/Materials/MaterialInfo.h @@ -330,6 +330,11 @@ API_ENUM(Attributes="Flags") enum class MaterialUsageFlags : uint32 /// The flag used to indicate that material uses refraction feature. /// UseRefraction = 1 << 6, + + /// + /// The flag used to indicate that material uses per-pixel depth offset feature. + /// + UseDepthOffset = 1 << 7, }; DECLARE_ENUM_OPERATORS(MaterialUsageFlags); diff --git a/Source/Engine/Graphics/Materials/MaterialShader.h b/Source/Engine/Graphics/Materials/MaterialShader.h index 007afee67..48a9abe5e 100644 --- a/Source/Engine/Graphics/Materials/MaterialShader.h +++ b/Source/Engine/Graphics/Materials/MaterialShader.h @@ -10,7 +10,7 @@ /// /// Current materials shader version. /// -#define MATERIAL_GRAPH_VERSION 159 +#define MATERIAL_GRAPH_VERSION 160 class Material; class GPUShader; diff --git a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Layer.cpp b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Layer.cpp index b7af16cb2..993a61469 100644 --- a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Layer.cpp +++ b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Layer.cpp @@ -27,10 +27,12 @@ MaterialGenerator::MaterialGraphBoxesMapping MaterialGenerator::MaterialGraphBox { 12, TEXT("TessellationMultiplier"), MaterialTreeType::VertexShader, MaterialValue(VariantType::Float, TEXT("4.0f")) }, { 13, TEXT("WorldDisplacement"), MaterialTreeType::DomainShader, MaterialValue::InitForZero(VariantType::Float3) }, { 14, TEXT("SubsurfaceColor"), MaterialTreeType::PixelShader, MaterialValue::InitForZero(VariantType::Float3) }, + { 15, TEXT("DepthOffset"), MaterialTreeType::PixelShader, MaterialValue::InitForZero(VariantType::Float) }, }; const MaterialGenerator::MaterialGraphBoxesMapping& MaterialGenerator::GetMaterialRootNodeBox(MaterialGraphBoxes box) { + static_assert(ARRAY_COUNT(MaterialGenerator::MaterialGraphBoxesMappings) == 16, "Invalid amount of boxes added for root node. Please update the code above"); return MaterialGraphBoxesMappings[static_cast(box)]; } diff --git a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Layers.cpp b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Layers.cpp index 63718b329..7007bf7d9 100644 --- a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Layers.cpp +++ b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Layers.cpp @@ -103,6 +103,7 @@ void MaterialGenerator::ProcessGroupLayers(Box* box, Node* node, Value& value) EAT_BOX(AmbientOcclusion); EAT_BOX(Opacity); EAT_BOX(Refraction); + EAT_BOX(DepthOffset); EAT_BOX(Mask); EAT_BOX(Emissive); EAT_BOX(SubsurfaceColor); @@ -204,6 +205,7 @@ void MaterialGenerator::ProcessGroupLayers(Box* box, Node* node, Value& value) EAT_BOX(AmbientOcclusion); EAT_BOX(Opacity); EAT_BOX(Refraction); + EAT_BOX(DepthOffset); EAT_BOX(Mask); EAT_BOX(Emissive); EAT_BOX(SubsurfaceColor); @@ -246,12 +248,15 @@ void MaterialGenerator::ProcessGroupLayers(Box* box, Node* node, Value& value) EAT_BOX(AmbientOcclusion); EAT_BOX(Opacity); EAT_BOX(Refraction); + EAT_BOX(DepthOffset); EAT_BOX(Mask); EAT_BOX(Emissive); CHECK_MATERIAL_FEATURE(Emissive, UseEmissive); CHECK_MATERIAL_FEATURE(Normal, UseNormal); CHECK_MATERIAL_FEATURE(Mask, UseMask); + CHECK_MATERIAL_FEATURE(Refraction, UseRefraction); + CHECK_MATERIAL_FEATURE(DepthOffset, UseDepthOffset); break; } @@ -331,6 +336,7 @@ void MaterialGenerator::ProcessGroupLayers(Box* box, Node* node, Value& value) CHECK_MATERIAL_FEATURE(Normal, UseNormal); CHECK_MATERIAL_FEATURE(Mask, UseMask); CHECK_MATERIAL_FEATURE(Refraction, UseRefraction); + CHECK_MATERIAL_FEATURE(DepthOffset, UseDepthOffset); break; } diff --git a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.cpp b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.cpp index b1aab0049..20722e494 100644 --- a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.cpp +++ b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.cpp @@ -256,6 +256,7 @@ bool MaterialGenerator::Generate(WriteStream& source, MaterialInfo& materialInfo eatMaterialGraphBox(baseLayer, MaterialGraphBoxes::Roughness); eatMaterialGraphBox(baseLayer, MaterialGraphBoxes::Opacity); eatMaterialGraphBox(baseLayer, MaterialGraphBoxes::Refraction); + eatMaterialGraphBox(baseLayer, MaterialGraphBoxes::DepthOffset); eatMaterialGraphBox(baseLayer, MaterialGraphBoxes::SubsurfaceColor); eatMaterialGraphBox(baseLayer, MaterialGraphBoxes::Mask); } diff --git a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.h b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.h index 92f238508..d0823d359 100644 --- a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.h +++ b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.h @@ -6,7 +6,6 @@ #include "Engine/Graphics/Materials/MaterialInfo.h" #include "Engine/Graphics/Materials/MaterialParams.h" -#include "Engine/Content/AssetsContainer.h" #include "MaterialLayer.h" #include "Types.h" @@ -90,6 +89,11 @@ enum class MaterialGraphBoxes /// SubsurfaceColor = 14, + /// + /// The custom depth offset applied per-pixel. + /// + DepthOffset = 15, + /// /// The amount of input boxes. /// diff --git a/Source/Engine/Tools/MaterialGenerator/MaterialLayer.cpp b/Source/Engine/Tools/MaterialGenerator/MaterialLayer.cpp index 33b3dfed3..8de2d6edb 100644 --- a/Source/Engine/Tools/MaterialGenerator/MaterialLayer.cpp +++ b/Source/Engine/Tools/MaterialGenerator/MaterialLayer.cpp @@ -129,6 +129,7 @@ void MaterialLayer::UpdateFeaturesFlags() CHECK_BOX_AS_FEATURE(PositionOffset, UsePositionOffset); CHECK_BOX_AS_FEATURE(WorldDisplacement, UseDisplacement); CHECK_BOX_AS_FEATURE(Refraction, UseRefraction); + CHECK_BOX_AS_FEATURE(DepthOffset, UseDepthOffset); #undef CHECK_BOX_AS_FEATURE } @@ -179,7 +180,8 @@ MaterialLayer* MaterialLayer::Load(const Guid& id, ReadStream* graphData, const ADD_BOX(TessellationMultiplier, Float); ADD_BOX(WorldDisplacement, Float3); ADD_BOX(SubsurfaceColor, Float3); - static_assert(static_cast(MaterialGraphBoxes::MAX) == 15, "Invalid amount of boxes added for root node. Please update the code above"); + ADD_BOX(DepthOffset, Float); + static_assert(static_cast(MaterialGraphBoxes::MAX) == 16, "Invalid amount of boxes added for root node. Please update the code above"); ASSERT(layer->Root->Boxes.Count() == static_cast(MaterialGraphBoxes::MAX)); #if BUILD_DEBUG // Test for valid pointers after node upgrade @@ -225,11 +227,12 @@ void MaterialLayer::createRootNode() INIT_BOX(Normal, Float3); INIT_BOX(Opacity, Float); INIT_BOX(Refraction, Float); + INIT_BOX(DepthOffset, Float); INIT_BOX(PositionOffset, Float3); INIT_BOX(TessellationMultiplier, Float); INIT_BOX(WorldDisplacement, Float3); INIT_BOX(SubsurfaceColor, Float3); - static_assert(static_cast(MaterialGraphBoxes::MAX) == 15, "Invalid amount of boxes created for root node. Please update the code above"); + static_assert(static_cast(MaterialGraphBoxes::MAX) == 16, "Invalid amount of boxes created for root node. Please update the code above"); #undef INIT_BOX // Mark as root diff --git a/Source/Shaders/MaterialCommon.hlsl b/Source/Shaders/MaterialCommon.hlsl index 1f516a4fc..01ba12e8c 100644 --- a/Source/Shaders/MaterialCommon.hlsl +++ b/Source/Shaders/MaterialCommon.hlsl @@ -83,9 +83,10 @@ struct Material float Opacity; float3 SubsurfaceColor; float Refraction; + float3 WorldDisplacement; float Mask; float TessellationMultiplier; - float3 WorldDisplacement; + float DepthOffset; #if USE_CUSTOM_VERTEX_INTERPOLATORS float4 CustomVSToPS[CUSTOM_VERTEX_INTERPOLATORS_COUNT]; #endif From 238095b86291143f7d48e9ab094875f13a8bd87e Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 29 Jan 2023 22:10:22 +0100 Subject: [PATCH 03/23] Add `DefaultValue` support for scripting parameters --- Source/Tools/Flax.Build/Bindings/BindingsGenerator.Parsing.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Parsing.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Parsing.cs index 1f8f46815..bca9b2d9d 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Parsing.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Parsing.cs @@ -337,6 +337,9 @@ namespace Flax.Build.Bindings case "attributes": currentParam.Attributes = tag.Value; break; + case "defaultvalue": + currentParam.DefaultValue = tag.Value; + break; default: bool valid = false; ParseFunctionParameterTag?.Invoke(ref valid, tag, ref currentParam); From 9b3d15aa46293158649c5de4161e639c810e0db2 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 30 Jan 2023 00:52:32 +0100 Subject: [PATCH 04/23] Add `Renderer::DrawActors` for quick actors rendering in custom render passes --- Source/Engine/Renderer/RenderList.cpp | 6 ++++ Source/Engine/Renderer/Renderer.cpp | 44 ++++++++++++++++----------- Source/Engine/Renderer/Renderer.cs | 12 ++++++++ Source/Engine/Renderer/Renderer.h | 12 +++++--- 4 files changed, 52 insertions(+), 22 deletions(-) diff --git a/Source/Engine/Renderer/RenderList.cpp b/Source/Engine/Renderer/RenderList.cpp index f34c2c358..86f3b29a5 100644 --- a/Source/Engine/Renderer/RenderList.cpp +++ b/Source/Engine/Renderer/RenderList.cpp @@ -2,6 +2,9 @@ #include "RenderList.h" #include "Engine/Core/Collections/Sorting.h" +#if !BUILD_RELEASE +#include "Engine/Core/Utilities.h" +#endif #include "Engine/Graphics/Materials/IMaterial.h" #include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/GPUContext.h" @@ -646,6 +649,9 @@ void RenderList::ExecuteDrawCalls(const RenderContext& renderContext, DrawCallsL { if (list.IsEmpty()) return; +#if !BUILD_RELEASE + CHECK(Utilities::CountBits((uint32)renderContext.View.Pass) == 1); // Ensure proper pass is set (single bit flag) +#endif PROFILE_GPU_CPU("Drawing"); const auto* drawCallsData = drawCalls.Get(); const auto* listData = list.Indices.Get(); diff --git a/Source/Engine/Renderer/Renderer.cpp b/Source/Engine/Renderer/Renderer.cpp index 295a2ea77..965a9bf5a 100644 --- a/Source/Engine/Renderer/Renderer.cpp +++ b/Source/Engine/Renderer/Renderer.cpp @@ -236,24 +236,7 @@ void Renderer::DrawSceneDepth(GPUContext* context, SceneRenderTask* task, GPUTex renderContext.View.Prepare(renderContext); // Call drawing (will collect draw calls) - if (customActors.HasItems()) - { - // Draw custom actors - for (auto actor : customActors) - { - if (actor && actor->GetIsActive()) - actor->Draw(renderContext); - } - } - else - { - // Draw scene actors - RenderContextBatch renderContextBatch(renderContext); - Level::DrawActors(renderContextBatch); - for (const int64 label : renderContextBatch.WaitLabels) - JobSystem::Wait(label); - renderContextBatch.WaitLabels.Clear(); - } + DrawActors(renderContext, customActors); // Sort draw calls renderContext.List->SortDrawCalls(renderContext, false, DrawCallsListType::Depth); @@ -287,6 +270,31 @@ void Renderer::DrawPostFxMaterial(GPUContext* context, const RenderContext& rend context->ResetRenderTarget(); } +void Renderer::DrawActors(RenderContext& renderContext, const Array& customActors) +{ + if (customActors.HasItems()) + { + // Draw custom actors + for (Actor* actor : customActors) + { + if (actor && actor->GetIsActive()) + actor->Draw(renderContext); + } + } + else + { + // Draw scene actors + RenderContextBatch renderContextBatch(renderContext); + JobSystem::SetJobStartingOnDispatch(false); + Level::DrawActors(renderContextBatch, SceneRendering::DrawCategory::SceneDraw); + Level::DrawActors(renderContextBatch, SceneRendering::DrawCategory::SceneDrawAsync); + JobSystem::SetJobStartingOnDispatch(true); + for (const int64 label : renderContextBatch.WaitLabels) + JobSystem::Wait(label); + renderContextBatch.WaitLabels.Clear(); + } +} + void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderContextBatch& renderContextBatch) { auto context = GPUDevice::Instance->GetMainContext(); diff --git a/Source/Engine/Renderer/Renderer.cs b/Source/Engine/Renderer/Renderer.cs index 2e20efe18..564724460 100644 --- a/Source/Engine/Renderer/Renderer.cs +++ b/Source/Engine/Renderer/Renderer.cs @@ -13,9 +13,21 @@ namespace FlaxEngine /// Render task to use it's view description and the render buffers. /// The output texture. Must be valid and created. /// The custom set of actors to render. If empty, the loaded scenes will be rendered. + [Unmanaged] public static void DrawSceneDepth(GPUContext context, SceneRenderTask task, GPUTexture output, List customActors) { Internal_DrawSceneDepth(FlaxEngine.Object.GetUnmanagedPtr(context), FlaxEngine.Object.GetUnmanagedPtr(task), FlaxEngine.Object.GetUnmanagedPtr(output), Utils.ExtractArrayFromList(customActors)); } + + /// + /// Invoked drawing of the scene objects (collects draw calls into RenderList for a given RenderContext). + /// + /// The rendering context. + /// The custom set of actors to render. If empty, the loaded scenes will be rendered. + [Unmanaged] + public static void DrawActors(ref RenderContext renderContext, List customActors) + { + Internal_DrawActors(ref renderContext, Utils.ExtractArrayFromList(customActors)); + } } } diff --git a/Source/Engine/Renderer/Renderer.h b/Source/Engine/Renderer/Renderer.h index 654dde929..794a6dcc4 100644 --- a/Source/Engine/Renderer/Renderer.h +++ b/Source/Engine/Renderer/Renderer.h @@ -18,13 +18,11 @@ class Actor; /// API_CLASS(Static) class FLAXENGINE_API Renderer { -DECLARE_SCRIPTING_TYPE_NO_SPAWN(Renderer); + DECLARE_SCRIPTING_TYPE_NO_SPAWN(Renderer); public: - /// /// Determines whether the scene rendering system is ready (all shaders are loaded and helper resources are ready). /// - /// true if this rendering service is ready for scene rendering; otherwise, false. static bool IsReady(); /// @@ -34,7 +32,6 @@ public: static void Render(SceneRenderTask* task); public: - /// /// Draws scene objects depth (to the output Z buffer). The output must be depth texture to write hardware depth to it. /// @@ -53,4 +50,11 @@ public: /// The output texture. Must be valid and created. /// The input texture. It's optional. API_FUNCTION() static void DrawPostFxMaterial(GPUContext* context, API_PARAM(Ref) const RenderContext& renderContext, MaterialBase* material, GPUTexture* output, GPUTextureView* input); + + /// + /// Invoked drawing of the scene objects (collects draw calls into RenderList for a given RenderContext). + /// + /// The rendering context. + /// The custom set of actors to render. If empty, the loaded scenes will be rendered. + API_FUNCTION() static void DrawActors(API_PARAM(Ref) RenderContext& renderContext, API_PARAM(DefaultValue=null) const Array& customActors); }; From 5a3088308208e1346fa77ec872952b89e3dd89ce Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 31 Jan 2023 09:28:19 +0100 Subject: [PATCH 05/23] Add `AfterGBufferPass` for custom PostFx location --- Source/Engine/Graphics/Enums.h | 7 ++++++- Source/Engine/Renderer/GBufferPass.cpp | 14 +++++++++----- Source/Engine/Renderer/GBufferPass.h | 2 +- Source/Engine/Renderer/RenderList.cpp | 6 +++--- Source/Engine/Renderer/Renderer.cpp | 2 +- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Source/Engine/Graphics/Enums.h b/Source/Engine/Graphics/Enums.h index 2bbef6085..f419fbb71 100644 --- a/Source/Engine/Graphics/Enums.h +++ b/Source/Engine/Graphics/Enums.h @@ -635,7 +635,7 @@ API_ENUM() enum class PostProcessEffectLocation Default = 0, /// - ///The 'before' in-build PostFx pass (bloom, color grading, etc.). After Forward Pass (transparency) and fog effects. + /// The 'before' in-build PostFx pass (bloom, color grading, etc.). After Forward Pass (transparency) and fog effects. /// BeforePostProcessingPass = 1, @@ -659,6 +659,11 @@ API_ENUM() enum class PostProcessEffectLocation /// CustomUpscale = 5, + /// + /// The 'after' GBuffer rendering pass. Can be used to render custom geometry into GBuffer. Output is light buffer, single-target only (no output). + /// + AfterGBufferPass = 6, + API_ENUM(Attributes="HideInEditor") MAX, }; diff --git a/Source/Engine/Renderer/GBufferPass.cpp b/Source/Engine/Renderer/GBufferPass.cpp index 87ddf1bf2..0e548afea 100644 --- a/Source/Engine/Renderer/GBufferPass.cpp +++ b/Source/Engine/Renderer/GBufferPass.cpp @@ -146,7 +146,7 @@ void DebugOverrideDrawCallsMaterial(const RenderContext& renderContext, IMateria #endif -void GBufferPass::Fill(RenderContext& renderContext, GPUTextureView* lightBuffer) +void GBufferPass::Fill(RenderContext& renderContext, GPUTexture* lightBuffer) { PROFILE_GPU_CPU("GBuffer"); @@ -155,7 +155,7 @@ void GBufferPass::Fill(RenderContext& renderContext, GPUTextureView* lightBuffer auto context = device->GetMainContext(); GPUTextureView* targetBuffers[5] = { - lightBuffer, + lightBuffer->View(), renderContext.Buffers->GBuffer0->View(), renderContext.Buffers->GBuffer1->View(), renderContext.Buffers->GBuffer2->View(), @@ -168,7 +168,7 @@ void GBufferPass::Fill(RenderContext& renderContext, GPUTextureView* lightBuffer PROFILE_GPU_CPU_NAMED("Clear"); context->ClearDepth(*renderContext.Buffers->DepthBuffer); - context->Clear(lightBuffer, Color::Transparent); + context->Clear(lightBuffer->View(), Color::Transparent); context->Clear(renderContext.Buffers->GBuffer0->View(), Color::Transparent); context->Clear(renderContext.Buffers->GBuffer1->View(), Color::Transparent); context->Clear(renderContext.Buffers->GBuffer2->View(), Color(1, 0, 0, 0)); @@ -192,7 +192,7 @@ void GBufferPass::Fill(RenderContext& renderContext, GPUTextureView* lightBuffer renderContext.List->Sky->ApplySky(context, renderContext, Matrix::Identity); GPUPipelineState* materialPs = context->GetState(); const float complexity = (float)Math::Min(materialPs->Complexity, MATERIAL_COMPLEXITY_LIMIT) / MATERIAL_COMPLEXITY_LIMIT; - context->Clear(lightBuffer, Color(complexity, complexity, complexity, 1.0f)); + context->Clear(lightBuffer->View(), Color(complexity, complexity, complexity, 1.0f)); renderContext.List->Sky = nullptr; } } @@ -208,16 +208,20 @@ void GBufferPass::Fill(RenderContext& renderContext, GPUTextureView* lightBuffer renderContext.List->ExecuteDrawCalls(renderContext, DrawCallsListType::GBuffer); // Draw decals - DrawDecals(renderContext, lightBuffer); + DrawDecals(renderContext, lightBuffer->View()); // Draw objects that cannot get decals context->SetRenderTarget(*renderContext.Buffers->DepthBuffer, ToSpan(targetBuffers, ARRAY_COUNT(targetBuffers))); renderContext.List->ExecuteDrawCalls(renderContext, DrawCallsListType::GBufferNoDecals); + GPUTexture* nullTexture = nullptr; + renderContext.List->RunCustomPostFxPass(context, renderContext, PostProcessEffectLocation::AfterGBufferPass, lightBuffer, nullTexture); + // Draw sky if (renderContext.List->Sky && _skyModel && _skyModel->CanBeRendered()) { PROFILE_GPU_CPU_NAMED("Sky"); + context->SetRenderTarget(*renderContext.Buffers->DepthBuffer, ToSpan(targetBuffers, ARRAY_COUNT(targetBuffers))); DrawSky(renderContext, context); } diff --git a/Source/Engine/Renderer/GBufferPass.h b/Source/Engine/Renderer/GBufferPass.h index d33d92b22..6ff59d1d9 100644 --- a/Source/Engine/Renderer/GBufferPass.h +++ b/Source/Engine/Renderer/GBufferPass.h @@ -32,7 +32,7 @@ public: /// /// The rendering context. /// Light buffer to output material emissive light and precomputed indirect lighting - void Fill(RenderContext& renderContext, GPUTextureView* lightBuffer); + void Fill(RenderContext& renderContext, GPUTexture* lightBuffer); /// /// Render debug view diff --git a/Source/Engine/Renderer/RenderList.cpp b/Source/Engine/Renderer/RenderList.cpp index 86f3b29a5..17bd8ee16 100644 --- a/Source/Engine/Renderer/RenderList.cpp +++ b/Source/Engine/Renderer/RenderList.cpp @@ -268,7 +268,7 @@ void RenderList::RunPostFxPass(GPUContext* context, RenderContext& renderContext { if (fx->Location == locationB) { - if (fx->UseSingleTarget) + if (fx->UseSingleTarget || output == nullptr) { fx->Render(context, renderContext, input, nullptr); } @@ -301,9 +301,9 @@ void RenderList::RunMaterialPostFxPass(GPUContext* context, RenderContext& rende bindParams.Input = *input; material->Bind(bindParams); context->DrawFullscreenTriangle(); - context->ResetRenderTarget(); Swap(output, input); } + context->ResetRenderTarget(); } } @@ -315,7 +315,7 @@ void RenderList::RunCustomPostFxPass(GPUContext* context, RenderContext& renderC { if (fx->Location == location) { - if (fx->UseSingleTarget) + if (fx->UseSingleTarget || output == nullptr) { fx->Render(context, renderContext, input, nullptr); } diff --git a/Source/Engine/Renderer/Renderer.cpp b/Source/Engine/Renderer/Renderer.cpp index 965a9bf5a..550c7c4e7 100644 --- a/Source/Engine/Renderer/Renderer.cpp +++ b/Source/Engine/Renderer/Renderer.cpp @@ -431,7 +431,7 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont } // Fill GBuffer - GBufferPass::Instance()->Fill(renderContext, lightBuffer->View()); + GBufferPass::Instance()->Fill(renderContext, lightBuffer); // Debug drawing if (renderContext.View.Mode == ViewMode::GlobalSDF) From c9fce7e4aa01a69f7812e6013e58c0b02e7aa349 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 31 Jan 2023 09:28:48 +0100 Subject: [PATCH 06/23] Add GBuffer textures to the C# scripting --- Source/Engine/Graphics/RenderBuffers.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Source/Engine/Graphics/RenderBuffers.h b/Source/Engine/Graphics/RenderBuffers.h index 86a621afc..23db15523 100644 --- a/Source/Engine/Graphics/RenderBuffers.h +++ b/Source/Engine/Graphics/RenderBuffers.h @@ -45,10 +45,14 @@ public: { struct { - GPUTexture* GBuffer0; - GPUTexture* GBuffer1; - GPUTexture* GBuffer2; - GPUTexture* GBuffer3; + /// Gets the GBuffer texture 0. RGB: Color, A: AO + API_FIELD(ReadOnly) GPUTexture* GBuffer0; + /// Gets the GBuffer texture 1. RGB: Normal, A: ShadingModel + API_FIELD(ReadOnly) GPUTexture* GBuffer1; + /// Gets the GBuffer texture 2. R: Roughness, G: Metalness, B:Specular + API_FIELD(ReadOnly) GPUTexture* GBuffer2; + /// Gets the GBuffer texture 3. RGBA: Custom Data + API_FIELD(ReadOnly) GPUTexture* GBuffer3; }; GPUTexture* GBuffer[4]; From c39d1283f8080fdb692a62c432707d3cd0598a19 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 31 Jan 2023 09:29:04 +0100 Subject: [PATCH 07/23] Add sort order for custom model drawing --- Source/Engine/Content/Assets/Model.cpp | 4 ++-- Source/Engine/Content/Assets/Model.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Engine/Content/Assets/Model.cpp b/Source/Engine/Content/Assets/Model.cpp index d54bc1ae8..9319f2667 100644 --- a/Source/Engine/Content/Assets/Model.cpp +++ b/Source/Engine/Content/Assets/Model.cpp @@ -187,7 +187,7 @@ BoundingBox Model::GetBox(int32 lodIndex) const return LODs[lodIndex].GetBox(); } -void Model::Draw(const RenderContext& renderContext, MaterialBase* material, const Matrix& world, StaticFlags flags, bool receiveDecals) const +void Model::Draw(const RenderContext& renderContext, MaterialBase* material, const Matrix& world, StaticFlags flags, bool receiveDecals, int16 sortOrder) const { if (!CanBeRendered()) return; @@ -203,7 +203,7 @@ void Model::Draw(const RenderContext& renderContext, MaterialBase* material, con lodIndex = ClampLODIndex(lodIndex); // Draw - LODs[lodIndex].Draw(renderContext, material, world, flags, receiveDecals); + LODs[lodIndex].Draw(renderContext, material, world, flags, receiveDecals, DrawPass::Default, 0, sortOrder); } template diff --git a/Source/Engine/Content/Assets/Model.h b/Source/Engine/Content/Assets/Model.h index ffc14d5da..d0ddee758 100644 --- a/Source/Engine/Content/Assets/Model.h +++ b/Source/Engine/Content/Assets/Model.h @@ -181,7 +181,8 @@ public: /// The world transformation of the model. /// The object static flags. /// True if rendered geometry can receive decals, otherwise false. - API_FUNCTION() void Draw(API_PARAM(Ref) const RenderContext& renderContext, MaterialBase* material, API_PARAM(Ref) const Matrix& world, StaticFlags flags = StaticFlags::None, bool receiveDecals = true) const; + /// Object sorting key. + API_FUNCTION() void Draw(API_PARAM(Ref) const RenderContext& renderContext, MaterialBase* material, API_PARAM(Ref) const Matrix& world, StaticFlags flags = StaticFlags::None, bool receiveDecals = true, int16 sortOrder = 0) const; /// /// Draws the model. From c46ea56af2783968d7dfea3e43aba1a34d528c47 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 31 Jan 2023 14:04:00 +0100 Subject: [PATCH 08/23] Rename `DepthTestEnable` to `DepthEnable` in Graphics PSO to match actual logic --- Source/Engine/Debug/DebugDraw.cpp | 6 +++--- Source/Engine/Graphics/GPUDevice.cpp | 2 +- Source/Engine/Graphics/GPUPipelineState.h | 10 +++++----- .../Graphics/Materials/DeferredMaterialShader.cpp | 11 ++++++++--- .../Graphics/Materials/DeformableMaterialShader.cpp | 4 ++-- .../Graphics/Materials/ForwardMaterialShader.cpp | 4 ++-- .../Engine/Graphics/Materials/GUIMaterialShader.cpp | 4 ++-- .../Graphics/Materials/ParticleMaterialShader.cpp | 2 +- .../Graphics/Materials/TerrainMaterialShader.cpp | 4 ++-- .../DirectX/DX11/GPUPipelineStateDX11.cpp | 2 +- .../DirectX/DX12/GPUPipelineStateDX12.cpp | 2 +- .../GraphicsDevice/Vulkan/GPUPipelineStateVulkan.cpp | 2 +- Source/Engine/Render2D/Render2D.cpp | 2 +- Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp | 4 ++-- Source/Engine/Renderer/LightPass.cpp | 4 ++-- Source/Engine/Renderer/Utils/MultiScaler.cpp | 2 +- 16 files changed, 35 insertions(+), 30 deletions(-) diff --git a/Source/Engine/Debug/DebugDraw.cpp b/Source/Engine/Debug/DebugDraw.cpp index 0b58172ab..a1dfa0b61 100644 --- a/Source/Engine/Debug/DebugDraw.cpp +++ b/Source/Engine/Debug/DebugDraw.cpp @@ -140,13 +140,13 @@ struct PsData bool Create(GPUPipelineState::Description& desc) { - desc.DepthTestEnable = true; + desc.DepthEnable = true; desc.DepthWriteEnable = false; Depth = GPUDevice::Instance->CreatePipelineState(); if (Depth->Init(desc)) return true; - desc.DepthTestEnable = false; + desc.DepthEnable = false; NoDepthTest = GPUDevice::Instance->CreatePipelineState(); if (NoDepthTest->Init(desc)) return false; @@ -156,7 +156,7 @@ struct PsData NoDepthTestDepthWrite = GPUDevice::Instance->CreatePipelineState(); if (NoDepthTestDepthWrite->Init(desc)) return false; - desc.DepthTestEnable = true; + desc.DepthEnable = true; DepthWrite = GPUDevice::Instance->CreatePipelineState(); return DepthWrite->Init(desc); } diff --git a/Source/Engine/Graphics/GPUDevice.cpp b/Source/Engine/Graphics/GPUDevice.cpp index 1c3ade229..fe7c59e3a 100644 --- a/Source/Engine/Graphics/GPUDevice.cpp +++ b/Source/Engine/Graphics/GPUDevice.cpp @@ -76,7 +76,7 @@ bool GPUPipelineState::Init(const Description& desc) Complexity += tessCost; if (desc.DepthWriteEnable) Complexity += 5; - if (desc.DepthTestEnable) + if (desc.DepthEnable) Complexity += 5; if (desc.BlendMode.BlendEnable) Complexity += 20; diff --git a/Source/Engine/Graphics/GPUPipelineState.h b/Source/Engine/Graphics/GPUPipelineState.h index a8f9c449b..647d8da04 100644 --- a/Source/Engine/Graphics/GPUPipelineState.h +++ b/Source/Engine/Graphics/GPUPipelineState.h @@ -24,16 +24,16 @@ public: { DECLARE_SCRIPTING_TYPE_NO_SPAWN(Description); + /// + /// Enable/disable depth (DepthFunc and DepthWriteEnable) + /// + API_FIELD() bool DepthEnable; + /// /// Enable/disable depth write /// API_FIELD() bool DepthWriteEnable; - /// - /// Enable/disable depth test - /// - API_FIELD() bool DepthTestEnable; - /// /// Enable/disable depth clipping /// diff --git a/Source/Engine/Graphics/Materials/DeferredMaterialShader.cpp b/Source/Engine/Graphics/Materials/DeferredMaterialShader.cpp index 9e5f43957..52a0bd551 100644 --- a/Source/Engine/Graphics/Materials/DeferredMaterialShader.cpp +++ b/Source/Engine/Graphics/Materials/DeferredMaterialShader.cpp @@ -137,8 +137,13 @@ void DeferredMaterialShader::Unload() bool DeferredMaterialShader::Load() { auto psDesc = GPUPipelineState::Description::Default; - psDesc.DepthTestEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None; psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == MaterialFeaturesFlags::None; + if (EnumHasAnyFlags(_info.FeaturesFlags, MaterialFeaturesFlags::DisableDepthTest)) + { + psDesc.DepthFunc = ComparisonFunc::Always; + if (!psDesc.DepthWriteEnable) + psDesc.DepthEnable = false; + } // Check if use tessellation (both material and runtime supports it) const bool useTess = _info.TessellationMode != TessellationMethod::None && GPUDevice::Instance->Limits.HasTessellation; @@ -183,7 +188,7 @@ bool DeferredMaterialShader::Load() // Motion Vectors pass psDesc.DepthWriteEnable = false; - psDesc.DepthTestEnable = true; + psDesc.DepthEnable = true; psDesc.DepthFunc = ComparisonFunc::LessEqual; psDesc.VS = _shader->GetVS("VS"); psDesc.PS = _shader->GetPS("PS_MotionVectors"); @@ -201,7 +206,7 @@ bool DeferredMaterialShader::Load() psDesc.CullMode = CullMode::TwoSided; psDesc.DepthClipEnable = false; psDesc.DepthWriteEnable = true; - psDesc.DepthTestEnable = true; + psDesc.DepthEnable = true; psDesc.DepthFunc = ComparisonFunc::Less; psDesc.HS = nullptr; psDesc.DS = nullptr; diff --git a/Source/Engine/Graphics/Materials/DeformableMaterialShader.cpp b/Source/Engine/Graphics/Materials/DeformableMaterialShader.cpp index 83bfc457b..24775241b 100644 --- a/Source/Engine/Graphics/Materials/DeformableMaterialShader.cpp +++ b/Source/Engine/Graphics/Materials/DeformableMaterialShader.cpp @@ -112,7 +112,7 @@ bool DeformableMaterialShader::Load() { _drawModes = DrawPass::Depth | DrawPass::QuadOverdraw; auto psDesc = GPUPipelineState::Description::Default; - psDesc.DepthTestEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None; + psDesc.DepthEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None; psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == MaterialFeaturesFlags::None; // Check if use tessellation (both material and runtime supports it) @@ -170,7 +170,7 @@ bool DeformableMaterialShader::Load() psDesc.CullMode = CullMode::TwoSided; psDesc.DepthClipEnable = false; psDesc.DepthWriteEnable = true; - psDesc.DepthTestEnable = true; + psDesc.DepthEnable = true; psDesc.DepthFunc = ComparisonFunc::Less; psDesc.HS = nullptr; psDesc.DS = nullptr; diff --git a/Source/Engine/Graphics/Materials/ForwardMaterialShader.cpp b/Source/Engine/Graphics/Materials/ForwardMaterialShader.cpp index a1646a154..d391f3295 100644 --- a/Source/Engine/Graphics/Materials/ForwardMaterialShader.cpp +++ b/Source/Engine/Graphics/Materials/ForwardMaterialShader.cpp @@ -130,7 +130,7 @@ bool ForwardMaterialShader::Load() _drawModes = DrawPass::Depth | DrawPass::Forward | DrawPass::QuadOverdraw; auto psDesc = GPUPipelineState::Description::Default; - psDesc.DepthTestEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None; + psDesc.DepthEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None; psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == MaterialFeaturesFlags::None; // Check if use tessellation (both material and runtime supports it) @@ -200,7 +200,7 @@ bool ForwardMaterialShader::Load() psDesc.CullMode = CullMode::TwoSided; psDesc.DepthClipEnable = false; psDesc.DepthWriteEnable = true; - psDesc.DepthTestEnable = true; + psDesc.DepthEnable = true; psDesc.DepthFunc = ComparisonFunc::Less; psDesc.HS = nullptr; psDesc.DS = nullptr; diff --git a/Source/Engine/Graphics/Materials/GUIMaterialShader.cpp b/Source/Engine/Graphics/Materials/GUIMaterialShader.cpp index 795d16311..17be156bb 100644 --- a/Source/Engine/Graphics/Materials/GUIMaterialShader.cpp +++ b/Source/Engine/Graphics/Materials/GUIMaterialShader.cpp @@ -89,13 +89,13 @@ bool GUIMaterialShader::Load() psDesc0.PS = _shader->GetPS("PS_GUI"); psDesc0.BlendMode = BlendingMode::AlphaBlend; - psDesc0.DepthTestEnable = psDesc0.DepthWriteEnable = true; + psDesc0.DepthEnable = psDesc0.DepthWriteEnable = true; _cache.Depth = GPUDevice::Instance->CreatePipelineState(); _cache.NoDepth = GPUDevice::Instance->CreatePipelineState(); bool failed = _cache.Depth->Init(psDesc0); - psDesc0.DepthTestEnable = psDesc0.DepthWriteEnable = false; + psDesc0.DepthEnable = psDesc0.DepthWriteEnable = false; failed |= _cache.NoDepth->Init(psDesc0); if (failed) diff --git a/Source/Engine/Graphics/Materials/ParticleMaterialShader.cpp b/Source/Engine/Graphics/Materials/ParticleMaterialShader.cpp index 43dd9d447..ec39ef41b 100644 --- a/Source/Engine/Graphics/Materials/ParticleMaterialShader.cpp +++ b/Source/Engine/Graphics/Materials/ParticleMaterialShader.cpp @@ -189,7 +189,7 @@ bool ParticleMaterialShader::Load() { _drawModes = DrawPass::Depth | DrawPass::Forward | DrawPass::QuadOverdraw; GPUPipelineState::Description psDesc = GPUPipelineState::Description::Default; - psDesc.DepthTestEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None; + psDesc.DepthEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None; psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == MaterialFeaturesFlags::None; auto vsSprite = _shader->GetVS("VS_Sprite"); diff --git a/Source/Engine/Graphics/Materials/TerrainMaterialShader.cpp b/Source/Engine/Graphics/Materials/TerrainMaterialShader.cpp index 7c25a12fc..575f71b34 100644 --- a/Source/Engine/Graphics/Materials/TerrainMaterialShader.cpp +++ b/Source/Engine/Graphics/Materials/TerrainMaterialShader.cpp @@ -133,7 +133,7 @@ void TerrainMaterialShader::Unload() bool TerrainMaterialShader::Load() { GPUPipelineState::Description psDesc = GPUPipelineState::Description::Default; - psDesc.DepthTestEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None; + psDesc.DepthEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None; psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == MaterialFeaturesFlags::None; // Check if use tessellation (both material and runtime supports it) @@ -182,7 +182,7 @@ bool TerrainMaterialShader::Load() psDesc.BlendMode = BlendingMode::Opaque; psDesc.DepthClipEnable = false; psDesc.DepthWriteEnable = true; - psDesc.DepthTestEnable = true; + psDesc.DepthEnable = true; psDesc.DepthFunc = ComparisonFunc::Less; psDesc.HS = nullptr; psDesc.DS = nullptr; diff --git a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUPipelineStateDX11.cpp b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUPipelineStateDX11.cpp index 97c1281a3..e3458fcae 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUPipelineStateDX11.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUPipelineStateDX11.cpp @@ -48,7 +48,7 @@ bool GPUPipelineStateDX11::Init(const Description& desc) PrimitiveTopology = (D3D11_PRIMITIVE_TOPOLOGY)((int32)D3D11_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST + (HS->GetControlPointsCount() - 1)); // States - DepthStencilStateIndex = static_cast(desc.DepthFunc) + (desc.DepthTestEnable ? 0 : 9) + (desc.DepthWriteEnable ? 0 : 18); + DepthStencilStateIndex = static_cast(desc.DepthFunc) + (desc.DepthEnable ? 0 : 9) + (desc.DepthWriteEnable ? 0 : 18); RasterizerStateIndex = static_cast(desc.CullMode) + (desc.Wireframe ? 0 : 3) + (desc.DepthClipEnable ? 0 : 6); BlendState = _device->GetBlendState(desc.BlendMode); diff --git a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUPipelineStateDX12.cpp b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUPipelineStateDX12.cpp index 982a27661..3bfe09401 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUPipelineStateDX12.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUPipelineStateDX12.cpp @@ -172,7 +172,7 @@ bool GPUPipelineStateDX12::Init(const Description& desc) } // Depth State - psDesc.DepthStencilState.DepthEnable = !!desc.DepthTestEnable; + psDesc.DepthStencilState.DepthEnable = !!desc.DepthEnable; psDesc.DepthStencilState.DepthWriteMask = desc.DepthWriteEnable ? D3D12_DEPTH_WRITE_MASK_ALL : D3D12_DEPTH_WRITE_MASK_ZERO; psDesc.DepthStencilState.DepthFunc = static_cast(desc.DepthFunc); psDesc.DepthStencilState.StencilEnable = FALSE; diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUPipelineStateVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUPipelineStateVulkan.cpp index 236a8c7ce..935f37873 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUPipelineStateVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUPipelineStateVulkan.cpp @@ -286,7 +286,7 @@ bool GPUPipelineStateVulkan::Init(const Description& desc) // Depth Stencil RenderToolsVulkan::ZeroStruct(_descDepthStencil, VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO); - _descDepthStencil.depthTestEnable = desc.DepthTestEnable; + _descDepthStencil.depthTestEnable = desc.DepthEnable; _descDepthStencil.depthWriteEnable = desc.DepthWriteEnable; _descDepthStencil.depthCompareOp = RenderToolsVulkan::ToVulkanCompareOp(desc.DepthFunc); _desc.pDepthStencilState = &_descDepthStencil; diff --git a/Source/Engine/Render2D/Render2D.cpp b/Source/Engine/Render2D/Render2D.cpp index 1fd384d44..b56c3e1a2 100644 --- a/Source/Engine/Render2D/Render2D.cpp +++ b/Source/Engine/Render2D/Render2D.cpp @@ -481,7 +481,7 @@ bool CachedPSO::Init(GPUShader* shader, bool useDepth) // Create pipeline states GPUPipelineState::Description desc = GPUPipelineState::Description::DefaultFullscreenTriangle; - desc.DepthTestEnable = desc.DepthWriteEnable = useDepth; + desc.DepthEnable = desc.DepthWriteEnable = useDepth; desc.DepthWriteEnable = false; desc.DepthClipEnable = false; desc.VS = shader->GetVS("VS"); diff --git a/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp b/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp index d4ac81f98..2ca702d4f 100644 --- a/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp +++ b/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp @@ -284,7 +284,7 @@ bool GlobalSurfaceAtlasPass::setupResources() if (!_psClear) { _psClear = device->CreatePipelineState(); - psDesc.DepthTestEnable = true; + psDesc.DepthEnable = true; psDesc.DepthWriteEnable = true; psDesc.DepthFunc = ComparisonFunc::Always; psDesc.VS = shader->GetVS("VS_Atlas"); @@ -292,7 +292,7 @@ bool GlobalSurfaceAtlasPass::setupResources() if (_psClear->Init(psDesc)) return true; } - psDesc.DepthTestEnable = false; + psDesc.DepthEnable = false; psDesc.DepthWriteEnable = false; psDesc.DepthFunc = ComparisonFunc::Never; if (!_psClearLighting) diff --git a/Source/Engine/Renderer/LightPass.cpp b/Source/Engine/Renderer/LightPass.cpp index 0b98067d7..0dda82171 100644 --- a/Source/Engine/Renderer/LightPass.cpp +++ b/Source/Engine/Renderer/LightPass.cpp @@ -98,7 +98,7 @@ bool LightPass::setupResources() if (_psLightPointInverted.Create(psDesc, shader, "PS_Point")) return true; psDesc.CullMode = CullMode::Normal; - psDesc.DepthTestEnable = true; + psDesc.DepthEnable = true; if (_psLightPointNormal.Create(psDesc, shader, "PS_Point")) return true; } @@ -112,7 +112,7 @@ bool LightPass::setupResources() if (_psLightSpotInverted.Create(psDesc, shader, "PS_Spot")) return true; psDesc.CullMode = CullMode::Normal; - psDesc.DepthTestEnable = true; + psDesc.DepthEnable = true; if (_psLightSpotNormal.Create(psDesc, shader, "PS_Spot")) return true; } diff --git a/Source/Engine/Renderer/Utils/MultiScaler.cpp b/Source/Engine/Renderer/Utils/MultiScaler.cpp index ce0b4ac3a..036c586a6 100644 --- a/Source/Engine/Renderer/Utils/MultiScaler.cpp +++ b/Source/Engine/Renderer/Utils/MultiScaler.cpp @@ -76,7 +76,7 @@ bool MultiScaler::setupResources() { psDesc.PS = shader->GetPS("PS_HalfDepth"); psDesc.DepthWriteEnable = true; - psDesc.DepthTestEnable = true; + psDesc.DepthEnable = true; psDesc.DepthFunc = ComparisonFunc::Always; if (_psHalfDepth->Init(psDesc)) return true; From 0709288eaccb28ef648f4aac200ff576c2a7e885 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 31 Jan 2023 14:22:37 +0100 Subject: [PATCH 09/23] Revert Depth Offset (wrong impl, can be done later) --- .../MaterialTemplates/Features/DeferredShading.hlsl | 8 -------- .../MaterialTemplates/Features/ForwardShading.hlsl | 8 -------- Content/Editor/MaterialTemplates/Surface.shader | 13 ++----------- Source/Editor/Surface/Archetypes/Material.cs | 10 +--------- Source/Engine/Content/Assets/Material.cpp | 4 ---- Source/Engine/Graphics/Materials/MaterialInfo.h | 5 ----- .../MaterialGenerator/MaterialGenerator.Layer.cpp | 3 +-- .../MaterialGenerator/MaterialGenerator.Layers.cpp | 5 ----- .../Tools/MaterialGenerator/MaterialGenerator.cpp | 1 - .../Tools/MaterialGenerator/MaterialGenerator.h | 5 ----- .../Tools/MaterialGenerator/MaterialLayer.cpp | 13 +++++-------- Source/Shaders/MaterialCommon.hlsl | 1 - 12 files changed, 9 insertions(+), 67 deletions(-) diff --git a/Content/Editor/MaterialTemplates/Features/DeferredShading.hlsl b/Content/Editor/MaterialTemplates/Features/DeferredShading.hlsl index 64cecd4f8..fd0023a91 100644 --- a/Content/Editor/MaterialTemplates/Features/DeferredShading.hlsl +++ b/Content/Editor/MaterialTemplates/Features/DeferredShading.hlsl @@ -22,9 +22,6 @@ void PS_GBuffer( #if USE_GBUFFER_CUSTOM_DATA ,out float4 RT3 : SV_Target4 #endif -#endif -#if USE_DEPTH_OFFSET - ,out float Depth : SV_Depth #endif ) { @@ -39,11 +36,6 @@ void PS_GBuffer( MaterialInput materialInput = GetMaterialInput(input); Material material = GetMaterialPS(materialInput); - // Depth offset -#if USE_DEPTH_OFFSET - Depth = (materialInput.SvPosition.z * materialInput.SvPosition.w) / (materialInput.SvPosition.w + material.DepthOffset); -#endif - // Masking #if MATERIAL_MASKED clip(material.Mask - MATERIAL_MASK_THRESHOLD); diff --git a/Content/Editor/MaterialTemplates/Features/ForwardShading.hlsl b/Content/Editor/MaterialTemplates/Features/ForwardShading.hlsl index 68278f949..cf596bb30 100644 --- a/Content/Editor/MaterialTemplates/Features/ForwardShading.hlsl +++ b/Content/Editor/MaterialTemplates/Features/ForwardShading.hlsl @@ -36,9 +36,6 @@ META_PS(USE_FORWARD, FEATURE_LEVEL_ES2) void PS_Forward( in PixelInput input ,out float4 output : SV_Target0 -#if USE_DEPTH_OFFSET - ,out float Depth : SV_Depth -#endif ) { output = 0; @@ -51,11 +48,6 @@ void PS_Forward( // Get material parameters MaterialInput materialInput = GetMaterialInput(input); Material material = GetMaterialPS(materialInput); - - // Depth offset -#if USE_DEPTH_OFFSET - Depth = (materialInput.SvPosition.z * materialInput.SvPosition.w) / (materialInput.SvPosition.w + material.DepthOffset); -#endif // Masking #if MATERIAL_MASKED diff --git a/Content/Editor/MaterialTemplates/Surface.shader b/Content/Editor/MaterialTemplates/Surface.shader index 3e93ddbb6..1e8589ff2 100644 --- a/Content/Editor/MaterialTemplates/Surface.shader +++ b/Content/Editor/MaterialTemplates/Surface.shader @@ -587,18 +587,14 @@ void ClipLODTransition(PixelInput input) // Pixel Shader function for Depth Pass META_PS(true, FEATURE_LEVEL_ES2) -void PS_Depth(PixelInput input -#if USE_DEPTH_OFFSET - ,out float Depth : SV_Depth -#endif - ) +void PS_Depth(PixelInput input) { #if USE_DITHERED_LOD_TRANSITION // LOD masking ClipLODTransition(input); #endif -#if MATERIAL_MASKED || MATERIAL_BLEND != MATERIAL_BLEND_OPAQUE || USE_DEPTH_OFFSET +#if MATERIAL_MASKED || MATERIAL_BLEND != MATERIAL_BLEND_OPAQUE // Get material parameters MaterialInput materialInput = GetMaterialInput(input); Material material = GetMaterialPS(materialInput); @@ -610,11 +606,6 @@ void PS_Depth(PixelInput input #if MATERIAL_BLEND != MATERIAL_BLEND_OPAQUE clip(material.Opacity - MATERIAL_OPACITY_THRESHOLD); #endif - - // Depth offset -#if USE_DEPTH_OFFSET - Depth = (materialInput.SvPosition.z * materialInput.SvPosition.w) / (materialInput.SvPosition.w + material.DepthOffset); -#endif #endif } diff --git a/Source/Editor/Surface/Archetypes/Material.cs b/Source/Editor/Surface/Archetypes/Material.cs index 5182dba50..1a797c67d 100644 --- a/Source/Editor/Surface/Archetypes/Material.cs +++ b/Source/Editor/Surface/Archetypes/Material.cs @@ -40,7 +40,6 @@ namespace FlaxEditor.Surface.Archetypes TessellationMultiplier = 12, WorldDisplacement = 13, SubsurfaceColor = 14, - DepthOffset = 15, }; /// @@ -86,7 +85,6 @@ namespace FlaxEditor.Surface.Archetypes GetBox(MaterialNodeBoxes.TessellationMultiplier).Enabled = false; GetBox(MaterialNodeBoxes.WorldDisplacement).Enabled = false; GetBox(MaterialNodeBoxes.SubsurfaceColor).Enabled = false; - GetBox(MaterialNodeBoxes.DepthOffset).Enabled = false; return; } @@ -118,7 +116,6 @@ namespace FlaxEditor.Surface.Archetypes GetBox(MaterialNodeBoxes.TessellationMultiplier).Enabled = withTess; GetBox(MaterialNodeBoxes.WorldDisplacement).Enabled = withTess; GetBox(MaterialNodeBoxes.SubsurfaceColor).Enabled = info.ShadingModel == MaterialShadingModel.Subsurface || info.ShadingModel == MaterialShadingModel.Foliage; - GetBox(MaterialNodeBoxes.DepthOffset).Enabled = true; break; } case MaterialDomain.PostProcess: @@ -137,7 +134,6 @@ namespace FlaxEditor.Surface.Archetypes GetBox(MaterialNodeBoxes.TessellationMultiplier).Enabled = false; GetBox(MaterialNodeBoxes.WorldDisplacement).Enabled = false; GetBox(MaterialNodeBoxes.SubsurfaceColor).Enabled = false; - GetBox(MaterialNodeBoxes.DepthOffset).Enabled = false; break; } case MaterialDomain.Decal: @@ -158,7 +154,6 @@ namespace FlaxEditor.Surface.Archetypes GetBox(MaterialNodeBoxes.TessellationMultiplier).Enabled = false; GetBox(MaterialNodeBoxes.WorldDisplacement).Enabled = false; GetBox(MaterialNodeBoxes.SubsurfaceColor).Enabled = false; - GetBox(MaterialNodeBoxes.DepthOffset).Enabled = false; break; } case MaterialDomain.GUI: @@ -177,7 +172,6 @@ namespace FlaxEditor.Surface.Archetypes GetBox(MaterialNodeBoxes.TessellationMultiplier).Enabled = false; GetBox(MaterialNodeBoxes.WorldDisplacement).Enabled = false; GetBox(MaterialNodeBoxes.SubsurfaceColor).Enabled = false; - GetBox(MaterialNodeBoxes.DepthOffset).Enabled = false; break; } case MaterialDomain.VolumeParticle: @@ -196,7 +190,6 @@ namespace FlaxEditor.Surface.Archetypes GetBox(MaterialNodeBoxes.TessellationMultiplier).Enabled = false; GetBox(MaterialNodeBoxes.WorldDisplacement).Enabled = false; GetBox(MaterialNodeBoxes.SubsurfaceColor).Enabled = false; - GetBox(MaterialNodeBoxes.DepthOffset).Enabled = false; break; } default: throw new ArgumentOutOfRangeException(); @@ -288,7 +281,7 @@ namespace FlaxEditor.Surface.Archetypes Title = "Material", Description = "Main material node", Flags = NodeFlags.MaterialGraph | NodeFlags.NoRemove | NodeFlags.NoSpawnViaGUI | NodeFlags.NoSpawnViaPaste | NodeFlags.NoCloseButton, - Size = new Float2(150, 320), + Size = new Float2(150, 300), Elements = new[] { NodeElementArchetype.Factory.Input(0, "", true, typeof(void), 0), @@ -306,7 +299,6 @@ namespace FlaxEditor.Surface.Archetypes NodeElementArchetype.Factory.Input(12, "Tessellation Multiplier", true, typeof(float), 12), NodeElementArchetype.Factory.Input(13, "World Displacement", true, typeof(Float3), 13), NodeElementArchetype.Factory.Input(14, "Subsurface Color", true, typeof(Float3), 14), - NodeElementArchetype.Factory.Input(15, "Depth Offset", true, typeof(float), 15), } }, new NodeArchetype diff --git a/Source/Engine/Content/Assets/Material.cpp b/Source/Engine/Content/Assets/Material.cpp index fb2313ff7..76ed34b80 100644 --- a/Source/Engine/Content/Assets/Material.cpp +++ b/Source/Engine/Content/Assets/Material.cpp @@ -426,9 +426,6 @@ void Material::InitCompilationOptions(ShaderCompilationOptions& options) info.BlendMode != MaterialBlendMode::Opaque && EnumHasAnyFlags(info.UsageFlags, MaterialUsageFlags::UseRefraction) && (info.FeaturesFlags & MaterialFeaturesFlags::DisableDistortion) == MaterialFeaturesFlags::None; - const bool useDepthOffset = - (info.Domain == MaterialDomain::Surface) && - EnumHasAnyFlags(info.UsageFlags, MaterialUsageFlags::UseDepthOffset); // @formatter:off static const char* Numbers[] = @@ -499,7 +496,6 @@ void Material::InitCompilationOptions(ShaderCompilationOptions& options) options.Macros.Add({ "USE_FORWARD", Numbers[useForward ? 1 : 0] }); options.Macros.Add({ "USE_DEFERRED", Numbers[isSurfaceOrTerrainOrDeformable && info.BlendMode == MaterialBlendMode::Opaque ? 1 : 0] }); options.Macros.Add({ "USE_DISTORTION", Numbers[useDistortion ? 1 : 0] }); - options.Macros.Add({ "USE_DEPTH_OFFSET", Numbers[useDepthOffset ? 1 : 0] }); #endif } diff --git a/Source/Engine/Graphics/Materials/MaterialInfo.h b/Source/Engine/Graphics/Materials/MaterialInfo.h index 11eb8c14f..86fab4548 100644 --- a/Source/Engine/Graphics/Materials/MaterialInfo.h +++ b/Source/Engine/Graphics/Materials/MaterialInfo.h @@ -330,11 +330,6 @@ API_ENUM(Attributes="Flags") enum class MaterialUsageFlags : uint32 /// The flag used to indicate that material uses refraction feature. /// UseRefraction = 1 << 6, - - /// - /// The flag used to indicate that material uses per-pixel depth offset feature. - /// - UseDepthOffset = 1 << 7, }; DECLARE_ENUM_OPERATORS(MaterialUsageFlags); diff --git a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Layer.cpp b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Layer.cpp index 993a61469..61a487074 100644 --- a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Layer.cpp +++ b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Layer.cpp @@ -27,12 +27,11 @@ MaterialGenerator::MaterialGraphBoxesMapping MaterialGenerator::MaterialGraphBox { 12, TEXT("TessellationMultiplier"), MaterialTreeType::VertexShader, MaterialValue(VariantType::Float, TEXT("4.0f")) }, { 13, TEXT("WorldDisplacement"), MaterialTreeType::DomainShader, MaterialValue::InitForZero(VariantType::Float3) }, { 14, TEXT("SubsurfaceColor"), MaterialTreeType::PixelShader, MaterialValue::InitForZero(VariantType::Float3) }, - { 15, TEXT("DepthOffset"), MaterialTreeType::PixelShader, MaterialValue::InitForZero(VariantType::Float) }, }; const MaterialGenerator::MaterialGraphBoxesMapping& MaterialGenerator::GetMaterialRootNodeBox(MaterialGraphBoxes box) { - static_assert(ARRAY_COUNT(MaterialGenerator::MaterialGraphBoxesMappings) == 16, "Invalid amount of boxes added for root node. Please update the code above"); + static_assert(ARRAY_COUNT(MaterialGenerator::MaterialGraphBoxesMappings) == 15, "Invalid amount of boxes added for root node. Please update the code above"); return MaterialGraphBoxesMappings[static_cast(box)]; } diff --git a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Layers.cpp b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Layers.cpp index 7007bf7d9..8db8a0d0d 100644 --- a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Layers.cpp +++ b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.Layers.cpp @@ -103,7 +103,6 @@ void MaterialGenerator::ProcessGroupLayers(Box* box, Node* node, Value& value) EAT_BOX(AmbientOcclusion); EAT_BOX(Opacity); EAT_BOX(Refraction); - EAT_BOX(DepthOffset); EAT_BOX(Mask); EAT_BOX(Emissive); EAT_BOX(SubsurfaceColor); @@ -205,7 +204,6 @@ void MaterialGenerator::ProcessGroupLayers(Box* box, Node* node, Value& value) EAT_BOX(AmbientOcclusion); EAT_BOX(Opacity); EAT_BOX(Refraction); - EAT_BOX(DepthOffset); EAT_BOX(Mask); EAT_BOX(Emissive); EAT_BOX(SubsurfaceColor); @@ -248,7 +246,6 @@ void MaterialGenerator::ProcessGroupLayers(Box* box, Node* node, Value& value) EAT_BOX(AmbientOcclusion); EAT_BOX(Opacity); EAT_BOX(Refraction); - EAT_BOX(DepthOffset); EAT_BOX(Mask); EAT_BOX(Emissive); @@ -256,7 +253,6 @@ void MaterialGenerator::ProcessGroupLayers(Box* box, Node* node, Value& value) CHECK_MATERIAL_FEATURE(Normal, UseNormal); CHECK_MATERIAL_FEATURE(Mask, UseMask); CHECK_MATERIAL_FEATURE(Refraction, UseRefraction); - CHECK_MATERIAL_FEATURE(DepthOffset, UseDepthOffset); break; } @@ -336,7 +332,6 @@ void MaterialGenerator::ProcessGroupLayers(Box* box, Node* node, Value& value) CHECK_MATERIAL_FEATURE(Normal, UseNormal); CHECK_MATERIAL_FEATURE(Mask, UseMask); CHECK_MATERIAL_FEATURE(Refraction, UseRefraction); - CHECK_MATERIAL_FEATURE(DepthOffset, UseDepthOffset); break; } diff --git a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.cpp b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.cpp index 20722e494..b1aab0049 100644 --- a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.cpp +++ b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.cpp @@ -256,7 +256,6 @@ bool MaterialGenerator::Generate(WriteStream& source, MaterialInfo& materialInfo eatMaterialGraphBox(baseLayer, MaterialGraphBoxes::Roughness); eatMaterialGraphBox(baseLayer, MaterialGraphBoxes::Opacity); eatMaterialGraphBox(baseLayer, MaterialGraphBoxes::Refraction); - eatMaterialGraphBox(baseLayer, MaterialGraphBoxes::DepthOffset); eatMaterialGraphBox(baseLayer, MaterialGraphBoxes::SubsurfaceColor); eatMaterialGraphBox(baseLayer, MaterialGraphBoxes::Mask); } diff --git a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.h b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.h index d0823d359..f93a2204d 100644 --- a/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.h +++ b/Source/Engine/Tools/MaterialGenerator/MaterialGenerator.h @@ -89,11 +89,6 @@ enum class MaterialGraphBoxes /// SubsurfaceColor = 14, - /// - /// The custom depth offset applied per-pixel. - /// - DepthOffset = 15, - /// /// The amount of input boxes. /// diff --git a/Source/Engine/Tools/MaterialGenerator/MaterialLayer.cpp b/Source/Engine/Tools/MaterialGenerator/MaterialLayer.cpp index 8de2d6edb..c09a24e35 100644 --- a/Source/Engine/Tools/MaterialGenerator/MaterialLayer.cpp +++ b/Source/Engine/Tools/MaterialGenerator/MaterialLayer.cpp @@ -129,7 +129,6 @@ void MaterialLayer::UpdateFeaturesFlags() CHECK_BOX_AS_FEATURE(PositionOffset, UsePositionOffset); CHECK_BOX_AS_FEATURE(WorldDisplacement, UseDisplacement); CHECK_BOX_AS_FEATURE(Refraction, UseRefraction); - CHECK_BOX_AS_FEATURE(DepthOffset, UseDepthOffset); #undef CHECK_BOX_AS_FEATURE } @@ -171,17 +170,16 @@ MaterialLayer* MaterialLayer::Load(const Guid& id, ReadStream* graphData, const LOG(Warning, "Missing root node in '{0}'.", caller); layer->createRootNode(); } - // Ensure to have valid root node - else if (layer->Root->Boxes.Count() != static_cast(MaterialGraphBoxes::MAX)) + // Ensure to have valid root node + else if (layer->Root->Boxes.Count() < static_cast(MaterialGraphBoxes::MAX)) { #define ADD_BOX(type, valueType) \ - if(layer->Root->Boxes.Count() <= static_cast(MaterialGraphBoxes::type)) \ + if (layer->Root->Boxes.Count() <= static_cast(MaterialGraphBoxes::type)) \ layer->Root->Boxes.Add(MaterialGraphBox(layer->Root, static_cast(MaterialGraphBoxes::type), VariantType::valueType)) ADD_BOX(TessellationMultiplier, Float); ADD_BOX(WorldDisplacement, Float3); ADD_BOX(SubsurfaceColor, Float3); - ADD_BOX(DepthOffset, Float); - static_assert(static_cast(MaterialGraphBoxes::MAX) == 16, "Invalid amount of boxes added for root node. Please update the code above"); + static_assert(static_cast(MaterialGraphBoxes::MAX) == 15, "Invalid amount of boxes added for root node. Please update the code above"); ASSERT(layer->Root->Boxes.Count() == static_cast(MaterialGraphBoxes::MAX)); #if BUILD_DEBUG // Test for valid pointers after node upgrade @@ -227,12 +225,11 @@ void MaterialLayer::createRootNode() INIT_BOX(Normal, Float3); INIT_BOX(Opacity, Float); INIT_BOX(Refraction, Float); - INIT_BOX(DepthOffset, Float); INIT_BOX(PositionOffset, Float3); INIT_BOX(TessellationMultiplier, Float); INIT_BOX(WorldDisplacement, Float3); INIT_BOX(SubsurfaceColor, Float3); - static_assert(static_cast(MaterialGraphBoxes::MAX) == 16, "Invalid amount of boxes created for root node. Please update the code above"); + static_assert(static_cast(MaterialGraphBoxes::MAX) == 15, "Invalid amount of boxes created for root node. Please update the code above"); #undef INIT_BOX // Mark as root diff --git a/Source/Shaders/MaterialCommon.hlsl b/Source/Shaders/MaterialCommon.hlsl index 01ba12e8c..4bf44674c 100644 --- a/Source/Shaders/MaterialCommon.hlsl +++ b/Source/Shaders/MaterialCommon.hlsl @@ -86,7 +86,6 @@ struct Material float3 WorldDisplacement; float Mask; float TessellationMultiplier; - float DepthOffset; #if USE_CUSTOM_VERTEX_INTERPOLATORS float4 CustomVSToPS[CUSTOM_VERTEX_INTERPOLATORS_COUNT]; #endif From 8c5d421c45a263f4a888a73fe4a6a76e5b5a4bdc Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 31 Jan 2023 15:18:19 +0100 Subject: [PATCH 10/23] Update build number --- Flax.flaxproj | 2 +- Source/FlaxEngine.Gen.cs | 4 ++-- Source/FlaxEngine.Gen.h | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Flax.flaxproj b/Flax.flaxproj index 9871870d7..2553a3727 100644 --- a/Flax.flaxproj +++ b/Flax.flaxproj @@ -3,7 +3,7 @@ "Version": { "Major": 1, "Minor": 5, - "Build": 6335 + "Build": 6336 }, "Company": "Flax", "Copyright": "Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.", diff --git a/Source/FlaxEngine.Gen.cs b/Source/FlaxEngine.Gen.cs index 2fc05aa27..8b5988063 100644 --- a/Source/FlaxEngine.Gen.cs +++ b/Source/FlaxEngine.Gen.cs @@ -13,5 +13,5 @@ using System.Runtime.InteropServices; [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("b8442186-4a70-7c85-704a-857c68060f38")] -[assembly: AssemblyVersion("1.5.6335")] -[assembly: AssemblyFileVersion("1.5.6335")] +[assembly: AssemblyVersion("1.5.6336")] +[assembly: AssemblyFileVersion("1.5.6336")] diff --git a/Source/FlaxEngine.Gen.h b/Source/FlaxEngine.Gen.h index 096baf8f3..35a86fa53 100644 --- a/Source/FlaxEngine.Gen.h +++ b/Source/FlaxEngine.Gen.h @@ -3,11 +3,11 @@ #pragma once #define FLAXENGINE_NAME "FlaxEngine" -#define FLAXENGINE_VERSION Version(1, 5, 6335) -#define FLAXENGINE_VERSION_TEXT "1.5.6335" +#define FLAXENGINE_VERSION Version(1, 5, 6336) +#define FLAXENGINE_VERSION_TEXT "1.5.6336" #define FLAXENGINE_VERSION_MAJOR 1 #define FLAXENGINE_VERSION_MINOR 5 -#define FLAXENGINE_VERSION_BUILD 6335 +#define FLAXENGINE_VERSION_BUILD 6336 #define FLAXENGINE_COMPANY "Flax" #define FLAXENGINE_COPYRIGHT "Copyright (c) 2012-2023 Wojciech Figat. All rights reserved." From b93e97dd76bda7e3b45915da560a27061c0e3b8b Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 31 Jan 2023 15:19:34 +0100 Subject: [PATCH 11/23] Add `EnumHasNoneFlags` --- Source/Engine/Core/Types/BaseTypes.h | 7 +++++++ Source/Engine/Renderer/ColorGradingPass.cpp | 2 +- Source/Engine/Renderer/LightPass.cpp | 2 +- Source/Engine/Renderer/MotionBlurPass.cpp | 6 +++--- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Source/Engine/Core/Types/BaseTypes.h b/Source/Engine/Core/Types/BaseTypes.h index 9db3020e1..b766d42ec 100644 --- a/Source/Engine/Core/Types/BaseTypes.h +++ b/Source/Engine/Core/Types/BaseTypes.h @@ -164,5 +164,12 @@ constexpr bool EnumHasAllFlags(T value, T flags) return ((__underlying_type(T))value & (__underlying_type(T))flags) == (__underlying_type(T))flags; } +// Returns true if given enum value has none of enum flags set +template +constexpr bool EnumHasNoneFlags(T value, T flags) +{ + return ((__underlying_type(T))value & (__underlying_type(T))flags) == 0; +} + // Returns byte offset from the object pointer in vtable to the begin of the given inherited type implementation #define VTABLE_OFFSET(type, baseType) (((intptr)static_cast((type*)1))-1) diff --git a/Source/Engine/Renderer/ColorGradingPass.cpp b/Source/Engine/Renderer/ColorGradingPass.cpp index fbfa4eae6..fa8e7facc 100644 --- a/Source/Engine/Renderer/ColorGradingPass.cpp +++ b/Source/Engine/Renderer/ColorGradingPass.cpp @@ -62,7 +62,7 @@ bool ColorGradingPass::Init() formatSupportFlags |= FormatSupport::Texture3D; else formatSupportFlags |= FormatSupport::Texture2D; - if (!EnumHasAllFlags(formatSupport, formatSupportFlags)) + if (EnumHasNoneFlags(formatSupport, formatSupportFlags)) { // Fallback to format that is supported on every washing machine _lutFormat = PixelFormat::R8G8B8A8_UNorm; diff --git a/Source/Engine/Renderer/LightPass.cpp b/Source/Engine/Renderer/LightPass.cpp index 0dda82171..30b0b78bb 100644 --- a/Source/Engine/Renderer/LightPass.cpp +++ b/Source/Engine/Renderer/LightPass.cpp @@ -50,7 +50,7 @@ bool LightPass::Init() #endif auto format = PixelFormat::R8G8_UNorm; - if (!EnumHasAllFlags(GPUDevice::Instance->GetFormatFeatures(format).Support, (FormatSupport::RenderTarget | FormatSupport::ShaderSample | FormatSupport::Texture2D))) + if (EnumHasNoneFlags(GPUDevice::Instance->GetFormatFeatures(format).Support, (FormatSupport::RenderTarget | FormatSupport::ShaderSample | FormatSupport::Texture2D))) { format = PixelFormat::B8G8R8A8_UNorm; } diff --git a/Source/Engine/Renderer/MotionBlurPass.cpp b/Source/Engine/Renderer/MotionBlurPass.cpp index e5f622fc5..d425df80f 100644 --- a/Source/Engine/Renderer/MotionBlurPass.cpp +++ b/Source/Engine/Renderer/MotionBlurPass.cpp @@ -62,11 +62,11 @@ bool MotionBlurPass::Init() // Prepare formats for the buffers auto format = PixelFormat::R16G16_Float; - if (!EnumHasAllFlags(GPUDevice::Instance->GetFormatFeatures(format).Support, FormatSupport::RenderTarget | FormatSupport::ShaderSample | FormatSupport::Texture2D)) + if (EnumHasNoneFlags(GPUDevice::Instance->GetFormatFeatures(format).Support, FormatSupport::RenderTarget | FormatSupport::ShaderSample | FormatSupport::Texture2D)) { - if (!EnumHasAllFlags(GPUDevice::Instance->GetFormatFeatures(PixelFormat::R32G32_Float).Support, FormatSupport::RenderTarget | FormatSupport::ShaderSample | FormatSupport::Texture2D)) + if (EnumHasNoneFlags(GPUDevice::Instance->GetFormatFeatures(PixelFormat::R32G32_Float).Support, FormatSupport::RenderTarget | FormatSupport::ShaderSample | FormatSupport::Texture2D)) format = PixelFormat::R32G32_Float; - else if (!EnumHasAllFlags(GPUDevice::Instance->GetFormatFeatures(PixelFormat::R16G16B16A16_Float).Support, FormatSupport::RenderTarget | FormatSupport::ShaderSample | FormatSupport::Texture2D)) + else if (EnumHasNoneFlags(GPUDevice::Instance->GetFormatFeatures(PixelFormat::R16G16B16A16_Float).Support, FormatSupport::RenderTarget | FormatSupport::ShaderSample | FormatSupport::Texture2D)) format = PixelFormat::R16G16B16A16_Float; else format = PixelFormat::R32G32B32A32_Float; From a0c6add732796d6b30a5faa72d35ab062da1064e Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 31 Jan 2023 15:58:02 +0100 Subject: [PATCH 12/23] Add `ViewFlags::Sky` for conditional sky/skybox rendering --- Source/Editor/Viewport/EditorViewport.cs | 1 + Source/Editor/Windows/EditGameWindow.cs | 4 ++-- Source/Engine/Graphics/Enums.h | 13 +++++++++---- Source/Engine/Level/Actors/Sky.cpp | 2 +- Source/Engine/Level/Actors/Skybox.cpp | 2 +- Source/Engine/Renderer/GBufferPass.cpp | 6 +++--- Source/Engine/Renderer/ProbesRenderer.cpp | 1 + Source/Engine/ShadowsOfMordor/Builder.cpp | 1 + 8 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Source/Editor/Viewport/EditorViewport.cs b/Source/Editor/Viewport/EditorViewport.cs index aa9e3638f..f56370352 100644 --- a/Source/Editor/Viewport/EditorViewport.cs +++ b/Source/Editor/Viewport/EditorViewport.cs @@ -1521,6 +1521,7 @@ namespace FlaxEditor.Viewport new ViewFlagOptions(ViewFlags.PointLights, "Point Lights"), new ViewFlagOptions(ViewFlags.SpotLights, "Spot Lights"), new ViewFlagOptions(ViewFlags.SkyLights, "Sky Lights"), + new ViewFlagOptions(ViewFlags.Sky, "Sky"), new ViewFlagOptions(ViewFlags.Fog, "Fog"), new ViewFlagOptions(ViewFlags.SpecularLight, "Specular Light"), new ViewFlagOptions(ViewFlags.Decals, "Decals"), diff --git a/Source/Editor/Windows/EditGameWindow.cs b/Source/Editor/Windows/EditGameWindow.cs index 9335cd00b..698972b64 100644 --- a/Source/Editor/Windows/EditGameWindow.cs +++ b/Source/Editor/Windows/EditGameWindow.cs @@ -430,7 +430,7 @@ namespace FlaxEditor.Windows writer.WriteAttributeString("MovementSpeed", Viewport.MovementSpeed.ToString()); writer.WriteAttributeString("OrthographicScale", Viewport.OrthographicScale.ToString()); writer.WriteAttributeString("UseOrthographicProjection", Viewport.UseOrthographicProjection.ToString()); - writer.WriteAttributeString("ViewFlags", ((long)Viewport.Task.View.Flags).ToString()); + writer.WriteAttributeString("ViewFlags", ((ulong)Viewport.Task.View.Flags).ToString()); } /// @@ -463,7 +463,7 @@ namespace FlaxEditor.Windows if (bool.TryParse(node.GetAttribute("UseOrthographicProjection"), out value1)) Viewport.UseOrthographicProjection = value1; - if (long.TryParse(node.GetAttribute("ViewFlags"), out long value3)) + if (ulong.TryParse(node.GetAttribute("ViewFlags"), out ulong value3)) Viewport.Task.ViewFlags = (ViewFlags)value3; // Reset view flags if opening with different engine version (ViewFlags enum could be modified) diff --git a/Source/Engine/Graphics/Enums.h b/Source/Engine/Graphics/Enums.h index f419fbb71..55657f507 100644 --- a/Source/Engine/Graphics/Enums.h +++ b/Source/Engine/Graphics/Enums.h @@ -879,7 +879,7 @@ API_ENUM() enum class ViewMode /// /// Frame rendering flags used to switch between graphics features. /// -API_ENUM(Attributes="Flags") enum class ViewFlags : int64 +API_ENUM(Attributes="Flags") enum class ViewFlags : uint64 { /// /// Nothing. @@ -1016,20 +1016,25 @@ API_ENUM(Attributes="Flags") enum class ViewFlags : int64 /// GlobalSDF = 1 << 25, + /// + /// Shows/hides the Sky/Skybox rendering. + /// + Sky = 1 << 26, + /// /// Default flags for Game. /// - DefaultGame = Reflections | DepthOfField | Fog | Decals | MotionBlur | SSR | AO | GI | DirectionalLights | PointLights | SpotLights | SkyLights | Shadows | SpecularLight | AntiAliasing | CustomPostProcess | Bloom | ToneMapping | EyeAdaptation | CameraArtifacts | LensFlares | ContactShadows | GlobalSDF, + DefaultGame = Reflections | DepthOfField | Fog | Decals | MotionBlur | SSR | AO | GI | DirectionalLights | PointLights | SpotLights | SkyLights | Shadows | SpecularLight | AntiAliasing | CustomPostProcess | Bloom | ToneMapping | EyeAdaptation | CameraArtifacts | LensFlares | ContactShadows | GlobalSDF | Sky, /// /// Default flags for Editor. /// - DefaultEditor = Reflections | Fog | Decals | DebugDraw | SSR | AO | GI | DirectionalLights | PointLights | SpotLights | SkyLights | Shadows | SpecularLight | AntiAliasing | CustomPostProcess | Bloom | ToneMapping | EyeAdaptation | CameraArtifacts | LensFlares | EditorSprites | ContactShadows | GlobalSDF, + DefaultEditor = Reflections | Fog | Decals | DebugDraw | SSR | AO | GI | DirectionalLights | PointLights | SpotLights | SkyLights | Shadows | SpecularLight | AntiAliasing | CustomPostProcess | Bloom | ToneMapping | EyeAdaptation | CameraArtifacts | LensFlares | EditorSprites | ContactShadows | GlobalSDF | Sky, /// /// Default flags for materials/models previews generating. /// - DefaultAssetPreview = Reflections | Decals | DirectionalLights | PointLights | SpotLights | SkyLights | SpecularLight | AntiAliasing | Bloom | ToneMapping | EyeAdaptation | CameraArtifacts | LensFlares | ContactShadows, + DefaultAssetPreview = Reflections | Decals | DirectionalLights | PointLights | SpotLights | SkyLights | SpecularLight | AntiAliasing | Bloom | ToneMapping | EyeAdaptation | CameraArtifacts | LensFlares | ContactShadows | Sky, }; DECLARE_ENUM_OPERATORS(ViewFlags); diff --git a/Source/Engine/Level/Actors/Sky.cpp b/Source/Engine/Level/Actors/Sky.cpp index f0ccf84b4..dcb2bb77e 100644 --- a/Source/Engine/Level/Actors/Sky.cpp +++ b/Source/Engine/Level/Actors/Sky.cpp @@ -81,7 +81,7 @@ void Sky::InitConfig(AtmosphericFogData& config) const void Sky::Draw(RenderContext& renderContext) { - if (HasContentLoaded()) + if (HasContentLoaded() && EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::Sky)) { // Ensure to have pipeline state cache created if (_psSky == nullptr || _psFog == nullptr) diff --git a/Source/Engine/Level/Actors/Skybox.cpp b/Source/Engine/Level/Actors/Skybox.cpp index 8606b179e..7d35a2776 100644 --- a/Source/Engine/Level/Actors/Skybox.cpp +++ b/Source/Engine/Level/Actors/Skybox.cpp @@ -40,7 +40,7 @@ void Skybox::Draw(RenderContext& renderContext) setupProxy(); isReady = _proxyMaterial && _proxyMaterial->IsReady(); } - if (isReady) + if (isReady && EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::Sky)) { renderContext.List->Sky = this; } diff --git a/Source/Engine/Renderer/GBufferPass.cpp b/Source/Engine/Renderer/GBufferPass.cpp index 0e548afea..0e5e8508a 100644 --- a/Source/Engine/Renderer/GBufferPass.cpp +++ b/Source/Engine/Renderer/GBufferPass.cpp @@ -218,7 +218,7 @@ void GBufferPass::Fill(RenderContext& renderContext, GPUTexture* lightBuffer) renderContext.List->RunCustomPostFxPass(context, renderContext, PostProcessEffectLocation::AfterGBufferPass, lightBuffer, nullTexture); // Draw sky - if (renderContext.List->Sky && _skyModel && _skyModel->CanBeRendered()) + if (renderContext.List->Sky && _skyModel && _skyModel->CanBeRendered() && EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::Sky)) { PROFILE_GPU_CPU_NAMED("Sky"); context->SetRenderTarget(*renderContext.Buffers->DepthBuffer, ToSpan(targetBuffers, ARRAY_COUNT(targetBuffers))); @@ -283,7 +283,7 @@ public: GPUTextureView* GBufferPass::RenderSkybox(RenderContext& renderContext, GPUContext* context) { GPUTextureView* result = nullptr; - if (renderContext.List->Sky && _skyModel && _skyModel->CanBeRendered()) + if (renderContext.List->Sky && _skyModel && _skyModel->CanBeRendered() && EnumHasAnyFlags(renderContext.View.Flags, ViewFlags::Sky)) { // Initialize skybox texture auto& skyboxData = *renderContext.Buffers->GetCustomBuffer(TEXT("Skybox")); @@ -430,7 +430,7 @@ void GBufferPass::DrawDecals(RenderContext& renderContext, GPUTextureView* light { // Skip if no decals to render auto& decals = renderContext.List->Decals; - if (decals.IsEmpty() || _boxModel == nullptr || !_boxModel->CanBeRendered()) + if (decals.IsEmpty() || _boxModel == nullptr || !_boxModel->CanBeRendered() || EnumHasNoneFlags(renderContext.View.Flags, ViewFlags::Decals)) return; PROFILE_GPU_CPU("Decals"); diff --git a/Source/Engine/Renderer/ProbesRenderer.cpp b/Source/Engine/Renderer/ProbesRenderer.cpp index 376c8632d..769765102 100644 --- a/Source/Engine/Renderer/ProbesRenderer.cpp +++ b/Source/Engine/Renderer/ProbesRenderer.cpp @@ -268,6 +268,7 @@ bool ProbesRenderer::Init() ViewFlags::SkyLights | ViewFlags::Decals | ViewFlags::Shadows | + ViewFlags::Sky | ViewFlags::Fog; view.Mode = ViewMode::NoPostFx; view.IsOfflinePass = true; diff --git a/Source/Engine/ShadowsOfMordor/Builder.cpp b/Source/Engine/ShadowsOfMordor/Builder.cpp index 426925c43..ccf956d47 100644 --- a/Source/Engine/ShadowsOfMordor/Builder.cpp +++ b/Source/Engine/ShadowsOfMordor/Builder.cpp @@ -448,6 +448,7 @@ bool ShadowsOfMordor::Builder::initResources() ViewFlags::DirectionalLights | ViewFlags::PointLights | ViewFlags::SpotLights | + ViewFlags::Sky | ViewFlags::Shadows | ViewFlags::Decals | ViewFlags::SkyLights | From b071cdb843463c1f50b6484c7d50b31ba455a61d Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 31 Jan 2023 16:01:56 +0100 Subject: [PATCH 13/23] Expose various engine features to scripting --- Source/Engine/Core/Math/Viewport.cs | 21 +++++---------------- Source/Engine/Graphics/Enums.h | 2 +- Source/Engine/Graphics/GPUDevice.h | 2 +- Source/Engine/Graphics/RenderView.cpp | 8 ++++++++ Source/Engine/Graphics/RenderView.h | 8 +------- Source/Engine/Renderer/Renderer.h | 3 +-- 6 files changed, 17 insertions(+), 27 deletions(-) diff --git a/Source/Engine/Core/Math/Viewport.cs b/Source/Engine/Core/Math/Viewport.cs index cf100dc9c..b375e416c 100644 --- a/Source/Engine/Core/Math/Viewport.cs +++ b/Source/Engine/Core/Math/Viewport.cs @@ -161,6 +161,11 @@ namespace FlaxEngine } } + /// + /// Gets the aspect ratio used by the viewport. + /// + public float AspectRatio => !Mathf.IsZero(Height) ? Width / Height : 0f; + /// /// Determines whether the specified is equal to this instance. /// @@ -326,21 +331,5 @@ namespace FlaxEngine vector /= w; } } - - /// - /// Gets the aspect ratio used by the viewport. - /// - /// The aspect ratio. - public float AspectRatio - { - get - { - if (!Mathf.IsZero(Height)) - { - return Width / Height; - } - return 0f; - } - } } } diff --git a/Source/Engine/Graphics/Enums.h b/Source/Engine/Graphics/Enums.h index 55657f507..74c859352 100644 --- a/Source/Engine/Graphics/Enums.h +++ b/Source/Engine/Graphics/Enums.h @@ -514,7 +514,7 @@ public: API_FIELD(ReadOnly) static BlendingMode Additive; /// - /// Gets the alpha blending. + /// Gets the alpha blending. Source alpha controls the output color (0 - use destination color, 1 - use source color). /// API_FIELD(ReadOnly) static BlendingMode AlphaBlend; diff --git a/Source/Engine/Graphics/GPUDevice.h b/Source/Engine/Graphics/GPUDevice.h index 37fc8cb87..4dbcf6d06 100644 --- a/Source/Engine/Graphics/GPUDevice.h +++ b/Source/Engine/Graphics/GPUDevice.h @@ -134,7 +134,7 @@ public: /// /// Quad rendering shader /// - GPUShader* QuadShader; + API_FIELD(ReadOnly) GPUShader* QuadShader; /// /// The current task being executed. diff --git a/Source/Engine/Graphics/RenderView.cpp b/Source/Engine/Graphics/RenderView.cpp index 736609e0c..baa5d5058 100644 --- a/Source/Engine/Graphics/RenderView.cpp +++ b/Source/Engine/Graphics/RenderView.cpp @@ -84,6 +84,14 @@ void RenderView::PrepareCache(const RenderContext& renderContext, float width, f MainScreenSize = mainView->ScreenSize; } +void RenderView::SetUp(const Matrix& viewProjection) +{ + // Copy data + Matrix::Invert(viewProjection, IVP); + Frustum.SetMatrix(viewProjection); + CullingFrustum = Frustum; +} + void RenderView::SetUp(const Matrix& view, const Matrix& projection) { // Copy data diff --git a/Source/Engine/Graphics/RenderView.h b/Source/Engine/Graphics/RenderView.h index d64e05d4b..52e317a51 100644 --- a/Source/Engine/Graphics/RenderView.h +++ b/Source/Engine/Graphics/RenderView.h @@ -255,13 +255,7 @@ public: public: // Set up view with custom params // @param viewProjection View * Projection matrix - void SetUp(const Matrix& viewProjection) - { - // Copy data - Matrix::Invert(viewProjection, IVP); - Frustum.SetMatrix(viewProjection); - CullingFrustum = Frustum; - } + void SetUp(const Matrix& viewProjection); // Set up view with custom params // @param view View matrix diff --git a/Source/Engine/Renderer/Renderer.h b/Source/Engine/Renderer/Renderer.h index 794a6dcc4..885b8ca43 100644 --- a/Source/Engine/Renderer/Renderer.h +++ b/Source/Engine/Renderer/Renderer.h @@ -29,9 +29,8 @@ public: /// Performs rendering for the input task. /// /// The scene rendering task. - static void Render(SceneRenderTask* task); + API_FUNCTION() static void Render(SceneRenderTask* task); -public: /// /// Draws scene objects depth (to the output Z buffer). The output must be depth texture to write hardware depth to it. /// From 831af77eff3597f0b1e7d834a23b909ed85238cf Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 31 Jan 2023 16:18:04 +0100 Subject: [PATCH 14/23] Fix rendering with custom feature-set --- Source/Engine/Renderer/PostProcessingPass.cpp | 18 ++++-------------- Source/Engine/Renderer/Renderer.cpp | 4 ++-- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/Source/Engine/Renderer/PostProcessingPass.cpp b/Source/Engine/Renderer/PostProcessingPass.cpp index 058ceabab..159282bcd 100644 --- a/Source/Engine/Renderer/PostProcessingPass.cpp +++ b/Source/Engine/Renderer/PostProcessingPass.cpp @@ -181,24 +181,13 @@ void PostProcessingPass::Dispose() void PostProcessingPass::Render(RenderContext& renderContext, GPUTexture* input, GPUTexture* output, GPUTexture* colorGradingLUT) { + PROFILE_GPU_CPU("Post Processing"); auto device = GPUDevice::Instance; auto context = device->GetMainContext(); auto& view = renderContext.View; - - PROFILE_GPU_CPU("Post Processing"); - + context->ResetRenderTarget(); - // Ensure to have valid data - if (checkIfSkipPass()) - { - // Resources are missing. Do not perform rendering. Just copy raw frame - context->SetRenderTarget(*output); - context->Draw(input); - return; - } - - // Cache data PostProcessSettings& settings = renderContext.List->Settings; bool useBloom = EnumHasAnyFlags(view.Flags, ViewFlags::Bloom) && settings.Bloom.Enabled && settings.Bloom.Intensity > 0.0f; bool useToneMapping = EnumHasAnyFlags(view.Flags, ViewFlags::ToneMapping); @@ -206,9 +195,10 @@ void PostProcessingPass::Render(RenderContext& renderContext, GPUTexture* input, bool useLensFlares = EnumHasAnyFlags(view.Flags, ViewFlags::LensFlares) && settings.LensFlares.Intensity > 0.0f && useBloom; // Ensure to have valid data and if at least one effect should be applied - if (!(useBloom || useToneMapping || useCameraArtifacts)) + if (checkIfSkipPass() || !(useBloom || useToneMapping || useCameraArtifacts)) { // Resources are missing. Do not perform rendering. Just copy raw frame + context->SetViewportAndScissors(output->Width(), output->Height()); context->SetRenderTarget(*output); context->Draw(input); return; diff --git a/Source/Engine/Renderer/Renderer.cpp b/Source/Engine/Renderer/Renderer.cpp index 550c7c4e7..d3ea5800e 100644 --- a/Source/Engine/Renderer/Renderer.cpp +++ b/Source/Engine/Renderer/Renderer.cpp @@ -312,6 +312,7 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont // Initialize setup RenderSetup& setup = renderContext.List->Setup; + const bool isGBufferDebug = GBufferPass::IsDebugView(renderContext.View.Mode); { PROFILE_CPU_NAMED("Setup"); if (renderContext.View.Origin != renderContext.View.PrevOrigin) @@ -319,7 +320,7 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont const int32 screenWidth = renderContext.Buffers->GetWidth(); const int32 screenHeight = renderContext.Buffers->GetHeight(); setup.UpscaleLocation = renderContext.Task->UpscaleLocation; - if (screenWidth < 16 || screenHeight < 16 || renderContext.Task->IsCameraCut) + if (screenWidth < 16 || screenHeight < 16 || renderContext.Task->IsCameraCut || isGBufferDebug || renderContext.View.Mode == ViewMode::NoPostFx) setup.UseMotionVectors = false; else { @@ -344,7 +345,6 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont renderContext.Buffers->Prepare(); // Build batch of render contexts (main view and shadow projections) - const bool isGBufferDebug = GBufferPass::IsDebugView(renderContext.View.Mode); { PROFILE_CPU_NAMED("Collect Draw Calls"); From ab51ecddb442471b6219eb2391bd9c153b6a1219 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 1 Feb 2023 11:05:29 +0100 Subject: [PATCH 15/23] Add `RenderBuffers::LinkedCustomBuffers` to reuse main game viewport rendered state (eg. GI) in sub-rendered view --- Source/Engine/Graphics/RenderBuffers.cpp | 3 +++ Source/Engine/Graphics/RenderBuffers.h | 7 +++++++ Source/Engine/Renderer/Config.h | 3 --- Source/Engine/Renderer/ForwardPass.cpp | 8 +++----- Source/Engine/Renderer/RenderList.cpp | 6 ------ Source/Shaders/GI/DDGI.shader | 2 +- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Source/Engine/Graphics/RenderBuffers.cpp b/Source/Engine/Graphics/RenderBuffers.cpp index 32d0d1848..e0f4869ad 100644 --- a/Source/Engine/Graphics/RenderBuffers.cpp +++ b/Source/Engine/Graphics/RenderBuffers.cpp @@ -128,6 +128,8 @@ void RenderBuffers::SetUseAlpha(bool value) const RenderBuffers::CustomBuffer* RenderBuffers::FindCustomBuffer(const StringView& name) const { + if (LinkedCustomBuffers) + return LinkedCustomBuffers->FindCustomBuffer(name); for (const CustomBuffer* e : CustomBuffers) { if (e->Name == name) @@ -196,6 +198,7 @@ bool RenderBuffers::Init(int32 width, int32 height) void RenderBuffers::Release() { LastEyeAdaptationTime = 0; + LinkedCustomBuffers = nullptr; for (int32 i = 0; i < _resources.Count(); i++) _resources[i]->ReleaseGPU(); diff --git a/Source/Engine/Graphics/RenderBuffers.h b/Source/Engine/Graphics/RenderBuffers.h index 23db15523..4010760c9 100644 --- a/Source/Engine/Graphics/RenderBuffers.h +++ b/Source/Engine/Graphics/RenderBuffers.h @@ -178,6 +178,8 @@ public: template T* GetCustomBuffer(const StringView& name) { + if (LinkedCustomBuffers) + return LinkedCustomBuffers->GetCustomBuffer(name); CustomBuffer* result = (CustomBuffer*)FindCustomBuffer(name); if (!result) { @@ -206,6 +208,11 @@ public: /// API_FIELD(ReadOnly) GPUTexture* MotionVectors; + /// + /// External Render Buffers used to redirect FindCustomBuffer/GetCustomBuffer calls. Can be linked to other rendering task (eg. main game viewport) to reuse graphics effect state from it (eg. use GI from main game view in in-game camera renderer). + /// + API_FIELD() RenderBuffers* LinkedCustomBuffers = nullptr; + public: /// /// Allocates the buffers. diff --git a/Source/Engine/Renderer/Config.h b/Source/Engine/Renderer/Config.h index ac3fcbd6e..659369a71 100644 --- a/Source/Engine/Renderer/Config.h +++ b/Source/Engine/Renderer/Config.h @@ -117,6 +117,3 @@ PACK_STRUCT(struct ProbeData { // Default format for the shadow map textures #define SHADOW_MAPS_FORMAT PixelFormat::D16_UNorm - -// Material distortion offsets output pass (material uses PS_Distortion, ForwardPass resolves the offsets) -#define Distortion_Pass_Output_Format PixelFormat::R8G8B8A8_UNorm diff --git a/Source/Engine/Renderer/ForwardPass.cpp b/Source/Engine/Renderer/ForwardPass.cpp index 0eb637eea..53c9b74bd 100644 --- a/Source/Engine/Renderer/ForwardPass.cpp +++ b/Source/Engine/Renderer/ForwardPass.cpp @@ -107,7 +107,7 @@ void ForwardPass::Render(RenderContext& renderContext, GPUTexture* input, GPUTex const int32 height = renderContext.Buffers->GetHeight(); const int32 distortionWidth = width; const int32 distortionHeight = height; - const auto tempDesc = GPUTextureDescription::New2D(distortionWidth, distortionHeight, Distortion_Pass_Output_Format); + const auto tempDesc = GPUTextureDescription::New2D(distortionWidth, distortionHeight, PixelFormat::R8G8B8A8_UNorm); auto distortionRT = RenderTargetPool::Get(tempDesc); RENDER_TARGET_POOL_SET_NAME(distortionRT, "Forward.Distortion"); @@ -119,15 +119,13 @@ void ForwardPass::Render(RenderContext& renderContext, GPUTexture* input, GPUTex // Render distortion pass view.Pass = DrawPass::Distortion; mainCache->ExecuteDrawCalls(renderContext, distortionList); + + // Copy combined frame with distortion from transparent materials context->SetViewportAndScissors((float)width, (float)height); context->ResetRenderTarget(); context->ResetSR(); - - // Bind inputs context->BindSR(0, input); context->BindSR(1, distortionRT); - - // Copy combined frame with distortion from transparent materials context->SetRenderTarget(output->View()); context->SetState(_psApplyDistortion); context->DrawFullscreenTriangle(); diff --git a/Source/Engine/Renderer/RenderList.cpp b/Source/Engine/Renderer/RenderList.cpp index 17bd8ee16..1a4cc0205 100644 --- a/Source/Engine/Renderer/RenderList.cpp +++ b/Source/Engine/Renderer/RenderList.cpp @@ -2,9 +2,6 @@ #include "RenderList.h" #include "Engine/Core/Collections/Sorting.h" -#if !BUILD_RELEASE -#include "Engine/Core/Utilities.h" -#endif #include "Engine/Graphics/Materials/IMaterial.h" #include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/GPUContext.h" @@ -649,9 +646,6 @@ void RenderList::ExecuteDrawCalls(const RenderContext& renderContext, DrawCallsL { if (list.IsEmpty()) return; -#if !BUILD_RELEASE - CHECK(Utilities::CountBits((uint32)renderContext.View.Pass) == 1); // Ensure proper pass is set (single bit flag) -#endif PROFILE_GPU_CPU("Drawing"); const auto* drawCallsData = drawCalls.Get(); const auto* listData = list.Indices.Get(); diff --git a/Source/Shaders/GI/DDGI.shader b/Source/Shaders/GI/DDGI.shader index 7090b9f94..258b38474 100644 --- a/Source/Shaders/GI/DDGI.shader +++ b/Source/Shaders/GI/DDGI.shader @@ -576,7 +576,7 @@ void PS_IndirectLighting(Quad_VS2PS input, out float4 output : SV_Target0) // Calculate lighting float3 diffuseColor = GetDiffuseColor(gBuffer); float3 diffuse = Diffuse_Lambert(diffuseColor); - output = float4(diffuse * irradiance * gBuffer.AO, saturate(length(irradiance))); + output.rgb = diffuse * irradiance * gBuffer.AO; } #endif From 45a30990bade2963e78ad7a0a7c7b866f5de0cf5 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 1 Feb 2023 11:07:48 +0100 Subject: [PATCH 16/23] Add `GPUContext::SetBlendFactor` --- Source/Engine/Graphics/GPUContext.h | 6 + Source/Engine/Graphics/RenderTools.cpp | 139 ++++++------------ .../DirectX/DX11/GPUContextDX11.cpp | 11 +- .../DirectX/DX11/GPUContextDX11.h | 2 + .../DirectX/DX12/GPUContextDX12.cpp | 5 + .../DirectX/DX12/GPUContextDX12.h | 1 + .../GraphicsDevice/Null/GPUContextNull.h | 4 + .../Vulkan/GPUContextVulkan.cpp | 6 + .../GraphicsDevice/Vulkan/GPUContextVulkan.h | 1 + 9 files changed, 83 insertions(+), 92 deletions(-) diff --git a/Source/Engine/Graphics/GPUContext.h b/Source/Engine/Graphics/GPUContext.h index 593282555..99a226193 100644 --- a/Source/Engine/Graphics/GPUContext.h +++ b/Source/Engine/Graphics/GPUContext.h @@ -315,6 +315,12 @@ public: /// The array with render targets to bind. API_FUNCTION() virtual void SetRenderTarget(GPUTextureView* depthBuffer, const Span& rts) = 0; + /// + /// Sets the blend factor that modulate values for a pixel shader, render target, or both. + /// + /// Blend factors, one for each RGBA component. + API_FUNCTION() virtual void SetBlendFactor(const Float4& value) = 0; + public: /// /// Unbinds all shader resource slots and flushes the change with the driver (used to prevent driver detection of resource hazards, eg. when down-scaling the texture). diff --git a/Source/Engine/Graphics/RenderTools.cpp b/Source/Engine/Graphics/RenderTools.cpp index 67cbce85b..8389e5d3c 100644 --- a/Source/Engine/Graphics/RenderTools.cpp +++ b/Source/Engine/Graphics/RenderTools.cpp @@ -181,116 +181,75 @@ uint32 GetHash(const BlendingMode& key) return hash; } +// @formatter:off + BlendingMode BlendingMode::Opaque = { - false, - // AlphaToCoverageEnable - false, - // BlendEnable - Blend::One, - // SrcBlend - Blend::Zero, - // DestBlend - Operation::Add, - // BlendOp - Blend::One, - // SrcBlendAlpha - Blend::Zero, - // DestBlendAlpha - Operation::Add, - // BlendOpAlpha - ColorWrite::All, - // RenderTargetWriteMask + false, // AlphaToCoverageEnable + false, // BlendEnable + Blend::One, // SrcBlend + Blend::Zero, // DestBlend + Operation::Add, // BlendOp + Blend::One, // SrcBlendAlpha + Blend::Zero, // DestBlendAlpha + Operation::Add, // BlendOpAlpha + ColorWrite::All, // RenderTargetWriteMask }; BlendingMode BlendingMode::Additive = { - false, - // AlphaToCoverageEnable - true, - // BlendEnable - Blend::SrcAlpha, - // SrcBlend - Blend::One, - // DestBlend - Operation::Add, - // BlendOp - Blend::SrcAlpha, - // SrcBlendAlpha - Blend::One, - // DestBlendAlpha - Operation::Add, - // BlendOpAlpha - ColorWrite::All, - // RenderTargetWriteMask + false, // AlphaToCoverageEnable + true, // BlendEnable + Blend::SrcAlpha, // SrcBlend + Blend::One, // DestBlend + Operation::Add, // BlendOp + Blend::SrcAlpha, // SrcBlendAlpha + Blend::One, // DestBlendAlpha + Operation::Add, // BlendOpAlpha + ColorWrite::All, // RenderTargetWriteMask }; BlendingMode BlendingMode::AlphaBlend = { - false, - // AlphaToCoverageEnable - true, - // BlendEnable - Blend::SrcAlpha, - // SrcBlend - Blend::InvSrcAlpha, - // DestBlend - Operation::Add, - // BlendOp - Blend::One, - // SrcBlendAlpha - Blend::InvSrcAlpha, - // DestBlendAlpha - Operation::Add, - // BlendOpAlpha - ColorWrite::All, - // RenderTargetWriteMask + false, // AlphaToCoverageEnable + true, // BlendEnable + Blend::SrcAlpha, // SrcBlend + Blend::InvSrcAlpha, // DestBlend + Operation::Add, // BlendOp + Blend::One, // SrcBlendAlpha + Blend::InvSrcAlpha, // DestBlendAlpha + Operation::Add, // BlendOpAlpha + ColorWrite::All, // RenderTargetWriteMask }; BlendingMode BlendingMode::Add = { - false, - // AlphaToCoverageEnable - true, - // BlendEnable - Blend::One, - // SrcBlend - Blend::One, - // DestBlend - Operation::Add, - // BlendOp - Blend::One, - // SrcBlendAlpha - Blend::One, - // DestBlendAlpha - Operation::Add, - // BlendOpAlpha - ColorWrite::All, - // RenderTargetWriteMask + false, // AlphaToCoverageEnable + true, // BlendEnable + Blend::One, // SrcBlend + Blend::One, // DestBlend + Operation::Add, // BlendOp + Blend::One, // SrcBlendAlpha + Blend::One, // DestBlendAlpha + Operation::Add, // BlendOpAlpha + ColorWrite::All, // RenderTargetWriteMask }; BlendingMode BlendingMode::Multiply = { - false, - // AlphaToCoverageEnable - true, - // BlendEnable - Blend::Zero, - // SrcBlend - Blend::SrcColor, - // DestBlend - Operation::Add, - // BlendOp - Blend::Zero, - // SrcBlendAlpha - Blend::SrcAlpha, - // DestBlendAlpha - Operation::Add, - // BlendOpAlpha - ColorWrite::All, - // RenderTargetWriteMask + false, // AlphaToCoverageEnable + true, // BlendEnable + Blend::Zero, // SrcBlend + Blend::SrcColor, // DestBlend + Operation::Add, // BlendOp + Blend::Zero, // SrcBlendAlpha + Blend::SrcAlpha, // DestBlendAlpha + Operation::Add, // BlendOpAlpha + ColorWrite::All, // RenderTargetWriteMask }; +// @formatter:on + FeatureLevel RenderTools::GetFeatureLevel(ShaderProfile profile) { switch (profile) diff --git a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUContextDX11.cpp b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUContextDX11.cpp index 06f666e12..2ac639e30 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUContextDX11.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUContextDX11.cpp @@ -103,6 +103,7 @@ void GPUContextDX11::FrameBegin() CurrentPS = nullptr; CurrentCS = nullptr; CurrentPrimitiveTopology = D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED; + CurrentBlendFactor = Float4::One; // Bind static samplers ID3D11SamplerState* samplers[] = @@ -267,6 +268,13 @@ void GPUContextDX11::SetRenderTarget(GPUTextureView* depthBuffer, const SpanOMSetBlendState(CurrentBlendState, CurrentBlendFactor.Raw, D3D11_DEFAULT_SAMPLE_MASK); +} + void GPUContextDX11::ResetSR() { _srDirtyFlag = false; @@ -560,8 +568,7 @@ void GPUContextDX11::SetState(GPUPipelineState* state) if (CurrentBlendState != blendState) { CurrentBlendState = blendState; - FLOAT blendFactor[4] = { 1, 1, 1, 1 }; - _context->OMSetBlendState(blendState, blendFactor, D3D11_DEFAULT_SAMPLE_MASK); + _context->OMSetBlendState(blendState, CurrentBlendFactor.Raw, D3D11_DEFAULT_SAMPLE_MASK); } if (CurrentVS != vs) { diff --git a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUContextDX11.h b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUContextDX11.h index 209968fda..b623cba3b 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUContextDX11.h +++ b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUContextDX11.h @@ -61,6 +61,7 @@ private: GPUShaderProgramPSDX11* CurrentPS; GPUShaderProgramCSDX11* CurrentCS; D3D11_PRIMITIVE_TOPOLOGY CurrentPrimitiveTopology; + Float4 CurrentBlendFactor; public: @@ -115,6 +116,7 @@ public: void SetRenderTarget(GPUTextureView* rt) override; void SetRenderTarget(GPUTextureView* depthBuffer, GPUTextureView* rt) override; void SetRenderTarget(GPUTextureView* depthBuffer, const Span& rts) override; + void SetBlendFactor(const Float4& value) override; void ResetSR() override; void ResetUA() override; void ResetCB() override; diff --git a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.cpp b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.cpp index b8af1178b..54f1a4290 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.cpp @@ -845,6 +845,11 @@ void GPUContextDX12::SetRenderTarget(GPUTextureView* depthBuffer, const SpanOMSetBlendFactor(value.Raw); +} + void GPUContextDX12::ResetSR() { for (int32 slot = 0; slot < GPU_MAX_SR_BINDED; slot++) diff --git a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.h b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.h index 4ab6c9155..c870cf71e 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.h +++ b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUContextDX12.h @@ -166,6 +166,7 @@ public: void SetRenderTarget(GPUTextureView* rt) override; void SetRenderTarget(GPUTextureView* depthBuffer, GPUTextureView* rt) override; void SetRenderTarget(GPUTextureView* depthBuffer, const Span& rts) override; + void SetBlendFactor(const Float4& value) override; void ResetSR() override; void ResetUA() override; void ResetCB() override; diff --git a/Source/Engine/GraphicsDevice/Null/GPUContextNull.h b/Source/Engine/GraphicsDevice/Null/GPUContextNull.h index a1ffc290a..7568bb60c 100644 --- a/Source/Engine/GraphicsDevice/Null/GPUContextNull.h +++ b/Source/Engine/GraphicsDevice/Null/GPUContextNull.h @@ -84,6 +84,10 @@ public: { } + void SetBlendFactor(const Float4& value) override + { + } + void ResetSR() override { } diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp index 5c13dd896..d52b446e3 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp @@ -966,6 +966,12 @@ void GPUContextVulkan::SetRenderTarget(GPUTextureView* depthBuffer, const SpanGetCmdBuffer(); + vkCmdSetBlendConstants(cmdBuffer->GetHandle(), value.Raw); +} + void GPUContextVulkan::ResetSR() { Platform::MemoryClear(_srHandles, sizeof(_srHandles)); diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.h b/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.h index 2b8d9f122..63224b2d0 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.h +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.h @@ -184,6 +184,7 @@ public: void SetRenderTarget(GPUTextureView* rt) override; void SetRenderTarget(GPUTextureView* depthBuffer, GPUTextureView* rt) override; void SetRenderTarget(GPUTextureView* depthBuffer, const Span& rts) override; + void SetBlendFactor(const Float4& value) override; void ResetSR() override; void ResetUA() override; void ResetCB() override; From ee19c8e856c3c2bbab667148baea0dbb6cf7e86c Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 1 Feb 2023 11:12:29 +0100 Subject: [PATCH 17/23] Update engine assets --- Content/Editor/Camera/M_Camera.flax | 4 ++-- Content/Editor/CubeTexturePreviewMaterial.flax | 4 ++-- Content/Editor/DebugMaterials/DDGIDebugProbes.flax | 4 ++-- Content/Editor/DebugMaterials/SingleColor/Decal.flax | 4 ++-- Content/Editor/DebugMaterials/SingleColor/Particle.flax | 4 ++-- Content/Editor/DebugMaterials/SingleColor/Surface.flax | 4 ++-- .../Editor/DebugMaterials/SingleColor/SurfaceAdditive.flax | 4 ++-- Content/Editor/DebugMaterials/SingleColor/Terrain.flax | 4 ++-- Content/Editor/DefaultFontMaterial.flax | 4 ++-- Content/Editor/Gizmo/FoliageBrushMaterial.flax | 4 ++-- Content/Editor/Gizmo/Material.flax | 4 ++-- Content/Editor/Gizmo/MaterialWire.flax | 4 ++-- Content/Editor/Gizmo/SelectionOutlineMaterial.flax | 2 +- Content/Editor/Gizmo/VertexColorsPreviewMaterial.flax | 4 ++-- Content/Editor/Highlight Material.flax | 4 ++-- Content/Editor/Icons/IconsMaterial.flax | 4 ++-- Content/Editor/IesProfilePreviewMaterial.flax | 2 +- Content/Editor/Particles/Particle Material Color.flax | 4 ++-- Content/Editor/Particles/Smoke Material.flax | 4 ++-- Content/Editor/SpriteMaterial.flax | 4 ++-- Content/Editor/Terrain/Circle Brush Material.flax | 4 ++-- Content/Editor/Terrain/Highlight Terrain Material.flax | 4 ++-- Content/Editor/TexturePreviewMaterial.flax | 2 +- Content/Editor/Wires Debug Material.flax | 4 ++-- Content/Engine/DefaultDeformableMaterial.flax | 4 ++-- Content/Engine/DefaultMaterial.flax | 4 ++-- Content/Engine/DefaultTerrainMaterial.flax | 4 ++-- Content/Engine/SingleColorMaterial.flax | 4 ++-- Content/Engine/SkyboxMaterial.flax | 4 ++-- Content/Shaders/GI/DDGI.flax | 4 ++-- 30 files changed, 57 insertions(+), 57 deletions(-) diff --git a/Content/Editor/Camera/M_Camera.flax b/Content/Editor/Camera/M_Camera.flax index 768ed42d6..0b6416124 100644 --- a/Content/Editor/Camera/M_Camera.flax +++ b/Content/Editor/Camera/M_Camera.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ec25eba344fed990157e902029f7b113e4fda7ed5630a6b3b693d5c07351a178 -size 30138 +oid sha256:838a974f8892427cc77088f81b994ff611b7451d9ca9af961d3bde534c19c6e3 +size 30094 diff --git a/Content/Editor/CubeTexturePreviewMaterial.flax b/Content/Editor/CubeTexturePreviewMaterial.flax index fd3d482bf..7278d0c55 100644 --- a/Content/Editor/CubeTexturePreviewMaterial.flax +++ b/Content/Editor/CubeTexturePreviewMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2cf6beb5cefcfd91c758b7940b7ed26f435c5e5144233d88c5daf274e8b05c1e -size 31691 +oid sha256:c1764cdebc180b19b6bdb498f9efa0c7179eaab0140a090a532f264caa3c5b9c +size 31647 diff --git a/Content/Editor/DebugMaterials/DDGIDebugProbes.flax b/Content/Editor/DebugMaterials/DDGIDebugProbes.flax index 68f46f7d4..cab929fe0 100644 --- a/Content/Editor/DebugMaterials/DDGIDebugProbes.flax +++ b/Content/Editor/DebugMaterials/DDGIDebugProbes.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a34e48c787818a3a22072142c6a51aa8dd37ae03a1f96526f6021302c6f6508a -size 41832 +oid sha256:02491143310feee47a1573c5fe23bd1e22782ffe17b0a90422215ebe9bfdc023 +size 41028 diff --git a/Content/Editor/DebugMaterials/SingleColor/Decal.flax b/Content/Editor/DebugMaterials/SingleColor/Decal.flax index 0c3b3b6c0..dd703e770 100644 --- a/Content/Editor/DebugMaterials/SingleColor/Decal.flax +++ b/Content/Editor/DebugMaterials/SingleColor/Decal.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e47d5133f12b96d0ce9cde651032b9ede2eec0a099d3702d02bf26a31c9ec051 -size 7696 +oid sha256:c7155b92cfb77d19a1079578943eb73b082bc11dfb6864adc9e5b1e4bab338f2 +size 7489 diff --git a/Content/Editor/DebugMaterials/SingleColor/Particle.flax b/Content/Editor/DebugMaterials/SingleColor/Particle.flax index 30db32463..5075d81d7 100644 --- a/Content/Editor/DebugMaterials/SingleColor/Particle.flax +++ b/Content/Editor/DebugMaterials/SingleColor/Particle.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7a509d2985b590d20d892189684d31ffcf71e0306637ddb93948d8a9649168c5 -size 31753 +oid sha256:3831bf81114e81a44528b3f166a716920c78add4facd6a188c3ca2e3d51e2de3 +size 31708 diff --git a/Content/Editor/DebugMaterials/SingleColor/Surface.flax b/Content/Editor/DebugMaterials/SingleColor/Surface.flax index f60f7c4cf..3b11d2b4c 100644 --- a/Content/Editor/DebugMaterials/SingleColor/Surface.flax +++ b/Content/Editor/DebugMaterials/SingleColor/Surface.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b091889f827c292b2656aa64af9b9101a1eb465b7c9818e6358b2928d9f69c29 -size 30034 +oid sha256:2953c64143861a82b5ba3471cf76edb503bc0cb0c0a28f9b97de83eafe4f84f0 +size 29990 diff --git a/Content/Editor/DebugMaterials/SingleColor/SurfaceAdditive.flax b/Content/Editor/DebugMaterials/SingleColor/SurfaceAdditive.flax index 0bbf43c36..67adb11ea 100644 --- a/Content/Editor/DebugMaterials/SingleColor/SurfaceAdditive.flax +++ b/Content/Editor/DebugMaterials/SingleColor/SurfaceAdditive.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8e7af2e0901a62301e6cfbb7df915e04486073dbeee0904adea99774ee9d93d5 -size 31919 +oid sha256:6d19b52df092ffc457db2d122e80542f5a3c63ea1e29b178a96450a82a52052b +size 31873 diff --git a/Content/Editor/DebugMaterials/SingleColor/Terrain.flax b/Content/Editor/DebugMaterials/SingleColor/Terrain.flax index 20220b081..2feb001ab 100644 --- a/Content/Editor/DebugMaterials/SingleColor/Terrain.flax +++ b/Content/Editor/DebugMaterials/SingleColor/Terrain.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:07d8e970f92010b4fdb3a058415a758d87d2117bf7668b1fa4471a13fc623177 -size 21238 +oid sha256:bc2fe7a3466d4548f73aa4d5d3bb67bd9b33175f9253b218b4e7610019368938 +size 20769 diff --git a/Content/Editor/DefaultFontMaterial.flax b/Content/Editor/DefaultFontMaterial.flax index d93a64e18..9cf6491dd 100644 --- a/Content/Editor/DefaultFontMaterial.flax +++ b/Content/Editor/DefaultFontMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:25f8315d4bfdc65c101a6b8b423b999d058321f158ad4fc98bffe74678b8b2d3 -size 30213 +oid sha256:6f18a205661867897c7c555da73fc04529b9922f4f1bfa858604fe982bcf2322 +size 30169 diff --git a/Content/Editor/Gizmo/FoliageBrushMaterial.flax b/Content/Editor/Gizmo/FoliageBrushMaterial.flax index 8a3cdb2df..86509d484 100644 --- a/Content/Editor/Gizmo/FoliageBrushMaterial.flax +++ b/Content/Editor/Gizmo/FoliageBrushMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:485cedb18db31cb18c7991dbda99dcc3440b48b0f49b219b563731e5304504c5 -size 38691 +oid sha256:6747c15e1bf43384b57b544be4d70e260a5ef5a89cf69eac371429b6205a18a1 +size 37868 diff --git a/Content/Editor/Gizmo/Material.flax b/Content/Editor/Gizmo/Material.flax index 66f72fd47..0b0d3fd8c 100644 --- a/Content/Editor/Gizmo/Material.flax +++ b/Content/Editor/Gizmo/Material.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a1a0beaec89af72a7622512963b3a431c61fad77d289794e2fde2e256f7b3f37 -size 32457 +oid sha256:bf16bc35903e23c0b7f59ca2a34de4b48d94d95980796a3201d5dbaff5b63f3c +size 32411 diff --git a/Content/Editor/Gizmo/MaterialWire.flax b/Content/Editor/Gizmo/MaterialWire.flax index 532a49b86..1f38c6e5d 100644 --- a/Content/Editor/Gizmo/MaterialWire.flax +++ b/Content/Editor/Gizmo/MaterialWire.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3938bb1381efc2842f73f514dcb3289f29fda2504c2550a25e807080dc8150b0 -size 31670 +oid sha256:25b0e59a469631c94033633928fabc1c7bcf16b8903c24e2a36805e16052a968 +size 31624 diff --git a/Content/Editor/Gizmo/SelectionOutlineMaterial.flax b/Content/Editor/Gizmo/SelectionOutlineMaterial.flax index 20cb250ad..bc26ec449 100644 --- a/Content/Editor/Gizmo/SelectionOutlineMaterial.flax +++ b/Content/Editor/Gizmo/SelectionOutlineMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c68d577cc0d761c5ba02992b666f2ceb85c6178a5b2639b14bbcabdc449a1c03 +oid sha256:7ac836ef9f715ac8c46f583b4b0a8bb77dd3d4ac9c5cc84ae1199694b2f0849b size 16202 diff --git a/Content/Editor/Gizmo/VertexColorsPreviewMaterial.flax b/Content/Editor/Gizmo/VertexColorsPreviewMaterial.flax index 539fa76ad..6166adc63 100644 --- a/Content/Editor/Gizmo/VertexColorsPreviewMaterial.flax +++ b/Content/Editor/Gizmo/VertexColorsPreviewMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:145a977ccd4fc5f0ef8dc7411331a414e473c13cc3a7fde8b9fa9cb02f3156a1 -size 31147 +oid sha256:81552ebd313ceb552ef4b536ecf1cb8060578d00107e3dcde2fadb1d0d766654 +size 31103 diff --git a/Content/Editor/Highlight Material.flax b/Content/Editor/Highlight Material.flax index 78fd05c06..b3ddcd5bb 100644 --- a/Content/Editor/Highlight Material.flax +++ b/Content/Editor/Highlight Material.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:53f86e6b1f6d1f9c31845a86a028a67937f79b90b878783601b752b1c82f67e2 -size 30269 +oid sha256:36f165ae76fa91b99b071736c6ae1bd329e6bc4b4556d8229798b2a18f48ea20 +size 30271 diff --git a/Content/Editor/Icons/IconsMaterial.flax b/Content/Editor/Icons/IconsMaterial.flax index 9b6e5e1e6..196c16f19 100644 --- a/Content/Editor/Icons/IconsMaterial.flax +++ b/Content/Editor/Icons/IconsMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4751716e158f8390e4f451e4eb64df71472a4b1f822247995be4417a81169880 -size 30197 +oid sha256:4da6e914c1f458f82585a4564a14e9b65ca1d5b36b680580a1aa563915173b2f +size 30199 diff --git a/Content/Editor/IesProfilePreviewMaterial.flax b/Content/Editor/IesProfilePreviewMaterial.flax index 097ca7846..03479e1a9 100644 --- a/Content/Editor/IesProfilePreviewMaterial.flax +++ b/Content/Editor/IesProfilePreviewMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cddc591a3af95c1c49983ee0e220ec39ad93e9af4a113d20cb2d5ded9f3230f4 +oid sha256:73ae37b799d131c887f983667e0e85b11ca5b6318d9927da779cbc8a570c6bd7 size 18217 diff --git a/Content/Editor/Particles/Particle Material Color.flax b/Content/Editor/Particles/Particle Material Color.flax index 2847afa57..8af6e240b 100644 --- a/Content/Editor/Particles/Particle Material Color.flax +++ b/Content/Editor/Particles/Particle Material Color.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:357608bdb965c0bc4391cccb8c2ffacdc7eda4542e3bf09e81f9d899626e06b5 -size 29945 +oid sha256:81c4302ab2103b31669943eea45da3589a127b3a2b3855832bca9e880bf3ce32 +size 29948 diff --git a/Content/Editor/Particles/Smoke Material.flax b/Content/Editor/Particles/Smoke Material.flax index a3c824681..41d4254dd 100644 --- a/Content/Editor/Particles/Smoke Material.flax +++ b/Content/Editor/Particles/Smoke Material.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6fa22067784d57637da65339a71a722360a441ecb4c266242e65212dbe2db1be -size 37133 +oid sha256:18ce95219dc62718fa9aa2a0763a4686c9342f652270299c863641d6229e7639 +size 37136 diff --git a/Content/Editor/SpriteMaterial.flax b/Content/Editor/SpriteMaterial.flax index 8cfcdb81b..310818af7 100644 --- a/Content/Editor/SpriteMaterial.flax +++ b/Content/Editor/SpriteMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7dc760c37c70008e1d8e71f392138d54d4a6308df768381864994027474f94e3 -size 31226 +oid sha256:26303ad922aba5d64e893bb613cfb033e2b6067d78f0b02d43fdd3a16ee11aa6 +size 31182 diff --git a/Content/Editor/Terrain/Circle Brush Material.flax b/Content/Editor/Terrain/Circle Brush Material.flax index 730130f85..588a5af00 100644 --- a/Content/Editor/Terrain/Circle Brush Material.flax +++ b/Content/Editor/Terrain/Circle Brush Material.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:131dac4676de0b4ac8257cd450b7538307383143d352265b062f6689d5215374 -size 27619 +oid sha256:acfc660dc2683899c5be5a3331d7e3e756a34deb30cfc3d117b5dfb9c64a94e3 +size 27150 diff --git a/Content/Editor/Terrain/Highlight Terrain Material.flax b/Content/Editor/Terrain/Highlight Terrain Material.flax index 3ee054ccf..c0e295c08 100644 --- a/Content/Editor/Terrain/Highlight Terrain Material.flax +++ b/Content/Editor/Terrain/Highlight Terrain Material.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:adf85e5679b8a0a4f78663d0a119e1819641a0460100595654fe31649b798c1d -size 21291 +oid sha256:28443ded233eb27922c3ce7ed2146ed416ce13104ad9c4c5af2833d916098c7a +size 20822 diff --git a/Content/Editor/TexturePreviewMaterial.flax b/Content/Editor/TexturePreviewMaterial.flax index 90235d453..e048a3355 100644 --- a/Content/Editor/TexturePreviewMaterial.flax +++ b/Content/Editor/TexturePreviewMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:26ff727713fd57c857f9a21e369f3a91ae3188e95cb9d762cac523d8c663262a +oid sha256:3d97d1dbe12d3d580567cdca83f5bfc933ddd2fc9adeec896e2d29ff665fc64e size 10413 diff --git a/Content/Editor/Wires Debug Material.flax b/Content/Editor/Wires Debug Material.flax index f58128c37..8e345b22e 100644 --- a/Content/Editor/Wires Debug Material.flax +++ b/Content/Editor/Wires Debug Material.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f1ab66e68b7d4e237232e4abac2be1763b4149109a619901b00862a3a86639e5 -size 30269 +oid sha256:98f08deb52704baf10689caba74b87e03c5386404edc1a0af90ae49958db9c94 +size 30271 diff --git a/Content/Engine/DefaultDeformableMaterial.flax b/Content/Engine/DefaultDeformableMaterial.flax index 1b90f7fc3..e7d5ad014 100644 --- a/Content/Engine/DefaultDeformableMaterial.flax +++ b/Content/Engine/DefaultDeformableMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c58b87b135659215bbea0094368511c1b925fc82df35d2e6403ccbbcd34e9322 -size 18914 +oid sha256:419c36e4c8eb2f030fd6ab52459ae5d3d55955373b0ae788650963066b4b70d7 +size 18530 diff --git a/Content/Engine/DefaultMaterial.flax b/Content/Engine/DefaultMaterial.flax index 8c54ba2c8..72e710180 100644 --- a/Content/Engine/DefaultMaterial.flax +++ b/Content/Engine/DefaultMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2fb9906c87a1e11261ca8a12fde8a5e808827599d3f423ebfd2437bd5c26d375 -size 32065 +oid sha256:5bb044bd9e1e7c9e9f9f2d172d9f3ff80b0b396e85f542411a34f1da1bda4cc5 +size 32021 diff --git a/Content/Engine/DefaultTerrainMaterial.flax b/Content/Engine/DefaultTerrainMaterial.flax index 8787991a0..7ddce7853 100644 --- a/Content/Engine/DefaultTerrainMaterial.flax +++ b/Content/Engine/DefaultTerrainMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e7676a6523be037dbfa10e2957c2175f650978e7850af443f4c859f687f5f89f -size 23381 +oid sha256:26d2de798c935312ba874b6f8eb0c1f9f2b34d5a1b702a6d52babf03c72e2cd4 +size 22912 diff --git a/Content/Engine/SingleColorMaterial.flax b/Content/Engine/SingleColorMaterial.flax index ede999b2c..96e289d44 100644 --- a/Content/Engine/SingleColorMaterial.flax +++ b/Content/Engine/SingleColorMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:26fe92bc72d726fde4811aee6056f3b8ed0797a433d5a76b07c24dd20bc42199 -size 30235 +oid sha256:441c5469d76d887643e042e6ae699d245064719544b48f41c59aceb76b4fb4af +size 30191 diff --git a/Content/Engine/SkyboxMaterial.flax b/Content/Engine/SkyboxMaterial.flax index 97875e653..11a14defc 100644 --- a/Content/Engine/SkyboxMaterial.flax +++ b/Content/Engine/SkyboxMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:46f557106d4b4b7768cdeb0db8da1d1ae40637495afef2fe71b3591d82063f55 -size 31433 +oid sha256:c89778519d234c281efbcaaf5fedc0bc4a26212832d466bf4f6e571813030740 +size 31389 diff --git a/Content/Shaders/GI/DDGI.flax b/Content/Shaders/GI/DDGI.flax index c8f8eee9d..5ad91546e 100644 --- a/Content/Shaders/GI/DDGI.flax +++ b/Content/Shaders/GI/DDGI.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6b00a1519c9fe2303a05c10ae4061649c4073a3f65a3bd8c2af848cdc7bf5e53 -size 23702 +oid sha256:7e314ba50df6a9358dfe10d383f20e7a4bb30e180e32f5bb83e8a63d9dfbcb39 +size 23668 From baabc5d16fa24edf03e501367a21ae64fafd4f9c Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 1 Feb 2023 11:38:22 +0100 Subject: [PATCH 18/23] Add `AfterForwardPass` for custom postfx render location --- Source/Engine/Graphics/Enums.h | 18 ++++++++++++++---- Source/Engine/Renderer/Renderer.cpp | 4 ++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Source/Engine/Graphics/Enums.h b/Source/Engine/Graphics/Enums.h index 74c859352..7d9b5ceb3 100644 --- a/Source/Engine/Graphics/Enums.h +++ b/Source/Engine/Graphics/Enums.h @@ -591,22 +591,22 @@ API_ENUM() enum class Quality : byte API_ENUM() enum class MaterialPostFxLocation : byte { /// - /// The after post processing pass using LDR input frame. + /// The 'after' post processing pass using LDR input frame. /// AfterPostProcessingPass = 0, /// - /// The before post processing pass using HDR input frame. + /// The 'before' post processing pass using HDR input frame. /// BeforePostProcessingPass = 1, /// - /// The before forward pass but after GBuffer with HDR input frame. + /// The 'before' forward pass but after GBuffer with HDR input frame. /// BeforeForwardPass = 2, /// - /// The after custom post effects. + /// The 'after' custom post effects. /// AfterCustomPostEffects = 3, @@ -620,6 +620,11 @@ API_ENUM() enum class MaterialPostFxLocation : byte /// AfterAntiAliasingPass = 5, + /// + /// The 'after' forward pass but before any post processing. + /// + AfterForwardPass = 6, + API_ENUM(Attributes="HideInEditor") MAX, }; @@ -664,6 +669,11 @@ API_ENUM() enum class PostProcessEffectLocation /// AfterGBufferPass = 6, + /// + /// The 'after' forward pass but before any post processing. + /// + AfterForwardPass = 7, + API_ENUM(Attributes="HideInEditor") MAX, }; diff --git a/Source/Engine/Renderer/Renderer.cpp b/Source/Engine/Renderer/Renderer.cpp index d3ea5800e..584ab6b45 100644 --- a/Source/Engine/Renderer/Renderer.cpp +++ b/Source/Engine/Renderer/Renderer.cpp @@ -545,6 +545,10 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont RENDER_TARGET_POOL_SET_NAME(frameBuffer, "FrameBuffer"); ForwardPass::Instance()->Render(renderContext, lightBuffer, frameBuffer); + // Material and Custom PostFx + renderContext.List->RunMaterialPostFxPass(context, renderContext, MaterialPostFxLocation::AfterForwardPass, frameBuffer, lightBuffer); + renderContext.List->RunCustomPostFxPass(context, renderContext, PostProcessEffectLocation::AfterForwardPass, frameBuffer, lightBuffer); + // Cleanup context->ResetRenderTarget(); context->ResetSR(); From 36ba1d995306006f965d9fea7e2f521b4d3d8ba6 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 2 Feb 2023 13:05:54 +0100 Subject: [PATCH 19/23] Add play/pause widget and keybind for particles preview in asset Editor --- .../Previews/ParticleSystemPreview.cs | 63 +++++++++++++++++-- Source/Engine/Particles/ParticleEffect.cpp | 4 +- Source/Engine/Particles/ParticleEffect.h | 3 +- 3 files changed, 62 insertions(+), 8 deletions(-) diff --git a/Source/Editor/Viewport/Previews/ParticleSystemPreview.cs b/Source/Editor/Viewport/Previews/ParticleSystemPreview.cs index e845ae62c..78c44f654 100644 --- a/Source/Editor/Viewport/Previews/ParticleSystemPreview.cs +++ b/Source/Editor/Viewport/Previews/ParticleSystemPreview.cs @@ -2,8 +2,10 @@ using FlaxEditor.GUI.ContextMenu; using FlaxEditor.Viewport.Cameras; +using FlaxEditor.Viewport.Widgets; using FlaxEngine; using FlaxEngine.GUI; +using System; using Object = FlaxEngine.Object; namespace FlaxEditor.Viewport.Previews @@ -14,10 +16,12 @@ namespace FlaxEditor.Viewport.Previews /// public class ParticleSystemPreview : AssetPreview { + private bool _playSimulation = false; private ParticleEffect _previewEffect; private ContextMenuButton _showBoundsButton; private ContextMenuButton _showOriginButton; private ContextMenuButton _showParticleCounterButton; + private ViewportWidgetButton _playPauseButton; private StaticModel _boundsModel; private StaticModel _originModel; private bool _showParticlesCounter; @@ -39,7 +43,25 @@ namespace FlaxEditor.Viewport.Previews /// /// Gets or sets a value indicating whether to play the particles simulation in editor. /// - public bool PlaySimulation { get; set; } = false; + public bool PlaySimulation + { + get => _playSimulation; + set + { + if (_playSimulation == value) + return; + _playSimulation = value; + PlaySimulationChanged?.Invoke(); + + if (_playPauseButton != null) + _playPauseButton.Icon = value ? Editor.Instance.Icons.Pause64 : Editor.Instance.Icons.Play64; + } + } + + /// + /// Occurs when particles simulation playback state gets changed. + /// + public event Action PlaySimulationChanged; /// /// Gets or sets a value indicating whether to show particle effect bounding box. @@ -161,11 +183,22 @@ namespace FlaxEditor.Viewport.Previews // Link actors for rendering Task.AddCustomActor(_previewEffect); - if (useWidgets) + if (!useWidgets) + return; + _showBoundsButton = ViewWidgetShowMenu.AddButton("Bounds", () => ShowBounds = !ShowBounds); + _showOriginButton = ViewWidgetShowMenu.AddButton("Origin", () => ShowOrigin = !ShowOrigin); + _showParticleCounterButton = ViewWidgetShowMenu.AddButton("Particles Counter", () => ShowParticlesCounter = !ShowParticlesCounter); + + // Play/Pause widget { - _showBoundsButton = ViewWidgetShowMenu.AddButton("Bounds", () => ShowBounds = !ShowBounds); - _showOriginButton = ViewWidgetShowMenu.AddButton("Origin", () => ShowOrigin = !ShowOrigin); - _showParticleCounterButton = ViewWidgetShowMenu.AddButton("Particles Counter", () => ShowParticlesCounter = !ShowParticlesCounter); + var playPauseWidget = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperRight); + _playPauseButton = new ViewportWidgetButton(null, Editor.Instance.Icons.Pause64) + { + TooltipText = "Simulation playback play (F5) or pause (F6)", + Parent = playPauseWidget, + }; + _playPauseButton.Clicked += button => PlaySimulation = !PlaySimulation; + playPauseWidget.Parent = this; } } @@ -200,7 +233,7 @@ namespace FlaxEditor.Viewport.Previews // Manually update simulation if (PlaySimulation) { - _previewEffect.UpdateSimulation(); + _previewEffect.UpdateSimulation(true); } // Keep bounds matching the model @@ -228,6 +261,23 @@ namespace FlaxEditor.Viewport.Previews } } + /// + public override bool OnKeyDown(KeyboardKeys key) + { + var inputOptions = Editor.Instance.Options.Options.Input; + if (inputOptions.Play.Process(this, key)) + { + PlaySimulation = true; + return true; + } + if (inputOptions.Pause.Process(this, key)) + { + PlaySimulation = false; + return true; + } + return base.OnKeyDown(key); + } + /// public override void OnDestroy() { @@ -239,6 +289,7 @@ namespace FlaxEditor.Viewport.Previews _showBoundsButton = null; _showOriginButton = null; _showParticleCounterButton = null; + _playPauseButton = null; base.OnDestroy(); } diff --git a/Source/Engine/Particles/ParticleEffect.cpp b/Source/Engine/Particles/ParticleEffect.cpp index 4b8cec37a..4b7923439 100644 --- a/Source/Engine/Particles/ParticleEffect.cpp +++ b/Source/Engine/Particles/ParticleEffect.cpp @@ -258,7 +258,7 @@ void ParticleEffect::ResetSimulation() Instance.ClearState(); } -void ParticleEffect::UpdateSimulation() +void ParticleEffect::UpdateSimulation(bool singleFrame) { // Skip if need to if (!IsActiveInHierarchy() @@ -270,6 +270,8 @@ void ParticleEffect::UpdateSimulation() // Request update _lastUpdateFrame = Engine::FrameCount; _lastMinDstSqr = MAX_Real; + if (singleFrame) + Instance.LastUpdateTime = (UseTimeScale ? Time::Update.Time : Time::Update.UnscaledTime).GetTotalSeconds(); Particles::UpdateEffect(this); } diff --git a/Source/Engine/Particles/ParticleEffect.h b/Source/Engine/Particles/ParticleEffect.h index 6ace026af..3487a35f4 100644 --- a/Source/Engine/Particles/ParticleEffect.h +++ b/Source/Engine/Particles/ParticleEffect.h @@ -334,7 +334,8 @@ public: /// /// Performs the full particles simulation update (postponed for the next particle manager update). /// - API_FUNCTION() void UpdateSimulation(); + /// True if update animation by a single frame only (time time since last engine update), otherwise will update simulation with delta time since last update. + API_FUNCTION() void UpdateSimulation(bool singleFrame = false); /// /// Updates the actor bounds. From b64475bcfa59af1189884312558ce9594d7cdccb Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 2 Feb 2023 15:53:16 +0100 Subject: [PATCH 20/23] Fix particle module initialization if it reuses graph from other module --- Source/Engine/Particles/Graph/ParticleEmitterGraph.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Engine/Particles/Graph/ParticleEmitterGraph.h b/Source/Engine/Particles/Graph/ParticleEmitterGraph.h index e5801827e..7b0b53eb7 100644 --- a/Source/Engine/Particles/Graph/ParticleEmitterGraph.h +++ b/Source/Engine/Particles/Graph/ParticleEmitterGraph.h @@ -556,7 +556,7 @@ public: // Compute particle data layout and initialize used nodes (for only used nodes, start depth searching rom the modules) Layout.AddAttribute(TEXT("Position"), ParticleAttribute::ValueTypes::Float3); -#define PROCESS_MODULES(modules) for (int32 i = 0; i < modules.Count(); i++) { InitializeNode(modules[i]); } +#define PROCESS_MODULES(modules) for (int32 i = 0; i < modules.Count(); i++) { modules[i]->Used = false; InitializeNode(modules[i]); } PROCESS_MODULES(SpawnModules); PROCESS_MODULES(InitModules); PROCESS_MODULES(UpdateModules); From 50faa49c0f3ecb724ec99dd69f988a4d3286ac1c Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 2 Feb 2023 15:53:55 +0100 Subject: [PATCH 21/23] Add spacebar for play/pause in animated model and particles previews --- .../Editor/Viewport/Previews/AnimatedModelPreview.cs | 6 +++++- .../Editor/Viewport/Previews/ParticleSystemPreview.cs | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Viewport/Previews/AnimatedModelPreview.cs b/Source/Editor/Viewport/Previews/AnimatedModelPreview.cs index b9f27f77b..268295405 100644 --- a/Source/Editor/Viewport/Previews/AnimatedModelPreview.cs +++ b/Source/Editor/Viewport/Previews/AnimatedModelPreview.cs @@ -428,8 +428,12 @@ namespace FlaxEditor.Viewport.Previews case KeyboardKeys.F: // Pay respect.. ViewportCamera.SetArcBallView(_previewModel.Box); - break; + return true; + case KeyboardKeys.Spacebar: + PlayAnimation = !PlayAnimation; + return true; } + return base.OnKeyDown(key); } diff --git a/Source/Editor/Viewport/Previews/ParticleSystemPreview.cs b/Source/Editor/Viewport/Previews/ParticleSystemPreview.cs index 78c44f654..1e0c89528 100644 --- a/Source/Editor/Viewport/Previews/ParticleSystemPreview.cs +++ b/Source/Editor/Viewport/Previews/ParticleSystemPreview.cs @@ -264,6 +264,16 @@ namespace FlaxEditor.Viewport.Previews /// public override bool OnKeyDown(KeyboardKeys key) { + switch (key) + { + case KeyboardKeys.F: + ViewportCamera.SetArcBallView(_previewEffect.Box); + return true; + case KeyboardKeys.Spacebar: + PlaySimulation = !PlaySimulation; + return true; + } + var inputOptions = Editor.Instance.Options.Options.Input; if (inputOptions.Play.Process(this, key)) { @@ -275,6 +285,7 @@ namespace FlaxEditor.Viewport.Previews PlaySimulation = false; return true; } + return base.OnKeyDown(key); } From aa8d6f7c79526b24f3087e874eed01c551fb8531 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 3 Feb 2023 13:30:48 +0100 Subject: [PATCH 22/23] Fix ribbon particles triangle indices ordering to prevent artifacts --- .../Editor/MaterialTemplates/Particle.shader | 46 +++--- .../Graphics/Materials/MaterialShader.h | 2 +- .../Materials/ParticleMaterialShader.cpp | 3 - Source/Engine/Particles/Particles.cpp | 143 ++++++++++-------- Source/Engine/Particles/ParticlesData.cpp | 3 +- Source/Engine/Particles/ParticlesData.h | 5 +- Source/Engine/Renderer/DrawCall.h | 1 - 7 files changed, 109 insertions(+), 94 deletions(-) diff --git a/Content/Editor/MaterialTemplates/Particle.shader b/Content/Editor/MaterialTemplates/Particle.shader index 18a270cc0..3f6b03a58 100644 --- a/Content/Editor/MaterialTemplates/Particle.shader +++ b/Content/Editor/MaterialTemplates/Particle.shader @@ -4,8 +4,6 @@ #define MATERIAL 1 #define USE_PER_VIEW_CONSTANTS 1 @3 -// Ribbons don't use sorted indices so overlap the segment distances buffer on the slot -#define HAS_SORTED_INDICES (!defined(_VS_Ribbon)) #include "./Flax/Common.hlsl" #include "./Flax/MaterialCommon.hlsl" @@ -18,6 +16,14 @@ struct SpriteInput float2 TexCoord : TEXCOORD; }; +struct RibbonInput +{ + uint Order : TEXCOORD0; + uint ParticleIndex : TEXCOORD1; + uint PrevParticleIndex : TEXCOORD2; + float Distance : TEXCOORD3; +}; + // Primary constant buffer (with additional material parameters) META_CB_BEGIN(0, Data) float4x4 WorldMatrix; @@ -45,13 +51,8 @@ float4x4 WorldMatrixInverseTransposed; // Particles attributes buffer ByteAddressBuffer ParticlesData : register(t0); -#if HAS_SORTED_INDICES // Sorted particles indices Buffer SortedIndices : register(t1); -#else -// Ribbon particles segments distances buffer -Buffer SegmentDistances : register(t1); -#endif // Shader resources @2 @@ -320,13 +321,11 @@ VertexOutput VS_Sprite(SpriteInput input, uint particleIndex : SV_InstanceID) { VertexOutput output; -#if HAS_SORTED_INDICES // Sorted particles mapping if (SortedIndicesOffset != 0xFFFFFFFF) { particleIndex = SortedIndices[SortedIndicesOffset + particleIndex]; } -#endif // Read particle data float3 particlePosition = GetParticleVec3(particleIndex, PositionOffset); @@ -457,13 +456,11 @@ VertexOutput VS_Model(ModelInput input, uint particleIndex : SV_InstanceID) { VertexOutput output; -#if HAS_SORTED_INDICES // Sorted particles mapping if (SortedIndicesOffset != 0xFFFFFFFF) { particleIndex = SortedIndices[SortedIndicesOffset + particleIndex]; } -#endif // Read particle data float3 particlePosition = GetParticleVec3(particleIndex, PositionOffset); @@ -566,12 +563,16 @@ VertexOutput VS_Model(ModelInput input, uint particleIndex : SV_InstanceID) // Vertex Shader function for Ribbon Rendering META_VS(true, FEATURE_LEVEL_ES2) -VertexOutput VS_Ribbon(uint vertexIndex : SV_VertexID) +META_VS_IN_ELEMENT(TEXCOORD, 0, R32_UINT, 0, 0, PER_VERTEX, 0, true) +META_VS_IN_ELEMENT(TEXCOORD, 1, R32_UINT, 0, ALIGN, PER_VERTEX, 0, true) +META_VS_IN_ELEMENT(TEXCOORD, 2, R32_UINT, 0, ALIGN, PER_VERTEX, 0, true) +META_VS_IN_ELEMENT(TEXCOORD, 3, R32_FLOAT, 0, ALIGN, PER_VERTEX, 0, true) +VertexOutput VS_Ribbon(RibbonInput input, uint vertexIndex : SV_VertexID) { VertexOutput output; // Get particle data - uint particleIndex = vertexIndex / 2; + uint particleIndex = input.ParticleIndex; int vertexSign = (((int)vertexIndex & 0x1) * 2) - 1; float3 position = GetParticlePosition(particleIndex); float ribbonWidth = RibbonWidthOffset != -1 ? GetParticleFloat(particleIndex, RibbonWidthOffset) : 20.0f; @@ -579,15 +580,13 @@ VertexOutput VS_Ribbon(uint vertexIndex : SV_VertexID) // Calculate ribbon direction float3 direction; - if (particleIndex == 0) + if (input.Order == 0) { - float3 nextParticlePos = GetParticlePosition(particleIndex + 1); - direction = nextParticlePos - position; + direction = GetParticlePosition(input.PrevParticleIndex) - position; } else { - float3 previousParticlePos = GetParticlePosition(particleIndex - 1); - direction = position - previousParticlePos; + direction = position - GetParticlePosition(input.PrevParticleIndex); } // Calculate particle orientation (tangent vectors) @@ -604,19 +603,16 @@ VertexOutput VS_Ribbon(uint vertexIndex : SV_VertexID) } // Calculate texture coordinates - float texCoordU; -#ifdef _VS_Ribbon if (RibbonUVTilingDistance != 0.0f) { - texCoordU = SegmentDistances[particleIndex] / RibbonUVTilingDistance; + output.TexCoord.x = input.Distance / RibbonUVTilingDistance; } else -#endif { - texCoordU = (float)particleIndex / RibbonSegmentCount; + output.TexCoord.x = (float)input.Order / (float)RibbonSegmentCount; } - float texCoordV = (vertexIndex + 1) & 0x1; - output.TexCoord = float2(texCoordU, texCoordV) * RibbonUVScale + RibbonUVOffset; + output.TexCoord.y = (vertexIndex + 1) & 0x1; + output.TexCoord = output.TexCoord * RibbonUVScale + RibbonUVOffset; // Compute world space vertex position output.WorldPosition = position + tangentRight * vertexSign * (ribbonWidth.xxx * 0.5f); diff --git a/Source/Engine/Graphics/Materials/MaterialShader.h b/Source/Engine/Graphics/Materials/MaterialShader.h index 48a9abe5e..be6a58741 100644 --- a/Source/Engine/Graphics/Materials/MaterialShader.h +++ b/Source/Engine/Graphics/Materials/MaterialShader.h @@ -10,7 +10,7 @@ /// /// Current materials shader version. /// -#define MATERIAL_GRAPH_VERSION 160 +#define MATERIAL_GRAPH_VERSION 161 class Material; class GPUShader; diff --git a/Source/Engine/Graphics/Materials/ParticleMaterialShader.cpp b/Source/Engine/Graphics/Materials/ParticleMaterialShader.cpp index ec39ef41b..8cf8299e9 100644 --- a/Source/Engine/Graphics/Materials/ParticleMaterialShader.cpp +++ b/Source/Engine/Graphics/Materials/ParticleMaterialShader.cpp @@ -154,9 +154,6 @@ void ParticleMaterialShader::Bind(BindParameters& params) materialData->RibbonUVOffset.Y = drawCall.Particle.Ribbon.UVOffsetY; materialData->RibbonSegmentCount = drawCall.Particle.Ribbon.SegmentCount; - if (drawCall.Particle.Ribbon.SegmentDistances) - context->BindSR(1, drawCall.Particle.Ribbon.SegmentDistances->View()); - break; } } diff --git a/Source/Engine/Particles/Particles.cpp b/Source/Engine/Particles/Particles.cpp index 89b787df2..b1ab02f18 100644 --- a/Source/Engine/Particles/Particles.cpp +++ b/Source/Engine/Particles/Particles.cpp @@ -28,13 +28,13 @@ #include "Editor/Editor.h" #endif -struct SpriteParticleVertex -{ +PACK_STRUCT(struct SpriteParticleVertex + { float X; float Y; float U; float V; -}; + }); class SpriteParticleRenderer { @@ -82,6 +82,14 @@ public: } }; +PACK_STRUCT(struct RibbonParticleVertex { + uint32 Order; + uint32 ParticleIndex; + uint32 PrevParticleIndex; + float Distance; + // TODO: pack into half/uint16 data + }); + struct EmitterCache { double LastTimeUsed; @@ -113,7 +121,6 @@ namespace ParticlesDrawCPU Array SortingKeys[2]; Array SortingIndices; Array SortedIndices; - Array RibbonTotalDistances; } class ParticleManagerService : public EngineService @@ -289,14 +296,17 @@ void DrawEmitterCPU(RenderContext& renderContext, ParticleBuffer* buffer, DrawCa { // Prepare ribbon data if (!buffer->GPU.RibbonIndexBufferDynamic) - { buffer->GPU.RibbonIndexBufferDynamic = New(0, (uint32)sizeof(uint16), TEXT("RibbonIndexBufferDynamic")); - } - buffer->GPU.RibbonIndexBufferDynamic->Clear(); + else + buffer->GPU.RibbonIndexBufferDynamic->Clear(); + if (!buffer->GPU.RibbonVertexBufferDynamic) + buffer->GPU.RibbonVertexBufferDynamic = New(0, (uint32)sizeof(RibbonParticleVertex), TEXT("RibbonVertexBufferDynamic")); + else + buffer->GPU.RibbonVertexBufferDynamic->Clear(); + auto& indexBuffer = buffer->GPU.RibbonIndexBufferDynamic->Data; + auto& vertexBuffer = buffer->GPU.RibbonVertexBufferDynamic->Data; // Setup all ribbon modules - auto& totalDistances = ParticlesDrawCPU::RibbonTotalDistances; - totalDistances.Clear(); for (int32 index = 0; index < renderModulesIndices.Count(); index++) { const int32 moduleIndex = renderModulesIndices[index]; @@ -313,74 +323,88 @@ void DrawEmitterCPU(RenderContext& renderContext, ParticleBuffer* buffer, DrawCa int32 count = buffer->CPU.Count; ASSERT(buffer->CPU.RibbonOrder.Count() == emitter->Graph.RibbonRenderingModules.Count() * buffer->Capacity); int32* ribbonOrderData = buffer->CPU.RibbonOrder.Get() + module->RibbonOrderOffset; - ParticleBufferCPUDataAccessor positionData(buffer, emitter->Graph.Layout.GetAttributeOffset(module->Attributes[0])); - int32 indices = 0; - + // Write ribbon indices/vertices + int32 indices = 0, segmentCount = 0; float totalDistance = 0.0f; - uint32 lastParticleIdx = ribbonOrderData[0]; - for (int32 i = 0; i < count; i++) + int32 firstVertexIndex = vertexBuffer.Count(); + uint32 idxPrev = ribbonOrderData[0], vertexPrev = 0; { - bool isNotLast = i != count - 1; - uint32 idx0 = ribbonOrderData[i]; - uint32 idx1 = 0; - Float3 direction; - if (isNotLast) + uint32 idxThis = ribbonOrderData[0]; + + // 2 vertices { - idx1 = ribbonOrderData[i + 1]; - direction = positionData[idx1] - positionData[lastParticleIdx]; - } - else - { - idx1 = ribbonOrderData[i - 1]; - direction = positionData[lastParticleIdx] - positionData[idx1]; + vertexBuffer.AddUninitialized(2 * sizeof(RibbonParticleVertex)); + auto ptr = (RibbonParticleVertex*)(vertexBuffer.Get() + firstVertexIndex); + + RibbonParticleVertex v = { 0, idxThis, idxThis, totalDistance }; + + *ptr++ = v; + *ptr++ = v; } - if (direction.LengthSquared() > 0.002f || !isNotLast) + idxPrev = idxThis; + } + for (uint32 i = 1; i < count; i++) + { + uint32 idxThis = ribbonOrderData[i]; + Float3 direction = positionData[idxThis] - positionData[idxPrev]; + const float distance = direction.Length(); + if (distance > 0.002f) { - totalDistances.Add(totalDistance); - lastParticleIdx = idx1; + totalDistance += distance; - if (isNotLast) + // 2 vertices { - auto idx = buffer->GPU.RibbonIndexBufferDynamic->Data.Count(); - buffer->GPU.RibbonIndexBufferDynamic->Data.AddDefault(6 * sizeof(uint16)); - auto ptr = (uint16*)(buffer->GPU.RibbonIndexBufferDynamic->Data.Get() + idx); + auto idx = vertexBuffer.Count(); + vertexBuffer.AddUninitialized(2 * sizeof(RibbonParticleVertex)); + auto ptr = (RibbonParticleVertex*)(vertexBuffer.Get() + idx); - idx0 *= 2; - idx1 *= 2; + // TODO: this could be optimized by manually fetching per-particle data in vertex shader (2x less data to send and fetch) + RibbonParticleVertex v = { i, idxThis, idxPrev, totalDistance }; - *ptr++ = idx0 + 1; - *ptr++ = idx1; - *ptr++ = idx0; + *ptr++ = v; + *ptr++ = v; + } - *ptr++ = idx0 + 1; - *ptr++ = idx1 + 1; - *ptr++ = idx1; + // 2 triangles + { + auto idx = indexBuffer.Count(); + indexBuffer.AddUninitialized(6 * sizeof(uint16)); + auto ptr = (uint16*)(indexBuffer.Get() + idx); + + uint32 i0 = vertexPrev; + uint32 i1 = vertexPrev + 2; + + *ptr++ = i0; + *ptr++ = i0 + 1; + *ptr++ = i1; + + *ptr++ = i0 + 1; + *ptr++ = i1 + 1; + *ptr++ = i1; indices += 6; } - } - totalDistance += direction.Length(); + idxPrev = idxThis; + segmentCount++; + vertexPrev += 2; + } + } + if (segmentCount == 0) + continue; + { + // Fix first particle vertex data to have proper direction + auto ptr0 = (RibbonParticleVertex*)(vertexBuffer.Get() + firstVertexIndex); + auto ptr1 = ptr0 + 1; + auto ptr2 = ptr1 + 1; + ptr0->PrevParticleIndex = ptr1->PrevParticleIndex = ptr2->ParticleIndex; } - if (indices == 0) - break; // Setup ribbon data - ribbonModulesSegmentCount[ribbonModuleIndex] = totalDistances.Count(); - if (totalDistances.HasItems()) - { - auto& ribbonSegmentDistancesBuffer = buffer->GPU.RibbonSegmentDistances[index]; - if (!ribbonSegmentDistancesBuffer) - { - ribbonSegmentDistancesBuffer = GPUDevice::Instance->CreateBuffer(TEXT("RibbonSegmentDistances")); - ribbonSegmentDistancesBuffer->Init(GPUBufferDescription::Typed(buffer->Capacity, PixelFormat::R32_Float, false, GPUResourceUsage::Dynamic)); - } - context->UpdateBuffer(ribbonSegmentDistancesBuffer, totalDistances.Get(), totalDistances.Count() * sizeof(float)); - } - + ribbonModulesSegmentCount[ribbonModuleIndex] = segmentCount; ribbonModulesDrawIndicesCount[index] = indices; ribbonModulesDrawIndicesPos += indices; @@ -391,6 +415,7 @@ void DrawEmitterCPU(RenderContext& renderContext, ParticleBuffer* buffer, DrawCa { // Upload data to the GPU buffer buffer->GPU.RibbonIndexBufferDynamic->Flush(context); + buffer->GPU.RibbonVertexBufferDynamic->Flush(context); } } @@ -490,13 +515,12 @@ void DrawEmitterCPU(RenderContext& renderContext, ParticleBuffer* buffer, DrawCa ribbon.UVScaleX *= sortUScale; ribbon.UVOffsetX += sortUOffset * uvScale.X; } - ribbon.SegmentDistances = ribbon.SegmentCount != 0 ? buffer->GPU.RibbonSegmentDistances[index] : nullptr; // TODO: invert particles rendering order if camera is closer to the ribbon end than start // Submit draw call drawCall.Geometry.IndexBuffer = buffer->GPU.RibbonIndexBufferDynamic->GetBuffer(); - drawCall.Geometry.VertexBuffers[0] = nullptr; + drawCall.Geometry.VertexBuffers[0] = buffer->GPU.RibbonVertexBufferDynamic->GetBuffer(); drawCall.Geometry.VertexBuffers[1] = nullptr; drawCall.Geometry.VertexBuffers[2] = nullptr; drawCall.Geometry.VertexBuffersOffsets[0] = 0; @@ -1187,7 +1211,6 @@ void ParticleManagerService::Dispose() ParticlesDrawCPU::SortingKeys[1].SetCapacity(0); ParticlesDrawCPU::SortingIndices.SetCapacity(0); ParticlesDrawCPU::SortedIndices.SetCapacity(0); - ParticlesDrawCPU::RibbonTotalDistances.SetCapacity(0); PoolLocker.Lock(); for (auto i = Pool.Begin(); i.IsNotEnd(); ++i) diff --git a/Source/Engine/Particles/ParticlesData.cpp b/Source/Engine/Particles/ParticlesData.cpp index 986e4cc9c..eace8d1e3 100644 --- a/Source/Engine/Particles/ParticlesData.cpp +++ b/Source/Engine/Particles/ParticlesData.cpp @@ -18,8 +18,7 @@ ParticleBuffer::~ParticleBuffer() SAFE_DELETE_GPU_RESOURCE(GPU.SortingKeysBuffer); SAFE_DELETE_GPU_RESOURCE(GPU.SortedIndices); SAFE_DELETE(GPU.RibbonIndexBufferDynamic); - for (auto& e : GPU.RibbonSegmentDistances) - SAFE_DELETE_GPU_RESOURCE(e); + SAFE_DELETE(GPU.RibbonVertexBufferDynamic); } bool ParticleBuffer::Init(ParticleEmitter* emitter) diff --git a/Source/Engine/Particles/ParticlesData.h b/Source/Engine/Particles/ParticlesData.h index 45cc455db..c47e18dc8 100644 --- a/Source/Engine/Particles/ParticlesData.h +++ b/Source/Engine/Particles/ParticlesData.h @@ -17,6 +17,7 @@ class ParticleEmitter; class Particles; class GPUBuffer; class DynamicIndexBuffer; +class DynamicVertexBuffer; /// /// The particle attribute that defines a single particle layout component. @@ -302,9 +303,9 @@ public: DynamicIndexBuffer* RibbonIndexBufferDynamic = nullptr; /// - /// The ribbon particles rendering segment distances buffer. Stored one per ribbon module. + /// The ribbon particles rendering vertex buffer (dynamic GPU access). /// - GPUBuffer* RibbonSegmentDistances[PARTICLE_EMITTER_MAX_RIBBONS] = {}; + DynamicVertexBuffer* RibbonVertexBufferDynamic = nullptr; /// /// The flag used to indicate that GPU buffers data should be cleared before next simulation. diff --git a/Source/Engine/Renderer/DrawCall.h b/Source/Engine/Renderer/DrawCall.h index f0c075285..9fd6c13b5 100644 --- a/Source/Engine/Renderer/DrawCall.h +++ b/Source/Engine/Renderer/DrawCall.h @@ -221,7 +221,6 @@ struct DrawCall float UVOffsetX; float UVOffsetY; uint32 SegmentCount; - GPUBuffer* SegmentDistances; } Ribbon; struct From 73ec370989bfcb9ba944cc338b17cfffe6c8ec37 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 3 Feb 2023 13:31:00 +0100 Subject: [PATCH 23/23] Update engine materials --- Content/Editor/Camera/M_Camera.flax | 2 +- Content/Editor/CubeTexturePreviewMaterial.flax | 2 +- Content/Editor/DebugMaterials/DDGIDebugProbes.flax | 2 +- Content/Editor/DebugMaterials/SingleColor/Decal.flax | 2 +- Content/Editor/DebugMaterials/SingleColor/Particle.flax | 4 ++-- Content/Editor/DebugMaterials/SingleColor/Surface.flax | 2 +- .../Editor/DebugMaterials/SingleColor/SurfaceAdditive.flax | 2 +- Content/Editor/DebugMaterials/SingleColor/Terrain.flax | 2 +- Content/Editor/DefaultFontMaterial.flax | 2 +- Content/Editor/Gizmo/FoliageBrushMaterial.flax | 2 +- Content/Editor/Gizmo/Material.flax | 2 +- Content/Editor/Gizmo/MaterialWire.flax | 2 +- Content/Editor/Gizmo/SelectionOutlineMaterial.flax | 2 +- Content/Editor/Gizmo/VertexColorsPreviewMaterial.flax | 2 +- Content/Editor/Highlight Material.flax | 2 +- Content/Editor/Icons/IconsMaterial.flax | 2 +- Content/Editor/IesProfilePreviewMaterial.flax | 2 +- Content/Editor/Particles/Particle Material Color.flax | 4 ++-- Content/Editor/Particles/Smoke Material.flax | 4 ++-- Content/Editor/SpriteMaterial.flax | 2 +- Content/Editor/Terrain/Circle Brush Material.flax | 2 +- Content/Editor/Terrain/Highlight Terrain Material.flax | 2 +- Content/Editor/TexturePreviewMaterial.flax | 2 +- Content/Editor/Wires Debug Material.flax | 2 +- Content/Engine/DefaultDeformableMaterial.flax | 2 +- Content/Engine/DefaultMaterial.flax | 2 +- Content/Engine/DefaultTerrainMaterial.flax | 2 +- Content/Engine/SingleColorMaterial.flax | 2 +- Content/Engine/SkyboxMaterial.flax | 2 +- 29 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Content/Editor/Camera/M_Camera.flax b/Content/Editor/Camera/M_Camera.flax index 0b6416124..26ba67429 100644 --- a/Content/Editor/Camera/M_Camera.flax +++ b/Content/Editor/Camera/M_Camera.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:838a974f8892427cc77088f81b994ff611b7451d9ca9af961d3bde534c19c6e3 +oid sha256:966db15e769106e448eedaaf8bff4d5724f63e813fc7f81c9da2962b37c9b57e size 30094 diff --git a/Content/Editor/CubeTexturePreviewMaterial.flax b/Content/Editor/CubeTexturePreviewMaterial.flax index 7278d0c55..28860d3cc 100644 --- a/Content/Editor/CubeTexturePreviewMaterial.flax +++ b/Content/Editor/CubeTexturePreviewMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c1764cdebc180b19b6bdb498f9efa0c7179eaab0140a090a532f264caa3c5b9c +oid sha256:c04e226f6f8aa0de1049694ed813b0bd75864da76be2df43fb9db08162daadaa size 31647 diff --git a/Content/Editor/DebugMaterials/DDGIDebugProbes.flax b/Content/Editor/DebugMaterials/DDGIDebugProbes.flax index cab929fe0..8e810f7d4 100644 --- a/Content/Editor/DebugMaterials/DDGIDebugProbes.flax +++ b/Content/Editor/DebugMaterials/DDGIDebugProbes.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:02491143310feee47a1573c5fe23bd1e22782ffe17b0a90422215ebe9bfdc023 +oid sha256:57066ba805fd3f21a1d48048c7d3a0ec4e4c66c5cdd1ca97553605987f43b460 size 41028 diff --git a/Content/Editor/DebugMaterials/SingleColor/Decal.flax b/Content/Editor/DebugMaterials/SingleColor/Decal.flax index dd703e770..f5ed08a03 100644 --- a/Content/Editor/DebugMaterials/SingleColor/Decal.flax +++ b/Content/Editor/DebugMaterials/SingleColor/Decal.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c7155b92cfb77d19a1079578943eb73b082bc11dfb6864adc9e5b1e4bab338f2 +oid sha256:6854135456c47f2c693ebd875d83812f29a6c93b6cddad9e267de2db261a6133 size 7489 diff --git a/Content/Editor/DebugMaterials/SingleColor/Particle.flax b/Content/Editor/DebugMaterials/SingleColor/Particle.flax index 5075d81d7..72e956e7a 100644 --- a/Content/Editor/DebugMaterials/SingleColor/Particle.flax +++ b/Content/Editor/DebugMaterials/SingleColor/Particle.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3831bf81114e81a44528b3f166a716920c78add4facd6a188c3ca2e3d51e2de3 -size 31708 +oid sha256:e737c911cffc1e1ad5cad3d7d4e13e24cdba7d08da4b488bf7bb41f098cb1638 +size 31713 diff --git a/Content/Editor/DebugMaterials/SingleColor/Surface.flax b/Content/Editor/DebugMaterials/SingleColor/Surface.flax index 3b11d2b4c..95bab955f 100644 --- a/Content/Editor/DebugMaterials/SingleColor/Surface.flax +++ b/Content/Editor/DebugMaterials/SingleColor/Surface.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2953c64143861a82b5ba3471cf76edb503bc0cb0c0a28f9b97de83eafe4f84f0 +oid sha256:129afa8e75f4e83307e3171993f6e3ae52a205456a629beae4a58ed84e435292 size 29990 diff --git a/Content/Editor/DebugMaterials/SingleColor/SurfaceAdditive.flax b/Content/Editor/DebugMaterials/SingleColor/SurfaceAdditive.flax index 67adb11ea..2fffdd0eb 100644 --- a/Content/Editor/DebugMaterials/SingleColor/SurfaceAdditive.flax +++ b/Content/Editor/DebugMaterials/SingleColor/SurfaceAdditive.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6d19b52df092ffc457db2d122e80542f5a3c63ea1e29b178a96450a82a52052b +oid sha256:7933e14f937b148d6b0c4a7fff10aa9b931f01e1bfe42ce3e5ff4575fbeeb463 size 31873 diff --git a/Content/Editor/DebugMaterials/SingleColor/Terrain.flax b/Content/Editor/DebugMaterials/SingleColor/Terrain.flax index 2feb001ab..6e85901e7 100644 --- a/Content/Editor/DebugMaterials/SingleColor/Terrain.flax +++ b/Content/Editor/DebugMaterials/SingleColor/Terrain.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bc2fe7a3466d4548f73aa4d5d3bb67bd9b33175f9253b218b4e7610019368938 +oid sha256:e21ef2afb59c22647d644502c6c0b6316f3e1b75be0b4ac95e4cde0701969d45 size 20769 diff --git a/Content/Editor/DefaultFontMaterial.flax b/Content/Editor/DefaultFontMaterial.flax index 9cf6491dd..87e8f541c 100644 --- a/Content/Editor/DefaultFontMaterial.flax +++ b/Content/Editor/DefaultFontMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6f18a205661867897c7c555da73fc04529b9922f4f1bfa858604fe982bcf2322 +oid sha256:a7838428fc9afa03649b25168f2458f7c06fc99c6a50f17579daa19ccc93916e size 30169 diff --git a/Content/Editor/Gizmo/FoliageBrushMaterial.flax b/Content/Editor/Gizmo/FoliageBrushMaterial.flax index 86509d484..8eb64e89d 100644 --- a/Content/Editor/Gizmo/FoliageBrushMaterial.flax +++ b/Content/Editor/Gizmo/FoliageBrushMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6747c15e1bf43384b57b544be4d70e260a5ef5a89cf69eac371429b6205a18a1 +oid sha256:67e5aba4c1eeb15231aef4001c7b0bb25db4243b871b1493774b1d1348310b22 size 37868 diff --git a/Content/Editor/Gizmo/Material.flax b/Content/Editor/Gizmo/Material.flax index 0b0d3fd8c..d44e7590a 100644 --- a/Content/Editor/Gizmo/Material.flax +++ b/Content/Editor/Gizmo/Material.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bf16bc35903e23c0b7f59ca2a34de4b48d94d95980796a3201d5dbaff5b63f3c +oid sha256:8b8d0157ba0eb18a8ab9613b4429343b4f52fdeb14d1adc73c0682a75b6a7466 size 32411 diff --git a/Content/Editor/Gizmo/MaterialWire.flax b/Content/Editor/Gizmo/MaterialWire.flax index 1f38c6e5d..db5910a4f 100644 --- a/Content/Editor/Gizmo/MaterialWire.flax +++ b/Content/Editor/Gizmo/MaterialWire.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:25b0e59a469631c94033633928fabc1c7bcf16b8903c24e2a36805e16052a968 +oid sha256:4dcae1147c6a225a8e5e0613d15950b77c05f3f90f60acdfa3943063ccc582a5 size 31624 diff --git a/Content/Editor/Gizmo/SelectionOutlineMaterial.flax b/Content/Editor/Gizmo/SelectionOutlineMaterial.flax index bc26ec449..1deecbcd9 100644 --- a/Content/Editor/Gizmo/SelectionOutlineMaterial.flax +++ b/Content/Editor/Gizmo/SelectionOutlineMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7ac836ef9f715ac8c46f583b4b0a8bb77dd3d4ac9c5cc84ae1199694b2f0849b +oid sha256:811b50ce2d2672bf7ce12dc161f6dc2038c5cfe8792012632ed89fb951c4058f size 16202 diff --git a/Content/Editor/Gizmo/VertexColorsPreviewMaterial.flax b/Content/Editor/Gizmo/VertexColorsPreviewMaterial.flax index 6166adc63..f9f1b97c7 100644 --- a/Content/Editor/Gizmo/VertexColorsPreviewMaterial.flax +++ b/Content/Editor/Gizmo/VertexColorsPreviewMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:81552ebd313ceb552ef4b536ecf1cb8060578d00107e3dcde2fadb1d0d766654 +oid sha256:30bcf9eb156bafe9b5536c040994877eab6cb0fe942fc31d744e5bff1bb02838 size 31103 diff --git a/Content/Editor/Highlight Material.flax b/Content/Editor/Highlight Material.flax index b3ddcd5bb..c13a1c0d4 100644 --- a/Content/Editor/Highlight Material.flax +++ b/Content/Editor/Highlight Material.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:36f165ae76fa91b99b071736c6ae1bd329e6bc4b4556d8229798b2a18f48ea20 +oid sha256:eb2d2b798b5fe819a0c137603b1c1bb598530ef01efb681690e5ce0901a550a9 size 30271 diff --git a/Content/Editor/Icons/IconsMaterial.flax b/Content/Editor/Icons/IconsMaterial.flax index 196c16f19..7966e8335 100644 --- a/Content/Editor/Icons/IconsMaterial.flax +++ b/Content/Editor/Icons/IconsMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4da6e914c1f458f82585a4564a14e9b65ca1d5b36b680580a1aa563915173b2f +oid sha256:2d4413df45e276c0cf6b0ede54ecf8dbf1a6f16ee12db3df9b409db2a632adc7 size 30199 diff --git a/Content/Editor/IesProfilePreviewMaterial.flax b/Content/Editor/IesProfilePreviewMaterial.flax index 03479e1a9..ba6d02979 100644 --- a/Content/Editor/IesProfilePreviewMaterial.flax +++ b/Content/Editor/IesProfilePreviewMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:73ae37b799d131c887f983667e0e85b11ca5b6318d9927da779cbc8a570c6bd7 +oid sha256:4d3c6d38944ae59d48c60c7e937c43b03d4659398ac05ac863fd4da16156529f size 18217 diff --git a/Content/Editor/Particles/Particle Material Color.flax b/Content/Editor/Particles/Particle Material Color.flax index 8af6e240b..3fbacc935 100644 --- a/Content/Editor/Particles/Particle Material Color.flax +++ b/Content/Editor/Particles/Particle Material Color.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:81c4302ab2103b31669943eea45da3589a127b3a2b3855832bca9e880bf3ce32 -size 29948 +oid sha256:3217b2dc041d3c41e77522a0766d99de0af26fd3ec28142cb9bb505b0fbc7723 +size 29953 diff --git a/Content/Editor/Particles/Smoke Material.flax b/Content/Editor/Particles/Smoke Material.flax index 41d4254dd..d12139eff 100644 --- a/Content/Editor/Particles/Smoke Material.flax +++ b/Content/Editor/Particles/Smoke Material.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:18ce95219dc62718fa9aa2a0763a4686c9342f652270299c863641d6229e7639 -size 37136 +oid sha256:8657cb23bdf2423f4535cb67da0487be72864a12d53e9521fdc99bce752ff518 +size 37141 diff --git a/Content/Editor/SpriteMaterial.flax b/Content/Editor/SpriteMaterial.flax index 310818af7..75f4d1f89 100644 --- a/Content/Editor/SpriteMaterial.flax +++ b/Content/Editor/SpriteMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:26303ad922aba5d64e893bb613cfb033e2b6067d78f0b02d43fdd3a16ee11aa6 +oid sha256:eae8e6b9147611dcf98b181339d3b581128a877b55c8b52b586b7d3fe43d01b2 size 31182 diff --git a/Content/Editor/Terrain/Circle Brush Material.flax b/Content/Editor/Terrain/Circle Brush Material.flax index 588a5af00..b014ffb1f 100644 --- a/Content/Editor/Terrain/Circle Brush Material.flax +++ b/Content/Editor/Terrain/Circle Brush Material.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:acfc660dc2683899c5be5a3331d7e3e756a34deb30cfc3d117b5dfb9c64a94e3 +oid sha256:1e73a50fe4296e58eff5942855dd655ba4c2c776ee3acc0451844645dda14247 size 27150 diff --git a/Content/Editor/Terrain/Highlight Terrain Material.flax b/Content/Editor/Terrain/Highlight Terrain Material.flax index c0e295c08..00560e1cb 100644 --- a/Content/Editor/Terrain/Highlight Terrain Material.flax +++ b/Content/Editor/Terrain/Highlight Terrain Material.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:28443ded233eb27922c3ce7ed2146ed416ce13104ad9c4c5af2833d916098c7a +oid sha256:f48c4f43dcf7e05255b41d763e1ca9b21d629df43d35b59b8574ae955d392fc4 size 20822 diff --git a/Content/Editor/TexturePreviewMaterial.flax b/Content/Editor/TexturePreviewMaterial.flax index e048a3355..d4ff0c0cd 100644 --- a/Content/Editor/TexturePreviewMaterial.flax +++ b/Content/Editor/TexturePreviewMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3d97d1dbe12d3d580567cdca83f5bfc933ddd2fc9adeec896e2d29ff665fc64e +oid sha256:2970eb5c0000661663a3cadffb1b8e67215f4425da24d5313e1d07fc44f0594d size 10413 diff --git a/Content/Editor/Wires Debug Material.flax b/Content/Editor/Wires Debug Material.flax index 8e345b22e..caa177eac 100644 --- a/Content/Editor/Wires Debug Material.flax +++ b/Content/Editor/Wires Debug Material.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:98f08deb52704baf10689caba74b87e03c5386404edc1a0af90ae49958db9c94 +oid sha256:6f8018999baf4b415d400b0b6150de27fbed48e2c93afbd16d074efc39b9c206 size 30271 diff --git a/Content/Engine/DefaultDeformableMaterial.flax b/Content/Engine/DefaultDeformableMaterial.flax index e7d5ad014..052d5946e 100644 --- a/Content/Engine/DefaultDeformableMaterial.flax +++ b/Content/Engine/DefaultDeformableMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:419c36e4c8eb2f030fd6ab52459ae5d3d55955373b0ae788650963066b4b70d7 +oid sha256:a70603cf2ace948b588924b39a1d31e309238782581f26b3388b8d9d3b44d4d7 size 18530 diff --git a/Content/Engine/DefaultMaterial.flax b/Content/Engine/DefaultMaterial.flax index 72e710180..588f85571 100644 --- a/Content/Engine/DefaultMaterial.flax +++ b/Content/Engine/DefaultMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5bb044bd9e1e7c9e9f9f2d172d9f3ff80b0b396e85f542411a34f1da1bda4cc5 +oid sha256:de63950e622426ed8905d19097a5f9d189da4a6300ae9a77577f0e7fab59a1bb size 32021 diff --git a/Content/Engine/DefaultTerrainMaterial.flax b/Content/Engine/DefaultTerrainMaterial.flax index 7ddce7853..e9af0516e 100644 --- a/Content/Engine/DefaultTerrainMaterial.flax +++ b/Content/Engine/DefaultTerrainMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:26d2de798c935312ba874b6f8eb0c1f9f2b34d5a1b702a6d52babf03c72e2cd4 +oid sha256:7c206df1af51d206c805449d5e6a4ce3fcaf70ac0c5310cf77dc0921a56e8552 size 22912 diff --git a/Content/Engine/SingleColorMaterial.flax b/Content/Engine/SingleColorMaterial.flax index 96e289d44..31af3b1c8 100644 --- a/Content/Engine/SingleColorMaterial.flax +++ b/Content/Engine/SingleColorMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:441c5469d76d887643e042e6ae699d245064719544b48f41c59aceb76b4fb4af +oid sha256:c87f422816ea68b3d6524b4f727d007ac4d5d2484931cf7a61cfe722b9c111d7 size 30191 diff --git a/Content/Engine/SkyboxMaterial.flax b/Content/Engine/SkyboxMaterial.flax index 11a14defc..df2859f7b 100644 --- a/Content/Engine/SkyboxMaterial.flax +++ b/Content/Engine/SkyboxMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c89778519d234c281efbcaaf5fedc0bc4a26212832d466bf4f6e571813030740 +oid sha256:0e8a62e94c4e265902ed2e95ea059dcc0aca50f79f7a6986ff5a6d99f034f3d3 size 31389