Sign in to follow this  

OpenGL DX lighting question!

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 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 a shot of my engine: Free Image Hosting at 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))]);
                   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();
		    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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this