Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Garbeld

Pages: [1]
1
Graphics / Re: Multiple layers and colorizing thereof
« on: December 18, 2012, 06:23:33 am »
When rendering the rendertextures using a sprite, you have an option in sf::Sprite thats called "setColor". Take a look at this; http://www.sfml-dev.org/documentation/2.0/classsf_1_1Sprite.php#a14def44da6437bfea20c4df5e71aba4c
On re-reading my post, I realize that my sentence was rather ambiguously phrased (I'm terrible at succinct explanations, one might tell): as a source pixel's color approaches black, the drawn pixel's color should approach red (or blue). So far as I'm aware, sf::Sprite::setColor will only allow me to do the opposite (as a source pixel's color approaches white ...).

I've since noticed that I can pass a blend mode when drawing sprites, and this seems to mostly work; simply draw an image consisting of a block of flat color atop the desired layers with sf::BlendAdd. Clear my window with white, draw my lower layers in, color them red, draw my non-coloured layer.
The only problem is that this doesn't seem to preserve transparency - I draw to an sf::RenderTexture and it has the correct colors, but is fully opaque. And I can't sf::BlendAdd a block of blue directly to the window after drawing my red layers, or else they turn magenta.

2
Graphics / Multiple layers and colorizing thereof
« on: December 14, 2012, 09:54:32 pm »
I have a variable length array of largeish (probably 640x480, enough to fill the app's window) images, from which I will take 5 (henceforth "layers") and draw them in order.
Each image is greyscale, and layer 2 will be drawn without change; layers 0,1,3,4 will be colorized and transparent (pixels will be rendered as red in layers 0,1, and blue in layers 3,4, in proportion to how dark they are).

I'm going to be drawing a lot of images (again, all greyscale) to layer 2, with frequent scale and rotation shifts; thus, I assume that it would be fastest and easiest (fewest lines of code, and not having to learn unfamiliar functions and/or math) for these layers to be rendertextures and drawing on layer 2 to be done with sprites. Assuming colorizing the layers is simple enough, then everything's basically solved and done. However, I'm not sure what the best way to go about that would be.

I'm guessing that the "correct" answer would involve shaders, but I'm not terribly familiar with them (or graphics cards, openGL, anything like that). A cursory search for shader tutorials didn't help me much.

Pages: [1]