Skip to content

Commit c81435c

Browse files
begin the final march towards raygen and throughput
1 parent 21a256a commit c81435c

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

examples_tests/22.RaytracedAO/raygen.comp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ vec3 nbl_glsl_MC_getNormalizedWorldSpaceV()
2424
{
2525
return normalizedV;
2626
}
27-
vec3 normalizedN; // TODO
27+
vec3 normalizedN;
2828
vec3 nbl_glsl_MC_getNormalizedWorldSpaceN()
2929
{
3030
return normalizedN;
@@ -94,8 +94,8 @@ struct SamplingData_t
9494
bool gen_sample_ray(out float maxT, out vec3 direction, out vec3 throughput, in SamplingData_t samplingData)
9595
{
9696
maxT = FLT_MAX;
97-
direction = -nbl_glsl_MC_getNormalizedWorldSpaceV();
98-
throughput = vec3(1.0);
97+
direction = nbl_glsl_MC_getNormalizedWorldSpaceN();
98+
throughput = vec3(1.0)/float(staticViewData.samplesPerPixelPerDispatch);
9999
return true;
100100
}
101101

@@ -201,12 +201,10 @@ void main()
201201
const uint realOutputID = outputID+i;
202202
if (validRay)
203203
{
204-
throughput.rgb /= float(staticViewData.samplesPerPixelPerDispatch);
205-
206-
const float tt = 1.0/1024.0;
207-
rays[realOutputID].origin = worldPosition+nbl_glsl_MC_getNormalizedWorldSpaceV()*tt;//-direction*0.5*maxT;/*+newray.direction*err?; TODO */
208-
rays[realOutputID].maxT = tt*2.0;
209-
rays[realOutputID].direction = -nbl_glsl_MC_getNormalizedWorldSpaceV();
204+
const float err = 1.0/512.0;
205+
rays[realOutputID].origin = worldPosition+direction*err;
206+
rays[realOutputID].maxT = max(maxT-err,0.0);
207+
rays[realOutputID].direction = direction;
210208
rays[realOutputID].mask = -1;
211209
rays[realOutputID]._active = 1;
212210
rays[realOutputID].backfaceCulling = int(packHalf2x16(throughput.ab));

examples_tests/22.RaytracedAO/resolve.comp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#version 430 core
22
#include "raytraceCommon.glsl"
33

4+
#include <nbl/builtin/glsl/ext/MitsubaLoader/instance_data_descriptor.glsl>
45

56
#include <nbl/builtin/glsl/ext/RadeonRays/intersection.glsl>
67
layout(set = 2, binding = 0, std430) restrict buffer Queries
@@ -20,7 +21,7 @@ void main()
2021

2122
vec3 color = vec3(0.0);
2223
uvec2 groupLocation = gl_WorkGroupID.xy*gl_WorkGroupSize.xy;
23-
for (uint i=0u; i<1u/*staticViewData.samplesPerPixelPerDispatch*/; i++)
24+
for (uint i=0u; i<staticViewData.samplesPerPixelPerDispatch; i++)
2425
{
2526
const uint rayID = baseID+i;
2627
nbl_glsl_ext_RadeonRays_Intersection hit = hits[rayID];
@@ -29,8 +30,12 @@ void main()
2930
if (hit.shapeid<0)
3031
continue;
3132

32-
color.r -= float(hit.shapeid);//staticViewData.samplesPerPixelPerDispatch;
33-
color.g -= float(hit.primid);//staticViewData.samplesPerPixelPerDispatch;
33+
// TODO: fetch from ray buffer
34+
const float thoughput = 1.0/7.0;
35+
36+
const bool frontface = true; // TODO: how to determine frontface easily from radeon rays!? barycentrics? ray direction vs. oriented cross product?
37+
nbl_glsl_MC_oriented_material_t material = nbl_glsl_MC_material_data_t_getOriented(InstData.data[hit.shapeid].material,frontface);
38+
color += nbl_glsl_MC_oriented_material_t_getEmissive(material)*thoughput;
3439

3540
// hit buffer needs clearing
3641
hits[rayID].shapeid = -1;
@@ -40,8 +45,6 @@ void main()
4045
else
4146
acc += color;
4247
storeAccumulation(acc,pixelCoord);
43-
acc = abs(color);
44-
acc.rg /= vec2(32.0,1023.0);
4548
imageStore(framebuffer,pixelCoord,uvec4(nbl_glsl_encodeRGB10A2(vec4(acc,1.0)),0u,0u,0u));
4649
}
4750
}

0 commit comments

Comments
 (0)