Skip to content

Commit

Permalink
fix(cloud-picture): fix glsl
Browse files Browse the repository at this point in the history
  • Loading branch information
yyc-git committed Sep 15, 2020
1 parent eb74b19 commit 540c991
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#extension GL_EXT_ray_tracing : enable
#extension GL_EXT_nonuniform_qualifier : enable
#extension GL_GOOGLE_include_directive : enable
#extension GL_EXT_scalar_block_layout : enable
#pragma shader_stage(closest)

#include "define.glsl"
Expand Down Expand Up @@ -40,7 +41,7 @@ void main() {
vec3 radiance = vec3(0.0);
vec3 throughput = prd.throughput;

vec3 seed = prd.seed;
uint seed = prd.seed;

HitShadingData data = getHitShadingData(gl_InstanceID, gl_PrimitiveID);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,32 @@
#pragma shader_stage(raygen)

#include "../common/camera.glsl"
#include "random.glsl"
#include "raycommon.glsl"

layout(location = 0) rayPayloadEXT hitPayload prd;

layout(set = 0, binding = 0) uniform accelerationStructureEXT topLevelAS;
layout(std140, set = 0, binding = 1) buffer PixelBuffer { vec4 pixels[]; }
pixelBuffer;

layout(std140, set = 0, binding = 2) uniform CommonData {
layout(std140, set = 0, binding = 2) uniform CommonData {
uint sampleCount;
uint totalSampleCount;
uint pad_0;
uint pad_1;
}
}
pushC;

void main() {
const ivec2 ipos = ivec2(gl_LaunchIDEXT.xy);
const ivec2 resolution = ivec2(gl_LaunchSizeEXT.xy);


const uint sampleCount = pushC.sampleCount;
const uint totalSampleCount = pushC.totalSampleCount;

const uint bounceCount = 3;



prd.seed = tea(tea(ipos.x, ipos.y), totalSampleCount);

const uint cullMask = 0xFF;
Expand All @@ -42,23 +41,25 @@ void main() {
const vec2 pixel = vec2(ipos.x + rnd(prd.seed), ipos.y + rnd(prd.seed));
const vec2 uv = (pixel / gl_LaunchSizeEXT.xy) * 2.0 - 1.0;


vec4 origin = uCamera.viewInverse * vec4(offset, 0, 1);
vec4 target = uCamera.projectionInverse * (vec4(uv.x, uv.y, 1, 1));
vec4 direction = uCamera.viewInverse * vec4(normalize(target.xyz * 1.0 - vec3(offset, 0)), 0);
vec4 direction = uCamera.viewInverse *
vec4(normalize(target.xyz * 1.0 - vec3(offset, 0)), 0);

vec3 radiance = vec3(0.0);
prd.throughput = vec3(1.0);

for (uint bb = 0; bb < bounceCount; ++bb) {
traceRayEXT(topLevelAS, gl_RayFlagsOpaqueEXT, cullMask, 0, 0, 0, origin.xyz, uCamera.near, direction.xyz, uCamera.far, 0);
traceRayEXT(topLevelAS, gl_RayFlagsOpaqueEXT, cullMask, 0, 0, 0,
origin.xyz, uCamera.near, direction.xyz, uCamera.far, 0);

radiance += prd.radiance;

// abort if the ray is either invalid or didn't hit anything
const float t = prd.t;
// if (t < 0.0 || prd.scatterDirection.w <= 0.0) break;
if (t < 0.0) break;
if (t < 0.0)
break;

// move the ray based on the bsdf direction
origin = origin + t * direction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
layout(location = 0) rayPayloadInEXT hitPayload prd;

void main() {
prd.throughput = vec3(0);
prd.throughput = vec3(0);
prd.radiance = vec3(0.15);
prd.t = -1.0;
}
}

0 comments on commit 540c991

Please sign in to comment.