Cube map reflection demo!
Blitz3D Forums/Blitz3D Programming/Cube map reflection demo!
| ||
http://www.blitzbasic.com/tmp/cubed.zip A Bloodlocust production! |
| ||
Oooh, sweet, sweet, sweet. Much better than the hacks I did to make a properly reflecting ocean... When's the update coming? :) Fredborg |
| ||
When will it be added to Blitz 3D? Very very nice. A beautiful water! Your level is made with Maplet 2? I saw a little flickering of the light. Does maplet support that feature. I 'm very excited about the furure of Blitz |
| ||
Wow! |
| ||
Cool stuff! A bit dark though! =] |
| ||
Simply Awesome. I wonder too if the level has been made with Maplet2... Nice dinamic light effect... and water... A bit dark for me too, but it gives 'atmosphere'... Can't wait for update(s)... ;-) Sergio. |
| ||
A bit dark, but it looked quite nice. |
| ||
It's nothing to do with Maplet -- it's just showing off the new cube map stuff... |
| ||
Nice one, Mark! |
| ||
very cool! |
| ||
Hehe that demo perfectly captured one of the reasons why we at Eternal Interactive are looking forward to cube mapping... ;) |
| ||
Holy Boing. Perfect ! |
| ||
It's cool, but how accurate is it? Will this work in anyhting other than a square reflecting pool? The reason I ask is he's basically rendering a single view from below the water's surface looking up. So If the edges of the reflection map don't watch up with the edges of the pond, I dunno what sorts of results you'll see at the edges of the pool. Maybe it will work though. I suppose those areas outside the circle of the pool would be images of the edges of the inside. I also wonder if this would look right on a large body of water, like an ocean. I guess you'd have to get the perspective of the camera right or else you might end up being able to see the reflection of an island miles from it. Assuming you could have an ocean that big. You could get an even more realistic look for the water if you combined cubic mapping with spherical refelction maps, and did multiple passes. I'm guessing that right now, he's got the cubic map multiplying with the color of the water so that the lighting on the water affects the brightness of the cubic map. But if I'm not mistaken, the cubic map should be additive blended, being that it is a reflection of light in the room. Of course neither of these is totally correct. Because the water's brightness would have an effect. I think what you could do to get a realistic water effect is this: 1. Make one surface with the cube map fullbright. 2. Create a spherical environment map with a gradient from white to black from top to bottom. Apply spherical map to next surface, with surface set to multiply. Reflections nearer the viewer will fade out. This surface should be fullbright. 3. Apply water texture to last surface, allow it to be affected by light. Set alpha to 50%. I don't have a pic of water I'm looking at right now so I can't be sure if that's totally accurate. One thing I would do is try to find a way to stretch objects in the water vertically. Scaling the camera on the Z axis may work. If you've ever paid attention to reflections on a wet road, what you get is very elongated images of the objects being reflected. And water often blurs the images in the same way I beleive. Painters use the technique to get a watery look. Another thing I might try is inverting the normals of the layer with the environment map, and allow it to be affected by light. That would darken the environment map where the water is brightest, and let the environment show through completely where the water is darkest. Though because of the way DX lighting can overbrighten things, you might need to darken the color of the surface a bit to cancel out the overbrightening. The methods I describe here of course require three passes which is more expensive. But the results would look more interesting and realistic. There may be some way to get a similar effect with the multitexturing units so as not to get a speed hit, I'll have to think about it. |
| ||
Now that's what I'm talking about! Darkheart |
| ||
sswift: lighten up |
| ||
sswift: haven't you seen the reflective sphere demo on blitzcoder? |
| ||
Nice!!! |
| ||
Thanks for all your comments everyone! It's cool, but how accurate is it? It'll work on anything! And yes it is accurate. I had great fun making this demo and hope people are inspired in their own projects too!Will this work in anyhting other than a square reflecting pool? The particle system is also single surface and the level exported using my new max exporter, which will be out soon. More demos to come... got a taste for it now! |
| ||
"sswift: lighten up" What? I'm offering suggestins how to make the effect better. What the heck is wrong with that. I said it looks cool. It can look better. I told you how. There is no "lightening up" to be done here. "sswift: haven't you seen the reflective sphere demo on blitzcoder?" Yes, I have. Why do you ask? That has nothing to do with this. "It'll work on anything! And yes it is accurate." How can you be so sure? Did you test it with different shapes of pool? For example, what if the pool is shaped like an H, and the camera in the center can't see the sides of the pool which are hidden by the arms it is between? The effect looks great. I am only questioning how many situations it can be used in without graphical glitches. It seems to me to be a kind of a hack which won't work right in every situation, though it is clearly preferable to spherical reflection maps, or nothing at all. I imagine that to get a better effect, one would need to be able to use stencil buffers, modify the camera's 3D transformation matrix, and use pixel/vertex shaders to distort the resulting flat mirror surface. Though pixel shaders I imagine wouldn't really work very well with a lot of surface displacement. Anyhow, even if there's no graphical glitches with different shapes of pools, the reflection sitll isn't entirely accurate. You can't distort the image on a flat mirror and expect to get an image which looks exactly the same as the one you would get from a wavy mirror. But it will be close enough for games for now. |
| ||
Hey that looks awesome! Did you make the water in Max too? I'm guessing you did since you can see the water from top and bottom. If so how did you do it? Also if the water was based on a Blitz terrain would the reflection look about the same? |
| ||
Sweet. Runs great on my old gf2. |
| ||
Mark, Wow... no really wow! I love it! Any date for the Cube Map update? IPete2. |
| ||
In around a week I think! |
| ||
Oh dear....took my breath away.... |
| ||
it is impressive I want this update it's cool. |
| ||
"sswift: haven't you seen the reflective sphere demo on blitzcoder?" Yes, I have. Why do you ask? That has nothing to do with this. Im sorry, I may have misunderstood.. I thought you were thinking it could only be applied to flat surfaces.. heh.. silly me ;) |
| ||
Quick cube map tut... Cube maps are just textures - but textures with 6 'sides'. The idea is that instead of using u,v coords to look up a texture, you use x,y,z 'vector' coords. Think of a vector with its origin at 0,0,0 within a cube centred at 0,0,0. The vector will 'point' to a texel on one of the six faces. This is the texel looked up by the hardware for a particular x,y,z texcoord. At the moment, I'm using D3D to generate a 'reflection vector' at each vertex. This means the texcoords used to index the cube map are atuomatically generated, and will represent the eye-to-vertex ray 'bounced' off the vertex (the bounce is calculate using the vertex normal). By drawing an environment on the cube sides, the end result is a pretty nifty reflection effect. |
| ||
Holy Flurking Snit! Excellent :) |
| ||
Looks great, nice piece of work |
| ||
FYI: PC1 with Nvida TNT2 card, Win XP, Athlon 900. I can see the water reflection in the demo posted above, but I can't see the sphere reflection in the (new downloaded) castle demo - that is, I do not see any sphere. ------------------------------------------ PC2 with Geforce card, Win XP, Pentium II, no sound card. I can't try the castle demo because sounds are used, hence the program quits. Having tryed, instead, the water reflection demo, and the water does not reflect the environment. BTW, impressive ! Sergio. |
| ||
Will you ALWAYS have to render all 6 sides of the 'cube'. I might be wrong, but in the (beautiful) water demo surely only 2 sides are required (the 'top' of the water and the 'bottom' of the water). I only say this 'cos it is a little bit sluggish on my Radeon DDR VIVO - which admittedly is getting on a bit ;) In case that made no sense at all, I'm thinking about a flat mirror on a wall. It really only needs one 'side' doesn't it? A mirrored cube would need all 6? Or am I WAY off here? Other thing that occurs to me is that this is rendering camera views directly to a texture (or if not directly it's shifting it a lot faster than CopyRect() ). I remember requesting a 'Render to Texture' feature a while ago, 'cos it would be great for stuff like security cameras. Is this now a possibility? :) Oh, and how did you do the flickering light effect? Is it multiple lightmaps or just good old DX lights? |
| ||
Hey I also just noticed that when you're under the water everything distorts and fogs in and out. Really great effects and artwork. |
| ||
"Other thing that occurs to me is that this is rendering camera views directly to a texture (or if not directly it's shifting it a lot faster than CopyRect() ). Actually if you look at the castle demo source, it's up to YOU to render each of the views and then you copy it to the cube map texture with copyrect. So it's not any faster than copyrect. DirectX 7 and 8, and maybe 9 have no way to render directly to a texture. |
| ||
I would imagine it's a caps issue so it is up to the blitz programmer to implement a default brush type for backward compatability. |
| ||
Will you ALWAYS have to render all 6 sides of the 'cube' You render what you want to render, when you want to with cube maps. You also choose what face of the cube to render to. |
| ||
Oh, okay. I thought the whole thing might be 'automated' somehow but it's good to see we've been given lots of control. :) The CopyRect() issue worries me slightly though, because it really isn't fast enough in realtime. I'd like to see a faster command for this purpose. Don't want to put a 'downer' on this thread though - this is VERY impressive work. :) :) :0 Any sort of vague time-frame on the Max exporter? |
| ||
@ Skitchy: The CopyRect() issue worries me slightly though, because it really isn't fast enough in realtime. I'd like to see a faster command for this purpose. It's much faster if you store the texture in VRAM (flag 256). |
| ||
Yeah, but the VRAM flag doesn't work on every 3d card, I've had a big test and some people worked, some people were slower than hell, and back. |
| ||
Chances are for hardware that does cubemaps, flag 256 is the dogs bollocks. |
| ||
Hey Rob, am I right in thinking we can use this in some form for rear view mirrors? IPete2. |
| ||
IPete... why not simply use another CameraViewport, X-scaling the camera by -1? |
| ||
Ipete, it's best to use render-to texture method for rear view mirrors as this is exactly the same process. 1. hide geometry you don't want reflected ie. your car & show the "rear view mirror cam". Hide the main game cam. 2. Renderworld. The rear view mirror cam is obviously pointing backwards. Ideally it's probably a small cameraviewport - ie 64x16. 3. copyrect 0,0,64,16,backbuffer(),0,0,texturebuffer(rearviewtex)... copyrect the back buffer (which you've just rendered to using renderworld) to the texture. 4. Show main cam, hide rear view cam. Etc... tidy up. 5. Repeat... and so on. tips: * using flags 256 for your rearview mirror texture will speed up the copyrect process. * you only need to entitytexture the rear view mirror once. It's a "live" texture. It will update when you write or copy images to it. * you can update the rear view mirror every second frame. It won't be noticable. * and so on... |
| ||
Rob, Cheers! IPete2. |
| ||
Awesome demo. This is why I bought Blitz! Can't wait for this feature! |
| ||
can't wait to see a bump map demo :) what else is in store for us? Cheers mark. |
| ||
now i know why everybody asking 'why the update so slow'.... here it is, mark working on this stuff lately - but it worth... |
| ||
Could someone maybe post screenshots? I can't see all the cool effects because I have an old computer (450MHz w/ATI Rage Fury Pro.) |
| ||
oh je... my ati xpert 2000 pro have problems with it... ![]() And the demo was very dark (on my LCD-Monitor) - i see only lights... (i add more light to the screen) |
| ||
Should it look right on a Geforce2 GTS? I see fog and distortion when looking up from in the pit, but it just looks like a pit with no specialFX from outside. |
| ||
Screenies:![]() Above shot, with a working watery cuberymappery reflectiony thingy... ![]() Shot looking at the face thingy from under the watery type stuff. Kinda faint, but you can see the tiles from the pool area on the water surface, bent, crooked and all wavey-ed up. |
| ||
it's fine on my gf1 so anything up from that should be good to. |
| ||
On a 32bit colour screen I see the reflection but on a 16 bit none - might be worth the people having problems checking this ? |
| ||
Cheers 4 the shots. Why no work 4 me. Aaargh!! |
| ||
On a 32bit colour screen I see the reflection but on a 16 bit none - might be worth the people having problems checking this ? I can confirm the 16bit problem. |
| ||
Holy shiznit! That top shot is fantastic. Does this demo require a newer version of DirectX? I don't recall what version I have installed but it certainly isn't the latest (running Blitz is all I've cared about and it only required DirectX 7 at least.) |
| ||
AFAIK cube & bump mapping is possible with DX7, so I think it's still DX7 (and I really hope it!) |
| ||
Much respect Mark, can't wait for the update. Was a little dark but ran fine on my gf4 mx MikeT |
| ||
question, what else can cube mapping do? other than this i don't know it's other benefits. |
| ||
Hi, Cubemapping is in DX7. The 16bit bug is a known bug. Glad you guys liked the demo! |
| ||
Using my laptop with an Intel830 chipset the demo runs fine with the reflections in both 16bit & 32bit mode. |
| ||
Yep works now cheers Alan |
| ||
Rob, will you describe the process used to create the nice water effects ? |
| ||
Yeah- also, pls can we have a version identical, but not using the cube map, for comparison purposes. Go awn! |
| ||
Hi lads - the cubed demo is HORRIBLY unoptimised. Due to a bug in my max exporter everything is exported twice! This means 2x the work needs to be done so it might be slow now but the next one will be fast... I will soon be uploading a version which will be optimised and automatically switch to software reflections if the hardware can't manage cube maps. |
| ||
S L A P! :) |
| ||
Well it still ran beautifully on my machine. Big nyah to all those with lesser equipment <grin> |
| ||
Impressive demo! :) As this being a demo, I noticed 2 things right off hand when straffing left and right looking at the pillors in the reflection : 1) The reflection jiggles when moving around. 2) I can see the reflection shift left when straffing left and it shift right when I straff right. As this being a demo, are those problems that can be solved to look smooth when moving? No bid deal I guess, just curious. |
| ||
1) a quirk of cube maps 2) because I update half the reflection map each frame - hence a little lag The plugin is now fixed, but the demo still hasn't been fixed :) |
| ||
Do it now you big embarasement :) |
| ||
@MrCredo. Looks like your water has frozen over. |
| ||
Look forward to the update. Besides cube mapping and driver caps are there any other new features? |
| ||
Could it be that this "bug" people are seeing in 16 bit color is in reality an untextured copy of the water plane which is showing through because of the lower precision of a 16 bit zbuffer? |
| ||
Could it be that this "bug" people are seeing in 16 bit color is in reality an untextured copy of the water plane which is showing through because of the lower precision of a 16 bit zbuffer? Works in 16bit mode ok for me though?!? |
| ||
The bug only applies to some Nvidia cards, not all of them. |
| ||
Yes, but zbuffering issues affect some cards more than others too. Maybe you should release a new demo just in case! |
| ||
The 16 bit bug is a very odd bug which causes the cubemapped object to draw behind everything else. Or at least that was how it manifested itself in Mark's updated castle demo. Very strange. |
| ||
wow! this is werid. I am trying the demo on a Dell computer at work. When I start the demo, my camera is rotated 90 degrees clockwise. Meaning that I am viewing the level as if im lying on my side. Also the Mouse Axii(axae? axis'? :P) are inverted. Left-Right movement moves the camera up and down, and Forward-Backward movement turns the cam sidesways. System: Dell PC Intel Pentium 4 @2Ghz 510 MB Ram DirectX 8.1 GfxCard: Intel (R) 82845G Onboard Graphics Controller Somehow , it seems, the world coordinate system gets twisted upside down on this machine. Anyone seen this behaviour before? |
| ||
It sounds to me like you have some video drivers that allow you to rotate the monitor 90 degrees, to view it like a page of text. Is that an LCD monitor you have? See if you can rotate it to page view. If not, look in the display properties for something which looks like it controls this monitor rotation thing. It would probably be under the advanced 3D stuff since you only seem to have the problem in 3D stuff since you seem to be writing emails fine. I can't relaly be of more help looking for what setting you may need to change though because I have never used a system capable of doing that sort of thing. |
| ||
indeed its an LCD screen. Btw when starting the demo it lets you choose the resolution. this was also messed up. all resolution width's and heights where switched instead of: 640 x 480 32 it showed: 480 x 640 32 this might support your idea about the display properties. Ill have a look when I get back at work tomorrow. Strange thing is tho, the lcd screen was not turned to letter-mode, its oriented like any other screen and the normal windows show up just fine.. Anyways, Ill have a fiddle with it tomorrow cheers! |
| ||
It makes me wish I could do cube mapping ... a tutorial on this would be nice :) Isss gorgeous. |
| ||
@PsychicParrot even with a tutorial you wouldn't be able to do it, not until mark releases the update :) |
| ||
With a GEForce 2 MX 400 + WinXP + 512 Mo Ram + DirectX 9 i don't see the water in 16 bits ??? NVidia Driver version 6.14.10.4403 |
| ||
Filax, Too much Gin perhaps? ;) IPete2. |
| ||
Just thought I'd let people know that ATi has been known to have 16-bit z-buffer issues. Even in the 9800 Pro with the latest drivers. |
| ||
@Rob Will the source to your demo be made available? The bit I'm most curious about is where you positioned the camera and how you set the camera zoom before rendering each face of the cube for the water. |
| ||
Just thought I'd let people know that ATi has been known to have 16-bit z-buffer issues. Even in the 9800 Pro with the latest drivers. Except the problem only happens with nVidia cards. :o> GfxCard: Intel (R) 82845G Onboard Graphics Controller This might be the problem. We have these at school aswell and you can accidently turn on some sort of feature that will turn the image a different way. I belive the hotkey is either the Right Alt or Ctrl key in conjuction with the arrow keys. Disabling the Intel Display Manager (or whatever it's called) might help. |
| ||
zut alore! c'est fantastique monsueir cummings! or thereabouts =] |
| ||
supports also only 32 bit mode gforce 440 mx |
| ||
I just HATE when people post to old threads.... leave them alone!! |
| ||
He can do what he wants. Leave -him- alone. =] |
| ||
Yeah! |
| ||
Dang this post is ancient! |
| ||
11 years ago post!? Mikorians say yeah today post! I wonder what that about! |
| ||
What was this? The download's broken. |
| ||
Here : http://www.blitzmax.com/logs/userlog.php?user=8652&log=1737 "cubed.zip by Rob" |
| ||
Thanks, RemiD. For a more direct link if you don't want to search through the page or use ctrl-f: https://app.box.com/s/8z1ikuyl51hfeg4rjzfk |