Giter VIP home page Giter VIP logo

Comments (3)

erichlof avatar erichlof commented on June 8, 2024 4

Hello @vinkovsky !

Yes it is possible to occlude the light and caustics rays that are passing through the volume (of gas, fog, smoke, etc.). The reason why the current demo (as your picture shows) does not block the light is simply because the 4 quads that make up the Cornell box are all single sided quads. I intentionally made them single sided (only visible if you are on the same side as the plane normal) because I kind of liked how the blue caustic light beam went all the way down into the void before tapering off. I just thought it looked kinda cool, but in reality we would never encounter such a magic wall or magic floor.

So all you have to do is find the quad intersect function and change the last boolean parameter from false to true. It should look like this on line 61 of the Volumetric_Rendering_Fragment.glsl file:

d = QuadIntersect( quads[i].v0, quads[i].v1, quads[i].v2, quads[i].v3, rOrigin, rDirection, true );

That last parameter 'true' means make the quad double-sided, as in real life. If it is 'false', then the quad is rendered single-sided and has back face culling (as in traditional rasterized 3d graphics pipelines).

A side note: I had commented out the quads for the floor and the ceiling of the Cornell box and set N_QUADS to 3 (Red left wall, White back wall, and Blue right wall. So if you want to add back the floor and/or the ceiling, you'll have to uncomment those in the 'SetupScene()' function, then make N_QUADS a higher number to match, like 4 or 5.

When I made these small changes, here's how it would look in real life:

BlockedCaustic2

BlockedCaustic

Pretty cool!

Oh, and about the occasional warning, that vec4 belongs to the RGBA Blue Noise texture. I sample that texture repeatedly very fast every animation frame, to produce low-noise random numbers between 0.0-1.0 for use with diffuse surfaces, shadow penumbras, transparency double images (refracted vs reflected), and even the blue hazy fog on this demo. This gives almost imperceptible noise patterns that are much smoother to the eye than mathematically-calculated random numbers in a GLSL shader. However, the cost is that if the RGBA Blue Noise texture is a little late in loading, the vec4 (R,G,B, and A) that needs to sample it to produce the smooth random numbers doesn't have anything to work with for a few seconds. At least, that's what I think is going on - I could be mistaken (GPUs and shaders are notoriously hard to debug).

Hope this helped!
-Erich

from three.js-pathtracing-renderer.

vinkovsky avatar vinkovsky commented on June 8, 2024 1

Thanks a lot, Erich! Works very impressive :)

from three.js-pathtracing-renderer.

vinkovsky avatar vinkovsky commented on June 8, 2024

Also sometimes i see this warn in the console

image

from three.js-pathtracing-renderer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.