Jump to content

[SOLVED] WidgetSprite image masking


photo

Recommended Posts

Posted

Hi all,

I want to know if it is possible ( and how) to do with image masking layers WidgetSprite . I've tried on my own without success.

Thanks.

  • 2 weeks later...
Posted
Hi Ivan,

 

Could you provide more information about your case? Give us some specifics about what you're trying to do, and we'll try to figure out all the ways to reach it.

 

Thanks!

Posted

Thanks for the answer and apoligies if my post wasn't clear.

It's something like this.

IN7cu.png

I want to create level bar filling another shape different from a rectangle. For example a bottle for water, or a heart for a health level.

Posted

Could this be handled by some Unigine script code based on Image class by copying (or combining) mask 1-channel image into A-channel of image RGBA instance ?

Posted

Hi Ivan,

 

Unfortunately, you need to write your own shaders to implement this.

Fortunately, we wrote a sample for you :)

 

Short description:

 

sprite/textures contains a sprite and a mask for it

sprite/material contains a material for the sprite and a mask

sprite/shaders contains vertex and fragment shaders for the material

 

In code, we create a new WidgetSpriteShader with the sprite and assign created material.

 

P.S. Don't forget to add binaries and core files to make the sample works!

 

Sorry for inconvenience caused.

 

 

 

 

sprite_mask.zip

×
×
  • Create New...