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

[Renderer] Quake style water #317

Closed
hzqst opened this issue Sep 18, 2023 · 4 comments
Closed

[Renderer] Quake style water #317

hzqst opened this issue Sep 18, 2023 · 4 comments

Comments

@hzqst
Copy link
Owner

hzqst commented Sep 18, 2023

	if( RP_NORMALPASS() && ( tr.viewparams.waterlevel >= 3 ))
	{
		RI->fov_x = atan( tan( DEG2RAD( RI->fov_x ) / 2 ) * ( 0.97 + sin( tr.time * 1.5 ) * 0.03 )) * 2 / (M_PI / 180.0);
		RI->fov_y = atan( tan( DEG2RAD( RI->fov_y ) / 2 ) * ( 1.03 - sin( tr.time * 1.5 ) * 0.03 )) * 2 / (M_PI / 180.0);
	}
 unsigned char* ptr = buffer;
 int amp = width/64;
 const int tick = (SDL_GetTicks()/4) & 1023;
 for(int yi = 0; yi < height; yi++, ptr+= width)
 {
  int shift = amp/2 + amp/2*sin((4*yi/(double)height + tick/(double)1024)*2*M_PI);
  memmove(ptr+shift, ptr, width-shift);
 }
 for(int xi = 0; xi < width; xi++)
 {
  int shift = amp/2 + amp/2*sin((4*xi/(double)width + tick/(double)1024)*2*M_PI);
  ptr = buffer + xi + (height-1)*width;
  for(int c = 0; c < height-shift; c++, ptr -= width)
   *ptr = *(ptr-shift*width);
 }
varying vec2 v_texcoord;

uniform float time;

uniform float wave_size;
uniform float wave_amount;
uniform float wave_speed;
uniform float transparency;

void main()
{
	//Wave Effect
    vec2 uv = v_texcoord;
    uv.x += cos(uv.y * wave_amount + time * wave_speed) / wave_size;
    uv.y += sin(uv.x * wave_amount + time * wave_speed) / wave_size;

	gl_FragColor = texture2D(gm_BaseTexture, uv);
	gl_FragColor.a *= transparency;
}

@di57inct
Copy link

Related to #215 ?

@hzqst
Copy link
Owner Author

hzqst commented Sep 18, 2023

Related to #215 ?

Nope

@di57inct
Copy link

Can you explain why that issue is not possible to fix?

@hzqst
Copy link
Owner Author

hzqst commented Sep 25, 2023

Done

@hzqst hzqst closed this as completed Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants