need some help with a simple shader

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By torohaifisch

hello everyone, i coded a little shader to invert screen colors

shader_type canvas_item;

void fragment () {

  vec4 tex= texture(SCREEN_TEXTURE,SCREEN_UV);
  COLOR= vec4(1.0-tex.r,1.0-tex.g,1.0-tex.b,1);

it does work but the problem i am having is that i want to use that shader in 2 different textures, but they seem to conflict with each other as in when they are both visible the second fails to inverse colors in some parts of the screen, but if only 1 is active it works
so idk maybe my coding is wrong (i dont know a lot about shaders).

EDIT: seems like it is related to the position of the nodes in the tree, if the first node using the shader is at the top and the second one at the bottom then the second one wont invert colors of the nodes or anything that is in between.

if anyone could help i would appreciate it.


What happens if you create a completely new shader with the same code on the second one?

Paintbox | 2018-07-17 13:15

yes i did that, created a new texture node and copied the code in a new shader but it doesnt change anything :frowning:

torohaifisch | 2018-07-17 16:53

ist really weird even if you put only one texture with the shader lets say u have:

  1. a panel node
  2. the texture with shader
  3. another panel node

in that order in the tree the shader doesnt take in count the last panel, at least in my case the last panel mirrors the screen view, but if i move the texture node to the bottom it works properly.

i think this screencap explains better Imgur: The magic of the Internet

torohaifisch | 2018-07-17 17:11