Nice cubic mapping function

Blitz3D Forums/Blitz3D Programming/Nice cubic mapping function

JoshK(Posted 2003) [#1]
I am not sure if this is precisely cubic mapping, but it looks darn good on flat surfaces. The whole key here is that your vertex normals need to be right. One face of an object should have all the normals in the same direction, or else you get ugly stretching like when you use sphere mapping on a flat surface.



I really recommend viewing this demo first:

http://www.leadwerks.com/storage/shiny.zip

Function cubicmapvertex(surf,v,cam,verts=1)

x#=EntityX(cam)
y#=EntityY(cam)
z#=EntityZ(cam)
pitch#=EntityPitch(cam)
yaw#=EntityYaw(cam)
roll#=EntityRoll(cam)

RotateEntity cam,0,0,0
AlignToVector cam,VertexNX(surf,v),VertexNY(surf,v),VertexNZ(surf,v),3
RotateEntity cam,EntityPitch(cam),EntityYaw(cam),0
TFormPoint 0,0,0,0,cam
tx#=TFormedX()
ty#=TFormedY()	
TFormPoint VertexX(surf,v),VertexY(surf,v),VertexZ(surf,v),m,cam
tz#=TFormedZ()
If tz<100 tz=100
VertexTexCoords surf,v,((TFormedX()-tx/5.0)/tz)/2.0,((TFormedY()-ty/2.0)/tz)/5.0,0,1

PositionEntity cam,x,y,z
RotateEntity cam,pitch,yaw,roll

End Function



JaviCervera(Posted 2003) [#2]
"User lib not found". You have one required DLL in your userlibs folder.


Chroma(Posted 2003) [#3]
Halo, you make me tired.


JoshK(Posted 2003) [#4]
I added water, with rippling cubic reflections. It's the best water i have ever seen in Blitz, perhaps the best i have seen in any game. Same download, source included.


BlitzSupport(Posted 2003) [#5]
Yeah, it's good.


HNPhan(Posted 2003) [#6]
very cool indeed


Space_guy(Posted 2003) [#7]
very nice but whats this Vextorx() command not included in teh sourcecode?


Dock(Posted 2003) [#8]
Looks really good ^_^ The effect makes everything feel very chrome, and combined with sphere mapping for other objects I'm sure it could look incredibly striking. Great work!


JoshK(Posted 2003) [#9]
I included the vector3d lib. You should be able to run the source.


JoshK(Posted 2003) [#10]
Framerates? I get the maximum framerate on my system, but I'd like to hear how it is doing on lower-spec systems.


Anthony Flack(Posted 2003) [#11]
It looks really lovely, but I'm only getting 30 FPS here. P4 1400 with geforce2 pro.


JoshK(Posted 2003) [#12]
How about changing the water detail until you find the maximum detail where your system still runs at its fastest.

The detail of the water can be controlled with CreateQuad(1000,50), where 50 indicates that the water is 50x50=2500 quads. (I can go to about 10,000 quads with no slowdown, or a detail level of 100.)

This really is meant as a practical, usable effect for games.

The cubic mapping itself, without the water, should be so fast that it doesn't matter how much you use it.


Anthony Flack(Posted 2003) [#13]
I can't compile the bb - vectorx (and I assume vectory and vectorz) function not found. I guess you made this in your own ide, and forgot to include a lib?


BlitzSupport(Posted 2003) [#14]
There's a .decls userlib thing in the archive -- stick it in your userlibs folder...


(tu) sinu(Posted 2003) [#15]
"I added water, with rippling cubic reflections. It's the best water i have ever seen in Blitz, perhaps the best i have seen in any game. Same download, source included."

sounds interesting, of to d/l it now, thanks halo.


Beaker(Posted 2003) [#16]
Nice demo and the water looks good. Not sure what I think about the wall mapping tho, looks nice when you move sideways, but strange when you move in/out.

It runs at about 30 fps on mine (faster in fullscreen). Changing the water quad detail makes only a little difference to the speed. If I change the 50 to a 5 I get 10 more FPS (in fullscreen).

I'm not sure the water is the best I've ever seen, (limiting myself to water in 'realistic' games) the water in OutCast takes some beating. And, the flowing water in Vietcong is pretty good.


JoshK(Posted 2003) [#17]
I'll check those out.

Yeah, the reflections move when you move in and out, and they should just scale. I'm sure it will get better.

The cubic mapping alone is super-fast, right?


Beaker(Posted 2003) [#18]
The line:
cubemap map
takes 10 millisecs every frame on my setup. Which is quite intensive. That is the thing slowing down the most.

The water with a setting of 50 takes 9 millisecs, but only 1 if I knock the setting down to 5.


Anthony Flack(Posted 2003) [#19]
Oh a userlib. Okay. Never used one o them before.


Dock(Posted 2003) [#20]
Would this technique be possible on an animated model?

Is it possible to adjust the normals of a model to point vertically each frame, and would this be processor intensive?


Rob(Posted 2003) [#21]
it's not possible with a deforming animated model unless you grab a list of frame normals.

It's always processor intensive.