detail textures and lod_level

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
Post Reply
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

detail textures and lod_level

Post by Vectrex »

does material lod_level actually work? I think I'm on the wrong track but even so it appears not to work (automatically anyway).
I'm trying to make detail texture that is only visible close up. It'd be nice if it faded in but just appearing would do.
Now this lod_level material thing, does that effect the whole mesh when it selects another technique? If it does then it'd be no good for detail textures.
Perhaps if I emptied the detail textures lower mip maps the graphics card would do it for me (would this still be processed further away?)
Any other strategies?

this is the material (first technique with detail texture, 2nd just plain)
[EDIT] fixed errors, still doesn't do anything

Code: Select all

material 09_-_Default
{
	lod_distances 500 1000
	technique
	{
		lod_index 0
		pass
		{
			ambient 1.0 1.0 1.0
			diffuse 1.0 1.0 1.0
			specular 0.1 0.1 0.1 40
			emissive 0.0 0.0 0.0
			scene_blend one zero
			depth_check on
			depth_func less_equal
			depth_write on
			depth_bias 0
			cull_software back
			lighting on
			fog_override false
			shading phong
			colour_write on

			texture_unit
			{
				texture tarmac.jpg 2d
				tex_address_mode wrap
				filtering linear linear point
				colour_op modulate
				scroll 0.0 0.0
				scale 1.0 1.0
				rotate 0.0
			}

			texture_unit
			{
				texture asphalt_004.jpg 2d
				tex_address_mode wrap
				filtering linear linear point
				colour_op_ex modulate_x2 src_texture src_current
				colour_op_multipass_fallback one one
				scroll 0.0 0.0
				scale 0.1 0.1
				rotate -28.0
			}
		}
	}
	technique
	{
		lod_index 1
		pass
		{
			ambient 1.0 1.0 1.0
			diffuse 1.0 1.0 1.0
			specular 0.5 0.5 0.5 40
			emissive 0.0 0.0 0.0
			scene_blend one zero
			depth_check on
			depth_func less_equal
			depth_write on
			depth_bias 0
			cull_software back
			lighting on
			fog_override false
			shading phong
			colour_write on

			texture_unit
			{
				texture Grass.jpg 2d
				tex_address_mode wrap
				filtering linear linear point
				colour_op modulate
				scroll 0.0 0.0
				scale 1.0 1.0
				rotate 0.0
			}
		}
	}
}

Last edited by Vectrex on Fri Sep 09, 2005 11:38 am, edited 4 times in total.
User avatar
regress
Halfling
Posts: 78
Joined: Sat Mar 26, 2005 8:39 pm

Post by regress »

I'm also curious about this...anyone that can comment?
regards
User avatar
BenO
Goblin
Posts: 241
Joined: Mon Apr 18, 2005 5:03 pm

Post by BenO »

really interesting \o/ waiting for details :P
Benjamin RIGAUD
Software Engineer
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

Post by Vectrex »

this is the type of detail texture i'm talking about actually. The small rocks are a second pass, but at a distance it looks nasty and repetitive

Image
User avatar
Chris Jones
Lich
Posts: 1742
Joined: Tue Apr 05, 2005 1:11 pm
Location: Gosport, South England
x 1

Post by Chris Jones »

wow, nice road texture :P
User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
x 4
Contact:

Post by tuan kuranes »

Isn't it actually implemented only on entities ?

So if your object derived from Renderable, MovableObject or SimpleRenderable you won't get it.

You have to override the _notifyCurrentCamera( Camera* cam ) to something like

Code: Select all

void MyMovableObject::_notifyCurrentCamera( Camera* cam )
 {
  MovableObject::_notifyCurrentCamera(cam);
  // Material LOD
  if ( mMaterial->getNumLodLevels() > 1 )
    mMaterialLODIndex = mMaterial->getLodIndexSquaredDepth(getSquaredViewDepth(cam));
}
and override getTechnique

Code: Select all

Technique* myMovableObject::getTechnique(void) const
{
  return mMaterial->getBestTechnique (mMaterialLODIndex);
}
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

Post by Vectrex »

ah I see. If this is the case then it'll be no good for detail textures (well for my specific case anyway) and the manual should definately be updated to explain this, espeically if it's not automatic and you have to do others things to get it to work.
In that case how would you suggest to do this? Wumpus' custom mipmap in dagon could do it I guess, by blanking out the lower mips.
I also guess the terrain engine devs would know how (I read one tecnique for measuring distance to nearby vertex points)
User avatar
Jon
Goblin
Posts: 227
Joined: Mon Oct 10, 2005 5:07 am
Location: Texas

Post by Jon »

Forgive me if I am flogging a dead horse, I am at the point where I know just enough to confuse everyone around me... But I saw this thread and wonder if there is another problem here.

When one specifies multiple lod_distances like

Code: Select all

   lod_distances 500 1000
This would imply the existance of three lod indexes, right?

Index 0 from distance 0 to 500
Index 1 from distance 500 to 1000
Index 2 from distance 1000 to infinity

The original material only had two lod indexes, and I'm curious what happens in this case.
Bringer of Darkness
Halfling
Posts: 98
Joined: Thu May 05, 2005 3:57 pm

Post by Bringer of Darkness »

Hm, it works fine for me without any adjustments needed...
Though I have used only one LOD level
lod_distances 250
Bringer of Darkness
Halfling
Posts: 98
Joined: Thu May 05, 2005 3:57 pm

Post by Bringer of Darkness »

Hm, it works fine for me without any adjustments needed...
Though I have used only one LOD level
lod_distances 250

The only problem I realized is, that possibly LOD distinction is calculated based upon the distance of the object from camera, not a pixel from camera - I understand that it would be different and more difficult, though it looks weird when the whole objects "jumps" to the new technique...
Post Reply