# How to consider only specifc geometry in a custom hlsl raytracer

**URL:** <https://forums.unrealengine.com/t/how-to-consider-only-specifc-geometry-in-a-custom-hlsl-raytracer/2707091>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, hlsl, question, CPP\
**Created:** [March 18, 2026, 6:28pm UTC](https://forums.unrealengine.com/t/how-to-consider-only-specifc-geometry-in-a-custom-hlsl-raytracer/2707091 "2026-03-18T18:28:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BoardCogs](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BoardCogs](https://forums.unrealengine.com/u/BoardCogs)\
**Post date:** [March 18, 2026, 6:28pm UTC](https://forums.unrealengine.com/t/how-to-consider-only-specifc-geometry-in-a-custom-hlsl-raytracer/2707091/1 "2026-03-18T18:28:39Z")

</div>

So, for the past three months or so I’ve been trying to setup a raytracing global shader that tries to simulate rays bouncing off of surfaces. The point is that I want to ignore most geometry and I only want to focus on specific surfaces I have put in place.

I’ve followed this tutorial: [Community Tutorial: How to Create a Custom Ray Tracing Shader as a Plugin](https://forums.unrealengine.com/t/community-tutorial-how-to-create-a-custom-ray-tracing-shader-as-a-plugin/1139396) and I made it work in UE 5.6, but now I’m stuck trying to filter out all geometry except the ones I need in one way or the other.

I’ve tried a bunch of approaches in many different ways, all fruitless up to this point:

1. Filtering out geometry in the TLAS before passing it to the shader as a parameter. I couldn’t make this work because the TLAS is derived directly from the FScene, and Unreal is very protective of this class and basically all others like FRayTracingScene and so on. It doesn’t allow to make a copy of these objects and trying to tamper with the ones used by every other engine process is obviously a recipe for disaster.

2. I tried looking for ways to filter by material in the shader. My geometry has a custom material, I thought maybe if I could get info about the material of a hit in the intersection attributes of any and closest hit I could just tell unreal to ignore everything that didn’t match. But I can’t seem to be able to access that information. Maybe it has to do with the fact that it’s a global shader, so variables with primitive data like material aren’t bound. i followed the tutorial I mentioned above, so the intersection attributes I get on the hit shaders are BuiltInTriangleIntersectionAttributes. As far as I know these don’t have any useful information, I tried searching in the source code and they don’t even seem to eist and I can’t find any information on them, is there a way to use another structure for the intersection attributes?

3. Last but not least, I tried looking for ways to filter geometry using the masks that are set when calling the hlsl TraceRay method. As an example, when calling:

This is a summary of my many attempts, hours of skimming through the source code to find inspiration because I can’t seem to find any official material on this matter. It seems unbelievable to me that a custom shader wouldn’t be able to access information about the material it’s hitting during a raytracing pass, but I genuinely can’t find any ways to do it in Unreal.

If you have any info or suggestions I would appreciate every bit of help!
