diff --git a/implicit3-rt/frag-render.glsl b/implicit3-rt/frag-render.glsl index 4887b7b..e7f28bf 100644 --- a/implicit3-rt/frag-render.glsl +++ b/implicit3-rt/frag-render.glsl @@ -7,7 +7,8 @@ out vec4 fragColor; uniform float iSeed; uniform vec2 iResolution; -uniform float iNFrame; +uniform float iSpp; +uniform float sSamples; uniform mat4 transformMatrix; uniform float uScale; @@ -523,6 +524,8 @@ float sampleHeight(float h, vec3 w) { return 0.0; } +#define RANDOM_WALK_DEPTH 8.0 + vec3 ggxSampleNormal(float alpha) { float r1 = randf(), r2 = randf(); float su = 2.0*PI*r2; @@ -552,7 +555,7 @@ vec4 sampleBsdfConductor(Material m, vec3 wi) { float h = 5.*STDEV; float e = 1.; vec3 w0, w = -wi; - for (int r = 0; r < 16; r++) { + for (float r = ZERO; r < RANDOM_WALK_DEPTH; r++) { h = sampleHeight(h, w); if(abs(h) > 5.*STDEV) break; @@ -569,7 +572,7 @@ float evalBsdfConductor(Material m, vec3 wi, vec3 wo) { float e = 1.; vec3 w = -wi; float total = 0.0; - for (int r = 0; r < 16; r++) { + for (float r = ZERO; r < RANDOM_WALK_DEPTH; r++) { h = sampleHeight(h, w); if(abs(h) > 5.*STDEV) break; @@ -598,7 +601,7 @@ vec4 sampleBsdfDielectric(Material m, vec3 wi) { float h = 5.*STDEV; vec3 w = -wi; float transmit = 1.0; - for (int r = 0; r < 16; r++) { + for (float r = ZERO; r < RANDOM_WALK_DEPTH; r++) { h = sampleHeight(h, w*transmit); if(abs(h) > 5.*STDEV) break; @@ -619,7 +622,7 @@ float evalBsdfDielectric(Material m, vec3 wi, vec3 wo) { vec3 w = -wi; float transmit = 1.0; float total = 0.0; - for (int r = 0; r < 16; r++) { + for (float r = ZERO; r < RANDOM_WALK_DEPTH; r++) { h = sampleHeight(h, w*transmit); if(abs(h) > 5.*STDEV) break; @@ -1264,11 +1267,24 @@ void main(void) { vec4 totcol = vec4(0); totcol = texelFetch(accumBuffer, ivec2(gl_FragCoord.xy), 0); - for (float fi=ZERO; fi sSamples) + continue; + vec2 ro_s = vXy; ro_s += (-1.0+2.0*vec2(randf(), randf())) / iResolution.xy; vec2 ro_sc = worldToScreen(vec3(0)).xy; @@ -1293,7 +1309,7 @@ void main(void) { float u = dot(col, ru), v = dot(col, rv), w = dot(col, rd); totcol = vec4(u, v, w, u*u+v*v); } - else totcol += vec4(col, 1) / iNFrame; + else totcol += vec4(col, 1) / sSamples; } } fragColor = totcol; diff --git a/implicit3-rt/index.html b/implicit3-rt/index.html index f1bbf6f..0d0be70 100644 --- a/implicit3-rt/index.html +++ b/implicit3-rt/index.html @@ -57,7 +57,7 @@ precision  - @@ -67,8 +67,8 @@ spp -
- @@ -78,7 +78,16 @@ path depth  - samples + MIS (beta)