forked from Dynamitos/Seele
More rt changes
This commit is contained in:
1 parent
3463ecd7b9
commit
42d98d7233
10 files changed
+55
-82
No files matched your search
@@ -24,5 +24,5 @@ void callable(inout CallablePayload payload)
|
||||
// gamma correction
|
||||
result = result / (result + float3(1.0));
|
||||
result = pow(result, float3(1.0/2.2));
|
||||
payload.color = result;
|
||||
payload.color = brdf.baseColor;
|
||||
}
|
||||
@@ -10,34 +10,34 @@ import RayTracingData;
|
||||
[shader("closesthit")]
|
||||
void closestHit(inout RayPayload hitValue, in BuiltInTriangleIntersectionAttributes attr)
|
||||
{
|
||||
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()];
|
||||
MeshData m = pScene.meshData[InstanceID()];
|
||||
|
||||
// offset into the index buffer
|
||||
uint indexOffset = m.firstIndex;
|
||||
// added to indices to reference correct part of global mesh pool
|
||||
uint vertexOffset = pScene.meshletInfos[m.meshletOffset].indicesOffset;
|
||||
|
||||
uint vertexIndex0 = vertexOffset + pRayTracingParams.indexBuffer[indexOffset + 3 * PrimitiveIndex() + 0];
|
||||
uint vertexIndex1 = vertexOffset + pRayTracingParams.indexBuffer[indexOffset + 3 * PrimitiveIndex() + 1];
|
||||
uint vertexIndex2 = vertexOffset + pRayTracingParams.indexBuffer[indexOffset + 3 * PrimitiveIndex() + 2];
|
||||
|
||||
VertexAttributes attr0 = pVertexData.getAttributes(vertexIndex0);
|
||||
VertexAttributes attr1 = pVertexData.getAttributes(vertexIndex1);
|
||||
VertexAttributes attr2 = pVertexData.getAttributes(vertexIndex2);
|
||||
|
||||
FragmentParameter f0 = attr0.getParameter(inst.transformMatrix);
|
||||
FragmentParameter f1 = attr1.getParameter(inst.transformMatrix);
|
||||
FragmentParameter f2 = attr2.getParameter(inst.transformMatrix);
|
||||
|
||||
FragmentParameter params = FragmentParameter.interpolate(f0, f1, f2, barycentricCoords);
|
||||
|
||||
CallablePayload callable;
|
||||
callable.params = params;
|
||||
|
||||
CallShader(InstanceID(), callable);
|
||||
//InstanceData inst = pScene.instances[InstanceID()];
|
||||
//MeshData m = pScene.meshData[InstanceID()];
|
||||
//
|
||||
//// offset into the index buffer
|
||||
//uint indexOffset = m.firstIndex;
|
||||
//// added to indices to reference correct part of global mesh pool
|
||||
//uint vertexOffset = pScene.meshletInfos[m.meshletOffset].indicesOffset;
|
||||
//
|
||||
//uint vertexIndex0 = vertexOffset + pRayTracingParams.indexBuffer[indexOffset + 3 * PrimitiveIndex() + 0];
|
||||
//uint vertexIndex1 = vertexOffset + pRayTracingParams.indexBuffer[indexOffset + 3 * PrimitiveIndex() + 1];
|
||||
//uint vertexIndex2 = vertexOffset + pRayTracingParams.indexBuffer[indexOffset + 3 * PrimitiveIndex() + 2];
|
||||
//
|
||||
//VertexAttributes attr0 = pVertexData.getAttributes(vertexIndex0);
|
||||
//VertexAttributes attr1 = pVertexData.getAttributes(vertexIndex1);
|
||||
//VertexAttributes attr2 = pVertexData.getAttributes(vertexIndex2);
|
||||
//
|
||||
//FragmentParameter f0 = attr0.getParameter(inst.transformMatrix);
|
||||
//FragmentParameter f1 = attr1.getParameter(inst.transformMatrix);
|
||||
//FragmentParameter f2 = attr2.getParameter(inst.transformMatrix);
|
||||
//
|
||||
//FragmentParameter params = FragmentParameter.interpolate(f0, f1, f2, barycentricCoords);
|
||||
//
|
||||
//CallablePayload callable;
|
||||
//callable.params = params;
|
||||
//
|
||||
//CallShader(InstanceID(), callable);
|
||||
|
||||
hitValue.color = float3(1, 0, 0);
|
||||
}
|
||||
@@ -25,10 +25,7 @@ void raygen()
|
||||
desc.TMin = tmin;
|
||||
desc.TMax = tmax;
|
||||
|
||||
pRayTracingParams.origins[DispatchRaysIndex().x + DispatchRaysDimensions().x * DispatchRaysIndex().y] = origin.xyz;
|
||||
pRayTracingParams.rayDirections[DispatchRaysIndex().x + DispatchRaysDimensions().x * DispatchRaysIndex().y] = direction.xyz;
|
||||
|
||||
TraceRay(pRayTracingParams.scene, 0, 0xff, 0, 1, 0, desc, payload);
|
||||
TraceRay(pRayTracingParams.scene, 0, 0xff, 0, 0, 0, desc, payload);
|
||||
|
||||
pRayTracingParams.image[DispatchRaysIndex().xy] = float4(payload.color, 1.0f);
|
||||
}
|
||||
@@ -5,8 +5,6 @@ struct RayTracingParams
|
||||
RaytracingAccelerationStructure scene;
|
||||
RWTexture2D<float4> image;
|
||||
StructuredBuffer<uint> indexBuffer;
|
||||
RWStructuredBuffer<float3> rayDirections;
|
||||
RWStructuredBuffer<float3> origins;
|
||||
};
|
||||
layout(set=5)
|
||||
ParameterBlock<RayTracingParams> pRayTracingParams;
|
||||
|
||||
Reference in new issue
Block a user