Interested in 2 effects made on shaders, blur and glow.
Which can be simply connected to the material.
const material = new THREE.ShaderMaterial({
fragmentShader,
vertexShader,
uniforms: {
time: { value: 0}
},
});
Maybe it will be some kind of libraries.
Tried using this repository.
but when compiling, it gives errors that this code is written under 2.0 and under 3.0 it does not fit.
Both blur and glow can usually only be applied in postprocessing, not per material, since they require the shader to be aware of the entire scene (unless you’d like these effects to appear on a 2D texture applied to an object. But that’ll look kinda flat and fake.)
Postprocessing already in use. But he is not selective, but layered.
So if I just assign a layer to certain objects, it will disappear from view behind other objects.
Therefore, need a shader.
As far as my expansive knowledge of computer graphics goes - it is once again not possible with just a material shader Fragment shader applied to a material cannot affect fragments / “pixels” that do not belong to that surface:
Shader applied to each cube as a ShaderMaterial can only define color of the specific cube (ex. red cube shader cannot affect color of blue / yellow / green cubes around. Which glow / blur would require.)
What you need is still - postprocessing. And, if you want be glow / blur to be selective - you will need at least 2 postprocessing passes. The general idea (for any kind of complex screen-space magic) is:
First Pass: render your scene to an invisible texture, in this pass render the objects you want to glow / be blurred in some colour, and everything else in another colour. Like this:
Second Pass: render the scene as you would usually with lighting / shadows / proper materials. Then use the texture from first pass to blur the fragments / “pixels” that were highlighted in the first pass:
if postprocessing it works on shaders, then it does it like that. And in the example of the repository, it seems to be written in the same way, sorry it’s just outdated.