Make cubemap light not shiney?

Blitz3D Forums/Blitz3D Beginners Area/Make cubemap light not shiney?

Ross C(Posted 2008) [#1]
I'm using a cubemap to light my character. It renders a small 16x16 cubemap of the surroundings, and it gives my character the look that he is being properly lit by his surroundings.

Looks great if he was wearing a shiney suit of armour ^_^

However, he's not. I have fiddled with different blend modes and setcubemode, and nothing really seems to work. In fact, the mode that best works, is the 3rd setcubemode. Which seems to invert the cubemap, but provide much better lighting.

Anyone have any ideas? I currently use the texture to provide detail and the cubemap to light him.


Ross C(Posted 2008) [#2]
Ok, i have partially solved this by making my cubemap 2x2. It seems to flesh the light out more. Looks like i'll need to show and hide some light sprites to make my torch light more visible. Also have the problem of surfaces with lightmaps creating more light than the light source. Only really a problem with particle light sources, so the show and hide sprite idea should work.

I may also hide the lightmaps when rendering, so i only get the light sources... But, i will lose any reflective surfaces...


Ross C(Posted 2008) [#3]
Anyone have any ideas or experiences doing this?


sswift(Posted 2008) [#4]
The more detailed the cubemap, the more detailed the reflection. The more detailed the reflection, the more shiny the surface appears. A matte surface is just one which scatters light more.

So you need to either blur your cubemaps, or if you can't afford to do that, use a low res one, which you have done. The low res one will not be as good of quality as a blurred one though, because you're only sampling four pixels on the screen, so you're gonna miss a lot.

I have a function in the code archives which will do a hardware accelerated blur. If you use that with a lower res texture to boot, it might work. But it would probably be costly to blur a larger texture enough.


Hm... a thought just occured to me how one might do a real box blur using a setup similar to the one I used, but different. It would be a little slower because it would require you to copy the texture twice, but it would allow greater blur radiuses to be done in realtime.

It would involve drawing several copies of the texture offset horizontally on top of one another using the darken+add method I have in my blur function, and then copying the result, and then using the result to do the same thing vertically, and then copying that result to use it as the final texture. I think that would result in a proper box blur. The method I used leaves little circle cutout looking things at the corners of things in your texture. So a blurred square has little circles on the corners that are missing kinda. Also since it has to use so many copies of the image to render the texture large blur radiuses, there's a lot of overdraw.


Ross C(Posted 2008) [#5]
Hmm, i might just go with blurring the cubemap. Thanks for your suggestion :o)


Gabriel(Posted 2008) [#6]
Depending on how your scene is painted, you might use a set of low contrast materials for rendering the reflection pass. Before rendering the cube map, paint everything with it's low contrast material and then afterward paint it back with the normal materials. Exactly what the materials should be depends on the blend mode you use, but for example, with add blend mode, a completely black material gives you nothing at all, so if you worked in dark to medium shades of your colors, it would temper the affect and save you having to post process anything.

Since your cubemap res is so low, I'm not sure if the post-processing cost would be higher or lower. Just a thought, based on something similar I do with per-object glow effects in my own game engine.


Ross C(Posted 2008) [#7]
Also a good suggestion. I'll try it out, thanks guys :o)

I was thinking of placing an appropriate sprite at each light emittor to give more light from them. But i'll have a tinker and see whats best.