A little help w/ CustomMaterials from the sages requested...
by Bryce "Cogburn" Weiner · in Torque Game Engine Advanced · 03/13/2007 (12:25 am) · 6 replies
I'm working on polishing up my TGEA-rific beam lasers so I can release it as a resource.
There's a few things that are still missing that I want to add and I need a little help implementing it.
Right now the laser beam is generated via PrimBuild... yuck. I'm going to stuff it into the vertex buffer instead. No problem.
I'd like to apply a CustomMaterial to the billboard, which offers the ability to perform a range of vertex and pixel shader effects on the beam, such as distort it the billboard collection into a lightning gun.
My issue is how to supply and apply a CustomMaterial to a programatically generated object? There are ample examples of how to apply one specific shader to an object, but nothing I can easily discern that shows how to apply a CustomMaterial.
There's a few things that are still missing that I want to add and I need a little help implementing it.
Right now the laser beam is generated via PrimBuild... yuck. I'm going to stuff it into the vertex buffer instead. No problem.
I'd like to apply a CustomMaterial to the billboard, which offers the ability to perform a range of vertex and pixel shader effects on the beam, such as distort it the billboard collection into a lightning gun.
My issue is how to supply and apply a CustomMaterial to a programatically generated object? There are ample examples of how to apply one specific shader to an object, but nothing I can easily discern that shows how to apply a CustomMaterial.
#2
How do I "fake" material hooks on my object so that the engine treats it in the same manner as a DTS.... but without having to go through the overhead of creating a TSShape?
I've looked into how a TSShape applies CustomMaterials, but it appears a bit "magical" from the code I have been able to trace through. I just can't seem to pin down where it connects the texture applied to the object with the CustomMaterial that is mapped to it.
03/14/2007 (5:37 pm)
Yes and no... It does have a material specified directly in the datablock, but I'm looking to treat my object more like how DTS are treated. The laser has a texture applied to it, but I would like a CustomMaterial to then affect that texture.How do I "fake" material hooks on my object so that the engine treats it in the same manner as a DTS.... but without having to go through the overhead of creating a TSShape?
I've looked into how a TSShape applies CustomMaterials, but it appears a bit "magical" from the code I have been able to trace through. I just can't seem to pin down where it connects the texture applied to the object with the CustomMaterial that is mapped to it.
#3
03/15/2007 (12:51 am)
Check out this resource http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=8835
#4
I don't like magic in my game engine.
03/15/2007 (1:06 am)
Good call, James. I think it might work, but it's still not quite what I'm after. Now it's turned into a hunt to find out exactly how this happens as much as it is to implement it myself.I don't like magic in my game engine.
#5
03/19/2007 (11:30 am)
If you are writing some kind of custom render then you need to track down the material in your render function, the engine can't do it for you (that would be magic indeed). Take a look at the WaterBlock code, or the GlowBuffer code to see some ways to go about doing this.
#6
Basically, I made the problem impossible because I didn't fully understand the pipeline to begin with.
From the way that materials behave throughout the engine, I was under the impression there was some magical "material manager" that was making the connection between "texture X" and "material Y" regardless of object type.
Looking closer, it only seems that way (on the scripting end) due to some clever development on your(?) part. :)
03/19/2007 (9:20 pm)
Makes perfect sense and I think that's what Phil was referring to, but I misunderstood.Basically, I made the problem impossible because I didn't fully understand the pipeline to begin with.
From the way that materials behave throughout the engine, I was under the impression there was some magical "material manager" that was making the connection between "texture X" and "material Y" regardless of object type.
Looking closer, it only seems that way (on the scripting end) due to some clever development on your(?) part. :)
Torque 3D Owner Phil Carlisle