feat: refine scene viewport gizmos and controls

This commit is contained in:
2026-03-31 21:26:40 +08:00
parent be15bc2fc4
commit 6d3a90ef74
16 changed files with 969 additions and 155 deletions

View File

@@ -88,6 +88,8 @@ PSOutput MainPS(VSOutput input) {
const float tanHalfFov = max(gCameraUpAndTanHalfFov.w, 1e-4);
const float aspect = max(gCameraForwardAndAspect.w, 1e-4);
const float transitionBlend = saturate(gGridTransition.x);
const float nearClip = gViewportNearFar.z;
const float sceneFarClip = gViewportNearFar.w;
const float2 ndc = float2(
(input.position.x / viewportSize.x) * 2.0 - 1.0,
@@ -104,19 +106,22 @@ PSOutput MainPS(VSOutput input) {
}
const float t = -cameraPosition.y / rayDirection.y;
if (t <= gViewportNearFar.z || t >= gViewportNearFar.w) {
if (t <= nearClip) {
discard;
}
const float3 worldPosition = cameraPosition + rayDirection * t;
const float4 clipPosition = mul(gViewProjectionMatrix, float4(worldPosition, 1.0));
if (clipPosition.w <= 1e-6) {
discard;
}
float depth = 0.999999;
if (t < sceneFarClip) {
const float4 clipPosition = mul(gViewProjectionMatrix, float4(worldPosition, 1.0));
if (clipPosition.w <= 1e-6) {
discard;
}
const float depth = clipPosition.z / clipPosition.w;
if (depth <= 0.0 || depth >= 1.0) {
discard;
depth = clipPosition.z / clipPosition.w;
if (depth <= 0.0 || depth >= 1.0) {
discard;
}
}
const float radialFade =