PDA

View Full Version : Camera sampled cube maps



RBURKE
January 29th, 2009, 08:41
Okay this is my first post since i discovered this wonderful app, and i hope my question is not one that has been answered before.

So a long time ago i had created a script in blender that would allow me to update a cube map on a per frame basis. The setup basically had an object that i wanted to put a reflection on. Instead of raytracing this reflection however it was simulated using a cube map. The object needing the reflection would have a camera placed inside of it an that camera would capture a image in the positive and negative of each of the world axis. IE one image for -x one for +x one for -y one for +y etc. Now those images where combined in a cube map and then applied to the object to create an approximation of the reflection. It worked very well.
Now what i would like to create is basically the same thing but updated in real time and not just at render time.

So the question is how would i go about making a node that would be able to capture the input from a camera or 6 cameras and convert this to a cube map being used in my shader network.
Is this even possible to do or is this an effect that can only be achieved at render time.

I would really like to be able to make this shader to create simulated reflections in my scene. that would update in realtime to reflect the change in the scenery or objects position.

i had explained this much more clearly in an earlier post but for some reason it is not showing on the forum so i reposted this one. If i am being unclear of what i am looking for please let me know i will try to clarify once im a bit more rested.

Thanks in advance for any advice, examples, or interest.

Ian_
January 30th, 2009, 03:16
Hello, and welcome to Mental Mill! Its nice to see new people joining the forum. :)

I'm sorry to disappoint you, but, to answer your question, no, having a node in Mental Mill, with dynamic cube maps that render out different views, isn't possible, yet. However, that isn't to say that this kind of effect couldn't be coded in the fx or cgfx file after its exported, but that would take some knowledge of hlsl editing. Dynamic cube maps are a good way of faking reflections, and they are used in a lot of game engines, but a lot of them use their own shader format too, that Mental Mill doesn't support, like the Unreal Engine for example.

Also keep in mind, that while Mental Mill is a powerful program, it is still a fairly young program, and its still in beta. Also its not only used to make shaders for games, but also there is a lot of focus on using it for rendering shaders in Mental Ray as well.

So for now, you may have to use static cube maps, also don't forget, you can use other types of maps for reflections, like spherical 360 degree maps, and light robe maps too.

BTW, your last post is here-
http://forum.mentalimages.com/showthread.php?t=5125

Hope this helps. - Ian

RBURKE
January 30th, 2009, 09:18
thank you i appreciate the effort here. Does any one have an example of such a code in a fx or cgfx shader file, i have a basic understanding of how i would need to implement it, but i tend to be much more proficient with the art side of things, so a little example code will help point me in the right direction.

Ian_
January 31st, 2009, 07:08
Hey, I am not very experienced in writing fx or cgfx shaders from scratch, I pretty much know how to modify them to do things like add techniques, adjust ui parameters, and a few other modifications.

As a starting point, I would also get familiar with the structure of fx shaders and then research on how to add dynamic cube maps, maybe from nvidias website. If you can figure out how to make dynamic cube maps within the fx file, one thing you could do is add that code, to a shader you exported from Mental Mill, plugging the result of the cube map code to the input of a math_color_abs node in the fx file.

This is a good method for adding extra functionality to a shader that Mental Mill doesn't support. Here you can find an example of this method, which involves adding vertex colors, to the input of a color node in an fx file-
http://forum.mentalimages.com/showthread.php?t=1396

I really don't have experience editing cgfx files, but I would think the method should work the same way for a cgfx file, as it would for an fx file.

Also these links might be helpful-
http://www.hiegel.fr/~zavie/Talks/Dynamic%20Texturing.pdf
http://smartdata.usbid.com/datasheets/usbid/2001/2001-q1/gdc2k_cube_maps.pdf
http://books.google.com/books?id=DgMSb_10l7IC&pg=PA107&lpg=PA107&dq=dynamic+cube+map+hlsl+reflections&source=web&ots=-mp47qQlxK&sig=UwswdHpyRr9ZeJNXfOeGcnp-Jcg&hl=en&ei=vOaDSZ2XB4-EtgeW19DRCQ&sa=X&oi=book_result&resnum=2&ct=result#PPP1,M1
http://www.cs.uoi.gr/~fudos/grad-exer2/hlsl-intro.pdf