Jump to content
  • Advertisement
Sign in to follow this  
Xavyiy

OpenGL DX lighting question!

This topic is 4269 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all!, I'm programing a liquid dynamic engine for implement to my game, and now I have a little question, I see the plasmapong.com engine and in the new 1.3 version it have a 3d lighting for the shaders, it's on opengl, my engine is over DX9 and C#, how I can obtain this effect? : Free Image Hosting at www.ImageShack.us a shot of my engine: Free Image Hosting at www.ImageShack.us and this is the code for drawing the base dynamic texture:
public void DibujaShaderVelocidad1(Color c)
        {
        	MainClass.device.RenderState.AlphaBlendEnable = true;
		    MainClass.device.VertexFormat = CustomVertex.TransformedColored.Format;
		  
		    CustomVertex.TransformedColored[] tmp = new CustomVertex.TransformedColored[6*N * N*2];
		    
		    int index = 0;
		    
		    int i, j;
            float x, y, h, d00, d01, d10, d11;
		    h = 1.0f/N;
		    for ( i=0 ; i<=N ; i++ )
            {
               x = (i-0.5f)*h;
               for( j=0 ; j<=N ; j++ )
                {
                   y = (j-0.5f)*h;
                  
                   d00 = Math.Abs(800*v[((i)+(N+2)*(j))]);
                   d01 = Math.Abs(800*v[((i)+(N+2)*(j+1))]);
                   d10 = Math.Abs(800*v[((i+1)+(N+2)*(j))]);
                   d11 = Math.Abs(800*v[((i+1)+(N+2)*(j+1))]);
  
                   if(d00>255)d00=255;
                   if(d01>255)d01=255;
                   if(d10>255)d10=255;
                   if(d11>255)d11=255;
        
                   tmp[index+0].X = x*MainClass.Tamano.Width;
                   tmp[index+0].Y = y*MainClass.Tamano.Height;
                   tmp[index+0].Z = 0.0f;
                   tmp[index+0].Rhw = 1.0f;
                   tmp[index+0].Color = Color.FromArgb((int) d00,c.R,c.G,c.B).ToArgb();
            
                   tmp[index+1].X = (x + h)*MainClass.Tamano.Width;
                   tmp[index+1].Y = y*MainClass.Tamano.Height;
                   tmp[index+1].Z = 0.0f;
                   tmp[index+1].Rhw = 1.0f;
                   tmp[index+1].Color = Color.FromArgb((int) d10,c.R,c.G,c.B).ToArgb();
         
                   tmp[index+2].X = x*MainClass.Tamano.Width;
                   tmp[index+2].Y = (y + h)*MainClass.Tamano.Height;
                   tmp[index+2].Z = 0.0f;
                   tmp[index+2].Rhw = 1.0f;
                   tmp[index+2].Color = Color.FromArgb((int) d01,c.R,c.G,c.B).ToArgb();
         
                   tmp[index+3].X = (x + h)*MainClass.Tamano.Width;
                   tmp[index+3].Y = y*MainClass.Tamano.Height;
                   tmp[index+3].Z = 0.0f;
                   tmp[index+3].Rhw = 1.0f;
                   tmp[index+3].Color = Color.FromArgb((int) d10,c.R,c.G,c.B).ToArgb();
      
                   tmp[index+4].X = (x + h)*MainClass.Tamano.Width;
                   tmp[index+4].Y = (y + h)*MainClass.Tamano.Height;
                   tmp[index+4].Z = 0.0f;
                   tmp[index+4].Rhw = 1.0f;
                   tmp[index+4].Color = Color.FromArgb((int) d11,c.R,c.G,c.B).ToArgb();
 
                   tmp[index+5].X = x*MainClass.Tamano.Width;
                   tmp[index+5].Y = (y + h)*MainClass.Tamano.Height;
                   tmp[index+5].Z = 0.0f;
                   tmp[index+5].Rhw = 1.0f;
                   tmp[index+5].Color = Color.FromArgb((int) d01,c.R,c.G,c.B).ToArgb();
         
                   index+=6;
               }
            }
		
		    MainClass.device.DrawUserPrimitives(PrimitiveType.TriangleList,tmp.Length/6+(N*4)+1, tmp);
		    MainClass.device.RenderState.AlphaBlendEnable = true;
        }
for obtain the 3d lighting effect it's only a device.Light[N] configuration? or it's more difficult to do? Thanks to all! and sorry for my little English : )

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!