DGL
https://delphigl.com/forum/

Ripples
https://delphigl.com/forum/viewtopic.php?f=19&t=3103
Seite 1 von 1

Autor:  Stucuk [ Fr Jul 30, 2004 17:18 ]
Betreff des Beitrags:  Ripples

I tryed to implement the ripple effect from Vereshagin Roman Vladimirovich's Q3 BSP Loader, eventualy i got it working, but there is a odd sideeffect from the blending. Fig 1 shows how it should look(strangly it works fine when looking at it from one direction) and Fig 2 shows the screwup. If im correct 2 parts of the "water" are being added together to make a less transparent area. My question is does anyone know a way to stop this. (without resorting to no transparency).

Render Code:
Code:
  1.  
  2.   glColor4f(1, 1, 1,1);
  3.   glEnable(GL_BLEND);
  4.   glBlendFunc(GL_SRC_COLOR, GL_ONE);
  5. //  glDepthMask(false);
  6.   glActiveTextureARB(GL_TEXTURE0_ARB);
  7. {  glEnable(GL_TEXTURE_GEN_S);
  8.   glEnable(GL_TEXTURE_GEN_T);}
  9.   glEnable(GL_TEXTURE_2D);                // Turn on texture mapping and bind the face's texture map
  10.   glBindTexture(GL_TEXTURE_2D, 4{WaterTexture});
  11.  
  12.   glActiveTextureARB(GL_TEXTURE1_ARB);
  13.   glEnable(GL_TEXTURE_2D);
  14.   glBindTexture(GL_TEXTURE_2D, 0);
  15.   For J :=0 to GridSize-1 do
  16.   begin
  17.     glBegin(GL_QUAD_STRIP);
  18.       for I :=0 to GridSize do
  19.       begin
  20.         glNormal3fv(@RealWater[NWater].Normals[I, J+1]);
  21.         glTexCoord2f((I/GridSize), ((J+1)/GridSize));
  22.         glVertex3fv(@RealWater[NWater].Vertex[I, J+1]);
  23.         glNormal3fv(@RealWater[NWater].Normals[I, J]);
  24.         glTexCoord2f((I/GridSize), (J/GridSize));
  25.         glVertex3fv(@RealWater[NWater].Vertex[I, J]);
  26.       end;
  27.     glEnd;
  28.   end;
  29.  // RealWater[NWater].ElapsedTime2 := ElapsedTime;
  30.  
  31.   glColor4f(1, 1, 1, 1);
  32.   glDisable(GL_BLEND);
  33. //  glDepthMask(true);
  34.   glActiveTextureARB(GL_TEXTURE0_ARB);
  35. {  glDisable(GL_TEXTURE_GEN_S);
  36.   glDisable(GL_TEXTURE_GEN_T);  }
  37.  


Dateianhänge:
Dateikommentar: Fig2
Ripples2.jpg [126.69 KiB]
57-mal heruntergeladen
Dateikommentar: Fig1
Ripples1.jpg [131.52 KiB]
57-mal heruntergeladen

Autor:  Stucuk [ Fr Jul 30, 2004 20:07 ]
Betreff des Beitrags: 

Iv managed to make it so particles can create ripples on the water, but i still can't figure out a solution to the blending bug.

Dateianhänge:
Ripples3.jpg [164.2 KiB]
48-mal heruntergeladen

Autor:  Stucuk [ Sa Jul 31, 2004 01:12 ]
Betreff des Beitrags: 

Well i "fixed" it, rearly its more of a "trick".

Code:
  1.  
  2.   glDisable(GL_CULL_FACE);
  3.   glEnable(GL_ALPHA_TEST);
  4.   glEnable(GL_BLEND);
  5.   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  6.   glColor4f(1, 1, 1, 0.9);
  7.   glActiveTextureARB(GL_TEXTURE0_ARB);
  8.  
  9.   glEnable(GL_TEXTURE_2D);                // Turn on texture mapping and bind the face's texture map
  10.   glBindTexture(GL_TEXTURE_2D, 6{WaterTexture});
  11.  
  12.   glActiveTextureARB(GL_TEXTURE1_ARB);
  13.   glEnable(GL_TEXTURE_2D);
  14.   glBindTexture(GL_TEXTURE_2D, 0);
  15.   For J :=0 to GridSize-1 do
  16.   begin
  17.     glBegin(GL_QUAD_STRIP);
  18.       for I :=0 to GridSize do
  19.       begin
  20.         glNormal3fv(@RealWater[NWater].Normals[I, J+1]);
  21.         glTexCoord2f((I/GridSize), ((J+1)/GridSize));
  22.         glVertex3fv(@RealWater[NWater].Vertex[I, J+1]);
  23.         glNormal3fv(@RealWater[NWater].Normals[I, J]);
  24.         glTexCoord2f((I/GridSize), (J/GridSize));
  25.         glVertex3fv(@RealWater[NWater].Vertex[I, J]);
  26.       end;
  27.     glEnd;
  28.   end;
  29.  
  30.   glColor4f(1, 1, 1, 1);
  31.   glDisable(GL_BLEND);
  32.   glActiveTextureARB(GL_TEXTURE0_ARB);
  33.  


With blend set to Alpha the colours alpha comes into effect. With a value of 0.9 there is no noticable "addition" between transparent parts of the water(because its hardly transparent but transparent enough to see objects through it)

Autor:  Sascha Willems [ Sa Jul 31, 2004 09:53 ]
Betreff des Beitrags: 

You said that two parts of the water are drawn over each other. If that's the case, can't you use multitexturing? That would eliminate all the problems that occure if you use blending and multipass.

Autor:  Stucuk [ Sa Jul 31, 2004 10:39 ]
Betreff des Beitrags: 

well 2 parts arn't drawn exactly over each other but sometimes depending on view parts become under other parts depth wise(due to ripples) and blending seems to make the parts colour "add" when the alpha is low.

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/