Juliano
Juliano

Reputation: 2562

How to change pixels from image to white and keep transparency?

How do I achieve this effect in Moai? I want to change every pixel of a image to white, but keep the transparency. And I don't want to generate extra images.

Effect sample

Upvotes: 1

Views: 102

Answers (1)

Joakim Tall
Joakim Tall

Reputation: 426

Create a custom shader! You can use the default deck texture shader as an example. It's in the source somewhere (moai-sim/MOAIShader.. something).

Then instead of settings glFragColor to sampler you set it to for example (white) glFragColor = vec4(1, 1, 1, 1) * sampler.a; So that you multiply the color white by the textures alpha value.

Look at samples/graphics/ for some shader code. It's not dead simple but it's very flexible once you get it up and running.

Upvotes: 0

Related Questions