texture combine question

How to do this?

I spent the last hour trying to get it right with no luck

Something like this:
Stage 1: the second texture, MModulate mode
Stage 2: third one (with the red crosses), MDecal mode
Stage 3: fourth one (one with the big black cross), MBlend, with green blend color

If the green one is supposed to be an arbitrary texture (not just a green colour), then it would be:
Stage 1 and 2 as above, but stage 2 has saved-result flag
Stage 3: the green texture
Stage 4: the fourth texture (one with the black cross), CMInterpolate between the saved-result texture and CSPrevious using this texture’s colour value.

It seems close, but still not right. The background texture (green) would in that case be the 3rd texture (the one with alpha)
That is, if Im doing this right

finalts.setCombineRgb(TextureStage.CMInterpolate, TextureStage.CSPrevious, TextureStage.COSrcColor, TextureStage.CSLastSavedResult, TextureStage.COSrcColor, TextureStage.CSTexture, TextureStage.COSrcColor)

Is “setSavedResult()” only used for this?

Oh, and why is the first stage MModulate?

You didnt mention a mode for the green textureStage, maybe thats the problem?

I used multiply mode because the lighting information would get lost otherwise.

And sorry, the third texture stage (with the green texture) should have the Replace mode.

Sorry, still doesnt seem to work as expected. The green color will be the inside of star, the 3rd stage (red crosses) the outher part of the black star.

Then simply swap the first two sources for the interpolate mode, like:

finalts.setCombineRgb(TextureStage.CMInterpolate, TextureStage.CSLastSavedResult, TextureStage.COSrcColor, TextureStage.CSPrevious, TextureStage.COSrcColor, TextureStage.CSTexture, TextureStage.COSrcColor)

thats not it

What’s the result, then? Try enabling the layers stage by stage to see where it goes awry.

Have a look: 2shared.com/file/vfD_yx81/tex.html

Sorry, yeah, I made a mistake with the last-saved-result thing. This should work:

plane = loader.loadModel('box')

tex1 = loader.loadTexture('3.png')
ts1 = TextureStage('ts1')
plane.setTexture(ts1, tex1)

tex2 = loader.loadTexture('1.png')
ts2 = TextureStage('ts2')
plane.setTexture(ts2, tex2)

tex3 = loader.loadTexture('2.png')
ts3 = TextureStage('ts3')
plane.setTexture(ts3, tex3)

final = loader.loadTexture('4.png')
finalts = TextureStage('finalts')
finalts.setCombineRgb(TextureStage.CMInterpolate, TextureStage.CSLastSavedResult, TextureStage.COSrcColor, TextureStage.CSPrevious, TextureStage.COSrcColor, TextureStage.CSTexture, TextureStage.COSrcColor)
plane.setTexture(finalts, final)

Other problems were that you didn’t specify a sort value for the texture stages and that you didn’t get rid of the noise texture on the box first.

I didnt know sort values were necessary, I thought they were just added on top of each other.
Anway it works.
Theres one problem, lightning is gone.
I can do this for the shader egenrator:

vertcolor = TextureStage("vertcolor")
	vertcolor.setCombineRgb(TextureStage.CMModulate, TextureStage.CSPrevious, TextureStage.COSrcColor, TextureStage.CSPrimaryColor, TextureStage.COSrcColor)
	plane.setTexture(vertcolor, "vertcolor")

but it wont work without it as I seem to be using the maximum allowed textures for my GPU. Is there any workaround if you dont want to use shaders? I dont want per vertex lightning. If I could just get the object change it’s color scale based on the light, it would work for me. I could set up a task for that, but it would be ugly.

Preserving lighting along with a big complex stack of textures without using shaders is difficult, sometimes impossible. Sorry. Blame the designers of the fixed-function OpenGL API.


oh, well, I guess for some cases (where I dont need to modify the UVs afterwards), I could somehow check if shaders are not used and use PIL to generate an image, save it to temporary place and load it into Panda. Wouldn’t be very fast, but at least would work. What do you think?

Nothing wrong with that approach.

How can you know if shaderGenerator is enabled?
And can you know if if hardware doesnt support shadergenerator?

Oh, I have other related questions:

how to have a tiled texture’s uv scale be independant of the object’s scale?

And if I scale a texture, it is scaled relative to the bottom-left corner of the uv, can I scale it along the center of the uv?