VideoDriver Material -> Global light switch..?

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply

Add IVideoDriver::setMaterialOverrides() / disableLighting()

I can see use cases for setMaterialOverrides()
7
70%
I can only see a use for disableLighting()
2
20%
I'll never use either.
0
No votes
I have no opinion but am addicted to voting in polls.
1
10%
 
Total votes: 10

Pan
Posts: 24
Joined: Tue Jan 20, 2009 9:36 am
Location: Bavaria, Germany

VideoDriver Material -> Global light switch..?

Post by Pan »

[Moved to Open Discussion and poll added by Rogerborg]

Hi!

I've been reading the forums for a while now, and started to work with Irrlicht some days ago. I used to program on OpenGL, and my primary problem at the moment is how to translate stuff I know in OpenGL to Irrlicht.

So this would be my first question, and any help would be appreciated (and hello new community, whee :wink: ).

Basically, what I'm trying to do is to switch lighting off. Up to now, I'm doing this one object at a time, by killing the lighting on each material by hand. What I would like to do, is to globally tell Irrlicht to simply don't ever use lightning at all.

I searched the forum, and found the function

Code: Select all

IVideoDriver::setMaterial
Which is documented as
All 3d drawing functions will draw geometry using this material thereafter.
Now, this sounds exactly like what I want, but now I'm wondering what happens beneath.. say for example, that there are a number of scene nodes, each with it's own material:

- Are those all ignored when the driver function overrides them..?

- And if so, how can I reset this, and use the scene node specific materials again?

- And finally: it it either the driver-material or the node's own materials? Meaning, I'd like to switch off lightning in the driver material (and thus disable lightning for the whole scene) but still use the color information (ie. the textures) of each individual scene node .. but it seems to me like it wouldn't work that way..?
Wanted: Schrödingers Cat. Dead or alive.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Sorry, it's not a persistent override: each scene node also calls IVideoDriver::setMaterial() to set up the appropriate material.

There's no global override, for the reason that you noted: it sets up all the material properties, which is generally not what you want to do.

It occurs to me though that we could have an IVideoDriver method to just disable lighting, and then modify each material as it's being set.

However, if we go down that route then we could do it properly, with an override material plus a bitmask to say which properties should be used to override those of individual materials.

Alternatively, that might not work at all. I'm stabbing in the dark here, pun fully intended.

I'm not sure how much demand there would be for that, so I've moved this to Open Discussion and added a poll.
Last edited by rogerborg on Tue Jan 20, 2009 1:32 pm, edited 2 times in total.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

+1 for global override. My shadow mapping framework could of been soooo much easier with that.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

yeah a function like:

video::IVideoDriver::setMaterialGlobal(video::SMaterial& mat);

and the to deactivate global override

video::IVideoDriver::deactivateMaterialGlobal(void);

so wen u cal setMaterialGlobal all setMaterial calls are neglected. of course u can change the global material with calling setMaterialGlobal again and when u call deactivate MaterialGlobal the normal setMaterial function will work again.

that would be so awesome
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

I was thinking of passing a * so that it can be disabled by calling with a 0 parameter.

Also, we'd want to provide a bitmask specifying which SMaterial properties to use to override individual material properties in the materials set with IVideoDriver::setMaterial(), rather than just crapping over the entire material.

So:

IVideoDriver::setMaterialOverrides(const SMaterial * material, u32 propertiesToOverride);

where propertiesToOverride is a composed of ORing flags for each SMaterial property.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

I don't mind crapping/regurgitating over the entire material personally, so if the bitmask thing proves too much for a start, I'll settle for anything I can get on this matter.

I would add, it would help with things like depth passes etc. Check out this recent post in the beginners forum: http://irrlicht.sourceforge.net/phpBB2/ ... p?p=183692

With the override function, that lad would have a slightly cleaner solution for his problems.

PS: When I tried to post this message earlier I got "Sorry, but only can reply to posts in this forum.". "But only can!!!" Who can?" "But only!" I guess it's related to the move/slice thing you did there.
setMaterialOverrides(const SMaterial * material, u32 propertiesToOverride);
setMaterialOverrides(const SMaterial * material, const u32 propertiesToOverride);
:wink:
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Oh yes, I'm also planning stuff like that :D I'll also need a bitmask and was already fiddling around with proper ways to split up the SMaterial with our E_MATERIAL_FLAGs and other stuff. This is required for turning whole scenes into wireframe display or disabling color channels (which also requires another Material member, but that's already done elsewhere :wink: )
So yes, we should really go for that one soon.
Pan
Posts: 24
Joined: Tue Jan 20, 2009 9:36 am
Location: Bavaria, Germany

Post by Pan »

Well, this thread certainly has expanded :)

Thanks for clearing up my problem!

To add to the discussion: I'm all for a global light switch, as I can see a lot of application for it (and being new to Irrlicht, I was kind of surprised that it wasn't there already).

As for a complete override material with a bitmask .. I could imagine this being a little bit of overkill..? If it is decided to put something like this into the engine, I would implement both of them. The light switch to be just very simple and fast, and the complete bitmask as an alternative for more advanced users.
Or something in between, I don't know ;)
Wanted: Schrödingers Cat. Dead or alive.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Well, hybrid is on the case, so it should be a quality solution, whatever it is. ;)
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Once you have the global material override, disabling light in the whole scene would be something like
driver->setOverrideMaterial(matWithoutLight, EMF_LIGHTING);
don't know if this is really overkill...
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

it seems overly complex... For a simple flag? i agree with the bitmasking its great.. but there should be a simple flag on scene manager i say, manager->setLightingEnabled(trueFalse);

That makes more sense. Then whenever a SMaterial is declared, or created, you can use <globalMatOverrides .x.y.z.a.b.c) and override its properties, and apply it. That way its an override.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

If there's a special method for lighting, why not for fog? Or for wireframe? Where does it all end? I'll tell you: DOGS AND CATS, LIVING TOGETHER.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Dark_Kilauea
Posts: 368
Joined: Tue Aug 21, 2007 1:43 am
Location: The Middle of Nowhere

Post by Dark_Kilauea »

Why not go a slightly different route? Instead of relying on a bitmask for properties to override, instead allow for a global material that exists by default. Then on a scene node basis, that material can be overridden. So, for instance, the global material can have lighting enabled, but on a scene node basis, it can be disabled if needed.

The problem with an override is that for custom shader materials, doing a global override may horribly break something. Granted, the user should probably fix that, but still.

I see it working like this: The global material can be updated and all scene nodes that have not had custom materials applied will change with the global one. Those with small modifications, like differing flags, will change as long as that particular flag is not overridden. Textures should probably be excluded from the global material and it may be better to define a global for each "class" (ie. solid vs transparent_add) of material.
rogerborg wrote:Every time someone learns to use a debugger, an angel gets their wings.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Or... your user app could just switch the global override before or after each render phase or even before or after each individual scene node.

We can't? Yes, we can!
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply