Greetings to all who are taking the time to read this message;
I've embarked on a journey to create a model of the Solar System using three.js. My goal is to simulate the Sun with a volumetric light effect similar to the one demonstrated here. However, since the tutorial utilizes an older version of three.js, I'm in the process of adapting the code to the latest edition.
The concept is rather straightforward:
- Set up two scenes within the same environment – one containing the volumetric light and a completely black object in orbit, and the other housing the object with the appropriate material
- Implement the volumetric light shading on the concealed layer
- Apply an additive blending shader on the top layer, utilizing the texture generated from rendering the hidden layer
I have successfully configured the two scenes as intended. However, here's the outcome:
import { RenderPass } from 'https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="087c607a6d6d483826393a3f2638">[email protected]</a>/examples/jsm/postprocessing/RenderPass.js';
import { ShaderPass } from 'https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="daaeb2a8bfbf9aeaf4ebe8edf4ea">[email protected]</a>/examples/jsm/postprocessing/ShaderPass.js';
import { EffectComposer } from 'https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2d59455f48486d1d031c1f1a031d">[email protected]</a>/examples/jsm/postprocessing/EffectComposer.js';
THREE.VolumetericLightShader = {
// Uniforms and shaders
};
THREE.AdditiveBlendingShader = {
// Uniforms and shaders
};
// RENDERER and scene setup
// Camera, lights, and geometries
function animate() {
requestAnimationFrame(animate);
render();
};
function render() {
// ... camera and light adjustments
// Modification positions and rendering steps
// Final rendering
}
animate();
Currently, there seems to be an issue where the texture utilized by the additive blending shader does not acknowledge the post-processing volumetric light effect. Interestingly, when I separately render the two layers by commenting out either the
oclcomposer.render()
or
composer.render()
at the end of the script, the effect renders correctly:
Rendered Hidden Layer (commenting composer.render())
Rendered Default Layer (commenting oclcomposer.render())
I'm facing challenges in troubleshooting this issue, mainly due to my limited expertise in 3D programming. Initially, I had hoped for a seamless integration of the shader to achieve the desired effect. Now, I seek to comprehend why the volumetric shader does not seem to impact the additive blending. Any assistance or insights would be greatly appreciated.