Making a custom rendered object.
by Brian Burke · in Torque 3D Professional · 10/18/2010 (11:06 pm) · 7 replies
Hello all, I was hoping someone would be able to give me a few words of advice on the project I'm working on, and tell me if I'm completely barking up the wrong tree.
My goal in this project is to create an object that, through a few shaders and at least one pre-render pass, is capable of modifying its own textures and normal maps on the fly. Basically, I need to render the object into onto an intermediary texture, and then use that to render back on to the texture and normal maps for the object.
I decided to create my own object, descended from a "SceneObject". I based roughly on the renderDelegate sample. However, unlike the renderDelegate sample, I'm loading a model file into a TSShapeInstance, and trying to render that with my shaders.
I have two questions
1) My immediate problem is that when I call GFX->setShader and then I call render on my TSShapeInstance, my shader is not applied. I assume it's being replaced by some shader in the shape definition, but I can't find where or how to override it.
2) My overall question, is am I going about this the best way, or is there a better, easier, more efficient, way to draw into an object's textures?
Any help or hints in the right direction would be greatly appreciated.
-Andy
(Edited for detail)
My goal in this project is to create an object that, through a few shaders and at least one pre-render pass, is capable of modifying its own textures and normal maps on the fly. Basically, I need to render the object into onto an intermediary texture, and then use that to render back on to the texture and normal maps for the object.
I decided to create my own object, descended from a "SceneObject". I based roughly on the renderDelegate sample. However, unlike the renderDelegate sample, I'm loading a model file into a TSShapeInstance, and trying to render that with my shaders.
I have two questions
1) My immediate problem is that when I call GFX->setShader and then I call render on my TSShapeInstance, my shader is not applied. I assume it's being replaced by some shader in the shape definition, but I can't find where or how to override it.
2) My overall question, is am I going about this the best way, or is there a better, easier, more efficient, way to draw into an object's textures?
Any help or hints in the right direction would be greatly appreciated.
-Andy
(Edited for detail)
About the author
#2
I guess the ultimate problem here is that I'm not familiar with the Torque3d draw pipeline, and I'm not sure what the best way to learn (quickly) would be.
10/19/2010 (11:11 pm)
Thanks. At least that tells me I'm not completely on the wrong track. I guess the ultimate problem here is that I'm not familiar with the Torque3d draw pipeline, and I'm not sure what the best way to learn (quickly) would be.
#3
Your way to do this is probably better if you don't need a general solution. Either way, I think the tutorials on the following page will help you get a firmer grip on the material system:
http://gameclay.com/documentation
Also, there are some render mesh / shape / object examples in the T3D directory, but at least one of them did not work the last time I tried using one of them (that was about 5 betas ago, so its probably fixed by now).
Good luck!
10/20/2010 (9:01 pm)
Another possible way to go would be extending the material system with a new material feature. Although this would require you to also become familiar with ShaderGen, it would in the end let you use this feature on any shape in your game. You might also need to create a new render bin for what you're after.Your way to do this is probably better if you don't need a general solution. Either way, I think the tutorials on the following page will help you get a firmer grip on the material system:
http://gameclay.com/documentation
Also, there are some render mesh / shape / object examples in the T3D directory, but at least one of them did not work the last time I tried using one of them (that was about 5 betas ago, so its probably fixed by now).
Good luck!
#4
This resource is not exactly related to what you are doing Andy, but does discuss the issue of rendering to a texture and then using it:
http://www.torquepowered.com/community/forums/viewthread/109335/
I will continue to try to direct people I know to this thread to help you out.
Anyone have any suggestions on what he might be doing wrong to not even have his shader be applied?
Andy, this is an HLSL shader, correct?
10/26/2010 (5:55 pm)
It seems like the most challenging part is going to be rendering to the texture and then subsequently using that. The reflection code does this but there is much built in support specific to reflection mapping that helps make this happen.This resource is not exactly related to what you are doing Andy, but does discuss the issue of rendering to a texture and then using it:
http://www.torquepowered.com/community/forums/viewthread/109335/
I will continue to try to direct people I know to this thread to help you out.
Anyone have any suggestions on what he might be doing wrong to not even have his shader be applied?
Andy, this is an HLSL shader, correct?
#5
I've been pulled off this project this week, but I'll probably be back on by Monday.
I figure the first thing I'll do is take a look at the feasibility of material/render bin solution suggested above. I suspect I'll want to mess with the render bins either way I go.
10/28/2010 (3:33 pm)
Thanks Paul.I've been pulled off this project this week, but I'll probably be back on by Monday.
I figure the first thing I'll do is take a look at the feasibility of material/render bin solution suggested above. I suspect I'll want to mess with the render bins either way I go.
#6
Sounds good. Feel free to contact me with any questions. Meanwhile I will continue to try to get advice on this and direct it at this post.
10/29/2010 (5:30 pm)
Andy,Sounds good. Feel free to contact me with any questions. Meanwhile I will continue to try to get advice on this and direct it at this post.
#7
11/11/2010 (1:18 pm)
Andy, are you back on this project again? Any progress?
Associate David Montgomery-Blake
David MontgomeryBlake