lightmap improvements

This commit is contained in:
Turánszki János
2024-12-27 16:01:52 +01:00
parent 9f11982eed
commit ac6fc30963
6 changed files with 31 additions and 17 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ static const int2 offsets[] = {
int2(-1, -1),
int2(1, -1),
int2(1, 1),
int2(-1, -1),
int2(-1, 1),
};
[numthreads(POSTPROCESS_BLOCKSIZE, POSTPROCESS_BLOCKSIZE, 1)]
+5 -5
View File
@@ -11,7 +11,6 @@ static const uint ANYTHIT_CUTOFF_AFTER_BOUNCE_COUNT = 4;
struct Input
{
float4 pos : SV_POSITION;
centroid float2 uv : TEXCOORD;
centroid float3 pos3D : WORLDPOSITION;
centroid float3 normal : NORMAL;
};
@@ -106,6 +105,8 @@ void BakeryPixelPush(inout float3 P, in float3 N, in float2 UV, inout RNG rng, i
float4 main(Input input) : SV_TARGET
{
float2 uv = input.pos.xy * xTraceResolution_rcp;
Surface surface;
surface.init();
surface.N = normalize(input.normal);
@@ -116,9 +117,8 @@ float4 main(Input input) : SV_TARGET
float3 P = input.pos3D;
float bakerydebug = 0;
BakeryPixelPush(P, surface.N, input.uv, rng, bakerydebug);
float2 uv = input.uv;
BakeryPixelPush(P, surface.N, uv, rng, bakerydebug);
RayDesc ray;
ray.Origin = P;
ray.Direction = sample_hemisphere_cos(surface.N, rng);
@@ -247,7 +247,7 @@ float4 main(Input input) : SV_TARGET
newRay.Origin = surface.P;
newRay.TMin = 0.0001;
newRay.TMax = dist;
newRay.Direction = L + max3(surface.sss);
newRay.Direction = normalize(L + max3(surface.sss));
#ifdef RTAPI
uint flags = RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES | RAY_FLAG_CULL_FRONT_FACING_TRIANGLES;
@@ -6,7 +6,6 @@ PUSHCONSTANT(push, LightmapPushConstants);
struct Output
{
float4 pos : SV_POSITION;
centroid float2 uv : TEXCOORD;
centroid float3 pos3D : WORLDPOSITION;
centroid float3 normal : NORMAL;
};
@@ -25,8 +24,6 @@ Output main(uint vertexID : SV_VertexID)
output.pos.y *= -1;
output.pos.xy += xTracePixelOffset;
output.uv = atl;
output.pos3D = mul(inst.transform.GetMatrix(), float4(pos, 1)).xyz;
output.normal = mul(inst.transformRaw.GetMatrixAdjoint(), nor);
+21 -7
View File
@@ -1445,11 +1445,7 @@ void LoadShaders()
desc.bs = &blendStates[BSTYPE_TRANSPARENT];
desc.dss = &depthStencils[DSSTYPE_DEPTHDISABLED];
RenderPassInfo renderpass_info;
renderpass_info.rt_count = 1;
renderpass_info.rt_formats[0] = Format::R32G32B32A32_FLOAT;
device->CreatePipelineState(&desc, &PSO_renderlightmap, &renderpass_info);
device->CreatePipelineState(&desc, &PSO_renderlightmap);
});
wi::jobsystem::Execute(ctx, [](wi::jobsystem::JobArgs args) {
PipelineStateDesc desc;
@@ -2304,7 +2300,7 @@ void SetUpStates()
rs = rasterizers[RSTYPE_DOUBLESIDED];
// Note: conservative raster can produce bright lightmap pixels, so now it's disabled!
// Note: conservative rasterization can cause GPU hang sometimes
//if (device->CheckCapability(GraphicsDeviceCapability::CONSERVATIVE_RASTERIZATION))
//{
// rs.conservative_rasterization_enable = true;
@@ -4609,6 +4605,8 @@ void UpdateRenderData(
auto prof_updatebuffer_cpu = wi::profiler::BeginRangeCPU("Update Buffers (CPU)");
auto prof_updatebuffer_gpu = wi::profiler::BeginRangeGPU("Update Buffers (GPU)", cmd);
barrier_stack.push_back(GPUBarrier::Buffer(&vis.scene->meshletBuffer, ResourceState::SHADER_RESOURCE, ResourceState::UNORDERED_ACCESS));
barrier_stack.push_back(GPUBarrier::Buffer(&buffers[BUFFERTYPE_FRAMECB], ResourceState::CONSTANT_BUFFER, ResourceState::COPY_DST));
if (vis.scene->instanceBuffer.IsValid())
{
@@ -15963,7 +15961,7 @@ void CreateVolumetricCloudResources(VolumetricCloudResources& res, XMUINT2 resol
desc.width = resolution.x / 4;
desc.height = resolution.y / 4;
desc.format = Format::R16G16B16A16_FLOAT;
desc.layout = ResourceState::SHADER_RESOURCE;
desc.layout = ResourceState::SHADER_RESOURCE_COMPUTE;
device->CreateTexture(&desc, nullptr, &res.texture_cloudRender);
device->SetName(&res.texture_cloudRender, "texture_cloudRender");
desc.format = Format::R32G32_FLOAT;
@@ -16191,7 +16189,23 @@ void Postprocess_VolumetricClouds_Upsample(
device->BindResource(&res.texture_reproject[temporal_output], 0, cmd);
device->BindResource(&res.texture_reproject_depth[temporal_output], 1, cmd);
{
GPUBarrier barriers[] = {
GPUBarrier::Image(&res.texture_reproject[temporal_output], res.texture_reproject[temporal_output].desc.layout, ResourceState::SHADER_RESOURCE),
GPUBarrier::Image(&res.texture_reproject_depth[temporal_output], res.texture_reproject_depth[temporal_output].desc.layout, ResourceState::SHADER_RESOURCE),
};
device->Barrier(barriers, arraysize(barriers), cmd);
}
device->Draw(3, 0, cmd);
{
GPUBarrier barriers[] = {
GPUBarrier::Image(&res.texture_reproject[temporal_output], ResourceState::SHADER_RESOURCE, res.texture_reproject[temporal_output].desc.layout),
GPUBarrier::Image(&res.texture_reproject_depth[temporal_output], ResourceState::SHADER_RESOURCE, res.texture_reproject_depth[temporal_output].desc.layout),
};
device->Barrier(barriers, arraysize(barriers), cmd);
}
}
wi::profiler::EndRange(range);
+3
View File
@@ -4577,6 +4577,9 @@ namespace wi::scene
object.lightmapWidth = wi::graphics::AlignTo(object.lightmapWidth, 4u);
object.lightmapHeight = wi::graphics::AlignTo(object.lightmapHeight, 4u);
object.lightmapWidth = clamp(object.lightmapWidth, 16u, 16384u);
object.lightmapHeight = clamp(object.lightmapHeight, 16u, 16384u);
TextureDesc desc;
desc.width = object.lightmapWidth;
desc.height = object.lightmapHeight;
+1 -1
View File
@@ -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 = 638;
const int revision = 639;
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);