- Home /
Merging colors of 2+ Projectors
Hello,
I am creating a game where the player is able to throw paint upon objects in the game world to reveal it. Initially the game world is mostly white, so they throw their colored paint to reveal walls, objects, etc.
Right now I create a projector to apply paint to surfaces, and these projectors are of red/blue/yellow color paint splats. However when two or more projectors hit any given area, the colors are not merging as I would expect them to.
My desired effect is to have the colors merge to their correct color when the projectors intersect, so red + yellow = orange, yellow + blue = green, etc. The current observed effects are:
red + blue = black
red + yellow = red
yellow + blue = black
all three together = black
I am currently using the Projector/Multiply shader on my material being projected. I know I have to use shaders to apply these rules, however I have no idea where to start, as I don't have much training or knowledge in shaders.
Could somebody please give me some references where I could learn to get my desired effect, or help me find a shader which already does this?
Thanks for your time.
Using Projector/$$anonymous$$ultiply is your problem. Take these colors for instance:
Red (1, 0, 0, 1)
Blue (0, 0, 1, 1)
If you are multiplying, the equation is:
Red Blue = ( Red.r Blue.r, Red.g Blue.g, Red.b Blue.b, Red.a Blue.a ) = ( 1 0, 0 0, 0 1, 1 * 1 ) = (0, 0, 0, 1) = Black
Same with yellow and red:
Red (1, 0, 0, 1)
Yellow(1, 1, 0, 1)
Red Yellow = ( Red.r Yellow.r, Red.g Yellow.g, Red.b Yellow.b, Red.a Yellow.a ) = ( 1 1, 0 1, 0 0, 1 * 1 ) = (1, 0, 0, 1) = Red
Ins$$anonymous$$d of a multiply, you should use an additive equation, so that way: you get the corresponding values:
Red + Blue = ( Red.r + Blue.r, Red.g + Blue.g, Red.b + Blue.b, Red.a + Blue.a ) = ( 1 + 0, 0 + 0, 0 + 1, 1 + 1 ) = (1, 0, 1, 1) = $$anonymous$$agenta
Answer by Freaking-Pingo · Mar 20, 2013 at 09:55 PM
Personally I don't have much experience with shaders either, but I think this can be achieved in a shader.
What you probably are looking for is blending colors. Perhaps in your current shader you are using additive color, which mean you have to go into that shader and change it to blending colors.
This is the best shot I can give you, but I may be wrong.