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 »

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.
User avatar
masterfalcon
OGRE Team Member
OGRE Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126
Contact:

Re: Entities, SubEntities and shadow receiver/caster

Post by masterfalcon »

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.
stoulouse
Greenskin
Posts: 116
Joined: Fri Mar 24, 2006 7:15 pm

Re: Entities, SubEntities and shadow receiver/caster

Post by stoulouse »

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?
FlorianGeorge
Halfling
Posts: 86
Joined: Tue Sep 01, 2009 7:15 pm
Location: Cologne, Germany
x 4

Re: Entities, SubEntities and shadow receiver/caster

Post by FlorianGeorge »

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.
stoulouse
Greenskin
Posts: 116
Joined: Fri Mar 24, 2006 7:15 pm

Re: Entities, SubEntities and shadow receiver/caster

Post by stoulouse »

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)...
Post Reply