Multi-pass shader
by Teromous · in Torque Game Engine Advanced · 09/16/2008 (9:29 pm) · 11 replies
I am wondering how to set up the second material for a multi-pass shader. Can anyone who's done this care to explain it a bit? For the most part I'm wondering what all can be added in the second material. Below is the example code from the documentation:
...so pass[0] would be implemented by doing...
Is this correct? Then if I did something like:
...it would just replace material from ShinyMetal2_0 right? So how do you set up a second pass?
new CustomMaterial( ShinyMetal2_0 )
{
texture[0] = "test/metalBump"; // bumpmap texture in texture unit 0
texture[3] = "$cubemap"; // cubemap texture in texture unit 3
cubemap = Lobby;
shader = BumpCubemap;
version = 2.0;
fallback = ShinyMetal1; // specify fallback for 1.1 hardware
pass[0] = ShinyMetal2_1; // specify second pass
specular = "1.0 1.0 1.0 0.0"; // can use the specular parameter from Material
specularPower = 8.0;
};...so pass[0] would be implemented by doing...
new CustomMaterial( ShinyMetal2_1 )
{
...
};Is this correct? Then if I did something like:
new CustomMaterial( ShinyMetal2_1 )
{
texture[0] = "test/metalBump";
...
};...it would just replace material from ShinyMetal2_0 right? So how do you set up a second pass?
About the author
#2
Simply put, you'll probably end up having to do some coding to get things a little more dynamic and getting it do do what you want. You can have a look at my comments on my blog (tgeaenhanced.blogspot.com) regarding Materials in TGEA.
09/18/2008 (10:31 am)
Hmmm, i can understand your dilemma and probably frustration. I think it needs saying that the CustomMaterial class is not all that it seems. It really is a bit of an orphaned entity in TGEA (my opinion anyways). I must add that GG is doing a great job on the Materials class but if you are going to do advanced/custom shading this will be of no use to you. I had to make excessive changes to the CustomMaterial pipeline to get it functioning properly. Also added some execution logic to the CustomMaterial pipeline. The rules like not defining textures in the first pass during a multipass chain is ridiculous, in fact the fixed texture staging is quite ridiculous. By default you cannot change the texture stages across several passes. Furthermore, I found that in build 1.7.0 the passes simply don't work unless you explicitly step through them during custom DrawPrimitive calls. You will find a lot of unexpected behavior using CustomMaterial instances. I suggest you step through the code in debug mode to get an idea of the execution behavior, this should clearly show you texture stage changes as well as allow you to probe the active pass (If you can get the passes going by using it right!)Simply put, you'll probably end up having to do some coding to get things a little more dynamic and getting it do do what you want. You can have a look at my comments on my blog (tgeaenhanced.blogspot.com) regarding Materials in TGEA.
#3
09/18/2008 (11:20 am)
Thank you for even responding to the thread! Just having somebody to shoot ideas and questions off of is very helpful, even if I can't figure some things out. Your changes to the engine are very impressive, especially the cloth. What are you planning to do with all of those changes you've made?
#4
09/21/2008 (7:45 pm)
I'll probably add the minor ones to the forums, I'm just busy writing a new software SDK for a company I do contract work for so my time is a bit limited. My focus is primarily focused on getting my TGEA work out on my blog - I rarely get time for this at the moment. I'll blog some stuff on my CustomMaterials changes quite soon so keep a lookout for that...
#5
Are you serious? Multipass simply doesn't work at all in 1.7.0? Have you tried in 1.7.1? I'm also trying to get multipass rendering to work on 1.7.1 but I have no idea what the rules are. Can you elaborate on any of them?
09/25/2008 (2:21 am)
Gerhard,Are you serious? Multipass simply doesn't work at all in 1.7.0? Have you tried in 1.7.1? I'm also trying to get multipass rendering to work on 1.7.1 but I have no idea what the rules are. Can you elaborate on any of them?
#6
I'll try and update you guys with some fixes for this but I'm a bit overwhelmed by people asking me for updates/fixes at the moment. I'll try to get onto this ASAP.
09/25/2008 (5:37 pm)
I have been running round a bit. Multipass doesn't work. If you take your debugger and step the code you'll see it doesn't exist anymore for CustomMaterials since release 1.7.0!I'll try and update you guys with some fixes for this but I'm a bit overwhelmed by people asking me for updates/fixes at the moment. I'll try to get onto this ASAP.
#7
09/25/2008 (9:19 pm)
Maybe I'm not understanding it properly, but I could have sworn I got Multipassing to work. I started with a Red Shader that just outputs red, then made pass[0] be a Blue Shader that just outputs blue, and when I ran it, I got a blue player.
#8
10/02/2008 (12:46 pm)
Hey, I have no clue how you made that happen! Anyways, like I say i discovered it to be highly unpredictable, post your code and I can have a look at it...
#9
10/02/2008 (11:25 pm)
@Gerhard, Check out my response toward the bottom of www.garagegames.com/mg/forums/result.thread.php?qt=78310, there I give an example. The Red/Blue Shaders I talk about have Vertex shaders that do nothing except set up the correct matrices and all the pixel shaders do is return either red or blue respectively.
#10
Next gen shading makes the game look like benchmarks, they need to create a new term.
Not frames per second, but seconds per frame.
btw, vtf is not flexible as r2vb
10/03/2008 (6:06 am)
Yes, CustomMaterial class is not all that it seems, but who needs more ?Next gen shading makes the game look like benchmarks, they need to create a new term.
Not frames per second, but seconds per frame.
btw, vtf is not flexible as r2vb
#11
Yeah...but all I would need is a translucent material to be affected by lights other than the sun. Could be a standard material for all I care...but it seems that (both std and custom) materials seem to disregard lights when translucent is set to true.
Added these parameters in my Custom Material (using DiffuseBump shader)...
dynamicLightingMaterial = AtlasDynamicLightingMaterial;
dynamicLightingMaskMaterial = AtlasDynamicLightingMaskMaterial;
...but as soon as translucent = true - the light goes away.
Tried to make my own shader, merging the dynamiclight-fetch into it - but with no luck. :-(
10/21/2008 (5:48 pm)
@Picasso:Yeah...but all I would need is a translucent material to be affected by lights other than the sun. Could be a standard material for all I care...but it seems that (both std and custom) materials seem to disregard lights when translucent is set to true.
Added these parameters in my Custom Material (using DiffuseBump shader)...
dynamicLightingMaterial = AtlasDynamicLightingMaterial;
dynamicLightingMaskMaterial = AtlasDynamicLightingMaskMaterial;
...but as soon as translucent = true - the light goes away.
Tried to make my own shader, merging the dynamiclight-fetch into it - but with no luck. :-(
Torque Owner Teromous