Faking 3d using shaders and lighting
by Ryan Neighbour · in Torque X 2D · 08/07/2007 (12:52 pm) · 6 replies
Hey all
I've been looking around the forums to see if anyone has tried this but I haven't had much luck (if there's a thread about this out there that someone knows about just point me to it and I'll be grateful).
Here's the situation:
I am very much interested in using TX (my teammate is as well) but as yet there's no 3d support. So what I figured we could do was make sprites out of our models and create bump and/or normal maps. Hopefully using these and some well placed lights would make things light up like they're 3d (sort of). We're doing a top down space shooter so we're not concerned about shadows on the "floor" of the levels.
My question is has anyone tried something like this? If so, did it look alright or just weird?
Any info/ideas/screens/anything would be very helpful.
I've been looking around the forums to see if anyone has tried this but I haven't had much luck (if there's a thread about this out there that someone knows about just point me to it and I'll be grateful).
Here's the situation:
I am very much interested in using TX (my teammate is as well) but as yet there's no 3d support. So what I figured we could do was make sprites out of our models and create bump and/or normal maps. Hopefully using these and some well placed lights would make things light up like they're 3d (sort of). We're doing a top down space shooter so we're not concerned about shadows on the "floor" of the levels.
My question is has anyone tried something like this? If so, did it look alright or just weird?
Any info/ideas/screens/anything would be very helpful.
About the author
Just started an M.Sc. in Electrical and Computer Engineering during which I'll be investigating the use of Agent Based Models in the field of Epidemiology. Aside from that, trying to get my first indie project off the ground and having a blast doing it.
#2
08/07/2007 (7:46 pm)
You can do what you see in the video. It may take a little shader writing, but it can be done with TorqueX as is.
#3
08/07/2007 (11:35 pm)
I'd like to see the relief map support seen in that video work its way into the editor for quick and easy use.
#4
@Tom
I've never done shader work but I'm more than willing to learn.
A problem that initially popped out at me was how to create the normal map from the height map but after a bit of thinking I may have found a half decent way of doing it.
The idea is that for every cell in the map and associated height (x, y, z) you just calculate the normals with all the adjecent cells ((x -1, y +1), (x, y+1), (x,y)) etc, then average them. I think that'll work. Since grad I haven't had to flex those math muscles but I think it's more or less right.
I'll definitely be playing with this over the coming weeks (if work allows). When I have something that more or less works I'll post some screens and maybe the code if it's clean enough.
08/08/2007 (1:52 am)
Thanks for the responses. @Tom
I've never done shader work but I'm more than willing to learn.
A problem that initially popped out at me was how to create the normal map from the height map but after a bit of thinking I may have found a half decent way of doing it.
The idea is that for every cell in the map and associated height (x, y, z) you just calculate the normals with all the adjecent cells ((x -1, y +1), (x, y+1), (x,y)) etc, then average them. I think that'll work. Since grad I haven't had to flex those math muscles but I think it's more or less right.
I'll definitely be playing with this over the coming weeks (if work allows). When I have something that more or less works I'll post some screens and maybe the code if it's clean enough.
#5
I think Tom was referring to the relief mapping when he spoke of writing shaders, as I don't think we've gotten that shader with any TorqueX releases, which is a shame. I believe the reason why they left it out is that it is quite a slow algorithm for practical usage beyond pretty demos...
In a real game with a relief mapping shader, the Xbox would probably catch on fire...
08/08/2007 (4:34 am)
There are freely available tools that will make a halfway decent normal map from a height map for you unless you are planning to dynamically generate your normal maps from your height maps at run time, which is always a possibility.I think Tom was referring to the relief mapping when he spoke of writing shaders, as I don't think we've gotten that shader with any TorqueX releases, which is a shame. I believe the reason why they left it out is that it is quite a slow algorithm for practical usage beyond pretty demos...
In a real game with a relief mapping shader, the Xbox would probably catch on fire...
#6
I just see it now: "Indie game burns down condo complex!" We're developing for the PC primarily with the 360 as an after thought (although the controller is probably the best way to play this) so that's not much of a concern right now.
Does anyone know sort of how 3d will be integrated into the current system (ie: will it be something like the way you can drag and drop 3d assets into TGB)?
08/08/2007 (11:48 am)
For our next project we'll probably be using dynamic height fields but for now I'll have to go looking for some tools because I'm a huge fan of anything that cuts down on dev time.I just see it now: "Indie game burns down condo complex!" We're developing for the PC primarily with the 360 as an after thought (although the controller is probably the best way to play this) so that's not much of a concern right now.
Does anyone know sort of how 3d will be integrated into the current system (ie: will it be something like the way you can drag and drop 3d assets into TGB)?
Torque Owner Ryan Neighbour
Default Studio Name
Since that video's a year old (and TX3d isn't done) I'm now just wanting to know if that type of shader support is still in TX (and TXB)?