Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLSL improvements #8

Open
mifi opened this issue Apr 22, 2020 · 1 comment
Open

GLSL improvements #8

mifi opened this issue Apr 22, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@mifi
Copy link
Owner

mifi commented Apr 22, 2020

GL backgrounds:
http://stack.gl/
https://www.shadertoy.com/
http://glslsandbox.com/
vantajs.com
https://www.shadertoy.com/view/XslGRr
https://github.com/willstall/30-days-of-shade
https://github.com/radixzz/awesome-glsl

@mifi mifi added the enhancement New feature or request label Apr 22, 2020
@aisoftllctesting
Copy link

Error in gl = Failed to format compiler error: TypeError: string.split is not a function
Gl Frag file code

void main()
{	
  gl_Position = ftransform();		
  gl_TexCoord[0] = gl_MultiTexCoord0;
}


// Scene buffer
uniform sampler2D tex0; 

// Currently not used in this demo!
uniform float time; 

// GeeXLab built-in uniform, width of
// the current render target
uniform float rt_w; 
// GeeXLab built-in uniform, height of
// the current render target
uniform float rt_h; 

// Swirl effect parameters
uniform float radius = 200.0;
uniform float angle = 0.8;
uniform vec2 center = vec2(400.0, 300.0);

vec4 PostFX(sampler2D tex, vec2 uv, float time)
{
  vec2 texSize = vec2(rt_w, rt_h);
  vec2 tc = uv * texSize;
  tc -= center;
  float dist = length(tc);
  if (dist < radius) 
  {
    float percent = (radius - dist) / radius;
    float theta = percent * percent * angle * 8.0;
    float s = sin(theta);
    float c = cos(theta);
    tc = vec2(dot(tc, vec2(c, -s)), dot(tc, vec2(s, c)));
  }
  tc += center;
  vec3 color = texture2D(tex0, tc / texSize).rgb;
  return vec4(color, 1.0);
}

void main (void)
{
  vec2 uv = gl_TexCoord[0].st;
  gl_FragColor = PostFX(tex0, uv, time);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants