Skip to content

Commit

Permalink
Add VK_NV_ray_tracing demo
Browse files Browse the repository at this point in the history
  • Loading branch information
httpdigest committed May 26, 2019
1 parent bb6f6f7 commit 475b266
Show file tree
Hide file tree
Showing 10 changed files with 12,318 additions and 17 deletions.
13 changes: 12 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<lwjgl.version>3.2.3-SNAPSHOT</lwjgl.version>
<swt.version>4.6.1</swt.version>
<joml.version>1.9.15-SNAPSHOT</joml.version>
<!-- Can be overwritten via -D property during mvn invoke to specify
<!-- Can be overwritten via -D property during mvn invoke to specify
a different demo. The package "org.lwjgl.demo." is prepended automatically. -->
<class>game.SpaceGame</class>
</properties>
Expand Down Expand Up @@ -247,6 +247,11 @@
<artifactId>lwjgl-shaderc</artifactId>
<version>${lwjgl.version}</version>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-vma</artifactId>
<version>${lwjgl.version}</version>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-glfw</artifactId>
Expand All @@ -271,6 +276,12 @@
<version>${lwjgl.version}</version>
<classifier>natives-${platform}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-vma</artifactId>
<version>${lwjgl.version}</version>
<classifier>natives-${platform}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-assimp</artifactId>
Expand Down
36 changes: 36 additions & 0 deletions res/org/lwjgl/demo/vulkan/closesthit.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright LWJGL. All rights reserved.
* License terms: https://www.lwjgl.org/license
*/
#version 460
#extension GL_NV_ray_tracing : require

layout(location = 0) rayPayloadInNV Payload {
vec3 normal;
float t;
} payload;

hitAttributeNV vec3 attribs;

layout(binding = 0, set = 0) uniform accelerationStructureNV topLevelAS;
layout(binding = 2, set = 0) uniform CameraProperties {
mat4 viewInverse;
mat4 projInverse;
vec4 lightPos;
} cam;
layout(binding = 4, set = 0) buffer Normals { vec4 n[]; } normals;
layout(binding = 5, set = 0) buffer Indices { uint i[]; } indices;

void main() {
ivec3 index = ivec3(
indices.i[3 * gl_PrimitiveID],
indices.i[3 * gl_PrimitiveID + 1],
indices.i[3 * gl_PrimitiveID + 2]
);
vec3 n0 = normals.n[index.x].xyz;
vec3 n1 = normals.n[index.y].xyz;
vec3 n2 = normals.n[index.z].xyz;
vec3 bc = vec3(1.0f - attribs.x - attribs.y, attribs.x, attribs.y);
payload.t = gl_RayTmaxNV;
payload.normal = normalize(n0 * bc.x + n1 * bc.y + n2 * bc.z);
}
Loading

0 comments on commit 475b266

Please sign in to comment.