Render temporal scene with motion, resolve and sharp UI
Native and manual checks / native (ubuntu-24.04) (push) Failing after 37s
Native and manual checks / manual (push) Successful in 28s
Windows editor and software Vulkan / windows-graphics (push) Canceled after 0s
Native and manual checks / native (windows-2025) (push) Canceled after 0s

This commit is contained in:
Emil
2026-09-24 03:16:44 +03:00
parent c53e51520c
commit 0dcc8790a0
9 changed files with 934 additions and 88 deletions
+55 -2
View File
@@ -122,8 +122,7 @@ float3 directBRDF(float3 base, float rough, float metal, float3 n, float3 view,
float3 spec=d*g*fresnel/max(4.0*nv*nl,0.001);
return ((1.0-fresnel)*(1.0-metal)*base/pi+spec)*nl;
}
[shader("fragment")]
float4 fragmentMain(VertexOutput v) : SV_Target {
float4 shadeScene(VertexOutput v) {
float4 sampled = colorMap.Sample(colorSampler, v.uv);
if (dot(v.normal,v.normal) < 1e-12) {
// UI/sprite tint is in display space; sRGB textures were decoded by Vulkan.
@@ -202,3 +201,57 @@ float4 fragmentMain(VertexOutput v) : SV_Target {
linear=linear/(1.0+linear);
return float4(pow(max(linear,0),float3(1.0/2.2)),base.a);
}
[shader("fragment")]
float4 fragmentMain(VertexOutput v) : SV_Target { return shadeScene(v); }
struct TemporalVertexInput {
float4 clip : POSITION;
float3 world : TEXCOORD0;
float3 normal : NORMAL;
float4 color : COLOR0;
float2 material : TEXCOORD1;
float2 uv : TEXCOORD2;
float4 previousClip : TEXCOORD3;
float motionValid : TEXCOORD4;
};
struct TemporalVertexOutput {
float4 position : SV_Position;
float3 world : TEXCOORD0;
float3 normal : NORMAL;
float4 color : COLOR0;
float2 material : TEXCOORD1;
float2 uv : TEXCOORD2;
float4 previousClip : TEXCOORD3;
float4 currentClip : TEXCOORD4;
float motionValid : TEXCOORD5;
};
[shader("vertex")]
TemporalVertexOutput temporalVertexMain(TemporalVertexInput v) {
TemporalVertexOutput o;
o.position=v.clip; o.world=v.world; o.normal=v.normal; o.color=v.color;
o.material=v.material; o.uv=v.uv; o.previousClip=v.previousClip;
o.currentClip=v.clip; o.motionValid=v.motionValid;
return o;
}
struct TemporalFragmentOutput {
float4 color : SV_Target0;
float4 velocity : SV_Target1;
};
[shader("fragment")]
TemporalFragmentOutput temporalFragmentMain(TemporalVertexOutput v) {
VertexOutput shading;
shading.position=v.position; shading.world=v.world; shading.normal=v.normal;
shading.color=v.color; shading.material=v.material; shading.uv=v.uv;
TemporalFragmentOutput result;
result.color=shadeScene(shading);
result.velocity=float4(0);
if (v.motionValid > .5 && result.color.a >= .999 &&
all(isfinite(v.currentClip)) && all(isfinite(v.previousClip)) &&
v.currentClip.w > 0 && v.previousClip.w > 0) {
result.velocity.xy=(v.currentClip.xy / v.currentClip.w -
v.previousClip.xy / v.previousClip.w) * .5;
result.velocity.z=v.previousClip.z / v.previousClip.w;
result.velocity.w=1;
}
return result;
}
+37
View File
@@ -28,6 +28,7 @@ struct InstanceRecord {
float4 previousExtent; // 192..207
uint4 metadata; // 208..223: x bits 0=HZB, 1=temporal prior valid; y=stableSlot,
// z=generation low 32, w=generation high 32 (zero = untracked)
column_major float4x4 previousModel; // 224..287
};
struct ViewRecord {
column_major float4x4 currentViewProjection; // 0..63
@@ -81,6 +82,42 @@ GpuSceneOutput gpuVertexMain(GpuSceneVertex vertex, uint drawInstance : SV_Vulka
return output;
}
struct GpuSceneTemporalOutput {
float4 position : SV_Position;
float3 world : TEXCOORD0;
float3 normal : NORMAL;
float4 color : COLOR0;
float2 material : TEXCOORD1;
float2 uv : TEXCOORD2;
float4 previousClip : TEXCOORD3;
float4 currentClip : TEXCOORD4;
float motionValid : TEXCOORD5;
};
[shader("vertex")]
GpuSceneTemporalOutput gpuTemporalVertexMain(GpuSceneVertex vertex,
uint drawInstance : SV_VulkanInstanceID) {
InstanceRecord instance = gfxInstances[gfxVisibleIds[gpuFrame.drawInfo.x + drawInstance]];
ViewRecord view = gfxViews[0];
float4 local = float4(vertex.position, 1);
float4 world = mul(instance.model, local);
GpuSceneTemporalOutput output;
output.position = mul(view.currentViewProjection, world);
output.currentClip = output.position;
output.previousClip = mul(view.previousViewProjection,
mul(instance.previousModel, local));
output.motionValid = (instance.metadata.x & 2u) != 0u ? 1.0 : 0.0;
output.world = world.xyz;
float3 normal = float3(dot(instance.normalRow0.xyz, vertex.normal),
dot(instance.normalRow1.xyz, vertex.normal),
dot(instance.normalRow2.xyz, vertex.normal));
float normalLength = length(normal);
output.normal = normalLength > 1e-8 ? normal / normalLength : float3(0, 0, 0);
output.color = vertex.color * instance.color;
output.material = instance.material.xy;
output.uv = vertex.uv;
return output;
}
[shader("vertex")]
float4 gpuShadowMain(GpuSceneVertex vertex, uint drawInstance : SV_VulkanInstanceID) : SV_Position {
InstanceRecord instance = gfxInstances[gfxVisibleIds[gpuFrame.drawInfo.x + drawInstance]];
+2 -4
View File
@@ -130,10 +130,8 @@ void temporalResolveMain(uint3 dispatchId : SV_DispatchThreadID) {
[[vk::binding(0,0)]] Texture2D<float4> resolvedHistoryColor;
[shader("vertex")]
float4 temporalCompositeVertexMain(uint vertexId : SV_VertexID) : SV_Position {
const float2 position = vertexId == 0 ? float2(-1, -1)
: vertexId == 1 ? float2(3, -1) : float2(-1, 3);
return float4(position, 0, 1);
float4 temporalCompositeVertexMain(float4 clip : POSITION) : SV_Position {
return clip;
}
[shader("fragment")]