Jump to content

[Solved] Filter "Godrays" which does not darken the background


Artfaith
 Share

Recommended Posts

Dear Community,

 

Thank you very much for the magnificent project!

 

Currently, I am trying to create a filter which is based on a shader ""Godrays" by alaingalvan", but the one which only lightens a certain area where "lights" exist on a transparent stage.

The current version creates dark places ('0x000000') where the "lights" are not shown, but the darkness must not surpass the background ('0x333333' or '0xffffff' as in CSS), so it would look like a transparent filter in the result. This is the incorrect behavior since it creates black background where the "lights" are (it is correct that it affects the background):

Screenshot_20230116_185408.png.94c2d3efc83c21846a445d62b1095a3b.png ~ Screenshot_20230116_185245.png.fafcfb26c2c01723b61078044f7f7448.png

 

Is it even possible using this filter/shader? Is it correct that the issue is in the color matrix ("float noise(in vec3 p)")?

Would it be correct to somehow base a pixel color on the source and only increase its "gain" instead?

 

I will highly appreciate any suggestion!

 

Best and kind regards

Edited by Artfaith
Marked "Solved"
Link to comment
Share on other sites

The issue was in the alpha channel! How did I miss...

Got the answer at StackOverflow by Eduardo Páez Rubio and am so grateful!

 

The line 153 must be changed from:

vec4 mist = vec4(noise, noise, noise, 1.0);
noise = mix(noise, 0.0, 0.3);

to:

noise = mix(noise, 0.0, 0.3);
vec4 mist = vec4(noise, noise, noise, noise);

 

Also, the line seems must be swapped with 154.

The working example: https://codepen.io/faither/pen/oNMqBab

Edited by Artfaith
Link to comment
Share on other sites

  • Artfaith changed the title to [Solved] Filter "Godrays" which does not darken the background

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...