Texture Masking or Clipping

What is the best and simple way to do masking effect to an image or texture?

Or is there a way to clip an object in 3D world instead of scaling it ?

Thanks

do you, by any chance, look for something like that ? http://www.panda3d.org/manual/index.php/Texture_Modes
look for “modulate mode” with a transparent/white texture

Ok, seems that it’s the only way to do masking effect. Not very neat after all.
But i’ll have a look on that.

Thanks for the idea :slight_smile:

There are also stencil buffers, clip planes, and scissor effects. All of them can be described as masking or clipping, and all of them have very different behaviors.

What effect, precisely, are you hoping to achieve?

David

Well if i have a clipping effect that would be the best solution.

I have 2 onscreenImage in the screen, to create a life bar effect (something like hero’s lifes or magic bar), and i want the background to hold still in the background. While the foreground image doing a clip effect, not a scale effect, because the bar is not sharp-squared, but with a rounded corner.
If I scale it than the round corner would transform into unexpected form.
If i can clip it as much as i want, then one corner will maintain its proportionality, while the other one will be chopped sharply.

Did the clipping effect you suggested can do as what i described above ?

Thanks in advance

A stencil buffer can do that kind of masking. It’s probably a much heavier hammer than you need, though.

If all you want is a health bar with rounded corners, consider applying a texture to your health bar with the corners alphaed out. You can still scale the internal bar to make it bigger or smaller, as long as you recalculate the UV’s to compensate for the scale–the scale will shorten the bar, but if the UV’s are still in the same place, the texture on the bar won’t move; instead, the bar will appear to move through the texture, keeping the corners just as round. One easy way to keep the UV’s always the same is to do something like this:

ts = TextureStage.getDefault()
healthBar.setTexGen(ts, TextureAttrib.MWorldPosition)
healthBar.setTexProjector(ts, render2, healthBar);
healthBar.setTexScale(ts, xs, ys)

This code is as described in the manual under Automatic Texture Coordinates. Set xs and ys to the appropriate scale for your texture.

David

Seems quite complex to me, whether i like it or not, i think i have to go in there somehow :confused:

Thanks for the advice