Shader Base Material

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
CuteAlien
Admin
Posts: 9644
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Shader Base Material

Post by CuteAlien »

Small note: If you code include files, be careful that if you set versions in your shaders those still have to be first line - even before includes (stuff like #version 430 compatibility).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Seven
Posts: 1030
Joined: Mon Nov 14, 2005 2:03 pm

Re: Shader Base Material

Post by Seven »

thanks for the heads up!
CuteAlien
Admin
Posts: 9644
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Shader Base Material

Post by CuteAlien »

I just run into the same problem that I needed the node per material (to figure out if I have non-uniform scaling). Turns out there is a pretty simple solution already: Use an ILightManager.
Like:

Code: Select all

class MyLightManager : public irr::scene::ILightManager
{
public:
	virtual void OnPreRender(irr::core::array<irr::scene::ISceneNode*>& lightList) {}
	virtual void OnPostRender(void) {}
	virtual void OnRenderPassPreRender(irr::scene::E_SCENE_NODE_RENDER_PASS renderPass) {}
	virtual void OnRenderPassPostRender(irr::scene::E_SCENE_NODE_RENDER_PASS renderPass) {}
	virtual void OnNodePreRender(irr::scene::ISceneNode* node)
	{
		CurrentNode = node;
	}
	virtual void OnNodePostRender(irr::scene::ISceneNode* node)
	{
		CurrentNode = 0;
	}

	irr::scene::ISceneNode* CurrentNode = 0;
};
Set that in the SceneManager and then CurrentNode will always have the node rendered right now.
And then give your ShaderCallbacks access to that lightmanager.
This works nice unless you also need to know the current meshbuffer rendered, but I've not run into that yet.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Seven
Posts: 1030
Joined: Mon Nov 14, 2005 2:03 pm

Re: Shader Base Material

Post by Seven »

interesting. I will look into that, thanks!
Post Reply