tag:blogger.com,1999:blog-5417138872461097808.post2356773038426705195..comments2023-08-13T06:00:11.959-07:00Comments on Tower22: Killing SpreeRickhttp://www.blogger.com/profile/04196340535742326978noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-5417138872461097808.post-14173013161170684252011-03-22T06:21:11.356-07:002011-03-22T06:21:11.356-07:00For proper lighting you do need normals indeed. Ho...For proper lighting you do need normals indeed. However, basic water from the old days often only used a simple ambient color (light position / normal do not matter then). The effect you describe happens when you apply diffuse and/or specular lighting. I would disable diffuse lighting. But if you want specular light from the sun, you do need your normals yes. However, you probably need more than 300 vertices to get a nice specular highlight though (or use per-pixel lighting via a pixelshader).<br /><br />http://www.imagico.de/pov/water/water05_3b.jpg<br />What you see here is (probably) just 1 big flat quad, but with a normalMap to do the normals. You'll need pixelshaders for this though, and using a flat quad doesn't work very well for a wild ocean with waves of course.<br /><br /><br />300 vertices is nothing. Don't worry about that. When doing animations on the CPU ("skinning") you do more complex calculations for thousands of vertices.<br /><br />> Shaders<br />Yep. Or at least if you know the positions of your neighbor vertices. If you compute the "wave formula" inside the vertex-shader, you should be able to figure out the positions of neighbor vertices. Otherwise you can do it the advanced way via geometry shaders, or texture-maps. But that might be a little bit out of the scope for now.<br /><br /><br />My advise:<br />- Program a grid<br />- Look into LOD in case you plan larger water surfaces, or detailed waves<br />- Use ambient lighting<br />- Compute normals and add specular lighting from the sun/moon<br />- If all works well, start on shadersRickhttps://www.blogger.com/profile/04196340535742326978noreply@blogger.comtag:blogger.com,1999:blog-5417138872461097808.post-29286313302828404362011-03-22T03:39:38.436-07:002011-03-22T03:39:38.436-07:00Thanks Rick.
You say that I don't need norma...Thanks Rick. <br /><br />You say that I don't need normals that much, but how will I accomplish waves "curvature" without lighting? If there won't be a light the interpolation between vertexes will not exists and the end user will see the triangles, right?<br /><br />I think I will need like 300 vertices. I know that this is not to much for the modern CPU, yet it feels somewhat wrong to calculate normals at each frame for them...<br /><br />Are you saying that with shaders I can take up a mesh and calculate normals by the GPU?Soul Intruderhttps://www.blogger.com/profile/16873694208138872553noreply@blogger.comtag:blogger.com,1999:blog-5417138872461097808.post-86326491155466413072011-03-22T00:29:56.793-07:002011-03-22T00:29:56.793-07:00Yes and no. A modern CPU can easily do (ten)thousa...Yes and no. A modern CPU can easily do (ten)thousands of such calculations. But if you are trying to render the entire Atlantic Ocean... <br /><br />That's why there is LOD. I suppose you are rendering a grid of quads for your water. You can reduce the gridsize as the distance grows. Thus detailed waves for nearby, just global ripples for a distance, flat huge quads for the far background. I have to admit I never tried LOD on heightfields, but that technique is quite old so there should be plenty of tutorials.<br /><br /><br />Usually shaders are used for these kind of calculations. Because GPU's are a lot faster with vector math. It's not nescesary, but keep it in mind. Another note... maybe you don't need normals that much, unless you want correct specular lighting or more advanced lighting tricks. You probably don't need basic diffuse lighting anyhow.Rickhttps://www.blogger.com/profile/04196340535742326978noreply@blogger.comtag:blogger.com,1999:blog-5417138872461097808.post-45456028374892729462011-03-22T00:16:18.245-07:002011-03-22T00:16:18.245-07:00Rick one more question regarding lighting :)
If I ...Rick one more question regarding lighting :)<br />If I want to do an animated water with a mesh then for each frame I need to recalculate mesh's vertices normals? I am afraid that this takes a lot of CPU time...Soul Intruderhttps://www.blogger.com/profile/16873694208138872553noreply@blogger.comtag:blogger.com,1999:blog-5417138872461097808.post-1344008324908791892011-03-16T13:40:54.560-07:002011-03-16T13:40:54.560-07:00Thanks Rick, that really helps me a lot :)Thanks Rick, that really helps me a lot :)Soul Intruderhttps://www.blogger.com/profile/16873694208138872553noreply@blogger.comtag:blogger.com,1999:blog-5417138872461097808.post-82309854046961781612011-03-16T03:49:34.479-07:002011-03-16T03:49:34.479-07:00Can't recall any tutorials, except those from ...Can't recall any tutorials, except those from Delphi3D.net. But unfortunately, that site is down. But Nehe might have some as well.<br /><br />Let's see where I started a long time ago...<br />The most simplest form<br />----------------------------------------<br />* plane(quad) with transparency applied (look at GL_BLEND and transparency options)<br />* Don't apply diffuse light on water, just overall ambient for now.<br />* load a seamless blueish wave texture. Before rendering the quad, enable that texture (glEnable(GL_TEXTURE_2D) , glBindTexture(myWaterTextureHandle ... )<br />* To make the waves roll over the plane, apply UV coordinate shifted. When you render the quad, just add an ever increasing value to the S and/or T values of the texcoords (glTexcoord2f( s,t ))<br /><br /><br />If that succeeds, you can go a step further with:<br />* Make the waterplane a quadgrid (eventually with LOD) instead of a single quad. Then let the CPU calculate the height of each vertice based on "wave calculations". The formula itself can be pretty complex, but there should be plenty on internet.<br />* Use specular lighting from the sun on your water. You need to make a quadgrid instead of a single huge quad though (or apply a pixelshader that does per-pixel lighting). OpenGL has some fixed parameters to setup a lightsource & material specular color.<br />* It is possible to make reflections without using shaders at all. But if you are going that way, I suggest to start studying shaders anyway.Rickhttps://www.blogger.com/profile/04196340535742326978noreply@blogger.comtag:blogger.com,1999:blog-5417138872461097808.post-53493727736173280202011-03-16T03:15:52.308-07:002011-03-16T03:15:52.308-07:00Rick, I know it is totaly unrelated to the post;) ...Rick, I know it is totaly unrelated to the post;) but could you recommend me some good easy to understand tutorial about making water? I don't want anything fancy cause I am OpenGL beginner :)<br />The water doesn't have to be ultra realistic, just to imitate it to the certain degree. However moving waves would be nice...:)Soul Intruderhttps://www.blogger.com/profile/16873694208138872553noreply@blogger.comtag:blogger.com,1999:blog-5417138872461097808.post-75856515011385459872011-03-09T11:58:28.858-08:002011-03-09T11:58:28.858-08:00And thank you!
That first busstop picture hits the...And thank you!<br />That first busstop picture hits the spot :)<br />That sci-fi rocket looks kinda cozy with the lights on actually.Rickhttps://www.blogger.com/profile/04196340535742326978noreply@blogger.comtag:blogger.com,1999:blog-5417138872461097808.post-37112739790502413542011-03-09T11:45:42.200-08:002011-03-09T11:45:42.200-08:00USSR architecture: http://dirty.ru/comments/307173...USSR architecture: http://dirty.ru/comments/307173cobahttps://www.blogger.com/profile/02930147544399867985noreply@blogger.com