Advertisement
HephepFever

Untitled

Dec 22nd, 2022
531
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. shader_type canvas_item;
  2.  
  3. uniform sampler2D text_left;
  4. uniform vec4 left_color : hint_color;
  5.  
  6. uniform sampler2D text_right;
  7. uniform vec4 right_color : hint_color;
  8.  
  9. bool approx_eq(vec4 c1, vec4 c2) { return all( lessThan( abs( c1 - c2 ), vec4( 0.001, 0.001, 0.001, 0.001) ) ); }
  10.  
  11. void fragment(){
  12.     vec4 color2;
  13.    
  14.     vec4 color = texture(TEXTURE, UV);
  15.    
  16.     COLOR = texture(TEXTURE, UV); //read from texture
  17.    
  18.    
  19.    
  20.     if (approx_eq(color, right_color))
  21.     {
  22.         color2 = texture(text_right, UV);
  23.         COLOR = color2;
  24.     }
  25.  
  26.     else if (approx_eq(color, left_color))
  27.     {
  28.         color2 = texture(text_left, UV);
  29.         COLOR = color2;
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement