1.85 release: halo's conclusion
Blitz3D Forums/Blitz3D Programming/1.85 release: halo's conclusion
| ||
Blitz3D rules. Here's a function to save an environment map. They look really cool.Function SaveEnvMap(file$,x#=0,y#=0,z#=0,size=256) camera=CreateCamera() PositionEntity camera,x,y,z CameraViewport camera,0,0,size,size i=CreateImage(size*6,size) RotateEntity camera,0,90,0 RenderWorld CopyRect 0,0,size,size,size*0,0,BackBuffer(),ImageBuffer(i) RotateEntity camera,0,0,0 RenderWorld CopyRect 0,0,size,size,size*1,0,BackBuffer(),ImageBuffer(i) RotateEntity camera,0,-90,0 RenderWorld CopyRect 0,0,size,size,size*2,0,BackBuffer(),ImageBuffer(i) RotateEntity camera,0,180,0 RenderWorld CopyRect 0,0,size,size,size*3,0,BackBuffer(),ImageBuffer(i) RotateEntity camera,-90,0,0 RenderWorld CopyRect 0,0,size,size,size*4,0,BackBuffer(),ImageBuffer(i) RotateEntity camera,90,0,0 RenderWorld CopyRect 0,0,size,size,size*5,0,BackBuffer(),ImageBuffer(i) SaveBuffer ImageBuffer(i),file FreeImage i FreeEntity camera End Function |
| ||
thanks dude! |
| ||
Nice one, famous stone with ring of light aound him (the coder formerly known as Halo). IPete2. |
| ||
I agree completely. 1.85 rocks! Cube mapping is completely awesome, and allows you to create awesome reflection and water effects, and the new GetSurfaceBrush() and that commands have made my life a lot easier. TextureName$() rocks!!! |
| ||
That's a very handy Function. Good work. You should put it in the code archives. |
| ||
Hey, this is handy - I was going to do something like this myself, but now there is no need. Thanks! :) |
| ||
Yeah !!!! this totally rox!!! thnx!!! |
| ||
Um, it does rule -- however, can someone please demonstrate with code HOW to do nice water reflections?? All of my attempts do not look right. |
| ||
Rob is working on his source code right now i believe. He said he'd release it :) |
| ||
For water, I would think that rendering with Halo's setup, with the water hidden, and the camera in the center of the pool, at water level, would work. Have you tried that? If so post the code and maybe we can fix it. |
| ||
Ok, check out the file www.adgames.biz/test.zip Basically I've hacked up the code from the docs, commented out the dynamic cube map stuff and used a cube map generated from Halo's function. I get the same behavior both ways though -- the reflection looks incorrect when you start moving the POV camera around. Sorry for the messy hacked up code. I'm wondering if to correct this you have to match the cube map cameras' orientation to that of the POV camera. I tried it but ran into more troubles due to my lack of expertise. Whups! The download above has a cube map that was created without the water hidden but it won't make a difference with the problem I'm having. |
| ||
water hidden, and the camera in the center of the pool, at water level, would work Yup, that's the correct way to do it... but making the water move realistically is somewhat bigger problem I think. |
| ||
wma: Your demo doesn't work. I see a couple trees and some ground and a sky, but no water or anyhting else cubic mapped. |
| ||
wma: Okay I got your demo to work by uncommenting the commented out stuff but I'm not sure how to go about fixing it. I tried a few different cube modes... It seems like there are four or five different modes I think. Anyhow, none of them gave the desired effect. I think maybe you're going to have to render the cubemap from different points of view as the camera moves about. Which you'd have to do anyway if you want dynamic objects like players and monsters to also be reflected in the water. |
| ||
Can someone clarify for a thicky? I can't see the point of this. Wma's test is nice, but when you move the camera the tree reflections quickly end up in the wrong place. Sswift, is this what you mean about having to recalc the pos of the camera constantly? Also, sorry to be a pain, but what IS environment mapping? What has Rockstar achieved here? What is the point of this code? Thanks. |
| ||
John: Yes, what you are seeing is the problem. "Environment mapping" is many things. It can be cubic or spherical. What we're trying to do here is get cubic environment maps to work. How those work is you have a texture which has six faces of a cube laid out in it, and then these are projected onto the side of the object you apply the map to. In one of the modes anyways. This for example gives the appearance that the object is reflecting the image on the right side of the cube map, which ideally is showing what is to the right side of the object in the world. See Halo's image above? That's a cube map, though laid out differently than it is internally. That is created by sticking a camera at some point in the world and rendering six 90 degree FOV square camera views pointing in six different directions. |
| ||
What if we try to match the cube map cameras' orientation to that of the POV camera, but make its pitch opposite of the POV camera -- will that work? |
| ||
I don't know. Try it. :-) |
| ||
Tried it. Either I didn't do it right or its just a plain bad idea cause its still not correct. Anyhow, just for yucks, add the line below into the main loop and comment out the scaleentity command for the teapot -- the texture warping actually makes for semi convincing poor mans water motion. If only the relfection were correct I'd be happy. TurnEntity teapot,0,1,0 |