Fixing many links issues.

Corrected shaders
This commit is contained in:
mklefrancois 2020-03-31 18:35:37 +02:00
parent b6402f0c09
commit 95912b873b
32 changed files with 135 additions and 123 deletions

View file

@ -96,7 +96,7 @@ In `raytrace.rgen`, at the beginning of `main()`, initialize the random seed:
~~~~ C++
// Initialize the random number
uint seed = tea(gl_LaunchIDNV.y * gl_LaunchSizeNV.x + gl_LaunchIDNV.x, pushC.frame);
uint seed = tea(gl_LaunchIDEXT.y * gl_LaunchSizeEXT.x + gl_LaunchIDEXT.x, pushC.frame);
~~~~
Then we need two random numbers to vary the X and Y inside the pixel, except for frame 0, where we always shoot
@ -113,7 +113,7 @@ vec2 subpixel_jitter = pushC.frame == 0 ? vec2(0.5f, 0.5f) : vec2(r1, r2);
Now we only need to change how we compute the pixel center:
~~~~ C++
const vec2 pixelCenter = vec2(gl_LaunchIDNV.xy) + subpixel_jitter;
const vec2 pixelCenter = vec2(gl_LaunchIDEXT.xy) + subpixel_jitter;
~~~~
## Storing or Updating
@ -126,13 +126,13 @@ Otherwise, we combine the new image with the previous `frame` frames.
if(pushC.frame > 0)
{
float a = 1.0f / float(pushC.frame + 1);
vec3 old_color = imageLoad(image, ivec2(gl_LaunchIDNV.xy)).xyz;
imageStore(image, ivec2(gl_LaunchIDNV.xy), vec4(mix(old_color, prd.hitValue, a), 1.f));
vec3 old_color = imageLoad(image, ivec2(gl_LaunchIDEXT.xy)).xyz;
imageStore(image, ivec2(gl_LaunchIDEXT.xy), vec4(mix(old_color, prd.hitValue, a), 1.f));
}
else
{
// First frame, replace the value in the buffer
imageStore(image, ivec2(gl_LaunchIDNV.xy), vec4(prd.hitValue, 1.f));
imageStore(image, ivec2(gl_LaunchIDEXT.xy), vec4(prd.hitValue, 1.f));
}
~~~~
@ -263,7 +263,7 @@ To do this, add a constant to `raytrace.rgen` (this could alternatively be added
const int NBSAMPLES = 10;
~~~~
In `main()`, after initializing the random number seed, create a loop that encloses the lines from the generation of `r1` and `r2` to the `traceNV` call, and accumulates the colors returned by `traceNV`. At the end of the loop, divide by the number of samples that were taken.
In `main()`, after initializing the random number seed, create a loop that encloses the lines from the generation of `r1` and `r2` to the `traceRayEXT` call, and accumulates the colors returned by `traceRayEXT`. At the end of the loop, divide by the number of samples that were taken.
~~~~ C++
vec3 hitValues = vec3(0);
@ -273,7 +273,7 @@ In `main()`, after initializing the random number seed, create a loop that enclo
float r1 = rnd(seed);
float r2 = rnd(seed);
// ...
// TraceNV( ... );
// TraceRayEXT( ... );
hitValues += prd.hitValue;
}
prd.hitValue = hitValues / NBSAMPLES;