Forest Pack Q&A
by Kyle Carter · in Torque Game Engine · 10/27/2007 (1:50 am) · 196 replies
In followup to my blog post, please post any questions about the Forest Pack release here.
#42
10/29/2007 (12:25 pm)
It does work, as Ben says, and it works really well. It's nice for my purpose, which is to have trees appear on mountainsides. I can easily specify where trees should be present or absent by painting on the appropriate terrain (snowy vs. rocky).
#43
Now if i can just find out how the tree was made (as far as that detail level).
@Ben, Thank you for this wonderful resource, and thank you for this excellent write up, i hope one day all TGE (or GG) docs are written in such a manor... It really helps! You go through every single parameter (With examples!)and i appreciate it!
10/29/2007 (12:33 pm)
Fantastic! Karen Ho gave me the impression that it did not pay attention to painted textures =)Now if i can just find out how the tree was made (as far as that detail level).
@Ben, Thank you for this wonderful resource, and thank you for this excellent write up, i hope one day all TGE (or GG) docs are written in such a manor... It really helps! You go through every single parameter (With examples!)and i appreciate it!
#44
10/29/2007 (1:58 pm)
Thanks! I'm glad the docs are of use to you. Of course, it wasn't all me - I got help from Tom Spilman and the illustrious Adam deGrandis.
#45
my forest object setting
the outcome still the same, no tree on the painted texture.
i did a debugging on createForest(), the problem is
is there anything wrong in my setting and working procedure? i greatly appreciate any help.
10/30/2007 (9:08 am)
Painted textures do work? very weird it doesn't work on my system. to confirm the problem, i removed all settings in Terrain Texture Editor and i created a big and hard brush size == 25x25 to paint ForestDirt.jpg on the otherwise white color terrain.my forest object setting
%this.addForestEntry("BurningBush", "starter.forest/data/terrains/forest/ForestDirt", 100, 5);
%this.addForestEntry("OakTree01", "starter.forest/data/terrains/forest/ForestGrass", 100, 5);
%this.addForestEntry("OakTree02", "starter.forest/data/terrains/forest/ForestRock", 100, 5);the outcome still the same, no tree on the painted texture.
i did a debugging on createForest(), the problem is
// line 168 if ( (S32)groupNum == (S32)(*entry)->getTileIndex())always return false, getTileIndex() returns 3 on the painted tile, groupNum returns 0, 2 or 4 only.
is there anything wrong in my setting and working procedure? i greatly appreciate any help.
#46
10/30/2007 (11:11 am)
Hmm - and after you painted the terrain you saved the mission and restarted Torque?
#47
See my previous post:
10/30/2007 (1:01 pm)
Karen, do you have any tree created or none at all on other textures?See my previous post:
Quote:2) Until I unchecked single block only, my trees weren't visible, but the collision were performed.
#48
creator/newObject.cs (0): Unable to instantiate non-conobject class ForestClearing.
same error for both the forest and forestclearing.
I have verified that the forestclearing is compiling.
I added the forest.cs and exec'ed it as states in the manual.
did i miss something?
oh and by the way i am using a slightly modded version of stock 1.4.2.
10/30/2007 (1:06 pm)
This is a awesome resource. However i am getting an error when i try to add the forest, and forest clearing:creator/newObject.cs (0): Unable to instantiate non-conobject class ForestClearing.
same error for both the forest and forestclearing.
I have verified that the forestclearing is compiling.
I added the forest.cs and exec'ed it as states in the manual.
did i miss something?
oh and by the way i am using a slightly modded version of stock 1.4.2.
#49
this is my test procedure
1) press Alt-C after the TGEForest tech preview running, this is to gain camera control
2) navigate to the orc village
3) press F11 then select Window->Terrain Texture Painter
4) by default three textures were loaded, the other three were free
5) click on "Add..." button on one of the empty slot and select default.png
6) in Brush menu, select a Box, hard and 25 x 25 size brush
7) use the newly added default.png to paint on terrain, preferably on the forest ground, paint as many as possible
8) go File->save mission...
9) quit the demo program
10 restart the demo program and use alt-c to regain camera control
11) navigate to orc village again
12 forest still shown, eventhough the ground textures have changed to default.png
does this show that TGEForest actually doesnt work with painted texture?
there is a line in TGEForest installation manual
another question, anyone with TGE 1.5.2 able to render TGEForest with color? mine always shown in very dark color.
thanks in advance
10/31/2007 (9:45 am)
I tried few more test cases, painted texture still don't work on my system, therefore i decided to "reverse engineering", do tests on TGEForest demothis is my test procedure
1) press Alt-C after the TGEForest tech preview running, this is to gain camera control
2) navigate to the orc village
3) press F11 then select Window->Terrain Texture Painter
4) by default three textures were loaded, the other three were free
5) click on "Add..." button on one of the empty slot and select default.png
6) in Brush menu, select a Box, hard and 25 x 25 size brush
7) use the newly added default.png to paint on terrain, preferably on the forest ground, paint as many as possible
8) go File->save mission...
9) quit the demo program
10 restart the demo program and use alt-c to regain camera control
11) navigate to orc village again
12 forest still shown, eventhough the ground textures have changed to default.png
does this show that TGEForest actually doesnt work with painted texture?
there is a line in TGEForest installation manual
Quote:should i copy the forest folder into engine/game/fx? i tried, but it couldn't compile
Finally, copy the contents of the code directory into engine/game/fx.
another question, anyone with TGE 1.5.2 able to render TGEForest with color? mine always shown in very dark color.
thanks in advance
#50
Also having the lighting issue mentioned above. Having 30000+ black trees does give my map a haunted atmosphere though.
Other than these two issues, it works great with little performance hit.
11/02/2007 (1:36 am)
Hand painted textures do not work for me either. Using the TerrainTextureEditor the forest is created as expected. But if I use the TerrainTexturePainter to specifically designate areas where I want the forest it doesn't work. Also having the lighting issue mentioned above. Having 30000+ black trees does give my map a haunted atmosphere though.
Other than these two issues, it works great with little performance hit.
#51
I tested various configuration for repainting by "hand", soft brush, hard brush, I even switched the textures and ended with an empty terrain (without any trees).
Nice catch Karen! ;-)
11/02/2007 (2:26 am)
Karen and silentMike pointed to something I had not noticed, being too much excited.I tested various configuration for repainting by "hand", soft brush, hard brush, I even switched the textures and ended with an empty terrain (without any trees).
Nice catch Karen! ;-)
#52
Its been my experience in the past that the two texturing techniques have been treated differently in the past..this is why i asked.
11/02/2007 (11:29 am)
AH HA! . lol.Its been my experience in the past that the two texturing techniques have been treated differently in the past..this is why i asked.
#53
i tried to use mMaterialAlphaMap (no idea what is this, but terrain path following uses this to detect terrain texture) to determine terrain texture, but no luck so far
11/02/2007 (12:52 pm)
Good t know that i'm not alone :)i tried to use mMaterialAlphaMap (no idea what is this, but terrain path following uses this to detect terrain texture) to determine terrain texture, but no luck so far
#54
I'll spend some time this weekend to get the texture painting and lighting issues sorted out. Expect an update around Monday. Thanks for digging into this!
Ben
11/02/2007 (1:00 pm)
Hey guys,I'll spend some time this weekend to get the texture painting and lighting issues sorted out. Expect an update around Monday. Thanks for digging into this!
Ben
#55
11/03/2007 (11:55 am)
Fantastic, i have faith you will figure it out.
#56
A quick status update. I fixed the terrain material detection (now uses the strongest terrain texture in a given location to place the trees). I'm working on tracking down the lighting issue. It looks like there's a missing 2x multiplier in lighting intensity somewhere that got added by the TLK - you can look carefully and actually see that parts of the tree meshes are being lit, just super-dimly.
It also appears that some billboards are generated with erroneous alpha (so billboards are half-translucent). Has anyone else seen this?
Ben
11/04/2007 (4:50 pm)
Hey guys,A quick status update. I fixed the terrain material detection (now uses the strongest terrain texture in a given location to place the trees). I'm working on tracking down the lighting issue. It looks like there's a missing 2x multiplier in lighting intensity somewhere that got added by the TLK - you can look carefully and actually see that parts of the tree meshes are being lit, just super-dimly.
It also appears that some billboards are generated with erroneous alpha (so billboards are half-translucent). Has anyone else seen this?
Ben
#57
I get some lighting, but some not.
11/04/2007 (5:26 pm)
Here is what I see using this kit in the tge 1.5.2 starter.fps and using the terrain and demo provided with the pack.I get some lighting, but some not.
#58
First, go to line 140 of forestRender.cc in Forest::initMaterials() and make sure that the code looks like this:
That's a generally good change.
The sketchier bit is at line 74 of forestRenderMesh.cc. Comment out the entire block of fogging-related code so it looks like this:
Now nearby stuff will light correctly (I hope). But stuff will go to black when transitioning. It looks like when the lighting kit went in, some GL state got shuffled around and I'm still in the process of figuring out exactly what changed.
This ought to improve things quite a bit.
The fix for the materials is on line 148 of forestCreation.cc. Change this line:
to this:
Now the forest should respect the actual painted materials on the terrain.
Ok - that's it for tonight. Once I get the lighting issue nailed down, I'll do an update to the code drop on TDN so you don't have to manually sync up to the fixes in this thread.
11/04/2007 (6:02 pm)
Here's a temporary fix for the lighting issues.First, go to line 140 of forestRender.cc in Forest::initMaterials() and make sure that the code looks like this:
// we modulate in order to apply lighting... glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE); LightManager::sgSetupExposureRendering(); // <- potentially missing line // but we don't blend by default... glDisable(GL_BLEND); glDepthMask(GL_TRUE);
That's a generally good change.
The sketchier bit is at line 74 of forestRenderMesh.cc. Comment out the entire block of fogging-related code so it looks like this:
si->setEnvironmentMap(smState->getEnvironmentMap());
si->setEnvironmentMapOn(true,1);
// fog
/* U32 fm = TSShapeInstance::NO_FOG;
if (fi->getFogged())
fm = TSShapeInstance::FOG_MULTI_1;
{
glActiveTextureARB(GL_TEXTURE0_ARB + TSShapeInstance::smRenderData.fogTE);
if ((U32)TSShapeInstance::smRenderData.fogMethod != fm)
{
if (fm == TSShapeInstance::NO_FOG)
glDisable(GL_TEXTURE_2D);
else
glEnable(GL_TEXTURE_2D);
}
Point4F fog(TSShapeInstance::smRenderData.fogColor);
F32 fogAmount = fi->getFogAmount();
fog.w = fogAmount;
glTexEnvfv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_COLOR,fog);
// the ATI Rage 128 (amoung others) can't do constant alpha blend
if (TSShapeInstance::smRenderData.fogTexture &&
TSShapeInstance::smRenderData.fogColor.w != fogAmount)
{
U8 *bits = TSShapeInstance::smRenderData.fogBitmap->getWritableBits();
U8 fog = 255 * fogAmount;
for (U8 i = 0; i < 64; ++i)
{
bits[3] = fog;
bits += 4;
}
TSShapeInstance::smRenderData.fogHandle->refresh();
}
glActiveTextureARB(GL_TEXTURE0_ARB + TSShapeInstance::smRenderData.baseTE);
}
TSShapeInstance::smRenderData.fogColor.w = fi->getFogAmount();
TSShapeInstance::smRenderData.fogMethod = fm;
*/
// set up render data
TSShapeInstance::smRenderData.detailLevel = dl;
TSShapeInstance::ObjectInstance::smTransforms = si->mNodeTransforms.address();
const TSShape * shape = si->getShape();Now nearby stuff will light correctly (I hope). But stuff will go to black when transitioning. It looks like when the lighting kit went in, some GL state got shuffled around and I'm still in the process of figuring out exactly what changed.
This ought to improve things quite a bit.
The fix for the materials is on line 148 of forestCreation.cc. Change this line:
groupNum = terrain->getBaseMaterial(x, y);
to this:
// What kind of terrain tile are we on?
U8 alphas[TerrainBlock::MaterialGroups];
terrain->getMaterialAlpha(Point2I(x, y), alphas);
S32 maxMat = 0, maxMatIdx = 0;
for(S32 curMat=0; curMat<TerrainBlock::MaterialGroups; curMat++)
{
if(alphas[curMat] > maxMat)
{
maxMat = alphas[curMat];
maxMatIdx = curMat;
}
}
groupNum = maxMatIdx;Now the forest should respect the actual painted materials on the terrain.
Ok - that's it for tonight. Once I get the lighting issue nailed down, I'll do an update to the code drop on TDN so you don't have to manually sync up to the fixes in this thread.
#59
11/04/2007 (11:15 pm)
Thanks Ben. 8-)
#60
i found a solution for the lighting problem, without knowing the theory behind, my solution is
i don't know is this the best solution, and did i notice the tree color is a bit wash out now, i also wonder what will happen in night scene
11/05/2007 (6:07 am)
Wonderful, this fix the painter texture problem completely, now i know what does mMaterialAlpha do, it stores the alpha values of the eight terrain textures, i should had known it earlier, the name is so obviousi found a solution for the lighting problem, without knowing the theory behind, my solution is
// we modulate in order to apply lighting... glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE); LightManager::sgSetupExposureRendering(); // <- potentially missing line // but we don't blend by default... glDisable(GL_BLEND); glDepthMask(GL_TRUE); // lighting? TSShapeInstance::smRenderData.lightingOn = glIsEnabled(GL_LIGHTING); // set vertex color TSShapeInstance::smRenderData.vertexAlpha.set(); Point4F vertexColor(1,1,1,TSShapeInstance::smRenderData.vertexAlpha.current); glColor4fv(vertexColor); glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,vertexColor); LightManager::sgResetExposureRendering(); // **** add this magic line // this should be off by default, but we'll end up turning it on asap... glDisable(GL_TEXTURE_2D);
i don't know is this the best solution, and did i notice the tree color is a bit wash out now, i also wonder what will happen in night scene
Associate Kyle Carter