RGB - Materials

Is there a way to change the RGB (red, green blue) of a Panda Material (material defined with code)?

I want several materials going from dark to light.

I know about all these attribs:

setShininess(0.0);
setAmbient(Vec4(0.5, 0.5, 0.5, 1));
setDiffuse(Vec4(0.8, 0.8, 0.8, 1));
setEmission(Vec4(0.0, 0.0, 0.0, 1));
setSpecular(Vec4(0.0, 0.0, 0.0, 1));

I wonder if it’s the fact my Object has multiple textures assigned (via, texture stages)?

Usually, changing Diffuse and Ambient would be enough. I’m trying to avoid swapping multiple textures/texture stages.

(P3D 1.7.0)


:bulb:

I have an idea… Maybe I could just blend in a dark texture via, texture stage? That would make the entire object appear darker.


I think I found an issue that could be the problem… Let me test this out…


Crap! I found out the shader was off and normally you don’t see material color when it’s off. Turning it on caused some kind of error:

:gobj(error): created-shader: (20): error c5102: output semantic attrib "TEXCOORD" has too big of a numeric index (8):

:gobj(error): created-shader: (20): error C5041: cannot locate suitable resource to bind parameter "l_eye_normal"

Using OpenGL

The error looks a bit what I get when I try to use too many textures or effects (shadows,fog), my ol’gpu can’t take that much.

For colours- have you tested setColor() and setColorScale()? They change vertex colour.

Probably won’t work since the shader breaks anyway. I don’t even have shaders set for anything. I just turned it on for the one object just to see if the Material color would show up, so I’m not overloading anything.

What I found out was, the Object is getting dark from the lighting alone, which is great; that’s what I want.

BUT!

BUT! BUT! BUT! BUT! BUT! BUT!

:laughing:

Sorry…this little boy said that to me once when I gave him an answer to a question of his, but he didn’t like the answer.

Anway,

I found out the extra textures set to Decal mode are not getting darker. I can see the original texture for the object getting dark through the textures blending with it.

So I guess the question would be, how can I make the texture Decals get darker as well (if possible)?

If I can solve this, I can move on. The coding for my program is getting serious and it’s exciting me. :slight_smile:

I love a good challenge and so far I’m kicking butt. Of course, if I had PandaAPI knowledge like Mr. Drwr or rdb, I would be king by now. :smiley:

Ok, I found a solution for my issue. I just simply used small textures of different shades to lighten or darken my object through blending.

Took me awhile to figure out what was going on because Panda3D blends backwards. Lighter in essence create darker and darker creates lighter…

Wow.

All in all, back on track. :slight_smile:

I should have some solid updates for my showcase thread, soon.

What’s the deal with setColor?

I can get it to work but the problem is, it works one time and stops.

I created a function that calls setColor on an object, the object changes color, but when setColor is called again on the same object, the object keeps the same color.

This happens with or without flattenStrong.

Now that’s a mystery… :confused:

Are you calling setColor() on a Material? Since the material gets baked into the shader the first time it is rendered, you have to create a new Material object every time you want to change its color. Simply use m = Material(m).

David