How to use stencil maps(texture splatting)?

How can i use stencil maps in code?
I want to use more than one (with shader generator).

Basically, how to do something like:

map = loader.loadTexture("stencilMap.png")
texture = loader.loadTexture("grass.png")
texture.setWrapU(Texture.WMRepeat)
texture.setWrapV(Texture.WMRepeat)
ts = TextureStage('stencil1')
ts.setMode(TextureStage.MStencil)
model.setTexture(ts, map, texture)

I’m not sure what you mean by stencil map, but the stencil buffer is a property of the framebuffer–the pixels of the window you’re rendering to–and not really related to texturing. You can use the stencil buffer to precisely control which pixels of the screen are updated at certain operations, which is useful for certain specific effects. But it’s not something that you just “do”; you have to have something very specific in mind.

In Panda, the stencil buffer is controlled via the StencilAttrib class, which has a dizzying array of options.

David

I want to have model (plane as basic test sample).
Then i would have map.png which would be grayscale image with whiteish “A” in it.
I would also have seond image which would be in this case seamless grass texture “grass.png”.

I would like that grass image to be drawn(tiled) on plane where map.png is white(ish).

I made that with blender, file is here
dl.dropbox.com/u/14000546/1/src.7z

There is an .egg inside, turn per pixel lighting in pview to see it all correctly.

EDIT: This appears to be what you and I want:
[url]terrain texture splatting, fixed-function]
however I have no clue how to multiply the result with CSPrimaryColor as rdb mentions (I want my game to have shading without the shaderGenerator, if that makes sense)

------------------- End edit --------------------

Ah, I have (ironically) just recently been searching trying to figure out how to do exactly what it looks like you’re trying to do!

This is good news for me, anyway I (could be very wrong, however) this appears to be called texture splatting (at least a search in google appears with these results…)

I know, that was barely helpful, just sayin’ I’d really like to know how to do the same exact thing :wink:

~powerpup118[/url]

Thanks powerpup :slight_smile:
This does almost exactly what i want.
Almost meaning that i need to have sample on how to use one texture only.

In Anon’s snippet, he loads model and then uses stencil to paint grass and dirt.

I would like to load model, apply grass to it whole, and then apply dirt according to stencil.