It looks like you're new here. If you want to get involved, click one of these buttons!
If I was to try and do the following scenario:
Imagine 100 objects floating around the screen. When they intersect, the colour is intensified. Not overly interested in how to achieve the actual effect, but rather the setup.
Would a seperate shader be applied to each object? Would that be completely inefficient? Or would a shader be applied to a single background object that would render the final result?
How would the presence of many objects be able to contribute to the overall result in a shader on a single large object?
Really having trouble thinking this particular scenario through.
Comments
Well the setup relies heavily on the effect you want to achieve.
In the case of having colors intensify with overdraw, using additive blending might be a good start.
Other than that, having a shader per object will not help you much as all you'll have is the content of the object itself, not the content of the target surface. A full screen effect (usually called a postfx) would be the way to go.
You can even combine additive blending and a postfx shader to remap the color range, for example.
If you have a more precise effect you'd like to achieve, I'd be happy to try to give a better advice on it.
Thanks Iarwain. Ok, yes so additive blending (or a better one) is ultimately what I'd like to achieve.
Based on the above, one large object as my render area for my result shader is the way to go.
So the next step, how does the 100 similar objects floating around, and their textures influence what goes on it the shader? We have parameters for shaders in the orx config but I imagine I can't create a hundred parameters. That would be silly of course.
But the shader needs to take the texture and position information of each object and use it within itself to make the calculations. That's the next step.
Well, actually what you want to do is probably something along the lines of:
And that's about it.
Now if you simply want to have objects get brighter when they overlay on top of each other, a simple additive blend might do the trick. An example can be seen in the 2nd screenshot of the compositing tutorial:
Yep that's the trick! Thanks so much. Forgot about the composition tutorial: http://orx-project.org/wiki/en/tutorials/community/iarwain/compositing or the more recent data driven version: http://orx-project.org/wiki/lib/exe/fetch.php?tok=04a432&media=https://bitbucket.org/iarwain/compositing/src
And I forgot about the render to texture technique: http://orx-project.org/wiki/en/tutorials/viewport_render_to_texture