Entities, SubEntities and shadow receiver/caster

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
Post Reply
stoulouse
Greenskin
Posts: 116
Joined: Fri Mar 24, 2006 7:15 pm

Entities, SubEntities and shadow receiver/caster

Post by stoulouse » Sat Feb 02, 2013 6:04 pm

i've modified ogre source because it looks like some shadow receiver/caster flag was not checked correctly, here is what i've done:
in file OgreEntity.cpp, visitRenderables i've added visibility testing flag:

Code: Select all

 	void Entity::visitRenderables(Renderable::Visitor* visitor, 
 		bool debugRenderables)
 	{
 		// Visit each SubEntity
 		for (SubEntityList::iterator i = mSubEntityList.begin(); i != mSubEntityList.end(); ++i)
 		{
-			visitor->visit(*i, 0, false);
+			if ((*i)->isVisible())
+				visitor->visit(*i, 0, false);
 		}
 		// if manual LOD is in use, visit those too
 		ushort lodi = 1;
 		for (LODEntityList::iterator e = mLodEntityList.begin(); 
 			e != mLodEntityList.end(); ++e, ++lodi)
 		{
 			
 			uint nsub = (*e)->getNumSubEntities();
 			for (uint s = 0; s < nsub; ++s)
 			{
-				visitor->visit((*e)->getSubEntity(s), lodi, false);
+				if ((*e)->getSubEntity(s)->isVisible())
+					visitor->visit((*e)->getSubEntity(s), lodi, false);
 			}
 		}
 
 	}
so that only visible subentities are added to the renderable list.

then i've modified OgreSceneManager.cpp, validateRenderableForRendering:

Code: Select all

 bool SceneManager::validateRenderableForRendering(const Pass* pass, const Renderable* rend)
 {
     // Skip this renderable if we're doing modulative texture shadows, it casts shadows
     // and we're doing the render receivers pass and we're not self-shadowing
 	// also if pass number > 0
     if (!mSuppressShadows && mCurrentViewport->getShadowsEnabled() &&
 		isShadowTechniqueTextureBased())
 	{
-		if (mIlluminationStage == IRS_RENDER_RECEIVER_PASS && 
+		if (mIlluminationStage == IRS_RENDER_RECEIVER_PASS &&
+			!rend->getMaterial()->getReceiveShadows())
+		{
+			return false;
+		}
+		if (mIlluminationStage == IRS_RENDER_RECEIVER_PASS &&
 			rend->getCastsShadows() && !mShadowTextureSelfShadow)
 		{
 			return false;
 		}
 		// Some duplication here with validatePassForRendering, for transparents
 		if (((isShadowTechniqueModulative() && mIlluminationStage == IRS_RENDER_RECEIVER_PASS)
 			|| mIlluminationStage == IRS_RENDER_TO_TEXTURE || mSuppressRenderStateChanges) && 
 			pass->getIndex() > 0)
 		{
 			return false;
 		}
     }
because the renderable was added to the shadow receiver list without having been tested if he can receive shadows or not.

are those modifications correct? in my case the opengl frame doesn't show up anymore unnecessary draw call for not visible subentities and only shadow receiver meshes are renderer with shadows.
0 x

User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
Contact:

Re: Entities, SubEntities and shadow receiver/caster

Post by masterfalcon » Sat Feb 02, 2013 6:31 pm

The changes look reasonable. Do you have any concerns? Does everything appear correct to you? If so would you be able to create a pull request? Thanks.
0 x

stoulouse
Greenskin
Posts: 116
Joined: Fri Mar 24, 2006 7:15 pm

Re: Entities, SubEntities and shadow receiver/caster

Post by stoulouse » Sun Feb 03, 2013 5:12 pm

the problem is the commit on my repository contains several modification not only this. it includes also the RTSS/Multiple Shadow bug fix, is there a way to pull the request for only one file?
0 x

FlorianGeorge
Halfling
Posts: 86
Joined: Tue Sep 01, 2009 7:15 pm
Location: Cologne, Germany

Re: Entities, SubEntities and shadow receiver/caster

Post by FlorianGeorge » Thu Feb 07, 2013 5:25 pm

stoulouse wrote:the problem is the commit on my repository contains several modification not only this. it includes also the RTSS/Multiple Shadow bug fix, is there a way to pull the request for only one file?
Not sure about the one file request, but you could create a seperate fork that only containes these fixes (copy the files or export...import the patches) unless they themselves require other previous unsubmitted modifications in the repository.
0 x

stoulouse
Greenskin
Posts: 116
Joined: Fri Mar 24, 2006 7:15 pm

Re: Entities, SubEntities and shadow receiver/caster

Post by stoulouse » Sun Feb 10, 2013 7:00 pm

i can do that, but how to maintain a local repository with all my changes in that case. and if i have on local repository with all my changes and then create a fork for each commit and the send pull request and wait for approval, it means i'll have 13 local copy of ogre (one for my usage and 12 for my pending commits)...
0 x

Post Reply