My cubic map demo

Blitz3D Forums/Blitz3D Programming/My cubic map demo

sswift(Posted 2003) [#1]
I wrote this little demo of cubic mapping. It gives you a really good look at what each of the three cubic mapping modes do, and the effects you can get by using different cubic map resolutions.

I attempted to add the ability to blur a high res map, but for some reason my texture blurring code from the code archives fails completely when attempting to operate on a cubic map. I'm not sure why this is. Perhaps cubic textures can't be used in the same way as a regular texture. If it had just been some black smudge marks or something when it failed then I'd know what the problem is, but the effect I got was like the texture was crystalized, and I can't fathom why that is happening.

I know one way that will probably fix the problem, but I'd rather not have to resort to that method cause it would require several copyrects which would be much too slow to use in a real game.

Anyhow, here's the demo. Press 1 and 2 to select different cube mapping modes and resolutions.

http://earth.prohosting.com/scswift2/cubemapdemo.zip


Ross C(Posted 2003) [#2]
So, what does the third mode actually do? Is it some sort of inverted texture or something ? Nice code btw :)


HNPhan(Posted 2003) [#3]
the third one is like refraction o_O


sswift(Posted 2003) [#4]
"the third one is like refraction o_O"

Naw, cause if it was like refraction, then it would look like a lens.

Actually, I'd think you might get that sort of lens effect if you invert the teapot, but it wouldn't work 100% right, and cubic mapping seems to behave funny if the camera is inside an inverted cube with an environment map in certain modes... which seems kind of odd. But maybe that's just how those modes are supposed to behave. I think the chrome mode works right though. But overlapping geometry wouldn't look right which is why I think inverting the teapot won't work right.

Maybe if you actually flipped all the cubic maps around in some way it would look like a lens. Anyone care to make a cubic mapping function like the one in the code above that can do that right? :-)


sswift(Posted 2003) [#5]
Btw I updeated the demo so it now has a nicer skybox and can display an inverted cube with the cubemap on it if you press 3. Pressing 4 makes it dissapear. Don't press 2 while 3 is enabled or you'll get weird effects.


IPete2(Posted 2003) [#6]
Lovely stuff Shawn.

Thanks for the first Blitz stealth teapot! lol.


IPete2.


Gabriel(Posted 2003) [#7]
Erm.. I get CubeMapMode 1.. that's the typical ones I expected to see.

I don't get modes 2 and 3. Mode 2 seems to lock it to the local mesh coordinates, in which case, what's the point of cube mapping at all? You might just as well apply UV coordinates and use an ordinary texture.

Mode 3 doesn't show up here at all. I just a blank entity that's semi-transparent. I tried changing the texture res, but it doesn't show on the model, so I'm pretty sure there's nothing being mapped to the model in mode 3.


sswift(Posted 2003) [#8]
"I don't get modes 2 and 3. Mode 2 seems to lock it to the local mesh coordinates, in which case, what's the point of cube mapping at all? You might just as well apply UV coordinates and use an ordinary texture."

No, mode 2 does not lock it to the mesh. It projects it onto the mesh.

If the mesh was rotating you would see that the top of the cubemap always maps to whichever part of the model points towards the positive Y axis of the world.

I didn't rotate the teapot though because it would be very hard to tell that this is what is going on. When the teapot is rotating rather than the camera, it's hard to tell the difference between mode 1 and 2.

"Mode 3 doesn't show up here at all. I just a blank entity that's semi-transparent. I tried changing the texture res, but it doesn't show on the model, so I'm pretty sure there's nothing being mapped to the model in mode 3."

"A blank entity that's semi transparent". That sounds to me like something IS showing up.

The effect in this mode is not what you might expect so you might think you're not seeing it right when you are.

Hit F8 and post the screenshot here so we can see what you're seeing.


Mustang(Posted 2003) [#9]
When the teapot is rotating rather than the camera, it's hard to tell the difference between mode 1 and 2.



I changed the codeline that rotates the camera so that it rotates the teapot and the effect can be seen then better. Great demo, I have to do few own tests to see if the cubelighting really works, using true cubelight maps (level shots -> cubemap maps -> processed through HDR-Shop)

Diffuse and Specular Convolution


HDRshop can perform a diffuse or specular convolution on a high-dynamic range 360 degree panoramic image (also called a light probe). This is useful if you need to pre-compute a diffuse or rough specular texture map; for example, to light an object using a light probe in real time applications. The light probe must be in latitude/longitude format; see this tutorial on how to convert between various panoramic formats. Each pixel is replaced with the cosine-weighted integral of the corresponding hemisphere of incident illumination. In non-mathematical terms, the diffuse convolution is the image you'd want to use as an environment-map (indexed by the surface normal) to light a diffuse object in order to show it lit by a light probe. The specular convolution is the image you’d want to use as an environment map (indexed by the reflection vector) to light a rough but shiny object.



http://www.debevec.org/HDRShop/tutorial/tutorial6.html


sswift(Posted 2003) [#10]
Yeah but where are you gonna get HDR panoramas? :-)

I've been trying to get specular to look right, and improving the demo. Right now I have a version of the demo which uses a teapot that has two surfaces, so that you can alpha/color fade between two materials. Setting one layer to be a blurry cubemap, for diffuse colors, and setting the other to be a specular layer with a sharp skymap and using add mode for that layer gives nice bright highlights, but even if I multiply the specular map with itself using the second texture unit, it's not enough to drown out the darker parts of the image like the grass so that only the really bright stuff contributes to the specular highlights. So I'm still working on that. Of course it would be simple to fix if I wanted to just use precalculated maps, but I want to find a solution suitable for realtime envornment mapped lighting.


JoshK(Posted 2003) [#11]
What's nice is now we can use sky brushes for skyboxes instead of encasing everything in a giant box mesh.


Mustang(Posted 2003) [#12]
Yeah but where are you gonna get HDR panoramas? :-)


http://www.debevec.org/Probes/ :)

[just had to...!]

I've been trying to get specular to look right, and improving the demo. Right now I have a version of the demo which uses a teapot that has two surfaces, so that you can alpha/color fade between two materials. Setting one layer to be a blurry cubemap, for diffuse colors, and setting the other to be a specular layer with a sharp skymap and using add mode for that layer gives nice bright highlights, but even if I multiply the specular map with itself using the second texture unit, it's not enough to drown out the darker parts of the image like the grass so that only the really bright stuff contributes to the specular highlights. So I'm still working on that. Of course it would be simple to fix if I wanted to just use precalculated maps, but I want to find a solution suitable for realtime envornment mapped lighting.


I had exactly the same idea of doing specular (masked specular would be even cooler), as diffuse alone is not really enough.

My basic setting (for my FPS game) is a level with lightmaps and diffuse cubes generated from that (using for example Halos-- sorry RockStars handy code snippet).

For specular I have thought out many methods like using real-time lights for the second (additive specular) object but cubes would be better... I going to try if adjusting contrast etc would be enough to produce specular cubemaps, but then there is also the problem of true real-time lighting effect needs, like a rocket ammo blasting by that should also somehow contribute to the specular and overall lighting... dunno... but getting cubes for "static coolnes" is a good start at least.


Beaker(Posted 2003) [#13]
Any screenies, you guys, for people without graphics cards? :)


sswift(Posted 2003) [#14]
No, because you wouldn't be able to see them.


Rob(Posted 2003) [#15]
Plus beaker loves matrox mystique and is bald.


koekjesbaby(Posted 2003) [#16]
The Web page or file that you requested is temporarily unavailable. It has been so popular this month that it exceeded its free monthly traffic allotment. Access to this Web site will be restored on the first of next month. Please come back then.

that's a shame... is there another location i can donwload your demo from?


JaviCervera(Posted 2003) [#17]
Thanks for the first Blitz stealth teapot! lol.
In fact the second. I released a demo using fake env mapping some months ago.


sswift(Posted 2003) [#18]
"that's a shame... is there another location i can donwload your demo from?"

Earthlink SUCKS.

I would host it on my new Adelphia homepage but I can't because their web service is "temporarily unavailable". I have no idea how long I'll have to wait to get my free webspace there.

Anyone wanna provide me with some free webspace on their own web server? :-)

I'll see if I can setup yet another free webhosting site to host my stuff on. But it's always a pain for people to download files from those.


sswift(Posted 2003) [#19]
My cube mapping demo is now available here:

http://earth.prohosting.com/scswift2/cubemapdemo.zip

And here's a few screenshots:
Screenshots

(click links, then go to URL bar and press enter there... it's a pain in the ass using free webspace.)


Andy(Posted 2003) [#20]
No matter if I click or not, I am not able to download the file from the new position.

sending you an email sswift...

Andy


sswift(Posted 2003) [#21]
Okay I paid $5 (one time fee) to get a free prohosting account with 50 megs of space, 5gb of transfer, and NO BANNERS, so you should be able to download this now without problems.

http://sky.prohosting.com/scswift/cubemapdemo.zip


sswift(Posted 2003) [#22]
And here's that screenshot:



Wayne(Posted 2003) [#23]
Hey Shawn, won't that cut into your beer money this month ?

hehe


sswift(Posted 2003) [#24]
Not funny! :-) I really am that broke! :-)


IPete2(Posted 2003) [#25]
SSwift,

What worries me is that if a man of your talents is that poor then what chance do I have - really!??!?!?!?!

LOL ;)

IPete2.


sswift(Posted 2003) [#26]
IPete:
Well I choose to be that poor. :-) I'm trying to start a business.

I could get another job in the game industry as a level designer if I really wanted to. But I wouldn't want to get a job as a programmer. I don't like C/C++.

If I did get another job in the game industry I'd probably have to move away from home again and my dad's kinda lonley since my mom passed away so I'm gonna try to stick around for a while. Least for another year. Hopefully by then I will have finished some of my games and won't need to go to work for someone else.


IPete2(Posted 2003) [#27]
Shawn,

More power to you my friend.

It is tough starting and running your own business, but after the way that some employers treat people it is the only way forward.

I walked away from my very well paid job, just over two years ago, to set up SmartScreen, I haven't looked back, and yes I too am financially worse off than ever, however, I am my own boss, and my focus has never been more intense on stuff I enjoy doing, and I believe will have finacial rewards later.

Just got to hang in there during the hard times.

IPete2.


Beaker(Posted 2003) [#28]
sswift - thanks for the picture. I bought a new graphics card so I could see what all the fuss is about with these new demos. All very nice.

Good luck with your business ventures.


podperson(Posted 2003) [#29]
Mode 3 looks like thin wall refraction to me.


Rob(Posted 2003) [#30]
mode3 would make a lovely predator effect I suppose. Or a blur.


Dragon57(Posted 2003) [#31]
Hmm, when I run the demo all I see are a lot of gray triangles in the upper left corner of the screen instead of a teapot.

Any ideas?


sswift(Posted 2003) [#32]
Your card may not support cubic mapping.


John Blackledge(Posted 2003) [#33]
Shawn, as the man said 'more power to you'. Good luck with the business.


Mustang(Posted 2003) [#34]
Hmm, when I run the demo all I see are a lot of gray triangles in the upper left corner of the screen instead of a teapot.

Any ideas?



Ideas? Yes. Run this code:

http://www.blitzbasic.co.nz/b3ddocs/command.php?name=GfxDriverCaps3D&ref=3d_cat


Dragon57(Posted 2003) [#35]
@Mustang, thanks, indeed my card does not support cubic mapping. Oh well!

Any idea what generation or type of cards generally do not support this?

My card is a Matrox G400.


Beaker(Posted 2003) [#36]
Dragon57 - i just upgraded my Matrox G400 to a Geforce 4 mx440. Not the fastest card in the world but does all the nice new stuff.


Dock(Posted 2003) [#37]
A GF4 MX card is basically the same as a GF2 in terms of functions, but much faster of course. However, GF2/GF4MX are popular cards, and widely supported by software - they're a good choice.


Dragon57(Posted 2003) [#38]
I finally got home and tried this on my G4Ti4400. Purdy! :)


sswift(Posted 2003) [#39]
"However, GF2/GF4MX are popular cards, and widely supported by software - they're a good choice."

...If you want something two years old that won't run Doom 3 or Half Life 2 acceptably when they come out. :-)


Beaker(Posted 2003) [#40]
Yep, thats me. And it only cost me £50.

I'll get a new computer when I want to run Half Life 2 (forget Doom 3).


Jeremy Alessi(Posted 2003) [#41]
Nice, I like the cloaking effect.