当前位置: 首页 > 工具软件 > DXR > 使用案例 >

DXR相关

舒阳州
2023-12-01

Tips

DXR ray tracing tutorial中:

TraceRay(gRtScene,
RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH | RAY_FLAG_SKIP_CLOSEST_HIT_SHADER,
0xFF, 0, hitProgramCount, 0, rayAO, rayPayload);

We’re going to tell our ray to never run the closest-hit shader and to stop as soon as we find any intersection.
这里注意RAYFLAG可以设置为skip closest hit shader;在anyhit shader中只有通过alpha测试后才会得到有效的hit,才能结束search;整个过程中不会走closest hit shader,会走any hit shader,可能会走miss shader。这种设置可以在AO中发挥作用,具体看DXR ray tracing tutorial。

// What code is executed when our ray misses all geometry?
[shader("miss")]
void AoMiss(inout AORayPayload rayData)
{
	// Our ambient occlusion value is 1 if we hit nothing.
	rayData.aoValue = 1.0f;
}

// What code is executed when our ray hits a potentially transparent surface?
[shader("anyhit")]
void AoAnyHit(inout AORayPayload rayData, BuiltInTriangleIntersectionAttributes attribs)
{
	// Is this a transparent part of the surface?  If so, ignore this hit
	if (alphaTestFails(attribs))
		IgnoreHit();
}
 类似资料: