CustomMaterial multiple pass bug
by BBS Games · in Torque Game Engine Advanced · 05/17/2006 (1:33 am) · 8 replies
Hi,
I'm trying to do a multipass shader and when I set up more then 1 pass the engine hangs in this infinite loop (tsMesh.cpp):
if( matInst )
{
while( matInst->setupPass( sgData ) )
{
// set clamp/wrap
U32 flags = materials->getFlags(matIndex);
GFXTextureAddressMode smode = GFXAddressClamp;
GFXTextureAddressMode tmode = GFXAddressClamp;
if (flags & TSMaterialList::S_Wrap)
smode = GFXAddressWrap;
if (flags & TSMaterialList::T_Wrap)
tmode = GFXAddressWrap;
GFX->setTextureStageAddressModeU( 0, smode );
GFX->setTextureStageAddressModeV( 0, tmode );
// draw
GFX->drawPrimitive( i );
}
}
I was thinking that was a problem with my customized CustomMaterial but I've just tryed it with a fresh TSE build and hacked a material of terrain_water_demo :
new CustomMaterial(SixBump)
{
mapTo = two;
texture[0] = "metalcrate_bump";
texture[1] = "six";
texture[3] = "$cubemap";
cubemap = Lobby;
shader = BumpCubeDiff;
specular = "1.0 1.0 1.0 0.0";
specularPower = 20.0;
version = 2.0;
fallback = SixBumpFallback;
pass[0] = FiveBump;
pass[1] = Two;
};
solutions?
I'm trying to do a multipass shader and when I set up more then 1 pass the engine hangs in this infinite loop (tsMesh.cpp):
if( matInst )
{
while( matInst->setupPass( sgData ) )
{
// set clamp/wrap
U32 flags = materials->getFlags(matIndex);
GFXTextureAddressMode smode = GFXAddressClamp;
GFXTextureAddressMode tmode = GFXAddressClamp;
if (flags & TSMaterialList::S_Wrap)
smode = GFXAddressWrap;
if (flags & TSMaterialList::T_Wrap)
tmode = GFXAddressWrap;
GFX->setTextureStageAddressModeU( 0, smode );
GFX->setTextureStageAddressModeV( 0, tmode );
// draw
GFX->drawPrimitive( i );
}
}
I was thinking that was a problem with my customized CustomMaterial but I've just tryed it with a fresh TSE build and hacked a material of terrain_water_demo :
new CustomMaterial(SixBump)
{
mapTo = two;
texture[0] = "metalcrate_bump";
texture[1] = "six";
texture[3] = "$cubemap";
cubemap = Lobby;
shader = BumpCubeDiff;
specular = "1.0 1.0 1.0 0.0";
specularPower = 20.0;
version = 2.0;
fallback = SixBumpFallback;
pass[0] = FiveBump;
pass[1] = Two;
};
solutions?
#2
from terrain_water_demo/data/shapes/test/material.cs
I obtain an infinite loop
05/17/2006 (11:16 am)
Yeah I'm pretty sure...from terrain_water_demo/data/shapes/test/material.cs
new CustomMaterial(SixBump)
{
mapTo = two;
texture[0] = "metalcrate_bump";
texture[1] = "six";
texture[3] = "$cubemap";
cubemap = Lobby;
shader = BumpCubeDiff;
specular = "1.0 1.0 1.0 0.0";
specularPower = 20.0;
version = 2.0;
fallback = SixBumpFallback;
pass[0] = Two;
pass[1] = FiveBump;
};I obtain an infinite loop
#3
Wait a second. Yor material (SixBump) has matTo set to "two". The pass[0] material is also called "two". I smell naming clashes here. Care to post materials "two" and "fiveBump" too?
05/17/2006 (8:28 pm)
I have a material which uses only pass[0], and it works fine. I haven't tested having pass[1] or more. Wait a second. Yor material (SixBump) has matTo set to "two". The pass[0] material is also called "two". I smell naming clashes here. Care to post materials "two" and "fiveBump" too?
#4
05/17/2006 (11:21 pm)
Using only pass[0] everything works fine...Two and FiveBump are defined in the file terrain_water_demo/data/shapes/test/material.cs
#5
When a customMaterial setups up multiple passes, it calls setupSubPass() in each pass' customMaterial. This call doesn't exist in the Material class, it's CustomMaterial only, so I'm led to believe only customMaterials can be involved in multipass.
05/18/2006 (12:42 pm)
FiveBump is a Material, not a customMaterial. There's 99.9% odds that's the reason for your problem.When a customMaterial setups up multiple passes, it calls setupSubPass() in each pass' customMaterial. This call doesn't exist in the Material class, it's CustomMaterial only, so I'm led to believe only customMaterials can be involved in multipass.
#6
pass[0] = Two;
pass[1] = Two;
the engine hangs up...probably matInst->setupPass( sgData ) is not returning false on the last pass...I must investigate to understand why this is not working as expected
05/19/2006 (12:25 am)
@Manoel You could be right but even with this ->pass[0] = Two;
pass[1] = Two;
the engine hangs up...probably matInst->setupPass( sgData ) is not returning false on the last pass...I must investigate to understand why this is not working as expected
#7
05/25/2006 (5:49 pm)
Could be a bug. They should all be CustomMaterials. Haven't tested using the same material in 2 passes, let me know if you find anything for sure.
#8
05/26/2006 (6:05 am)
I've tryed with two different CustomMaterials and it hungs...however if you look at the source code you will see that the additional passes are only pointers to CustomMaterial objects so it shouldn't bother if you want to apply the same material twice (the code simply cycles through additional passes using mCurPass as index and returning after setting the stage data...so no recursive trubles on the way ).
Associate Manoel Neto
Default Studio Name