nevermind, its not supposed to work, anyhit is not invoked on opaque
This commit is contained in:
@@ -7,6 +7,8 @@ import StaticMeshVertexData;
|
||||
[shader("anyhit")]
|
||||
void anyhit(inout RayPayload hitValue, in BuiltInTriangleIntersectionAttributes attr)
|
||||
{
|
||||
if(RayTCurrent() > hitValue.t)
|
||||
return;
|
||||
const float3 barycentricCoords = float3(1.0f - attr.barycentrics.x - attr.barycentrics.y, attr.barycentrics.x, attr.barycentrics.y);
|
||||
|
||||
InstanceData inst = pScene.instances[InstanceID()];
|
||||
|
||||
@@ -110,6 +110,7 @@ void closestHit(inout RayPayload hitValue, in BuiltInTriangleIntersectionAttribu
|
||||
|
||||
hitValue.params = params.getLightingParameter();
|
||||
hitValue.materialParams = params.getMaterialParameter();
|
||||
|
||||
LightingParameter lightingParams = hitValue.params;
|
||||
lightingParams.viewDir_WS = -WorldRayDirection();
|
||||
let brdf = Material.prepare(hitValue.materialParams);
|
||||
@@ -165,7 +166,7 @@ void closestHit(inout RayPayload hitValue, in BuiltInTriangleIntersectionAttribu
|
||||
payload.anyHit = true;
|
||||
payload.hit = false;
|
||||
payload.rndSeed = hitValue.rndSeed;
|
||||
TraceRay(pRayTracingParams.scene, RAY_FLAG_CULL_BACK_FACING_TRIANGLES, 0xff, 0, 0, 0, rayDesc, payload);
|
||||
TraceRay(pRayTracingParams.scene, RAY_FLAG_CULL_BACK_FACING_TRIANGLES | RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH, 0xff, 0, 0, 0, rayDesc, payload);
|
||||
|
||||
// we have missed all geometry, so directional light is affecting us
|
||||
if(!payload.hit) {
|
||||
@@ -185,7 +186,7 @@ void closestHit(inout RayPayload hitValue, in BuiltInTriangleIntersectionAttribu
|
||||
rayDesc.TMin = eps;
|
||||
rayDesc.Origin = x;
|
||||
rayDesc.Direction = l;
|
||||
TraceRay(pRayTracingParams.scene, RAY_FLAG_CULL_BACK_FACING_TRIANGLES, 0xff, 0, 0, 0, rayDesc, payload);
|
||||
TraceRay(pRayTracingParams.scene, RAY_FLAG_CULL_BACK_FACING_TRIANGLES | RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH, 0xff, 0, 0, 0, rayDesc, payload);
|
||||
|
||||
// hitting only after the light
|
||||
if(!payload.hit) {
|
||||
|
||||
@@ -103,6 +103,7 @@ void raygen()
|
||||
RayPayload payload;
|
||||
// initialize accumulated radiance and bxdf
|
||||
payload.light=float3(0);
|
||||
payload.t = 10000.0f;
|
||||
payload.emissive = 1;
|
||||
payload.depth = 1;
|
||||
payload.rndSeed = rndSeed + 1;
|
||||
|
||||
@@ -18,6 +18,7 @@ struct RayPayload
|
||||
LightingParameter params;
|
||||
MaterialParameter materialParams;
|
||||
float3 light;
|
||||
float t;
|
||||
float emissive;
|
||||
uint depth;
|
||||
bool hit;
|
||||
|
||||
Reference in New Issue
Block a user