Refraction?
by Bryce · in Torque 3D Professional · 04/09/2013 (11:41 pm) · 5 replies
Hello again everyone!
Playing some classic SC: Chaos Theory today got me thinking. I watched a guard walk behind a bumpy glass window and saw the refracted image of him behind it, like this:

For a game from 2005, this absolutely blew me away. How feasible would it be to accomplish that with Torque 3D? I remember seeing some stuff a while back about a refraction shader and a backbuffer issue, but I don't know the current state of things (or anything about it for that matter). For someone like me who is deathly afraid of looking at the shader code, could someone maybe give me a some pointers in the right direction? We've already got refraction on water surfaces, would it be at all possible to give a glass material a special normal map and say "hey, you, refract things!"
I can dream, I guess. Help is appreciated!
-Bryce
Playing some classic SC: Chaos Theory today got me thinking. I watched a guard walk behind a bumpy glass window and saw the refracted image of him behind it, like this:

For a game from 2005, this absolutely blew me away. How feasible would it be to accomplish that with Torque 3D? I remember seeing some stuff a while back about a refraction shader and a backbuffer issue, but I don't know the current state of things (or anything about it for that matter). For someone like me who is deathly afraid of looking at the shader code, could someone maybe give me a some pointers in the right direction? We've already got refraction on water surfaces, would it be at all possible to give a glass material a special normal map and say "hey, you, refract things!"
I can dream, I guess. Help is appreciated!
-Bryce
#2
What you want to do is write a custom shader and apply it to a material, there is some very nice tutorials on the subject.
Like this one however don't know if you can just extend the material shader rather than writing one from Ground up.
04/10/2013 (2:47 am)
Write ze shader, should be very possible and not very hard to do.What you want to do is write a custom shader and apply it to a material, there is some very nice tutorials on the subject.
Like this one however don't know if you can just extend the material shader rather than writing one from Ground up.
#3
04/10/2013 (7:41 am)
@Lukas: Interesting, I just write the pixel shader and define it as a shader on the material and that's it? I wonder if I can use the water refraction code to do this.
#4
04/11/2013 (12:21 am)
There actually used to be a couple shaders that came with Torque, back when it was TGEA, that did exactly this. It's very easy to do, and yeah, clipping out some code from the water refraction would be a nice easy way to get it done. It's a pretty straight-forward and simple shader which gives some extra depth to the scene.
#5
04/11/2013 (12:23 am)
One thing I've never been clear on is how to get the HLSL code to find the information it needs. I'd love to have the refraction happen based on the material's normal map, but I've got no idea where to start.
Ahsan Muzaheed
Default Studio Name
what it was doing is reflecting environment around the objects on it's texture material.
may be that code can be used as mirror.may be also for refracted image
just a thought.never tried myself