Bump Map question
by Ronald J Nelson · in Torque Game Engine Advanced · 12/03/2008 (11:18 pm) · 16 replies
Is there any way to get bump maps in materials to work with objects like PrimBuild objects like decals and other objects that don't have a DTS or DIF file?
#2
12/04/2008 (4:09 pm)
Yeah I understood that when I was asking, but I guess I should have been asking if anyone had an example of it being done in something similar to decals?
#3
If you fixed the Decal vertex to match that of TSShape you should just be able to create a MaterialInstance and do the same sort of rendering. Just submit them as a MeshRenderInst like in ParticleEmitter::prepBatchRender() with your 'mat' set.
Its something we're meaning to try with both decals and particles, but haven't gotten around to it yet.
12/04/2008 (5:33 pm)
Nothing that i can think of... the only things which use ShaderGen Materials at the moment are TSShape and Interior. If you fixed the Decal vertex to match that of TSShape you should just be able to create a MaterialInstance and do the same sort of rendering. Just submit them as a MeshRenderInst like in ParticleEmitter::prepBatchRender() with your 'mat' set.
Its something we're meaning to try with both decals and particles, but haven't gotten around to it yet.
#4
12/04/2008 (9:33 pm)
Well I have tried using that technique and those of fXRenderObject and the the best I get is an invisible object.
#5
12/04/2008 (10:43 pm)
Well I found out it is failing for mCurPass >= mPasses.size() when I call MatInstance::setupPass for the material. I am basing the need for that off of every example throughout the code that I have seen and what it provides.
#6
How are you creating the material instance?
12/04/2008 (10:46 pm)
Sounds like the material isn't initialized properly... is mPasses.size() zero? That would be your problem.How are you creating the material instance?
#7
mMaterial is a member of the object and is declared like
MatInstance* mMaterial;
12/05/2008 (12:39 am)
Like this.// Load textures if valid.
if (*mMaterialName)
{
mMaterial = new MatInstance(mMaterialName);
}mMaterial is a member of the object and is declared like
MatInstance* mMaterial;
#8
That is not providing any message so it must be working. I tested it by removing the material from script and the test does work.
12/05/2008 (12:41 am)
Oh yeah I even test it withThat is not providing any message so it must be working. I tested it by removing the material from script and the test does work.
#9
Make sure your using the right vertex type to get the flags... else it will work incorrectly.
12/05/2008 (12:56 am)
You still need to initialize the material. If your using TGEA 1.8 beta you can do this...GFXVertexFlags vertFlags = (GFXVertexFlags)getGFXVertFlags((GFXVertexPNTTB*)NULL ); mMaterial = MaterialManager::get()->createMatInstance(mMaterialName, vertFlags);
Make sure your using the right vertex type to get the flags... else it will work incorrectly.
#10
12/05/2008 (1:58 am)
Well TOm the material is initialized and I am currently working with 1.03 for the moment. However I am very close. I can tell because the object is present, but it is up in the sky and a bit off to the side of the correct location and it is flickering massively. However the textures from the materials are correct. Here is the rendering code, perhaps you can point out my mistake.
#11
Oh and you only have to call mMaterial->init() once... it doesn't need to happen on every render.
12/05/2008 (2:50 am)
GFXVertexFlagUV0 is not a correct set of vertex flags. Use getGFXVertFlags() to generate the correct vertex flags for your geometry.... search the engine for an example of how to do that.Oh and you only have to call mMaterial->init() once... it doesn't need to happen on every render.
#12
How if I comment out the multWorld lines, it shows in the correct location again but the textures are no longer there and all you have is a gray flickering object.
12/05/2008 (3:37 am)
Thanks Tom but it is still flickering and out of place as before even after fixing those two things.How if I comment out the multWorld lines, it shows in the correct location again but the textures are no longer there and all you have is a gray flickering object.
#13
All this stuff.... setBaseRenderState(), disableShaders(), setTextureStageXXX, setTexture, etc isn't needed with materials. With a material it takes care of all that.
Also you should be doing "while( mMaterial->setupPass(sgData) )"... its ment to loop.
12/05/2008 (4:07 am)
Out of position means that most likely how your setting up your matrix is wrong.All this stuff.... setBaseRenderState(), disableShaders(), setTextureStageXXX, setTexture, etc isn't needed with materials. With a material it takes care of all that.
Also you should be doing "while( mMaterial->setupPass(sgData) )"... its ment to loop.
#14
Additionally it seems trying to set different materials for each utilizing the method I am is not going to work either. The second material overides the other material on the the surface it was intended for.
12/05/2008 (2:36 pm)
I figured out why it is crashing, it is because I am calling the two different render sections. It is also the reason why it is flickering when I have ithe while loops only set as if statements.Additionally it seems trying to set different materials for each utilizing the method I am is not going to work either. The second material overides the other material on the the surface it was intended for.
#15
I will have to test the need to init repeatedly because I agree with you Tom, it should not be that way.
What I need to figure out though is how you can get the base and bump from the material.
12/05/2008 (3:13 pm)
OK after reviewing the Blender code I think I see where I am going wrong. In the blender code they did have to init each material each render to allow multiple passes and objects and they set the texture rather that changing the render instance.I will have to test the need to init repeatedly because I agree with you Tom, it should not be that way.
What I need to figure out though is how you can get the base and bump from the material.
#16
Sorry but this is a piece of work that won't be free.
12/05/2008 (8:24 pm)
I have pulled all relevant code as I figured this one out and it was a bit more complicated as I needed to use a shader to pull it off successfully.Sorry but this is a piece of work that won't be free.
Associate Tom Spilman
Sickhead Games