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