updates:
- voxel gi fixes - material basecolor moved to VS - warning silences from fsr2 and compressonator
This commit is contained in:
@@ -40,7 +40,7 @@ wi::vector<ShaderEntry> shaders = {
|
||||
{"depthoffield_tileMaxCOC_horizontalCS", wi::graphics::ShaderStage::CS},
|
||||
{"voxelRadianceSecondaryBounceCS", wi::graphics::ShaderStage::CS},
|
||||
{"voxelSceneCopyClearCS", wi::graphics::ShaderStage::CS},
|
||||
{"voxelClearOnlyNormalCS", wi::graphics::ShaderStage::CS},
|
||||
{"voxelSceneCopyClearCS_TemporalSmoothing", wi::graphics::ShaderStage::CS },
|
||||
{"upsample_bilateral_float1CS", wi::graphics::ShaderStage::CS},
|
||||
{"upsample_bilateral_float4CS", wi::graphics::ShaderStage::CS},
|
||||
{"upsample_bilateral_unorm1CS", wi::graphics::ShaderStage::CS},
|
||||
@@ -161,7 +161,6 @@ wi::vector<ShaderEntry> shaders = {
|
||||
{"blur_bilateral_float3CS", wi::graphics::ShaderStage::CS },
|
||||
{"blur_bilateral_float4CS", wi::graphics::ShaderStage::CS },
|
||||
{"blur_bilateral_unorm1CS", wi::graphics::ShaderStage::CS },
|
||||
{"voxelSceneCopyClearCS_TemporalSmoothing", wi::graphics::ShaderStage::CS },
|
||||
{"normalsfromdepthCS", wi::graphics::ShaderStage::CS },
|
||||
{"volumetricCloud_curlnoiseCS", wi::graphics::ShaderStage::CS },
|
||||
{"volumetricCloud_detailnoiseCS", wi::graphics::ShaderStage::CS },
|
||||
|
||||
@@ -557,7 +557,7 @@ struct ShaderMeshInstancePointer
|
||||
|
||||
void init()
|
||||
{
|
||||
data = ~0;
|
||||
data = 0;
|
||||
}
|
||||
void Create(uint _instanceIndex, uint frustum_index = 0, float dither = 0)
|
||||
{
|
||||
|
||||
@@ -2588,16 +2588,6 @@
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">Pixel</ShaderType>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">Pixel</ShaderType>
|
||||
</FxCompile>
|
||||
<FxCompile Include="$(MSBuildThisFileDirectory)voxelClearOnlyNormalCS.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compute</ShaderType>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Compute</ShaderType>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Compute</ShaderType>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Compute</ShaderType>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Compute</ShaderType>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">Compute</ShaderType>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">Compute</ShaderType>
|
||||
</FxCompile>
|
||||
<FxCompile Include="$(MSBuildThisFileDirectory)voxelGS.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Geometry</ShaderType>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Geometry</ShaderType>
|
||||
|
||||
@@ -206,9 +206,6 @@
|
||||
<FxCompile Include="$(MSBuildThisFileDirectory)voxelSceneCopyClearCS.hlsl">
|
||||
<Filter>CS</Filter>
|
||||
</FxCompile>
|
||||
<FxCompile Include="$(MSBuildThisFileDirectory)voxelClearOnlyNormalCS.hlsl">
|
||||
<Filter>CS</Filter>
|
||||
</FxCompile>
|
||||
<FxCompile Include="$(MSBuildThisFileDirectory)upsample_bilateral_float1CS.hlsl">
|
||||
<Filter>CS</Filter>
|
||||
</FxCompile>
|
||||
|
||||
@@ -20,7 +20,7 @@ ImpostorOutput main(PixelInput input)
|
||||
{
|
||||
color = 1;
|
||||
}
|
||||
color *= GetMaterial().baseColor /** input.color*/;
|
||||
color *= input.color;
|
||||
clip(color.a - GetMaterial().alphaTest);
|
||||
|
||||
float3 N = normalize(input.nor);
|
||||
|
||||
@@ -40,6 +40,9 @@
|
||||
|
||||
#include "ShaderInterop_FSR2.h"
|
||||
|
||||
#pragma dxc diagnostic push
|
||||
#pragma dxc diagnostic ignored "-Wfor-redefinition"
|
||||
|
||||
#define FSR2_BIND_SRV_EXPOSURE 0
|
||||
#if FFX_FSR2_OPTION_LOW_RESOLUTION_MOTION_VECTORS
|
||||
#define FSR2_BIND_SRV_DILATED_MOTION_VECTORS 2
|
||||
@@ -95,3 +98,5 @@ void main(uint2 uGroupId : SV_GroupID, uint2 uGroupThreadId : SV_GroupThreadID)
|
||||
|
||||
Accumulate(uDispatchThreadId);
|
||||
}
|
||||
|
||||
#pragma dxc diagnostic pop
|
||||
|
||||
@@ -206,7 +206,7 @@ struct VertexSurface
|
||||
inline void create(in ShaderMaterial material, in VertexInput input)
|
||||
{
|
||||
position = input.GetPosition();
|
||||
color = unpack_rgba(input.GetInstance().color);
|
||||
color = GetMaterial().baseColor * unpack_rgba(input.GetInstance().color);
|
||||
color.a *= 1 - input.GetInstancePointer().GetDither();
|
||||
emissiveColor = input.GetInstance().emissive;
|
||||
|
||||
@@ -1113,7 +1113,7 @@ float4 main(PixelInput input, in bool is_frontface : SV_IsFrontFace) : SV_Target
|
||||
|
||||
|
||||
#ifdef OBJECTSHADER_USE_COLOR
|
||||
color *= GetMaterial().baseColor * input.color;
|
||||
color *= input.color;
|
||||
#endif // OBJECTSHADER_USE_COLOR
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ float4 main(PixelInput input) : SV_TARGET
|
||||
{
|
||||
color = 1;
|
||||
}
|
||||
color *= GetMaterial().baseColor * input.color;
|
||||
color *= input.color;
|
||||
|
||||
float3 emissiveColor = GetMaterial().GetEmissive();
|
||||
[branch]
|
||||
|
||||
@@ -95,14 +95,17 @@ void main(PSInput input)
|
||||
[branch]
|
||||
if (light.IsCastingShadow() >= 0)
|
||||
{
|
||||
const uint cascade = GetFrame().shadow_cascade_count - 1; // biggest cascade (coarsest resolution) will be used to voxelize
|
||||
float3 ShPos = mul(load_entitymatrix(light.GetMatrixIndex() + cascade), float4(P, 1)).xyz; // ortho matrix, no divide by .w
|
||||
float3 ShTex = ShPos.xyz * float3(0.5f, -0.5f, 0.5f) + 0.5f;
|
||||
|
||||
[branch]
|
||||
if ((saturate(ShTex.x) == ShTex.x) && (saturate(ShTex.y) == ShTex.y) && (saturate(ShTex.z) == ShTex.z))
|
||||
[loop]
|
||||
for (uint cascade = 0; cascade < GetFrame().shadow_cascade_count; ++cascade)
|
||||
{
|
||||
lightColor *= shadow_2D(light, ShPos, ShTex.xy, cascade);
|
||||
const float3 shadow_pos = mul(load_entitymatrix(light.GetMatrixIndex() + cascade), float4(P, 1)).xyz; // ortho matrix, no divide by .w
|
||||
const float3 shadow_uv = shadow_pos.xyz * float3(0.5f, -0.5f, 0.5f) + 0.5f;
|
||||
|
||||
if (is_saturated(shadow_uv))
|
||||
{
|
||||
lightColor *= shadow_2D(light, shadow_pos, shadow_uv.xy, cascade);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (GetFrame().options & OPTION_BIT_VOLUMETRICCLOUDS_SHADOWS)
|
||||
@@ -199,7 +202,7 @@ void main(PSInput input)
|
||||
color.rgb += emissiveColor;
|
||||
|
||||
uint color_encoded = PackVoxelColor(color);
|
||||
uint normal_encoded = pack_unitvector(N);
|
||||
uint normal_encoded = pack_half2(encode_oct(N));
|
||||
|
||||
// output:
|
||||
uint3 writecoord = floor(uvw * GetFrame().voxelradiance_resolution);
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#include "globals.hlsli"
|
||||
|
||||
#pragma dxc diagnostic push
|
||||
#pragma dxc diagnostic ignored "-Wambig-lit-shift"
|
||||
#pragma dxc diagnostic ignored "-Wunused-value"
|
||||
|
||||
#define ASPM_HLSL
|
||||
#include "compressonator/bcn_common_kernel.h"
|
||||
|
||||
@@ -151,3 +155,5 @@ void main(uint3 DTid : SV_DispatchThreadID)
|
||||
output[write_coord] = CompressBlockBC3_UNORM(block_rgb, block_a, CMP_QUALITY2, /*isSRGB =*/ false);
|
||||
#endif // UPDATE_SURFACEMAP
|
||||
}
|
||||
|
||||
#pragma dxc diagnostic pop
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#include "globals.hlsli"
|
||||
#include "voxelHF.hlsli"
|
||||
|
||||
RWStructuredBuffer<VoxelType> input_output : register(u0);
|
||||
|
||||
[numthreads(256, 1, 1)]
|
||||
void main(uint3 DTid : SV_DispatchThreadID)
|
||||
{
|
||||
input_output[DTid.x].normalMask = 0;
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
#define VOXEL_INITIAL_OFFSET 4
|
||||
#define VOXEL_INITIAL_OFFSET 1
|
||||
#include "globals.hlsli"
|
||||
#include "voxelHF.hlsli"
|
||||
#include "voxelConeTracingHF.hlsli"
|
||||
#include "lightingHF.hlsli"
|
||||
|
||||
Texture3D<float4> input_emission : register(t0);
|
||||
StructuredBuffer<VoxelType> input_voxelscene : register(t1);
|
||||
@@ -17,7 +18,8 @@ void main( uint3 DTid : SV_DispatchThreadID )
|
||||
|
||||
if (emission.a > 0)
|
||||
{
|
||||
float3 N = unpack_unitvector(input_voxelscene[DTid.x].normalMask);
|
||||
const uint idx = flatten3D(writecoord, GetFrame().voxelradiance_resolution);
|
||||
float3 N = decode_oct(unpack_half2(input_voxelscene[idx].normalMask));
|
||||
|
||||
float3 P = ((float3)writecoord + 0.5f) * GetFrame().voxelradiance_resolution_rcp;
|
||||
P = P * 2 - 1;
|
||||
@@ -26,9 +28,9 @@ void main( uint3 DTid : SV_DispatchThreadID )
|
||||
P *= GetFrame().voxelradiance_resolution;
|
||||
P += GetFrame().voxelradiance_center;
|
||||
|
||||
float4 radiance = ConeTraceDiffuse(input_emission, P, N);
|
||||
emission.rgb += ConeTraceDiffuse(input_emission, P, N).rgb;
|
||||
|
||||
output[writecoord] = emission + float4(radiance.rgb, 0);
|
||||
output[writecoord] = emission;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#include "globals.hlsli"
|
||||
#include "voxelHF.hlsli"
|
||||
|
||||
RWStructuredBuffer<VoxelType> input_output : register(u0);
|
||||
RWTexture3D<float4> output_emission : register(u1);
|
||||
StructuredBuffer<VoxelType> input : register(t0);
|
||||
RWTexture3D<float4> output_emission : register(u0);
|
||||
|
||||
[numthreads(256, 1, 1)]
|
||||
void main( uint3 DTid : SV_DispatchThreadID )
|
||||
{
|
||||
VoxelType voxel = input_output[DTid.x];
|
||||
VoxelType voxel = input[DTid.x];
|
||||
|
||||
const float4 color = UnpackVoxelColor(voxel.colorMask);
|
||||
|
||||
@@ -38,7 +38,4 @@ void main( uint3 DTid : SV_DispatchThreadID )
|
||||
{
|
||||
output_emission[writecoord] = 0;
|
||||
}
|
||||
|
||||
// delete emission data, but keep normals (no need to delete, we will only read normal values of filled voxels)
|
||||
input_output[DTid.x].colorMask = 0;
|
||||
}
|
||||
|
||||
@@ -141,8 +141,6 @@ namespace wi::backlog
|
||||
wi::Color theme_color_active = wi::Color::White();
|
||||
wi::Color theme_color_deactivating = wi::Color::lerp(theme_color_focus, wi::Color::White(), 0.5f);
|
||||
inputField.SetColor(theme_color_idle); // all states the same, it's gonna be always active anyway
|
||||
inputField.SetShadowRadius(5);
|
||||
inputField.SetShadowColor(wi::Color(80, 140, 180, 100));
|
||||
inputField.font.params.color = wi::Color(160, 240, 250, 255);
|
||||
inputField.font.params.shadowColor = wi::Color::Transparent();
|
||||
|
||||
@@ -189,8 +187,8 @@ namespace wi::backlog
|
||||
}
|
||||
pos = wi::math::Clamp(pos, -canvas.GetLogicalHeight(), 0);
|
||||
|
||||
inputField.SetSize(XMFLOAT2(canvas.GetLogicalWidth() - 20, 20));
|
||||
inputField.SetPos(XMFLOAT2(10, canvas.GetLogicalHeight() - 30 + pos));
|
||||
inputField.SetSize(XMFLOAT2(canvas.GetLogicalWidth() - 40, 20));
|
||||
inputField.SetPos(XMFLOAT2(20, canvas.GetLogicalHeight() - 40 + pos));
|
||||
inputField.Update(canvas, dt);
|
||||
|
||||
toggleButton.SetSize(XMFLOAT2(100, 100));
|
||||
@@ -220,6 +218,25 @@ namespace wi::backlog
|
||||
}
|
||||
wi::image::Draw(&backgroundTex, fx, cmd);
|
||||
|
||||
wi::image::Params inputbg;
|
||||
inputbg.color = wi::Color(80, 140, 180, 200);
|
||||
inputbg.pos = inputField.translation;
|
||||
inputbg.pos.x -= 8;
|
||||
inputbg.pos.y -= 8;
|
||||
inputbg.siz = inputField.GetSize();
|
||||
inputbg.siz.x += 16;
|
||||
inputbg.siz.y += 16;
|
||||
inputbg.enableCornerRounding();
|
||||
inputbg.corners_rounding[0].radius = 10;
|
||||
inputbg.corners_rounding[1].radius = 10;
|
||||
inputbg.corners_rounding[2].radius = 10;
|
||||
inputbg.corners_rounding[3].radius = 10;
|
||||
if (colorspace != ColorSpace::SRGB)
|
||||
{
|
||||
inputbg.enableLinearOutputMapping(9);
|
||||
}
|
||||
wi::image::Draw(wi::texturehelper::getWhite(), inputbg, cmd);
|
||||
|
||||
if (colorspace != ColorSpace::SRGB)
|
||||
{
|
||||
inputField.sprites[inputField.GetState()].params.enableLinearOutputMapping(9);
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace wi::image
|
||||
constexpr void enableHDR10OutputMapping() { _flags |= OUTPUT_COLOR_SPACE_HDR10_ST2084; }
|
||||
// enable linear output mapping, which means removing gamma curve and outputting in linear space (useful for blending in HDR space)
|
||||
constexpr void enableLinearOutputMapping(float scaling = 1.0f) { _flags |= OUTPUT_COLOR_SPACE_LINEAR; hdr_scaling = scaling; }
|
||||
constexpr void enableCornerRounding(float scaling = 1.0f) { _flags |= CORNER_ROUNDING; hdr_scaling = scaling; }
|
||||
constexpr void enableCornerRounding() { _flags |= CORNER_ROUNDING; }
|
||||
|
||||
// disable draw rectangle for base texture (whole texture will be drawn, no cutout)
|
||||
constexpr void disableDrawRect() { _flags &= ~DRAWRECT; }
|
||||
|
||||
+21
-20
@@ -7324,6 +7324,13 @@ void VoxelRadiance(const Visibility& vis, CommandList cmd)
|
||||
|
||||
BindCommonResources(cmd);
|
||||
|
||||
device->ClearUAV(&resourceBuffers[RBTYPE_VOXELSCENE], 0, cmd);
|
||||
{
|
||||
GPUBarrier barriers[] = {
|
||||
GPUBarrier::Memory(&resourceBuffers[RBTYPE_VOXELSCENE]),
|
||||
};
|
||||
device->Barrier(barriers, arraysize(barriers), cmd);
|
||||
}
|
||||
|
||||
device->RenderPassBegin(nullptr, 0, cmd, RenderPassFlags::ALLOW_UAV_WRITES);
|
||||
RenderMeshes(vis, renderQueue, RENDERPASS_VOXELIZE, FILTER_OPAQUE, cmd, false, nullptr, 1);
|
||||
@@ -7331,15 +7338,16 @@ void VoxelRadiance(const Visibility& vis, CommandList cmd)
|
||||
|
||||
{
|
||||
GPUBarrier barriers[] = {
|
||||
GPUBarrier::Memory(),
|
||||
GPUBarrier::Buffer(&resourceBuffers[RBTYPE_VOXELSCENE], ResourceState::UNORDERED_ACCESS, ResourceState::SHADER_RESOURCE),
|
||||
GPUBarrier::Image(&textures[TEXTYPE_3D_VOXELRADIANCE], ResourceState::SHADER_RESOURCE, ResourceState::UNORDERED_ACCESS)
|
||||
};
|
||||
device->Barrier(barriers, arraysize(barriers), cmd);
|
||||
}
|
||||
|
||||
// Copy the packed voxel scene data to a 3D texture, then delete the voxel scene emission data. The cone tracing will operate on the 3D texture
|
||||
device->EventBegin("Voxel Scene Copy - Clear", cmd);
|
||||
device->BindUAV(&resourceBuffers[RBTYPE_VOXELSCENE], 0, cmd);
|
||||
device->BindUAV(&textures[TEXTYPE_3D_VOXELRADIANCE], 1, cmd);
|
||||
device->BindResource(&resourceBuffers[RBTYPE_VOXELSCENE], 0, cmd);
|
||||
device->BindUAV(&textures[TEXTYPE_3D_VOXELRADIANCE], 0, cmd);
|
||||
|
||||
static bool smooth_copy = true;
|
||||
if (smooth_copy)
|
||||
@@ -7355,7 +7363,7 @@ void VoxelRadiance(const Visibility& vis, CommandList cmd)
|
||||
|
||||
{
|
||||
GPUBarrier barriers[] = {
|
||||
GPUBarrier::Memory(),
|
||||
GPUBarrier::Image(&textures[TEXTYPE_3D_VOXELRADIANCE], ResourceState::UNORDERED_ACCESS, ResourceState::SHADER_RESOURCE),
|
||||
};
|
||||
device->Barrier(barriers, arraysize(barriers), cmd);
|
||||
}
|
||||
@@ -7366,6 +7374,13 @@ void VoxelRadiance(const Visibility& vis, CommandList cmd)
|
||||
// Pre-integrate the voxel texture by creating blurred mip levels:
|
||||
GenerateMipChain(textures[TEXTYPE_3D_VOXELRADIANCE], MIPGENFILTER_LINEAR, cmd);
|
||||
|
||||
{
|
||||
GPUBarrier barriers[] = {
|
||||
GPUBarrier::Image(&textures[TEXTYPE_3D_VOXELRADIANCE_HELPER], ResourceState::SHADER_RESOURCE, ResourceState::UNORDERED_ACCESS)
|
||||
};
|
||||
device->Barrier(barriers, arraysize(barriers), cmd);
|
||||
}
|
||||
|
||||
device->BindResource(&textures[TEXTYPE_3D_VOXELRADIANCE], 0, cmd);
|
||||
device->BindResource(&resourceBuffers[RBTYPE_VOXELSCENE], 1, cmd);
|
||||
device->BindUAV(&textures[TEXTYPE_3D_VOXELRADIANCE_HELPER], 0, cmd);
|
||||
@@ -7375,20 +7390,8 @@ void VoxelRadiance(const Visibility& vis, CommandList cmd)
|
||||
|
||||
{
|
||||
GPUBarrier barriers[] = {
|
||||
GPUBarrier::Memory(),
|
||||
};
|
||||
device->Barrier(barriers, arraysize(barriers), cmd);
|
||||
}
|
||||
|
||||
device->EventBegin("Voxel Scene Clear Normals", cmd);
|
||||
device->BindUAV(&resourceBuffers[RBTYPE_VOXELSCENE], 0, cmd);
|
||||
device->BindComputeShader(&shaders[CSTYPE_VOXELCLEARONLYNORMAL], cmd);
|
||||
device->Dispatch((uint32_t)(voxelSceneData.res * voxelSceneData.res * voxelSceneData.res / 256), 1, 1, cmd);
|
||||
device->EventEnd(cmd);
|
||||
|
||||
{
|
||||
GPUBarrier barriers[] = {
|
||||
GPUBarrier::Memory(),
|
||||
GPUBarrier::Image(&textures[TEXTYPE_3D_VOXELRADIANCE_HELPER], ResourceState::UNORDERED_ACCESS, ResourceState::SHADER_RESOURCE),
|
||||
GPUBarrier::Buffer(&resourceBuffers[RBTYPE_VOXELSCENE], ResourceState::SHADER_RESOURCE, ResourceState::UNORDERED_ACCESS),
|
||||
};
|
||||
device->Barrier(barriers, arraysize(barriers), cmd);
|
||||
}
|
||||
@@ -7396,8 +7399,6 @@ void VoxelRadiance(const Visibility& vis, CommandList cmd)
|
||||
result = &textures[TEXTYPE_3D_VOXELRADIANCE_HELPER];
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Pre-integrate the voxel texture by creating blurred mip levels:
|
||||
{
|
||||
GenerateMipChain(*result, MIPGENFILTER_LINEAR, cmd);
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace wi::version
|
||||
// minor features, major updates, breaking compatibility changes
|
||||
const int minor = 71;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 124;
|
||||
const int revision = 125;
|
||||
|
||||
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user