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.


Topics - keysosaurus

Pages: [1]
1
NGUI 3 Support / Render Texture / ReadPixels Transparency Problem
« on: May 26, 2014, 06:46:15 AM »
Hello,

I've created a system to capture a sprite (or set of sprites) and then redraw that capture to the screen. NGUI is being used to manage the sprite rendering although I'm not sure it is important to the problem I am having.

The issue is that when the capture is drawn to the screen, blending seems to be incorrect in areas where a transparent image is drawn on top of an opaque one. The image attached shows the issue.

The character on the left is drawn with NGUI straight to the screen, it is how it is supposed to look. The face sprite is drawn first and then the makeup on top, all blended together.



The character on the right is one single image, created with the capture system. The blending is incorrect because wherever there is makeup on the face it is semi-transparent. As you can see from the image, the green box in the background is visible through the face.

Here is the process used to create the new image:

1. Render only the character to a render texture with a camera that has it's clear flags set to a solid color which is transparent.
2. Read the pixels of the render texture into a Texture2D so that it can be read from. This is now the source Texture2D.
3. Find the portion of the texture that the character is in and copy the pixels from the source Texture2D to the destination Texture2D. The destination Texture2D is a new atlas of images.
NOTE: Source and destination Texture2D objects have a transparent background.

It seems as if the alpha value of the topmost sprite is being picked up, either at the RenderTexture or ReadPixels stage, rather than the blended value.
Has anyone who has experienced this type of problem before got a solution to it?

2
NGUI 3 Support / Masking with Ngui 3.0
« on: September 30, 2013, 12:25:40 PM »
Hi, thanks for NGUI btw, it's a fantastic piece of software!   :D

I'm trying to render 2d characters and I want to make a mask so that their eyes look like they are inside their heads.

I have 3 images: an eye, a pupil and an eye mask.



The eye mask is rendered invisibly on top and needs to hide the pupil, but not the eye.

Is there a shader or something I'm missing that will get it to work correctly?
I got it working in the old ngui using a render queue hack but I cant seem to get it working in 3.0

Any help would be much appreciated!  :)

Cheers,

Keysosaurus

Pages: [1]