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:
parent
e6956acfbd
commit
ee946e2abf
98 changed files with 3291 additions and 2457 deletions
|
|
@ -1,2 +0,0 @@
|
|||
glslangvalidator -V textoverlay.vert -o textoverlay.vert.spv
|
||||
glslangvalidator -V textoverlay.frag -o textoverlay.frag.spv
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
glslangvalidator -V colorpass.vert -o colorpass.vert.spv
|
||||
glslangvalidator -V colorpass.frag -o colorpass.frag.spv
|
||||
|
||||
glslangvalidator -V phongpass.vert -o phongpass.vert.spv
|
||||
glslangvalidator -V phongpass.frag -o phongpass.frag.spv
|
||||
|
||||
glslangvalidator -V gaussblur.vert -o gaussblur.vert.spv
|
||||
glslangvalidator -V gaussblur.frag -o gaussblur.frag.spv
|
||||
|
||||
glslangvalidator -V skybox.vert -o skybox.vert.spv
|
||||
glslangvalidator -V skybox.frag -o skybox.frag.spv
|
||||
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
glslangvalidator -V particle.frag -o particle.frag.spv
|
||||
glslangvalidator -V particle.vert -o particle.vert.spv
|
||||
glslangvalidator -V particle.comp -o particle.comp.spv
|
||||
|
||||
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
glslangvalidator -V texture.frag -o texture.frag.spv
|
||||
glslangvalidator -V texture.vert -o texture.vert.spv
|
||||
glslangvalidator -V raytracing.comp -o raytracing.comp.spv
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
glslangvalidator -V edgedetect.comp -o edgedetect.comp.spv
|
||||
glslangvalidator -V emboss.comp -o emboss.comp.spv
|
||||
glslangvalidator -V sharpen.comp -o sharpen.comp.spv
|
||||
glslangvalidator -V texture.frag -o texture.frag.spv
|
||||
glslangvalidator -V texture.vert -o texture.vert.spv
|
||||
|
||||
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
glslangvalidator -V toon.vert -o toon.vert.spv
|
||||
glslangvalidator -V toon.frag -o toon.frag.spv
|
||||
glslangvalidator -V colorpass.vert -o colorpass.vert.spv
|
||||
glslangvalidator -V colorpass.frag -o colorpass.frag.spv
|
||||
glslangvalidator -V postprocess.vert -o postprocess.vert.spv
|
||||
glslangvalidator -V postprocess.frag -o postprocess.frag.spv
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
glslangvalidator -V base.vert -o base.vert.spv
|
||||
glslangvalidator -V base.frag -o base.frag.spv
|
||||
glslangvalidator -V displacement.tesc -o displacement.tesc.spv
|
||||
glslangvalidator -V displacement.tese -o displacement.tese.spv
|
||||
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
glslangvalidator -V sdf.vert -o sdf.vert.spv
|
||||
glslangvalidator -V sdf.frag -o sdf.frag.spv
|
||||
glslangvalidator -V bitmap.vert -o bitmap.vert.spv
|
||||
glslangvalidator -V bitmap.frag -o bitmap.frag.spv
|
||||
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
glslangvalidator -V base.vert -o base.vert.spv
|
||||
glslangvalidator -V base.frag -o base.frag.spv
|
||||
glslangvalidator -V normaldebug.geom -o normaldebug.geom.spv
|
||||
glslangvalidator -V mesh.vert -o mesh.vert.spv
|
||||
glslangvalidator -V mesh.frag -o mesh.frag.spv
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
glslangvalidator -V ground.vert -o ground.vert.spv
|
||||
glslangvalidator -V ground.frag -o ground.frag.spv
|
||||
glslangvalidator -V indirectdraw.vert -o indirectdraw.vert.spv
|
||||
glslangvalidator -V indirectdraw.frag -o indirectdraw.frag.spv
|
||||
glslangvalidator -V skysphere.vert -o skysphere.vert.spv
|
||||
glslangvalidator -V skysphere.frag -o skysphere.frag.spv
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
glslangvalidator -V instancing.vert -o instancing.vert.spv
|
||||
glslangvalidator -V instancing.frag -o instancing.frag.spv
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
glslangvalidator -V phong.vert -o phong.vert.spv
|
||||
glslangvalidator -V phong.frag -o phong.frag.spv
|
||||
glslangvalidator -V starsphere.vert -o starsphere.vert.spv
|
||||
glslangvalidator -V starsphere.frag -o starsphere.frag.spv
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec3 hitValue;
|
||||
|
||||
void main()
|
||||
{
|
||||
hitValue = vec3(0.0, 0.0, 0.2);
|
||||
}
|
||||
Binary file not shown.
|
|
@ -1,32 +0,0 @@
|
|||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(binding = 0, set = 0) uniform accelerationStructureNV topLevelAS;
|
||||
layout(binding = 1, set = 0, rgba8) uniform image2D image;
|
||||
layout(binding = 2, set = 0) uniform CameraProperties
|
||||
{
|
||||
mat4 viewInverse;
|
||||
mat4 projInverse;
|
||||
} cam;
|
||||
|
||||
layout(location = 0) rayPayloadNV vec3 hitValue;
|
||||
|
||||
void main()
|
||||
{
|
||||
const vec2 pixelCenter = vec2(gl_LaunchIDNV.xy) + vec2(0.5);
|
||||
const vec2 inUV = pixelCenter/vec2(gl_LaunchSizeNV.xy);
|
||||
vec2 d = inUV * 2.0 - 1.0;
|
||||
|
||||
vec4 origin = cam.viewInverse * vec4(0,0,0,1);
|
||||
vec4 target = cam.projInverse * vec4(d.x, d.y, 1, 1) ;
|
||||
vec4 direction = cam.viewInverse*vec4(normalize(target.xyz / target.w), 0) ;
|
||||
|
||||
uint rayFlags = gl_RayFlagsOpaqueNV;
|
||||
uint cullMask = 0xff;
|
||||
float tmin = 0.001;
|
||||
float tmax = 10000.0;
|
||||
|
||||
traceNV(topLevelAS, rayFlags, cullMask, 0, 0, 0, origin.xyz, tmin, direction.xyz, tmax, 0);
|
||||
|
||||
imageStore(image, ivec2(gl_LaunchIDNV.xy), vec4(hitValue, 0.0));
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,9 +0,0 @@
|
|||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec3 hitValue;
|
||||
|
||||
void main()
|
||||
{
|
||||
hitValue = vec3(0.0, 0.0, 0.2);
|
||||
}
|
||||
Binary file not shown.
|
|
@ -1,9 +0,0 @@
|
|||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
|
||||
layout(location = 2) rayPayloadInNV bool shadowed;
|
||||
|
||||
void main()
|
||||
{
|
||||
shadowed = false;
|
||||
}
|
||||
Binary file not shown.
|
|
@ -1,6 +0,0 @@
|
|||
glslangvalidator -V mesh.vert -o mesh.vert.spv
|
||||
glslangvalidator -V mesh.frag -o mesh.frag.spv
|
||||
glslangvalidator -V occluder.vert -o occluder.vert.spv
|
||||
glslangvalidator -V occluder.frag -o occluder.frag.spv
|
||||
glslangvalidator -V simple.vert -o simple.vert.spv
|
||||
glslangvalidator -V simple.frag -o simple.frag.spv
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
glslangvalidator -V particle.frag -o particle.frag.spv
|
||||
glslangvalidator -V particle.vert -o particle.vert.spv
|
||||
glslangvalidator -V normalmap.frag -o normalmap.frag.spv
|
||||
glslangvalidator -V normalmap.vert -o normalmap.vert.spv
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
glslangvalidator -V phong.vert -o phong.vert.spv
|
||||
glslangvalidator -V phong.frag -o phong.frag.spv
|
||||
glslangvalidator -V wireframe.vert -o wireframe.vert.spv
|
||||
glslangvalidator -V wireframe.frag -o wireframe.frag.spv
|
||||
glslangvalidator -V toon.vert -o toon.vert.spv
|
||||
glslangvalidator -V toon.frag -o toon.frag.spv
|
||||
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
glslangvalidator -V colorpass.vert -o colorpass.vert.spv
|
||||
glslangvalidator -V colorpass.frag -o colorpass.frag.spv
|
||||
glslangvalidator -V phongpass.vert -o phongpass.vert.spv
|
||||
glslangvalidator -V phongpass.frag -o phongpass.frag.spv
|
||||
glslangvalidator -V radialblur.vert -o radialblur.vert.spv
|
||||
glslangvalidator -V radialblur.frag -o radialblur.frag.spv
|
||||
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
#extension GL_EXT_ray_tracing : enable
|
||||
#extension GL_EXT_nonuniform_qualifier : enable
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec3 hitValue;
|
||||
hitAttributeNV vec3 attribs;
|
||||
layout(location = 0) rayPayloadInEXT vec3 hitValue;
|
||||
hitAttributeEXT vec3 attribs;
|
||||
|
||||
void main()
|
||||
{
|
||||
Binary file not shown.
9
data/shaders/glsl/raytracingbasic/miss.rmiss
Normal file
9
data/shaders/glsl/raytracingbasic/miss.rmiss
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#version 460
|
||||
#extension GL_EXT_ray_tracing : enable
|
||||
|
||||
layout(location = 0) rayPayloadInEXT vec3 hitValue;
|
||||
|
||||
void main()
|
||||
{
|
||||
hitValue = vec3(0.0, 0.0, 0.2);
|
||||
}
|
||||
BIN
data/shaders/glsl/raytracingbasic/miss.rmiss.spv
Normal file
BIN
data/shaders/glsl/raytracingbasic/miss.rmiss.spv
Normal file
Binary file not shown.
32
data/shaders/glsl/raytracingbasic/raygen.rgen
Normal file
32
data/shaders/glsl/raytracingbasic/raygen.rgen
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#version 460
|
||||
#extension GL_EXT_ray_tracing : enable
|
||||
|
||||
layout(binding = 0, set = 0) uniform accelerationStructureEXT topLevelAS;
|
||||
layout(binding = 1, set = 0, rgba8) uniform image2D image;
|
||||
layout(binding = 2, set = 0) uniform CameraProperties
|
||||
{
|
||||
mat4 viewInverse;
|
||||
mat4 projInverse;
|
||||
} cam;
|
||||
|
||||
layout(location = 0) rayPayloadEXT vec3 hitValue;
|
||||
|
||||
void main()
|
||||
{
|
||||
const vec2 pixelCenter = vec2(gl_LaunchIDEXT.xy) + vec2(0.5);
|
||||
const vec2 inUV = pixelCenter/vec2(gl_LaunchSizeEXT.xy);
|
||||
vec2 d = inUV * 2.0 - 1.0;
|
||||
|
||||
vec4 origin = cam.viewInverse * vec4(0,0,0,1);
|
||||
vec4 target = cam.projInverse * vec4(d.x, d.y, 1, 1) ;
|
||||
vec4 direction = cam.viewInverse*vec4(normalize(target.xyz), 0) ;
|
||||
|
||||
float tmin = 0.001;
|
||||
float tmax = 10000.0;
|
||||
|
||||
hitValue = vec3(0.0);
|
||||
|
||||
traceRayEXT(topLevelAS, gl_RayFlagsOpaqueEXT, 0xff, 0, 0, 0, origin.xyz, tmin, direction.xyz, tmax, 0);
|
||||
|
||||
imageStore(image, ivec2(gl_LaunchIDEXT.xy), vec4(hitValue, 0.0));
|
||||
}
|
||||
BIN
data/shaders/glsl/raytracingbasic/raygen.rgen.spv
Normal file
BIN
data/shaders/glsl/raytracingbasic/raygen.rgen.spv
Normal file
Binary file not shown.
|
|
@ -1,5 +1,5 @@
|
|||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
#extension GL_EXT_ray_tracing : require
|
||||
#extension GL_EXT_nonuniform_qualifier : enable
|
||||
|
||||
struct RayPayload {
|
||||
|
|
@ -9,11 +9,11 @@ struct RayPayload {
|
|||
float reflector;
|
||||
};
|
||||
|
||||
layout(location = 0) rayPayloadInNV RayPayload rayPayload;
|
||||
layout(location = 0) rayPayloadInEXT RayPayload rayPayload;
|
||||
|
||||
hitAttributeNV vec3 attribs;
|
||||
hitAttributeEXT vec3 attribs;
|
||||
|
||||
layout(binding = 0, set = 0) uniform accelerationStructureNV topLevelAS;
|
||||
layout(binding = 0, set = 0) uniform accelerationStructureEXT topLevelAS;
|
||||
layout(binding = 2, set = 0) uniform UBO
|
||||
{
|
||||
mat4 viewInverse;
|
||||
|
|
@ -68,7 +68,7 @@ void main()
|
|||
vec3 lightVector = normalize(ubo.lightPos.xyz);
|
||||
float dot_product = max(dot(lightVector, normal), 0.6);
|
||||
rayPayload.color = v0.color.rgb * vec3(dot_product);
|
||||
rayPayload.distance = gl_RayTmaxNV;
|
||||
rayPayload.distance = gl_RayTmaxEXT;
|
||||
rayPayload.normal = normal;
|
||||
|
||||
// Objects with full white vertex color are treated as reflectors
|
||||
BIN
data/shaders/glsl/raytracingreflections/closesthit.rchit.spv
Normal file
BIN
data/shaders/glsl/raytracingreflections/closesthit.rchit.spv
Normal file
Binary file not shown.
|
|
@ -1,5 +1,5 @@
|
|||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
#extension GL_EXT_ray_tracing : require
|
||||
|
||||
struct RayPayload {
|
||||
vec3 color;
|
||||
|
|
@ -8,14 +8,14 @@ struct RayPayload {
|
|||
float reflector;
|
||||
};
|
||||
|
||||
layout(location = 0) rayPayloadInNV RayPayload rayPayload;
|
||||
layout(location = 0) rayPayloadInEXT RayPayload rayPayload;
|
||||
|
||||
void main()
|
||||
{
|
||||
// View-independent background gradient to simulate a basic sky background
|
||||
const vec3 gradientStart = vec3(0.5, 0.6, 1.0);
|
||||
const vec3 gradientEnd = vec3(1.0);
|
||||
vec3 unitDir = normalize(gl_WorldRayDirectionNV);
|
||||
vec3 unitDir = normalize(gl_WorldRayDirectionEXT);
|
||||
float t = 0.5 * (unitDir.y + 1.0);
|
||||
rayPayload.color = (1.0-t) * gradientStart + t * gradientEnd;
|
||||
|
||||
Binary file not shown.
|
|
@ -1,7 +1,7 @@
|
|||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
#extension GL_EXT_ray_tracing : require
|
||||
|
||||
layout(binding = 0, set = 0) uniform accelerationStructureNV topLevelAS;
|
||||
layout(binding = 0, set = 0) uniform accelerationStructureEXT topLevelAS;
|
||||
layout(binding = 1, set = 0, rgba8) uniform image2D image;
|
||||
layout(binding = 2, set = 0) uniform CameraProperties
|
||||
{
|
||||
|
|
@ -18,22 +18,22 @@ struct RayPayload {
|
|||
float reflector;
|
||||
};
|
||||
|
||||
layout(location = 0) rayPayloadNV RayPayload rayPayload;
|
||||
layout(location = 0) rayPayloadEXT RayPayload rayPayload;
|
||||
|
||||
// Max. number of recursion is passed via a specialization constant
|
||||
layout (constant_id = 0) const int MAX_RECURSION = 0;
|
||||
|
||||
void main()
|
||||
{
|
||||
const vec2 pixelCenter = vec2(gl_LaunchIDNV.xy) + vec2(0.5);
|
||||
const vec2 inUV = pixelCenter/vec2(gl_LaunchSizeNV.xy);
|
||||
const vec2 pixelCenter = vec2(gl_LaunchIDEXT.xy) + vec2(0.5);
|
||||
const vec2 inUV = pixelCenter/vec2(gl_LaunchSizeEXT.xy);
|
||||
vec2 d = inUV * 2.0 - 1.0;
|
||||
|
||||
vec4 origin = cam.viewInverse * vec4(0,0,0,1);
|
||||
vec4 target = cam.projInverse * vec4(d.x, d.y, 1, 1) ;
|
||||
vec4 direction = cam.viewInverse*vec4(normalize(target.xyz / target.w), 0);
|
||||
|
||||
uint rayFlags = gl_RayFlagsOpaqueNV;
|
||||
uint rayFlags = gl_RayFlagsOpaqueEXT;
|
||||
uint cullMask = 0xff;
|
||||
float tmin = 0.001;
|
||||
float tmax = 10000.0;
|
||||
|
|
@ -41,7 +41,7 @@ void main()
|
|||
vec3 color = vec3(0.0);
|
||||
|
||||
for (int i = 0; i < MAX_RECURSION; i++) {
|
||||
traceNV(topLevelAS, rayFlags, cullMask, 0, 0, 0, origin.xyz, tmin, direction.xyz, tmax, 0);
|
||||
traceRayEXT(topLevelAS, rayFlags, cullMask, 0, 0, 0, origin.xyz, tmin, direction.xyz, tmax, 0);
|
||||
vec3 hitColor = rayPayload.color;
|
||||
|
||||
if (rayPayload.distance < 0.0f) {
|
||||
|
|
@ -58,5 +58,5 @@ void main()
|
|||
|
||||
}
|
||||
|
||||
imageStore(image, ivec2(gl_LaunchIDNV.xy), vec4(color, 0.0));
|
||||
imageStore(image, ivec2(gl_LaunchIDEXT.xy), vec4(color, 0.0));
|
||||
}
|
||||
Binary file not shown.
|
|
@ -1,12 +1,12 @@
|
|||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
#extension GL_EXT_ray_tracing : require
|
||||
#extension GL_EXT_nonuniform_qualifier : enable
|
||||
|
||||
layout(location = 0) rayPayloadInNV vec3 hitValue;
|
||||
layout(location = 2) rayPayloadNV bool shadowed;
|
||||
hitAttributeNV vec3 attribs;
|
||||
layout(location = 0) rayPayloadInEXT vec3 hitValue;
|
||||
layout(location = 2) rayPayloadEXT bool shadowed;
|
||||
hitAttributeEXT vec3 attribs;
|
||||
|
||||
layout(binding = 0, set = 0) uniform accelerationStructureNV topLevelAS;
|
||||
layout(binding = 0, set = 0) uniform accelerationStructureEXT topLevelAS;
|
||||
layout(binding = 2, set = 0) uniform UBO
|
||||
{
|
||||
mat4 viewInverse;
|
||||
|
|
@ -23,9 +23,9 @@ struct Vertex
|
|||
vec3 normal;
|
||||
vec2 uv;
|
||||
vec4 color;
|
||||
vec4 _pad0;
|
||||
vec4 _pad0;
|
||||
vec4 _pad1;
|
||||
};
|
||||
};
|
||||
|
||||
Vertex unpack(uint index)
|
||||
{
|
||||
|
|
@ -60,15 +60,15 @@ void main()
|
|||
// Basic lighting
|
||||
vec3 lightVector = normalize(ubo.lightPos.xyz);
|
||||
float dot_product = max(dot(lightVector, normal), 0.2);
|
||||
hitValue = v0.color.rgb * vec3(dot_product);
|
||||
hitValue = v0.color.rgb * dot_product;
|
||||
|
||||
// Shadow casting
|
||||
float tmin = 0.001;
|
||||
float tmax = 100.0;
|
||||
vec3 origin = gl_WorldRayOriginNV + gl_WorldRayDirectionNV * gl_HitTNV;
|
||||
float tmax = 10000.0;
|
||||
vec3 origin = gl_WorldRayOriginEXT + gl_WorldRayDirectionEXT * gl_HitTEXT;
|
||||
shadowed = true;
|
||||
// Offset indices to match shadow hit/miss index
|
||||
traceNV(topLevelAS, gl_RayFlagsTerminateOnFirstHitNV | gl_RayFlagsOpaqueNV|gl_RayFlagsSkipClosestHitShaderNV, 0xFF, 1, 0, 1, origin, tmin, lightVector, tmax, 2);
|
||||
// Trace shadow ray and offset indices to match shadow hit/miss shader group indices
|
||||
traceRayEXT(topLevelAS, gl_RayFlagsTerminateOnFirstHitEXT | gl_RayFlagsOpaqueEXT | gl_RayFlagsSkipClosestHitShaderEXT, 0xFF, 1, 0, 1, origin, tmin, lightVector, tmax, 2);
|
||||
if (shadowed) {
|
||||
hitValue *= 0.3;
|
||||
}
|
||||
BIN
data/shaders/glsl/raytracingshadows/closesthit.rchit.spv
Normal file
BIN
data/shaders/glsl/raytracingshadows/closesthit.rchit.spv
Normal file
Binary file not shown.
9
data/shaders/glsl/raytracingshadows/miss.rmiss
Normal file
9
data/shaders/glsl/raytracingshadows/miss.rmiss
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#version 460
|
||||
#extension GL_EXT_ray_tracing : require
|
||||
|
||||
layout(location = 0) rayPayloadInEXT vec3 hitValue;
|
||||
|
||||
void main()
|
||||
{
|
||||
hitValue = vec3(0.0, 0.0, 0.2);
|
||||
}
|
||||
BIN
data/shaders/glsl/raytracingshadows/miss.rmiss.spv
Normal file
BIN
data/shaders/glsl/raytracingshadows/miss.rmiss.spv
Normal file
Binary file not shown.
|
|
@ -1,7 +1,7 @@
|
|||
#version 460
|
||||
#extension GL_NV_ray_tracing : require
|
||||
#extension GL_EXT_ray_tracing : require
|
||||
|
||||
layout(binding = 0, set = 0) uniform accelerationStructureNV topLevelAS;
|
||||
layout(binding = 0, set = 0) uniform accelerationStructureEXT topLevelAS;
|
||||
layout(binding = 1, set = 0, rgba8) uniform image2D image;
|
||||
layout(binding = 2, set = 0) uniform CameraProperties
|
||||
{
|
||||
|
|
@ -10,24 +10,24 @@ layout(binding = 2, set = 0) uniform CameraProperties
|
|||
vec4 lightPos;
|
||||
} cam;
|
||||
|
||||
layout(location = 0) rayPayloadNV vec3 hitValue;
|
||||
layout(location = 0) rayPayloadEXT vec3 hitValue;
|
||||
|
||||
void main()
|
||||
{
|
||||
const vec2 pixelCenter = vec2(gl_LaunchIDNV.xy) + vec2(0.5);
|
||||
const vec2 inUV = pixelCenter/vec2(gl_LaunchSizeNV.xy);
|
||||
const vec2 pixelCenter = vec2(gl_LaunchIDEXT.xy) + vec2(0.5);
|
||||
const vec2 inUV = pixelCenter/vec2(gl_LaunchSizeEXT.xy);
|
||||
vec2 d = inUV * 2.0 - 1.0;
|
||||
|
||||
vec4 origin = cam.viewInverse * vec4(0,0,0,1);
|
||||
vec4 target = cam.projInverse * vec4(d.x, d.y, 1, 1) ;
|
||||
vec4 direction = cam.viewInverse*vec4(normalize(target.xyz / target.w), 0) ;
|
||||
|
||||
uint rayFlags = gl_RayFlagsOpaqueNV;
|
||||
uint rayFlags = gl_RayFlagsOpaqueEXT;
|
||||
uint cullMask = 0xff;
|
||||
float tmin = 0.001;
|
||||
float tmax = 10000.0;
|
||||
|
||||
traceNV(topLevelAS, rayFlags, cullMask, 0, 0, 0, origin.xyz, tmin, direction.xyz, tmax, 0);
|
||||
traceRayEXT(topLevelAS, rayFlags, cullMask, 0, 0, 0, origin.xyz, tmin, direction.xyz, tmax, 0);
|
||||
|
||||
imageStore(image, ivec2(gl_LaunchIDNV.xy), vec4(hitValue, 0.0));
|
||||
imageStore(image, ivec2(gl_LaunchIDEXT.xy), vec4(hitValue, 0.0));
|
||||
}
|
||||
Binary file not shown.
9
data/shaders/glsl/raytracingshadows/shadow.rmiss
Normal file
9
data/shaders/glsl/raytracingshadows/shadow.rmiss
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#version 460
|
||||
#extension GL_EXT_ray_tracing : require
|
||||
|
||||
layout(location = 2) rayPayloadInEXT bool shadowed;
|
||||
|
||||
void main()
|
||||
{
|
||||
shadowed = false;
|
||||
}
|
||||
BIN
data/shaders/glsl/raytracingshadows/shadow.rmiss.spv
Normal file
BIN
data/shaders/glsl/raytracingshadows/shadow.rmiss.spv
Normal file
Binary file not shown.
|
|
@ -1,7 +0,0 @@
|
|||
glslangvalidator -V offscreen.vert -o offscreen.vert.spv
|
||||
glslangvalidator -V offscreen.frag -o offscreen.frag.spv
|
||||
glslangvalidator -V quad.vert -o quad.vert.spv
|
||||
glslangvalidator -V quad.frag -o quad.frag.spv
|
||||
glslangvalidator -V scene.vert -o scene.vert.spv
|
||||
glslangvalidator -V scene.frag -o scene.frag.spv
|
||||
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
glslangvalidator -V offscreen.vert -o offscreen.vert.spv
|
||||
glslangvalidator -V offscreen.frag -o offscreen.frag.spv
|
||||
glslangvalidator -V scene.vert -o scene.vert.spv
|
||||
glslangvalidator -V scene.frag -o scene.frag.spv
|
||||
glslangvalidator -V cubemapdisplay.vert -o cubemapdisplay.vert.spv
|
||||
glslangvalidator -V cubemapdisplay.frag -o cubemapdisplay.frag.spv
|
||||
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
glslangvalidator -V sem.vert -o sem.vert.spv
|
||||
glslangvalidator -V sem.frag -o sem.frag.spv
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
glslangvalidator -V terrain.vert -o terrain.vert.spv
|
||||
glslangvalidator -V terrain.frag -o terrain.frag.spv
|
||||
glslangvalidator -V skysphere.vert -o skysphere.vert.spv
|
||||
glslangvalidator -V skysphere.frag -o skysphere.frag.spv
|
||||
glslangvalidator -V terrain.tesc -o terrain.tesc.spv
|
||||
glslangvalidator -V terrain.tese -o terrain.tese.spv
|
||||
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
glslangvalidator -V base.vert -o base.vert.spv
|
||||
glslangvalidator -V base.frag -o base.frag.spv
|
||||
glslangvalidator -V passthrough.tesc -o passthrough.tesc.spv
|
||||
glslangvalidator -V passthrough.tese -o passthrough.tese.spv
|
||||
glslangvalidator -V pntriangles.tesc -o pntriangles.tesc.spv
|
||||
glslangvalidator -V pntriangles.tese -o pntriangles.tese.spv
|
||||
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
glslangvalidator -V texture.vert -o texture.vert.spv
|
||||
glslangvalidator -V texture.frag -o texture.frag.spv
|
||||
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
glslangvalidator -V instancing.vert -o instancing.vert.spv
|
||||
glslangvalidator -V instancing.frag -o instancing.frag.spv
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
glslangvalidator -V logo.vert -o logo.vert.spv
|
||||
glslangvalidator -V logo.frag -o logo.frag.spv
|
||||
|
||||
glslangvalidator -V mesh.vert -o mesh.vert.spv
|
||||
glslangvalidator -V mesh.frag -o mesh.frag.spv
|
||||
|
||||
glslangvalidator -V skybox.vert -o skybox.vert.spv
|
||||
glslangvalidator -V skybox.frag -o skybox.frag.spv
|
||||
Loading…
Add table
Add a link
Reference in a new issue