Closed monkeykim111 closed 1 year ago
@monkeykim111 thank you for the code example! It looks like the issue is in my code, in this line:
This hard-codes the alpha of all pixels drawn to 1.
What we want instead is to draw with alpha = 1 in pixels where there is an outline, and alpha = 0 in pixels where there is no outline. This information is encoded in the outline
variable. So to fix this, change this line to:
gl_FragColor = vec4(vec3(outline * outlineColor), outline);
If you wanted the outline itself to be drawn with a specific alpha, you would do it like this:
float outlineAlpha = 0.25;
gl_FragColor = vec4(vec3(outline * outlineColor), outline * outlineAlpha);
Here's a diff of changes I made to your repo to confirm this working, including adding a background on the HTML page to confirm it is visible: diff.txt
Thank you very much! the problem is easily solved and the result is great. I was struggling with three js for the first time in my life. Your projects and kindness have helped me a lot. happy new year and have a nice day :)
Hello sir! I need a transparent background, not a black background in
Outline only
. I want the output to look like the picture below.For
Outlines V2
As in the code above, if alpha: true is given, a transparent background is output. like this picture.![outlines V2](https://user-images.githubusercontent.com/82593754/212608393-2e26b18e-af22-494b-ba27-753a0687664b.png)
However, in![image](https://user-images.githubusercontent.com/82593754/212608772-9e4ac444-63d1-4d19-9f76-563e848157ea.png)
Outline only
, no matter what I do, I cannot output a transparent background. like this picture.This is my forked repo. https://github.com/monkeykim111/webgl-outlines I used three js minimal version and changed gl_FragColor for
outline only
and ran several tests for transparent background here.And these are the sites I referenced. https://stackoverflow.com/questions/20899326/how-do-i-stop-effectcomposer-from-destroying-my-transparent-background
https://discourse.threejs.org/t/effect-composer-keep-transparency/4447
https://discourse.threejs.org/t/transparent-background/22742/3
please help thank you!!