Spline Road Material Problems
by Ronald J Nelson · in Torque Game Engine Advanced · 02/03/2009 (9:33 pm) · 46 replies
I have been working to make a spline or procedural road system use materials. So far I can get it to almost work perfectly when using Custom Materials that in my current example use the DiffuseBump shader. However I am having some initialization issues I am hoping someone can help me with. I am posting some screenshots, my rendering code, and my materials to show what I have done and to help illustrate my issue. Now I am doing my work for my game in TGEA 1.03 but having also been porting it to the newer versions for a later release and the problem is present in all versions.
First the starting issue is this:


As you can see changing camera angles effects the problem.
When you look closely you can see that the shader is working.

Now if I use spectator mode to run around the track and pass up and down through the object a couple of times the problem fixes itself.

***CODE REMOVED***
I am sure this is probably something simple, but I am not seeing it yet. Also, I have tried this on multiple computers with different hardware and the problem is pretty consistent in all cases.
First the starting issue is this:


As you can see changing camera angles effects the problem.
When you look closely you can see that the shader is working.

Now if I use spectator mode to run around the track and pass up and down through the object a couple of times the problem fixes itself.

***CODE REMOVED***
I am sure this is probably something simple, but I am not seeing it yet. Also, I have tried this on multiple computers with different hardware and the problem is pretty consistent in all cases.
#42
02/19/2009 (8:06 pm)
Don't know what happened but this thing started double posting on me and they don't have the delete post option out yet.
#43

Here is the current render code, its all pretty standard stuff as done in alot of other areas.
03/05/2009 (7:39 pm)
Well I am very close but am having one final issue that I have yet to figure out. I am getting an unstable render and the video below will explain it better.
Here is the current render code, its all pretty standard stuff as done in alot of other areas.
//---------------------------------------------------------------------------------------------
//GFX Setup
//---------------------------------------------------------------------------------------------
GFX->pushState();
GFX->pushWorldMatrix();
MatrixF proj = GFX->getProjectionMatrix();
MatrixF world = GFX->getWorldMatrix();
proj.mul(world);
proj.transpose();
gClientSceneGraph->getLightManager()->sgSetupLights(this);
SceneGraphData sgData;
// Store object and camera transform data
sgData.objTrans = getRenderTransform();
sgData.camPos = state->getCameraPosition();
// fog
sgData.useFog = true;
sgData.fogTex = gClientSceneGraph->getFogTexture();
sgData.fogHeightOffset = gClientSceneGraph->getFogHeightOffset();
sgData.fogInvHeightRange = gClientSceneGraph->getFogInvHeightRange();
sgData.visDist = gClientSceneGraph->getVisibleDistanceMod();
// grab the sun data from the light manager
const LightInfo *sunlight = gClientSceneGraph->getLightManager()->sgGetSpecialLight(LightManager::sgSunLightType);
sgData.light = *sunlight;
// misc
sgData.backBuffTex = GFX->getSfxBackBuffer();
//Set Shader info
GFX->setVertexShaderConstF( 0, (float*)&proj, 4 ); //C0
// Set up rendering state
GFX->setCullMode( GFXCullCCW );
initMainBuffer();
GFX->setVertexBuffer(vertMBuff);
GFXVertexPNTTBN *vert = NULL;
mMaterial->init(sgData, (GFXVertexFlags)getGFXVertFlags(vert));
while(mMaterial->setupPass(sgData))
{
GFX->setShader( mRoadShader->shader );
GFX->drawPrimitive(GFXTriangleStrip, 0, mRoadArray.size()-2);
}
GFX->setCullMode( GFXCullCCW );
initSideABuffer();
GFX->setVertexBuffer(vertABuff);
vert = NULL;
mEdgeAMaterial->init(sgData, (GFXVertexFlags)getGFXVertFlags(vert));
while(mEdgeAMaterial->setupPass(sgData))
{
GFX->setShader( mRoadShader->shader );
GFX->drawPrimitive(GFXTriangleStrip, 0, mRoadEdgeArray_a.size()-2);
}
GFX->setCullMode( GFXCullCCW );
initSideBBuffer();
GFX->setVertexBuffer(vertBBuff);
vert = NULL;
mEdgeBMaterial->init(sgData, (GFXVertexFlags)getGFXVertFlags(vert));
while(mEdgeBMaterial->setupPass(sgData))
{
GFX->setShader( mRoadShader->shader );
GFX->drawPrimitive(GFXTriangleStrip, 0, mRoadEdgeArray_b.size()-2);
}
mMaterialUpdate = false;
//gClientSceneGraph->getLightManager()->sgResetLights();
GFX->popWorldMatrix();
GFX->popState();
#44
03/08/2009 (9:21 pm)
OK does anyone have a suggestion on what could be causing this? I don't expect anyone to do the work for me, I am just a bit confused on why it is happening.
#45
03/12/2009 (1:40 pm)
How did you get the collision working?
#46
This actually not your code,but Duncan's completely different Spline Road system. The priciples are the same but the implementation is vastly different. Once I finish a couple more things we will be looking into sales.
I can only tell you it is an opcode polysoup collision system, but due to the differences, it would not have worked with your fxRoad system. All I can say is that when I tried to do it on your road, I was thinking way too small.
03/12/2009 (4:28 pm)
Dan - I didn't, Duncan Gray pulled this one off. I just joined together with him to do the rendering and some other stuff. Which as it turns out I have got most of it done. This actually not your code,but Duncan's completely different Spline Road system. The priciples are the same but the implementation is vastly different. Once I finish a couple more things we will be looking into sales.
I can only tell you it is an opcode polysoup collision system, but due to the differences, it would not have worked with your fxRoad system. All I can say is that when I tried to do it on your road, I was thinking way too small.
#47
03/12/2009 (4:31 pm)
I forgot to mention, the problems I was having was actually due to the fact that I was still trying to use TGEA 1.03 for this. The newer versions render state and lighting code is much better and has made it possible to get it working.
Torque Owner Ronald J Nelson
Code Hammer Games