some transparency
This commit is contained in:
@@ -53,6 +53,9 @@ void closestHit(inout RayPayload hitValue, in BuiltInTriangleIntersectionAttribu
|
||||
// gamma correction
|
||||
result = result / (result + float3(1.0));
|
||||
result = pow(result, float3(1.0/2.2));
|
||||
|
||||
|
||||
hitValue.color = result;
|
||||
hitValue.alpha = brdf.getAlpha();
|
||||
hitValue.intersection_WS = WorldRayOrigin() + RayTCurrent() * WorldRayDirection();
|
||||
hitValue.normal_WS = mul(params.getTangentToWorld(), brdf.getTangentNormal());
|
||||
}
|
||||
@@ -4,4 +4,7 @@ import RayTracingData;
|
||||
void miss(inout RayPayload p)
|
||||
{
|
||||
p.color = float3(0, 1, 0);
|
||||
p.alpha = 1;
|
||||
p.intersection_WS = float3(0, 0, 0);
|
||||
p.normal_WS = float3(0, 0, 0);
|
||||
}
|
||||
@@ -17,10 +17,20 @@ void raygen()
|
||||
rayDesc.Direction = mul(pViewParams.inverseViewMatrix, float4(normalize(target.xyz), 0)).xyz;
|
||||
rayDesc.TMin = 0.001;
|
||||
rayDesc.TMax = 10000.0;
|
||||
|
||||
const uint maxRays = 12;
|
||||
float3 color = float3(0, 0, 0);
|
||||
float alpha;
|
||||
for(uint i = 0; i < maxRays; ++i) {
|
||||
RayPayload payload;
|
||||
TraceRay(pRayTracingParams.scene, RAY_FLAG_FORCE_OPAQUE, 0xff, 0, 0, 0, rayDesc, payload);
|
||||
color = color.rgb * alpha + payload.color * payload.alpha;
|
||||
alpha = alpha + payload.alpha;
|
||||
rayDesc.Origin = payload.intersection_WS;
|
||||
if(alpha > 0.9){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
RayPayload payload;
|
||||
payload.rayDirection = rayDesc.Direction;
|
||||
TraceRay(pRayTracingParams.scene, RAY_FLAG_FORCE_OPAQUE, 0xff, 0, 0, 0, rayDesc, payload);
|
||||
|
||||
pRayTracingParams.image[int2(LaunchID.xy)] = float4(payload.color, 1.0);
|
||||
pRayTracingParams.image[int2(LaunchID.xy)] = float4(color, alpha);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ struct CallablePayload
|
||||
|
||||
struct RayPayload
|
||||
{
|
||||
float3 rayDirection;
|
||||
float3 color;
|
||||
float alpha;
|
||||
float3 intersection_WS;
|
||||
float3 normal_WS;
|
||||
};
|
||||
Reference in New Issue
Block a user