fast cubemapped simple water
Community Forums/Graphic Chat/fast cubemapped simple water
| ||
Ive put together a bit of code that may be useful to people. It allows you to create massive areas of moving water with huge vertex counts, without the need for realtime pulling of the vertices (because as i recently discovered (to my big design horror)is slow). Based on a rendering idea by Rob Cummings. I cannot waste anymore time on it but anyone who makes it better, let me know as im at 'that' stage in my project. Latest:---------------------------------------------------- While working on the TED demos, i decided to blow the cobwebs off this and have a new play around. Ive changed the interface slightly to allow for things like fog and cameraranges. Also, any object to be cubemapped (not only flat objects) by using an addreflection function. Also i noticed if i turned on the zbuffer & background clearing it seemed to help with some(not all) of the underwater inverting. But i cannot remember if i did this on the original, as ive played with it so many times. It seems to work fine now with terrains (there may be a little bit of disruprion here and there but is within tollerances.. well mine anyway :) There is also a cubemapexclusion list function where you can put all entitys that need to be hidden when entering the water below a certain depth. It seems to be working ok in my own tests. You can get the modified version from www.d-grafix.com/softwareted.html and click on the downloads section > island demo |
| ||
very nice :) |
| ||
Some of the best water I've seen Blitz do. |
| ||
yeah... that looks really nice... similar in technique to the cubed demo code that Rob Cummings put up a while back... as far as moving vertices around, i've gotten a decent looking ocean (not as pretty as cubemapped, but i can't decide on which one to use seeing as the cubed stuff looks so mirror like, and the ocean just aint like that... well, maybe in the carribean, on a balmy summer evening) and i cap off the simulation rate and fps at 60... both seem to run equally as fast and smooth (although yours looks a lot prettier)... also... if i drop one of my subs into the water, it looks fine from ground level... but if i move the viewpoint up a bit, this is what i see... the subs shadow seems to stretch towards the horizon... if the sub is suspended above the water, all looks fine though... --Mike |
| ||
Very sexy and a =very= usable interface. Many thanks for sharing :) |
| ||
Indeed, this is supersexy. I had to rename it to water_supersexy.zip to make sure I won't forget what it is (i mean, water.zip, what could this be). Very nice stuff, thanks a lot for sharing. This just gave me a inspirational kick. |
| ||
Dam... verrrrrrrrry nice! |
| ||
Absolutely outstanding. |
| ||
to red ocktober: no, its your subs leaky oil tank :) i think the back of the waves are reflecting the back of the sub. try lowering the amplitude I learned cubemapping from that technique! (didnt know who designed it). Oh well, thanx to rob for inspiring me. Cred where due!! My poor PC is a Duron800 with a geforce4mx so vertex calls and updatenormal calls really kill my framerate. if you care to share, i would really like to look at your vertex system, mabe its better written than the one i tried. anyway, enough waffle :) to all: Glad u like it, if anyone makes any breakthroughs with it let me know, and ill have a copy back. |
| ||
Thats wicked! I have been hunting around for some way to do what this does. Damn if only i knew at the time it was that easy! Thanks for sharing! |
| ||
hahaha... sub leaking oil, good one... ok, lets see... i tried playing with the amplitude, no luck... still get the oil slick... ... and since my chief engineer says the oil tanks are still full, it must be an underwater oil seepage of some sort... i'll play around with the code and see if i can figure out what's happening. again, this is verrry nice... suitable for lakes and ponds... but i really need ocean waves type water... ... something like this http://home.att.net/~subbase2/MovingShadedWater.wmv a lil test level i did in a6 using shaders and moving vertices... i also got one in blitz... without the cubemapping effects... lemme see if i can find it... [added] couldn't find it so i whipped up another one so you could see what i meant... http://home.att.net/~subbase2/oceanwaves.wmv this is running on a 733mhz gGeForce2 machine... but doesn't have the photorealistic cubemapping effects. --Mike |
| ||
@ Mike, Have you tried extracting the code from Fredbourgs' Roman Baths? It's a couple of functions and works really well. It may only work for smaller areas though - I don't know. The Roman Bath code is on the Gile[s] website and it updates in real-time (although it is a small area) - maybe there is a way to adapt it? ...Oh I just thought of a very stupid idea Mike, why don't you move the sub up to that height for the cubemapping update, generate the new cubemap and then put it back down to the place it should be for the renderworld? This way you'd maybe get the right effect even though its a completely crap way of doing it! @ D - Grafix - very nice sir - thanks for sharing. IPete2. |
| ||
thx IPete... will take a look at that... the Roman baths... and, ya see... why can't i ever come up with a fix like that!!! that aint stoopid at all... it's inspired... thx again... lets try it and see.. --Mike |
| ||
Mike, I just tried this with the following: Global sub=CreateCube() PositionEntity sub,0,1,0 ScaleEntity sub,23,13,13 www.smartscreenuk.com/Sub001.jpg www.smartscreenuk.com/sub002.jpg and I cant replicate what you are seeing...! Strange. The cube sub I create looks fantastic, the reflection is fine, just as you would expect from any angle, high or low. I wonder if something else is not quite right here? Can't think what would affect the reflections like that...what are the settings you are using? IPete2. |
| ||
hhhhmmmmmm.... [added] i get the same thing with the cube... hey, lemme try this on another machine... different video card... --Mike |
| ||
Aha! When I move the cube down into the water I get more of a reflection behind it! How strange! Maybe it is the vertical position of the cube camera? try moving it down or up the amount you moved the sub up to get a proper looking reflection. In the function which updates the cube camera... ;position cubemap camera camoffsety#=(EntityY(maincamera,True)-EntityY(entity,True)) PositionEntity camera,EntityX#(maincamera,True),EntityY#(entity,True)-camoffsety,EntityZ(maincamera,True) ...maybe? IPete2. ps it seemed to work better moving this camera up for me. Try half the distance as a compromise...seems to do it here. |
| ||
well... lets give it a try... in the meantime, i found that if i hide the sub and show it just before rendercubemaps() is called in the maion loop, that i get no reflection at all... sort of a fix :) --Mike |
| ||
Heres the new setting which worked for my cube shaped sub... camoffsety#=(EntityY(maincamera,True)+5) As a guide... BEFORE cube camera adjusted www.smartscreenuk.com/sub004.jpg AFTER cube camera adjusted www.smartscreenuk.com/sub005.jpg You get the reflection, and it is in the correct place, it may seem a little deeper than it should be though! Mike, it's my snooze time - let me know how you get on! Cheers! IPete2. |
| ||
thx IP... later --Mike |
| ||
Those waves need a bit more curvy randomness... Anyone thought of how to do this? |
| ||
Awesome water! Thanks for the gift. |
| ||
Very nice lateral thinking there =) ,although I can only see the environment map on this junk heap of a PC at work ^^ I'll look at replacing my vertex manipulated meshes using this method instead...I think the results will definitely look better and may just run faster on a wider range of PC's. Cheers. |
| ||
The cubemapper in my code uses the same technique as the baths code, so you will probably get the same result. I think you need to place objects at water level as its reflecting back what it sees under the water and thats why you are getting the reflection. Technically its 'doing exactly what it says on the tin', but looks crap. |
| ||
Currently I can see only one solution fo this oil slick problem: During Enviroment-Map Update -Hide anything that is completely below the water level. -Boolen Clip all meshes that are intersecting the water level, probably best use this code: http://www.blitzbasic.com/codearcs/codearcs.php?code=1143 , or think about to Pre-calc clipped hidden versions of the meshes with some slices raster. Whle the realtime clipping my be a bit slow (well, working on a copy of the originals anyway), the pre-calc solution may require a lot of ram. I guess it can be implemented pretty easily when you have all meshes and their Min and Max (world)Y Vertex Location inside an array or type, then simply parse that list each frame and Hide/Clip as required. EDIT: what I ask myself is: why isn't the green bottom texture of the skybox not mirrored the same bugous way then? |
| ||
uh realtime clipping may be too slow. I just tested it with a sphere with 100 Segments (that's about 40k tris) and my framerate drops to 150ms per frame on a Radeon 9200se. Rendering with the same amount of polies, but using a precalculated clipped version for the EnvMap was done in 33ms/f on this machine (total 80kTris for the normal Renderworld, inclusive water quad and of course, the clipped quad in the 6*EnvMap Update). BTW if you would use a relative small EnvMap resolution, it may be possible to use 6 cameras, each one with its own CameraViewport and angle, then create the Cubemap with a single renderworld. |
| ||
I remember reading somewhere that you don't have to render all 6 faces of the cube map, only the ones facing you. Anyway I just tried it and it works. I did not render the cube faces behind me or the cube face facing down and I only render 1 face per frame. I went from 200FPS to 280FPS :) |
| ||
Great work! Think about miplementing my cubemap functions to speed up cubemap rendernig though.. Most games even these days dont update the cubemaps each frame. :) |
| ||
Maybe ask this guy how he did it: http://www.blitzbasic.com/gallery/view_pic.php?id=170&gallery=hr&page=12 It looks to me like the character is intersecting the water. |
| ||
he probably did it something similar to this... it's all done with mirrors... see video... (880k small) http://home.att.net/~subbase2/oceanwaves.WMV with this method i at can get ocean waves... not ripples... but, i think i've gotta change the texture and lessen the wave action a bit... such a turbulent ocean wouldn't show a clear reflection, would it... also, now i gotta make a mirror friendly half a skybox :) [added] changed the pic and the lil video... got a half skybox working... (*** boat model by Guillaume Darier and Matthew Sebring ***) --Mike |
| ||
I don't know, the description specifically mentions cubemapping. |
| ||
yeah... i was just being funny... looking at it a lil more seriously... it does look like its cubemapped... i'm pursuing the mirrored approach... hey, take a quick look back at that lil video and the pic i just posted... i managed to get a half a skybox that works with a mirror... still playing around with various things to get things looking 'right' --Mike |
| ||
Well the Character on the Image who walks in the pool thing just obsures the relevant parts, so we don't know if he has the same problems or not. |
| ||
Man, this screws up royally on my system :) I literally see one side of the cubemap cube in the top left corner.. the middle of the screen flickers (just a band).. and it's REALLY slow (this is a 3.6ghz with a Geforce 6800 Ultra SLI (two cards)) [EDIT] works in windowed mode, does the above in fullscreen. Tracer |
| ||
the middle of the screen flickers (just a band).. This sounds like the recent bugs being reported between B3D and somewhat newer video cards... |
| ||
..on my machine everything working well and very very fast...P4, 2.4 GHz , 4 Gigs RAM,nVidia A310 256 MB Video RAM |
| ||
SR i'm not sure if it's the video cards or the new monitors, or a combination of the two... i experienced the samer thing... fixed it by adding this... Update World RenderWorld ... ... VWait:Flip False i'm using basically the timing algorithms on page 17 of the old written manual to limit my app speed... --Mike |
| ||
looks really nice. had some weird z fighting issues at work,, but it worked fine at home with an older graphics card |
| ||
See original edited post for latest. |
| ||
Hey. looking good! Funny- I recently pulled up my mirror code too. Progress is still slow- I'm yet to plop it in your code with the clipping of meshes at Y=n- which yould be darn excelent for this. Would make it usable in a game for sure :D |
| ||
Hi all, http://www.tomspeed.com/b3d_rangefog/ Check the userlib & clipping example there. It does hardware 'user-defined' plane clipping @ rendertime, might be useful for what you're doing. I'm revamping this userlib @ the request of Defoc8, update soon! Tom |
| ||
That Rob fellow keeps popping up everywhere like an egg of some sort. I wonder where I can find him? Someone told me he was last seen skiing down everest for laughs naked. He then pulled his parachute cord at the last minute. Apparently he was wearing a bright fuzzy ronald mcdonald wig at the time. |
| ||
@tom for some weird reason i can see the files but not download them !?? i think its a problem with my setup As ive had this before. Any chance you can email them to me? also, whats that shadow thingy, it doesnt calculate static or dynamic shads by chance? |
| ||
Tom, my system's based on your files ;) |
| ||
looks superb |
| ||
Check your Email, D-Grafix. I finally got round to my promise :) |
| ||
Is this zip still available somewhere? |
| ||
!!!!!ARGH! Attack of the UNDEAD THREAD!!!!!! :) Lost the original, but i got a slightly later version with water fog etc here : http://www.d-grafix.com?page=sourcecode I took this page off being linked as it is not finished and has not been updated for a year or more, but youre welcome to it. |
| ||
For me, the water looks really weird! :( Look at this: What could this be? The textures there are totaly random! |
| ||
No idea. Looks like the video card is messing up the cubemap or something. There are probably loads better ways to do this these days like rendering to textures directly etc... Not using some twobit intel GPU or anyting are you? |
| ||
Could that be from a buffer? :) |