Skip to content

Conversation

@freezy
Copy link
Owner

@freezy freezy commented Aug 21, 2025

Rewrite the dot shading function so it supports DXR. Also, ditch the emission fork which seems to work now and fixes the emission intensity.

@freezy freezy requested a review from Copilot August 21, 2025 06:46
@freezy freezy self-assigned this Aug 21, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes DXR (DirectX Raytracing) support for the dot matrix display shader by rewriting the dot shading function to handle anti-aliasing differently in ray tracing vs raster contexts. It also removes an emission fork that was previously necessary but now works correctly.

  • Adds DXR-safe anti-aliasing using UV feathering in ray tracing contexts instead of fwidth
  • Updates all dot shape functions (Ellipse, RoundedRectangle, Rectangle) to use the new AAWidth helper
  • Removes the HDRP_Emission custom function node that handled emission differently based on rendering pipeline

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
DotMatrixDisplayShader.hlsl Implements AAWidth helper function and updates shape functions to support DXR
DotMatrixDisplayGraph.shadergraph Removes emission fork node and updates shader graph connections

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

#else
return fwidth(d);
#endif
}
Copy link

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The magic number 0.75 should be defined as a named constant to improve maintainability and make it easier to tune.

Suggested change
}
// DXR-safe AA width helper: uses fwidth in raster, constant UV feather in ray tracing.
// Scale factor for UV feathering in AAWidth. Tune as needed.
static const float AA_UV_FEATHER_SCALE = 0.75;
inline float AAWidth(float d, float2 dimensions)
{
#ifdef SHADER_STAGE_RAY_TRACING
// Feather in UVs of a single dot cell. Tune the scale as needed.
float uvFeather = max(1.0 / max(dimensions.x, dimensions.y), 1e-4) * AA_UV_FEATHER_SCALE;
return uvFeather;
#else
return fwidth(d);
#endif
}

Copilot uses AI. Check for mistakes.
#else
return fwidth(d);
#endif
}
Copy link

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The magic number 1e-4 should be defined as a named constant to improve code clarity and avoid potential floating-point precision issues.

Suggested change
}
// DXR-safe AA width helper: uses fwidth in raster, constant UV feather in ray tracing.
// Minimum UV feather value to avoid floating-point precision issues
static const float MIN_UV_FEATHER = 1e-4;
inline float AAWidth(float d, float2 dimensions)
{
#ifdef SHADER_STAGE_RAY_TRACING
// Feather in UVs of a single dot cell. Tune the scale as needed.
float uvFeather = max(1.0 / max(dimensions.x, dimensions.y), MIN_UV_FEATHER) * 0.75;
return uvFeather;
#else
return fwidth(d);
#endif
}

Copilot uses AI. Check for mistakes.
@freezy freezy merged commit 8e40261 into master Aug 21, 2025
15 checks passed
@freezy freezy deleted the fix/dotmatrixshader branch August 21, 2025 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants