Page 1 of 1

Entities, SubEntities and shadow receiver/caster

Posted: Sat Feb 02, 2013 6:04 pm
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.

Re: Entities, SubEntities and shadow receiver/caster

Posted: Sat Feb 02, 2013 6:31 pm
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.

Re: Entities, SubEntities and shadow receiver/caster

Posted: Sun Feb 03, 2013 5:12 pm
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?

Re: Entities, SubEntities and shadow receiver/caster

Posted: Thu Feb 07, 2013 5:25 pm
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.

Re: Entities, SubEntities and shadow receiver/caster

Posted: Sun Feb 10, 2013 7:00 pm
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)...