Update ray tracing samples to use VK_KHR_ray_tracing (#753)

* Started updating ray tracing samples to KHR extension

* Updated GLSL shaders to use GL_EXT_ray_tracing

* Code cleanup, naming

* Fix include directories to use Vulkan headers from repository instead of NDK for the Android build

* Added new Android function pointers

* Renamed basic ray tracing sample

Added android build files

* Remove unused batch file

* Replaced remaining NV identifiers

* Updating ray tracing shadow sample to KHR extension

* Updated shaders to use KHR instead of NV extension

Fixed shader bindings

* Updating ray tracing reflections sample to KHR extension

* Renamed ray tracing reflections sample

* Renamed ray tracing shadows sample

Added android build files

* Removed no-longer used batch files for shader generation

* Proper alignment for the shader binding table

* Updated readme

* Reworked shader group setup

* Cleanup

* Reworked shader group setup

* Reworked shader group setup

* Code cleanup
This commit is contained in:
Sascha Willems 2020-08-15 17:59:02 +02:00 committed by GitHub
parent e6956acfbd
commit ee946e2abf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
98 changed files with 3291 additions and 2457 deletions

View file

@ -0,0 +1,18 @@
// Copyright 2020 Google LLC
struct Attribute
{
float2 attribs;
};
struct Payload
{
[[vk::location(0)]] float3 hitValue;
};
[shader("closesthit")]
void main(inout Payload p, in float3 attribs)
{
const float3 barycentricCoords = float3(1.0f - attribs.x - attribs.y, attribs.x, attribs.y);
p.hitValue = barycentricCoords;
}

Binary file not shown.

View file

@ -0,0 +1,12 @@
// Copyright 2020 Google LLC
struct Payload
{
[[vk::location(0)]] float3 hitValue;
};
[shader("miss")]
void main(inout Payload p)
{
p.hitValue = float3(0.0, 0.0, 0.2);
}

Binary file not shown.

View file

@ -0,0 +1,39 @@
// Copyright 2020 Google LLC
RaytracingAccelerationStructure rs : register(t0);
RWTexture2D<float4> image : register(u1);
struct CameraProperties
{
float4x4 viewInverse;
float4x4 projInverse;
};
cbuffer cam : register(b2) { CameraProperties cam; };
struct Payload
{
[[vk::location(0)]] float3 hitValue;
};
[shader("raygeneration")]
void main()
{
uint3 LaunchID = DispatchRaysIndex();
uint3 LaunchSize = DispatchRaysDimensions();
const float2 pixelCenter = float2(LaunchID.xy) + float2(0.5, 0.5);
const float2 inUV = pixelCenter/float2(LaunchSize.xy);
float2 d = inUV * 2.0 - 1.0;
float4 target = mul(cam.projInverse, float4(d.x, d.y, 1, 1));
RayDesc rayDesc;
rayDesc.Origin = mul(cam.viewInverse, float4(0,0,0,1)).xyz;
rayDesc.Direction = mul(cam.viewInverse, float4(normalize(target.xyz), 0)).xyz;
rayDesc.TMin = 0.001;
rayDesc.TMax = 10000.0;
Payload payload;
TraceRay(rs, RAY_FLAG_FORCE_OPAQUE, 0xff, 0, 0, 0, rayDesc, payload);
image[int2(LaunchID.xy)] = float4(payload.hitValue, 0.0);
}

Binary file not shown.