Horde3D http://horde3d.org/forums/ |
|
Procedural geometry normals http://horde3d.org/forums/viewtopic.php?f=2&t=1491 |
Page 1 of 1 |
Author: | polygoff [ 08.04.2011, 10:59 ] |
Post subject: | Procedural geometry normals |
I'm trying to use this codesniplet here The generated geometry looks fine at first, but when I apply a material with normalmapping (for example the rock texture from the samples), the quad just becomes a single brown solid. I tried changing the normalData around, but the problem persists. How can I analyze this error further? |
Author: | worstplayer [ 08.04.2011, 12:51 ] |
Post subject: | Re: Procedural geometry normals |
Looks like the geometry is missing tangent data, maybe that's the problem? |
Author: | polygoff [ 08.04.2011, 20:46 ] |
Post subject: | Re: Procedural geometry normals |
Trying to add that does not seem to help. I might be doing it wrong though. Here is a full snippet which should be copy&pasteable into any Horde3D setup (but don't work): Code: void StateGame::createSimpleGeometryRes() {
// Cache the resources H3DRes matRes = h3dAddResource(H3DResTypes::Material, "models/stone/stone.material.xml", 0); h3dutLoadResourcesFromDisk( _params->ContentDirectory.c_str() ); // Create the needed data for a simple quad that is textured on both sides float posData[] = { 0, 0, 0, 100, 0, 0, 0, 100, 0, 100, 100, 0 }; unsigned int vertexCount = 4; unsigned int indexData[] = { 0,1,2, 2,1,3, 3,1,2, 2,1,0 }; unsigned int triangleIndexCount = 12; unsigned int triangleIndexMax = 3; short normalData[] = { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1 }; short tangentData[] = { 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 }; short bitangentData[] = { 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0 }; float uvData[] = { 0, 0, 1, 0, 0, 1, 1, 1 }; H3DRes geoRes = h3dutCreateGeometryRes("geoRes", vertexCount, triangleIndexCount, posData, indexData, normalData, tangentData, bitangentData, uvData, 0); H3DNode model = h3dAddModelNode( H3DRootNode, "DynGeoModelNode", geoRes ); h3dAddMeshNode( model, "DynGeoMesh", matRes, 0, triangleIndexCount, 0, triangleIndexMax ); //h3dSetNodeTransform( model, 0,0,0, 0,40,0, 1,1,1 ); } |
Author: | worstplayer [ 15.04.2011, 12:50 ] |
Post subject: | Re: Procedural geometry normals |
Did some more experimenting. Yeah, setting tangent data in CreateGeometryRes doesn't work for me either. But it works from MapResStream. Strange. |
Author: | AlexL [ 15.04.2011, 17:18 ] |
Post subject: | Re: Procedural geometry normals |
Change line 680 in Horde3DUtils/main.cpp from Code: // Set number of streams to *( (uint32 *)pData ) = 1 + numTexSets + ( normalData ? 1 : 0 ); pData += sizeof( uint32 ); Code: // Set number of streams
*( (uint32 *)pData ) = 1 + numTexSets + ( normalData ? 1 : 0 ) + ((tangentData && bitangentData) ? 2 : 0); pData += sizeof( uint32 ); |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |