displacement

displacement

Shader code
shader_type canvas_item;

uniform float zoom = 300;
uniform bool pDir = false;
uniform bool noWrap = true;


void fragment() {
  float fB;
  float fC;


  vec2 posTex;
  vec4 color = vec4(0.0, 0.0, 0.0, 1.0);
  vec2 uv = SCREEN_UV;
vec2 fPixel = SCREEN_PIXEL_SIZE;

  if(pDir == false){
    fB = 1.0 - (zoom * fPixel.y);
	
    fC = max(0.02, 1.0 + (fB - 1.0) * 4.0 * pow((uv.x - 0.5), 2.0));
    
    posTex = uv * vec2(1.0, fC) + vec2(0.0, (1.0 - fC) / 2.0);
    
    if(noWrap == false || (posTex.y >= 0.0 && posTex.y <= 1.0)){
      COLOR.rgb = textureLod(SCREEN_TEXTURE, posTex, 0.0).rgb;
    }
  } else {
    fB = 1.0 - (zoom * fPixel.x);
    fC = max(0.05, 1.0 + (fB - 1.0) * 4.0 * pow((uv.y - 0.5), 2.0));
    
    posTex = uv * vec2(fC, 1.0) + vec2((1.0 - fC) / 2.0, 0.0);
    
    if(noWrap == false || (posTex.x >= 0.0 && posTex.x <= 1.0)){
      COLOR.rgb = textureLod(SCREEN_TEXTURE, posTex, 0.0).rgb;
    }
  }
}
This shader is a port from an existing Shadertoy project. Shadertoy shaders are by default protected under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) license unless anything else has been stated by the author. For more info, see our License terms.

More from Eeeeeeeee

Jolly 2 OFFICE DISPLACEMENT effect

Jolly 1 office with displacement effect

Related shaders

FNAF Faked 3D Displacement Shader

Jolly 1 office with displacement effect

Jolly 2 OFFICE DISPLACEMENT effect

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments