x


Help...About Transparent Shader.

Well, it's kind a weird problem...that I have 2 players right now. And I am setting [idlePlayer] to fade to half transparent when the [currentPlayer] touches [idlePlayer]. But here comes a problem, though the [idlePlayer] faded out, but I can not see the should be seen parts of [currentPlayer]...

For example, I have a 1-meter tall P1 and a 2-meter tall P-2. and when they stand together, P-1 fades out, and right now I should have seen the whole P-2 through the half-transparent P-1, but I only see the upper part of P-2, the rest of the parts which hiding behind P-1 is invisible...like Harry Potter wearing his invisibility cloak...

I am using the transparent Diffuse shader of Unity. I wander this is a shader problem...and asking for help.

Thanks very much!...you know, reading this my poor English... guess I gotta improve it.

alt text alt text

this is the problem I mentioned, you see in the left pic,we can see the human through thehalf-Alphaed robot, but in the right-pic, we can not see the whole human...

more ▼

asked Mar 02 '12 at 10:21 AM

wolvtodd gravatar image

wolvtodd
59 14 15 17

Thank you.. I have added the picture of my problem and updated the question.

Mar 03 '12 at 04:47 PM wolvtodd
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Maybe your problem is being caused by the way transparent objects are drawn: they use the render queue value to define who will be rendered first (and hidden by the other).
To solve this problem, you can set the queue number of the active player to a higher number - lower queue objects are drawn first, thus the higher queued ones will cover it.
If you have a main script controlling which player is currently active, you can add a code like this to it:

var baseQueue = 3001; // draw over the default transparent layer (3000)
var player1: Transform;
var player2: Transform;
var activePlayer: Transform;

function Update(){
  if (activePlayer == player1){ // draw player1 over player2
    player1.renderer.material.renderQueue = baseQueue+1;
    player2.renderer.material.renderQueue = baseQueue;
  } else { // draw player2 over player1
    player1.renderer.material.renderQueue = baseQueue;
    player2.renderer.material.renderQueue = baseQueue+1;
  }
}
more ▼

answered Mar 03 '12 at 04:58 PM

aldonaletto gravatar image

aldonaletto
55.3k 21 64 261

Thank you! that works perfect!!! Looks like you just showed me something that I had never seen before, guess I need to do some more study. anyway, thanks!

Mar 03 '12 at 05:13 PM wolvtodd
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2594

asked: Mar 02 '12 at 10:21 AM

Seen: 851 times

Last Updated: Mar 03 '12 at 05:13 PM