real-time image composition

I was wondering if it’s possible to do any image composition effects (I assumed it would be via code)? For example, blending two alpha channeled images together. Using Texture2D.SetPixel doesn’t have any masking or blending types involved, so I didn’t seem like the solution.

You can overlay a pixel onto a background pixel using the alpha value:-

var newPix = bgPix * (1.0 - overlayPix.a) + overlayPix * overlayPix.a
newPix.a = 1.0;

This is probably the most straightforward way of doing it but it will work the CPU quite hard if you use it every frame.

I’m thinking about ways to use “proceedure” to build height maps. I’m not sure how to implement your code, and it’s probably the lack of context around it that’s confusing me. This example might change the nature of the answer (or not). I’d like to use imageA with imageB, to get image C. Idealy I’d like to offset and rotate the images so that there are larger variations than these two images alone can provide. I also would like to then use the result as the alpha channel of another composited image. Perhaps I’m stumbling around when the solution is simply to find a way to do it with the.net framework, and not Unity specifically? Coming from Adobe Director, although tricky, I was able to do a fair amount of code-based image manipulation and I haven’t found the Unity comparison (and since Unity has kicked Director’s ass every step of the way so far, I assumed it was here somewhere).



Not sure if you’ve done this already, but have you looked at any of the scripts in the wiki? There’s a couple there that, although not exactly what you’re looking for, might give you some ideas.

Well I had fun crawling through the wiki scripts again, and getting side tracked as usual discovering the sweet stuff I missed the first 5 crawl throughs. Like you said, This might be what I was looking for, now I just need to try/figure it out. Thanks you guys!

:smile: Happens to me all the time. Glad you found something useful!