Add glow effect on line of my shader

Hello,

This is my first post on the forum so I hope it will be well done.
I made this shader material to have this yellow selection area but it should have a glow effect. However I can’t do it and I think that maybe one of you has already done it?

Thanks a lot for your help!

let m = new THREE.MeshStandardMaterial({
    map: diffuse,
    displacementMap: height,
    normalMap: normal,
    roughnessMap: roughness,
    aoMap: ao_map,
    displacementScale: 5,
    emissive:new THREE.Color('#FF4500'),
    emissiveMap: em_map,
    emissiveIntensity: 3.5,
    envMap: hdrEquirect,
    envMapIntensity : 4,
onBeforeCompile: shader => {
  	shader.uniforms.rectSize = uniforms.rectSize;
    shader.uniforms.rectWidth = uniforms.rectWidth;
    shader.uniforms.center = uniforms.center;
    shader.vertexShader = `
    	varying vec2 vPos;
      ${shader.vertexShader}
    `.replace(
    	`#include <fog_vertex>`,
      `#include <fog_vertex>
      	vPos = position.xz;
      `
    );
    shader.fragmentShader = `
      #define ss(a, b, c) smoothstep(a, b, c)
      uniform vec3 center;
      uniform vec2 rectSize;
      uniform float rectWidth;
	    varying vec2 vPos;
      ${shader.fragmentShader}
    `.replace(
      `#include <dithering_fragment>`,
      `#include <dithering_fragment>
      	
       	vec2 hSize = rectSize * 0.5;
        vec2 rPos = abs( vPos - center.xz ) - hSize;
        
        float rect = float(abs(max(rPos.x,rPos.y)) < rectWidth * 0.5);
        
        gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.93, 0.69, 0.22), rect * 0.5);
      
      `
    );
  }
});

The reseult :
Capture d’écran du 2022-02-09 17-06-47

Hi!
Have you tried bloom effect? three.js examples

Hi,
Thanks for your reply.
Yes I have applied this effect but he glow all the texture …
That why I think I have to apply a glow directly on the shader no ?

Would be great to see the result of what you’ve tried. Any link?

With a minor tweaking, bloom works okay.
BloomSimple_opt

1 Like

That’s amazing !
I will try with your solution tomorrow!
Thanks a lot, I will come back to you tomorrow.

Hello,
I try to apply the bloom on my shader but I get a red screen. I have to create a new material with the shader and the effect ?

You need to apply that unreal bloom effect to your scene, looking into the source code of the example.


I get this result, the effect is applied to the whole scene, right?

Only you know the setup of your scene :slight_smile: Tonemapping, intensity of light(s), type of material on your mesh and many other things.

Yes, I’m an idiot… it’s OK, it works! You are really good! Is it possible to keep the transparency of the background with composer render ?

Nice it’s work well ! Thanks a lot !
image
For the transparent background I saw that it was a bug being fixed I think no ?

My option: JSFiddle
Combination of this, this and this

@Corentin_motc About background transparency, try this solution: Shader to turns black into transparency. Bloompass - #2 by jscastro76

Oh yes it’s true that the glow is much better managed on yours ! Thank you very much! It’s great to have some advice from you!

I had a question! Is it possible to put a shader on a material that is transparent?That is to say that we could have this luminescent square on a transparent plane and underneath another object that we would see through the transparent plane. I don’t know if I’m making myself clear…

Sorry, I didn’t get what you mean. Any explanatory picture at least?

There is the result !


Here is a diagram to illustrate my point

Maybe makes sense to create a semitransparent flat frame, instead of drawing a rectangle on a plane?

Yes, it’s true, I thought about it but my problem is to make this semi-transparent plane take the shape of my land. It has to take the displacement map of the plane above.

With r136 it (kind of) works: Edit fiddle - JSFiddle - Code Playground