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 - 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 Documentation / Re: UIPanel
« on: April 09, 2014, 04:34:03 AM »
The problem with doing it that way is both textures in the shader are then offset.
I only want to offset the main texture as the mask texture keeps the pupils inside the eye socket.

It worked before, just wondering what has changed? Or where I can tweak the code myself?

3
NGUI 3 Documentation / Re: UIPanel
« on: April 08, 2014, 11:02:02 AM »
The shader is used to render eyes. It has two textures, one for the pupils and another used as a mask.
It uses texture offsets to move the pupils around, and works perfectly on non clipped panels.
"drawCall.dynamicMaterial.SetTextureOffset" is what i've been changing.

The offsets on the UITexture material seem to be updating in the inspector but the results can't be seen in game.

Any help would be greatly appreciated!

4
NGUI 3 Documentation / Re: UIPanel
« on: April 07, 2014, 06:34:30 AM »
I have a custom shader that I use, I named it (AlphaClip) and (SoftClip) so it could be used in clipped panels.

Is this not possible any more in the new system???

5
NGUI 3 Support / Re: Custom shaders clipping UITexture
« on: October 07, 2013, 12:15:24 PM »
@nwsx Thanks a million, works like a charm!  :)

@ArenMook Cheers, I'll change over to the new "dynamicMaterial" when its working, but for now I'm delighted and relieved!  ;)

@Avatarchik Sounds like we are doing something similar, but we split our t-shirt assets into layers and use UISprite.color to tint each layer individually.
It's only one draw call for each atlas (thanks again ArenMook!)

6
NGUI 3 Support / Re: Custom shaders clipping UITexture
« on: October 04, 2013, 05:13:53 AM »
Think you may be having the same problem as I am, materials don't update at runtime.

http://www.tasharen.com/forum/index.php?topic=6002.0

http://www.tasharen.com/forum/index.php?topic=4135.0

Seems to work fine in older versions of NGUI, just not 3.0  :(

7
NGUI 3 Support / Re: [Feature Request] 2nd UV coordinate set support.
« on: October 04, 2013, 04:27:03 AM »
Great to hear, hope you'll get to it soon!  :)

Tried my shader in an older version of NGUI (2.3.1) and it works perfectly. I can adjust the texture offsets in the material no problem!

What's changed in 3.0? Is it something small that I can roll back?

8
NGUI 3 Support / Re: [Feature Request] 2nd UV coordinate set support.
« on: October 03, 2013, 02:19:45 PM »
That's exactly what I'm trying to do, but I can't get the UVs animating.

http://www.tasharen.com/forum/index.php?topic=6002.0

Can't get it working at runtime, but it updates whenever I enter or exit play mode.

I'm obviously missing something, how did you guys do it?

9
NGUI 3 Support / Re: Offset animation
« on: October 03, 2013, 11:51:00 AM »
Did you get this working?

Trying to adjust the material properties on a UITexture to make the the texture animate, but it doesn't change at runtime.

Cheers

10
NGUI 3 Support / Re: [Feature Request] 2nd UV coordinate set support.
« on: October 03, 2013, 11:47:07 AM »
Did you end up getting this working?

Trying to do something similar, adjust the texture offset of the second texture on a material at runtime.

Cheers

11
NGUI 3 Support / Re: Masking with Ngui 3.0
« on: October 03, 2013, 10:18:29 AM »
Forgot to mention:

When I change the "UV Rectangle" on UITexture, it moves both textures, ie. the whole material.
When I change the offset of the textures on the material directly, nothing happens.

Any help would be much appreciated,

Cheers!

12
NGUI 3 Support / Re: Masking with Ngui 3.0
« on: October 03, 2013, 09:50:48 AM »
Brilliant, thanks!

Works very well on the alpha now but having trouble animating the pupils.

I want to keep the alpha texture in the same location but change the position of the pupil texture independently, so that they can look around.
Trying to mess with the texture UVs in the shader but can't seem to get it working.

Any advice???

Thanks again!

13
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]