bg.shader 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. shader_type canvas_item;
  2. render_mode blend_disabled;
  3. uniform float iTime;
  4. uniform int iFrame;
  5. uniform sampler2D iChannel0;
  6. uniform sampler2D iChannel1:hint_albedo;
  7. uniform sampler2D iChannel2:hint_albedo;
  8. uniform sampler2D iChannel3:hint_albedo;
  9. uniform vec2 l_res;
  10. uniform bool render;
  11. uniform bool render2;
  12. uniform bool render3;
  13. void mainImage( out vec4 fragColor, in vec2 fragCoord, in vec2 iResolution) {
  14. vec2 res = iResolution.xy / iResolution.y;
  15. float dv=l_res.y;
  16. if(res.x<l_res.x/l_res.y)dv=l_res.x;
  17. vec2 res2 = l_res/dv-(l_res/dv)/2.;
  18. if(res.x<l_res.x/l_res.y)res2*=res.x;
  19. vec2 uv = (fragCoord.xy) / iResolution.y - res/2.0;
  20. vec3 col=vec3(0.);
  21. if(!render3)
  22. col=texture(iChannel0,uv).rgb;
  23. else col=vec3(1.);
  24. col*=step(abs(uv.x),res2.x)*step(abs(uv.y),res2.y);
  25. if(!render){
  26. if(render2)
  27. col=mix(col*=0.95,clamp(texture(iChannel3,((fragCoord.xy) / iResolution.xy)).rgb,vec3(0.),vec3(1.)),dot(col,vec3(1.))/3.);
  28. else
  29. col=mix(col*=0.95,clamp(texture(iChannel1,((fragCoord.xy) / iResolution.xy)).rgb,vec3(0.),vec3(1.)),dot(col,vec3(1.))/3.);
  30. }
  31. else
  32. {
  33. col=mix(col*=0.95,clamp(texture(iChannel2,((fragCoord.xy) / iResolution.xy)).rgb,vec3(0.),vec3(1.)),dot(col,vec3(1.))/3.);
  34. }
  35. fragColor = vec4(col,1.);
  36. }
  37. void fragment(){
  38. vec2 iResolution=1./TEXTURE_PIXEL_SIZE;
  39. mainImage(COLOR,UV*iResolution,iResolution);
  40. }