9

Vulkan GLSL Ray Tracing Emulator

 2 years ago
source link: https://www.gsn-lib.org/apps/raytracing/index.php
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Vulkan GLSL Ray Tracing Emulator

Ray Gen. Closest-Hit Miss Intersection Any-Hit Acc. Structure Traversal Hit? No Yes
// gsnShaderOptions: precompiler="GL_EXT_ray_tracing, recursion: 2, app: 1"
// IMPORTANT: do not remove the line above
/**** COMMON START ****/
// In the COMMON section, the structs "RayPayloadType" and "HitAttributeType" must be defined.
// Furthermore, your own helper functions must be defined here (can be called in all shaders).
struct RayPayloadType {
vec3 contribution;
vec3 nextRayOrigin;
vec3 nextRayDirection;
bool shadowRayMiss;
float weight;
}; // type of the "payload" variable
struct HitAttributeType {
vec3 normal;
vec3 texCoord;
}; // type of the "hit" variable
const float PI = 3.14159265359;
// light parameters
const vec3 lightPos = vec3(0.0f, 5.0f, -6.0f);
const vec3 lightColor = vec3(1.0, 1.0, 1.0f);
const float illumiPerp = 20.0;
// camera
const float cameraExposure = 0.05;
// PBR parameters BLAS 0
const float ambientFactor0 = 0.2f;
const vec3 baseCol0 = pow(vec3(1.0000, 0.8980, 0.6196), vec3(2.2));
const vec3 emission0 = pow(vec3(0.0, 0.0, 0.0), vec3(2.2));
const float roughness0 = 0.4;
const float metallic0 = 1.0;
const float reflectance0 = 1.0;
const float whittedReflection0 = 0.5;
// PBR parameters BLAS 1
const float ambientFactor1 = 0.2f;
const vec3 baseCol11 = pow(vec3(0.8, 0.3, 0.15), vec3(2.2));
const vec3 baseCol12 = pow(vec3(0.9, 0.85, 0.05), vec3(2.2));
const vec3 emission1 = pow(vec3(0.0, 0.0, 0.0), vec3(2.2));
const float roughness1 = 1.0;
const float metallic1 = 0.0;
const float reflectance1 = 0.5;
const float whittedReflection1 = 0.0;
vec3 fresnelSchlick(float cosTheta, vec3 F0) {
return F0 + (1.0 - F0) * pow(1.0 - cosTheta, 5.0);

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK