Comments (3)
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:
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.
Thanks a lot, Erich! Works very impressive :)
from three.js-pathtracing-renderer.
Also sometimes i see this warn in the console
from three.js-pathtracing-renderer.
Related Issues (20)
- muti material not supported
- WebGPU port HOT 3
- More abstractions HOT 9
- Using more information from earlier samples HOT 3
- More samples per frame option HOT 63
- More compatibility with three js APIs HOT 2
- Just wondering how you handled something HOT 14
- Blue noise HOT 8
- GLTF viewer textures HOT 3
- sampler2D array HOT 14
- How to use this pathtracer in Freeciv 3D version? HOT 2
- [question] how to debug glsl in chrome? HOT 2
- GLTF_Model_Viewer didn't get the right result? HOT 6
- How to incorporate it into project? HOT 9
- statistical tool: bootstrapping
- Shadow Catcher HOT 1
- Support for a THREE.ParametricGeometry HOT 1
- GLTF_Viewer is not able to load textures HOT 1
- image stretched for BHV point light source HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from three.js-pathtracing-renderer.