Objects not receiving stencilshadows

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
shogun
Posts: 162
Joined: Wed Sep 05, 2007 11:02 am
Location: inside

Objects not receiving stencilshadows

Post by shogun »

Hello,

I'm sorry, but my problem with objects which shouldn't receive shadows is still existent. So I tried to modify Irrlicht directly by just adding a second renderpass for solid objects (after the one which draws the shadowvolumes!) and succeded somehow. Of course I had to add a "bool IsShadowReceiver" to the ISceneNode, so I have to say "node->SetShadowReceiver(true)" if I want my object to receive shadows, otherwise it's drawn after the shadow volumes.

As I'm not a real programmer my solution has still problems: the shadows now have some strange flickering (a screenshot here wouldn't suffice, one can see it only in motion). Perhaps somebody who works at the engine knows why.

Regards,
shogun
bull
Posts: 36
Joined: Wed Sep 12, 2007 8:49 am
Location: s1Ng4p0R3

Post by bull »

You should post your modification so everyone could see what is wrong.
shogun
Posts: 162
Joined: Wed Sep 05, 2007 11:02 am
Location: inside

Post by shogun »

You're right ...

Here's my modificated CSceneManager.cpp:

Code: Select all

// ...
u32 CSceneManager::registerNodeForRendering(ISceneNode* node, E_SCENE_NODE_RENDER_PASS time)
{
	// ...
	switch(time)
	{
		// ...
		case ESNRP_SOLID:
		if (!isCulled(node))
		{
			if (node->isShadowReceiver())
				SolidShadowReceiverNodeList.push_back( node );
			else
				SolidNonReceiverNodeList.push_back( node );
			taken = 1;
		}
		break;

	// ...

	case ESNRP_AUTOMATIC:
		if (!isCulled(node))
		{
			// ...

			// not transparent, register as solid
			if ( 0 == taken )
			{
				if (node->isShadowReceiver())
					SolidShadowReceiverNodeList.push_back( node );
				else
					SolidNonReceiverNodeList.push_back( node );

				taken = 1;
			}
		}
		break;

	// ... etc. ...



void CSceneManager::drawAll()
{
	// ...

	// render default objects, receiving shadows
	{
		CurrentRendertime = ESNRP_SOLID;
		SolidShadowReceiverNodeList.sort(); // sort by textures

		for (i=0; i<SolidShadowReceiverNodeList.size(); ++i)
			SolidShadowReceiverNodeList[i].node->render();

		Parameters.setAttribute ( "drawn", (s32) SolidShadowReceiverNodeList.size () );

		SolidShadowReceiverNodeList.set_used(0);
	}

	// render shadows
	{
		CurrentRendertime = ESNRP_SHADOW;
		for (i=0; i<ShadowNodeList.size(); ++i)
			ShadowNodeList[i]->render();

		if (!ShadowNodeList.empty())
			Driver->drawStencilShadow(true,ShadowColor, ShadowColor,
				ShadowColor, ShadowColor);

		ShadowNodeList.set_used(0);
	}

	// render default objects, not receiving shadows
	{
		CurrentRendertime = ESNRP_SOLID;
		SolidNonReceiverNodeList.sort(); // sort by textures

		for (i=0; i<SolidNonReceiverNodeList.size(); ++i)
			SolidNonReceiverNodeList[i].node->render();

		Parameters.setAttribute ( "drawn", (s32) SolidNonReceiverNodeList.size () );

		SolidNonReceiverNodeList.set_used(0);
	}

	// ... etc. ...
That's it. "SolidShadowReceiverNodeList" and "SolidNonReceiverNodeList" are just two core::array<DefaultNodeEntry> Arrays, the old "SolidNodeList" is deleted. "IsShadowReceiver" in includes\ISceneNode.h works like IsVisible, so it's not needed to post it.
Post Reply