multiple terra shadows

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Nickak2003
Goblin
Posts: 272
Joined: Thu Jun 10, 2004 4:19 am
x 26

multiple terra shadows

Post by Nickak2003 »

I am rendering multiple terras adjacent to each other. However, when I create a terra there is a function,

Code: Select all

	auto setupTerraShadows = [&]() {
		mHlmsPbsTerraShadows = new Ogre::HlmsPbsTerraShadows();
		mHlmsPbsTerraShadows->setTerra(mTerra);

	//Set the PBS listener so regular objects also receive terrain shadows
	Ogre::Hlms* hlmsPbs = root->getHlmsManager()->getHlms(Ogre::HLMS_PBS);
	hlmsPbs->setListener(mHlmsPbsTerraShadows);
	};

and this listener, I think, only works for one terra at a time? Is this the code I should be using for adjacent terras?

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5477
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1359

Re: multiple terra shadows

Post by dark_sylinc »

Hi!

I missed this forum post.

That's correct. The listener and shader code assumes objects receive shadows from only one Terra.

It could be possible to alter the code to support more than one, but it could be expensive because:

  1. All Terra Heightmaps would have to be bound at the same time

  2. Which Terra to use would have to be determined in the vertex or pixel shader, based on bounds data passed

  3. Which heightmap to pick would have to be chosen dynamically

And possibly other details.

Given that Terrains are often very, very big; the way my team deals with this is to swap the listener when getting close to the edge (with the "pop in/out" that entails).