Suggestion: Add define for default GUI material color

The GUI Material (Common/Matdefs/Gui/Gui.j3md) requires you to set a material color. Maybe make it a define instead so that you don’t need to if you use a texture. Like vertex color has.

If I understand you right, if it’s a define then the shader will get recompiled every time the color changes.



There are other ways to have a default value, though.

The suggestion is to make m_Color a define so it isn’t used unless it’s been set.

@androlo said:
The suggestion is to make m_Color a define so it isn't used unless it's been set.


And then every time the color changes the shader will be recompiled.... so say you are changing alpha to fade something in or out it will be 500x slower.

Better just make your own material.



The ones supplied with jme are great for smaller stuff (and generic so they fit mostly everywhere) and for learning, but at some point you probably need to modify them anyway.

@pspeed said:
And then every time the color changes the shader will be recompiled.... so say you are changing alpha to fade something in or out it will be 500x slower.

nope, I think he means to "associate" a define with m_Color, like it's done for other things in lighting material.
[java]
MaterialParameter{
Color Color
}

define{
USE_COLOR : Color
}
[/java]
as far as I understand, the shader will only be recompiled when you set the color for the first time or if you remove it.
@nehon said:
nope, I think he means to "associate" a define with m_Color, like it's done for other things in lighting material.
[java]
MaterialParameter{
Color Color
}

define{
USE_COLOR : Color
}
[/java]
as far as I understand, the shader will only be recompiled when you set the color for the first time or if you remove it.


It would be worth checking... since up until recently even some defines with the same value caused a recompile.

Still, material parameters support defaults... we could just make a default color, too/instead.

Yep, default should do the trick.



I’ll check this define thing

Cool, thanks. :smiley:



It’s just so you don’t get a 0,0,0,0 output if you don’t set material color (like unshaded and lighting etc.).

i think the shader will be recompiled every time you set a “brand new color” to it (i.e material.setParam(“Color”, ColorRGBA.PINK). But if you just change a parameter of the color (color.a = 0.5f) for instance, it shouldn’t recompile

It shouldn’t recompile unless you change a value from null to non-null, or the other way around. That’s the whole point. What would be the point of a boolean that “changes” from true to true, or false to false, causing the shader to constantly be recompiled? :?



EDIT: shouldn’t = woun’t

I wasn’t talking about what “should” or “shouldn’t” be… just expressing that things aren’t always what they should be. And in the case of optimizations like this down in Material it sometimes requires careful stepping if it isn’t what it “should” be.

Someone please do this. It’s a quick and easy fix. It’ll take someone (that knows how shader defines work) 5 seconds to do this. It’ll take someone who doesn’t another 5 seconds, since they can check unshaded.j3md or lighting.j3md and see how it’s done. Then all standard materials will work the exact same way.



Again - it’s just to make all standard materials work the same way.

I can’t. I’m on vacation for 2 weeks.

Maybe you could post a patch.