H: Material will not show up

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
Post Reply
Van
Hobgoblin
Posts: 512
Joined: Fri Nov 19, 2004 3:56 am
Contact:

H: Material will not show up

Post by Van »

Ogre: Dagon 1.2(RC2)

We are creating a planet using the createsphere() from the wiki. We actually create three spheres. Each one 5% large than the previous sphere and all three spheres are centered at the same location. So you have sphere inside a sphere, inside a sphere. We assign a material to each sphere. The first (inner) gets the land mass material; the second (middle) gets the cloud material; and the third (outter) gets the atmosphere/haze material. The problem? The problem is our second (clouds) and third (atmosphere) materials don't show up at all!

Our only lightsource is configured as:

Code: Select all

	mLight->setAttenuation(
		_SECTORSIZE_M,	// range - The absolute upper range of the light in world units. (Don't use -1 !!!! )
		1.0f,			// constant - The constant factor in the attenuation formula: 1.0 means never attenuate, 0.0 is complete attenuation.
		1.0f,			// linear - The linear factor in the attenuation formula: 1 means attenuate evenly over the distance.
		0.0f			// quadratic - The quadratic factor in the attenuation formula: adds a curvature to the attenuation formula.
	);

	// Set the type of light this is
	mLight->setType( Ogre::Light::LT_POINT );

	// In all cases, set these light values
	mLight->setDiffuseColour( Ogre::ColourValue::White );		// Default to white
	mLight->setSpecularColour( Ogre::ColourValue::White );		// Default to white

Material Script: Note that there are three definitions, one for each sphere.

Code: Select all


material Celestial/Planet/Surface/Default
{
  technique HLSL_DX9
  { 
    pass 
    { 
       
      vertex_program_ref FxMap_HLSL_VS 
      { 
        param_named_auto worldViewProj_matrix worldviewproj_matrix 
        param_named_auto lightPosition light_position_object_space 0 
        param_named_auto eyePosition camera_position_object_space 
      } 

      fragment_program_ref FxMap_HLSL_PS 
      { 
        param_named ambientColor float4 1 1 1 1
      } 

      // Normal map 
      texture_unit 
      { 
        texture Planet01_nor.tga
        tex_coord_set 0 
        filtering trilinear 
      } 

      // Base diffuse texture map 
      texture_unit 
      { 
        texture planet01_diffuse.dds
		rotate_anim .05
        filtering trilinear 
        tex_coord_set 1 
      } 

      // Fx map for specular intensity, specular size, diffuse intensity, emissive intensity 
      texture_unit 
      { 
        texture planet01_spec.dds
        filtering trilinear 
        tex_coord_set 2 
      } 
    } 
  } 
} 

// ***************************************************************************

material Celestial/Planet/Clouds/Default
{
	technique
	{
		pass
		{	
			depth_write off
			scene_blend colour_blend
			ambient 0 0 0 0
			diffuse 1 1 1 1
			specular 0 0 0 1 0
			emissive 0 0 0 0
			texture_unit
			{
				texture	planet02_clouds.dds
				scroll_anim .1 0
				tex_address_mode wrap
				filtering trilinear
			}
			
		}
	}
}

// ***************************************************************************

material Celestial/Planet/Atmosphere/Default
{
	technique
	{
		pass
		{	
			depth_write off
			scene_blend colour_blend
			ambient 0 0 0  0
			diffuse 1 1 1 1 
			specular 0 0 0 1 0
			emissive 0 0 0 0
			texture_unit
			{
				texture	planet02_air.dds
				tex_address_mode wrap
				filtering trilinear
			}
		}
	}
}


We searched the Wiki and forums and found some similar posts have have added buildTangentVectors() and setNormaliseNormals() functions to the manually created sphere meshes however those changes didn't yield any results:

Code: Select all


	// Create the Ogre Mesh
	createSphereMesh( mUniqueName, mSphereRadius, mSphereRings, mSphereSegments );

	// Create the Ogre Entity
	Ogre::Entity *mEntity = mSceneMgr->createEntity( mUniqueName, mUniqueName );
	if ( !mEntity ) return false;

	// Build Vertex Data - this is for biteme
	// TODO: Remove?
	unsigned short src, dest;
	Ogre::MeshPtr pMesh = mEntity->getMesh();
	if ( !pMesh->suggestTangentVectorBuildParams(src, dest) )
		pMesh->buildTangentVectors( src, dest);

	mEntity->setNormaliseNormals( true );


Perhaps someone can see what we are doing wrong.
Van
Hobgoblin
Posts: 512
Joined: Fri Nov 19, 2004 3:56 am
Contact:

Post by Van »

Update.

We set the linear to zero in our lightsource and that fixed our problem. The material is now appearing.
Post Reply