Conversation
There was a problem hiding this comment.
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 | ||
| } |
There was a problem hiding this comment.
[nitpick] The magic number 0.75 should be defined as a named constant to improve maintainability and make it easier to tune.
| } | |
| // 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 | |
| } |
| #else | ||
| return fwidth(d); | ||
| #endif | ||
| } |
There was a problem hiding this comment.
[nitpick] The magic number 1e-4 should be defined as a named constant to improve code clarity and avoid potential floating-point precision issues.
| } | |
| // 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 | |
| } |
Rewrite the dot shading function so it supports DXR. Also, ditch the emission fork which seems to work now and fixes the emission intensity.