Results 1 to 7 of 7

Thread: rasterizer & transparency & framebuffer

  1. #1
    Join Date
    Feb 2011
    Posts
    2

    Default rasterizer & transparency & framebuffer

    Hi there,

    I'm trying to write a shader that use transparency with rasterizer and put each passes into user framebuffer. For some reasons, I found that the output for each pass doesn't look right.

    Can anyone shed some light on this?

    I tried 'rast useopacity' but still doesn't work.

  2. #2

    Default

    If you render with rasterizer, the alpha value is used as transparency value. e.g. I wrote a hair shader where I simply forgot to set the alpha value of the *result. So it was still 0 and in rasterizer I could not see anyting where in scanline everything worked fine.

    So you can either set the alpha value to a desired number or you can set the opacity explicitly with mi_opacity_set() if it differs from your alpha.

  3. #3
    Join Date
    Feb 2011
    Posts
    2

    Default

    thanks for the answer haggi.

    I've already set the alpha value, and also tried the mi_opacity_set.
    I'm writing hair shader as well and I tried to do the tip fade by setting alpha to 1 at root and interpolate to 0 at tip.

    I tried my shader with one single hair, I can see the result with the opacity but it doesn't look right to me.

    It has the opacity but it doesn't seem to be 1 at root and 0 at tip after all. but when I wrote out the same output to framebuffer the result in framebuffer came out as I expected.

    But the problem is I like the look of the result that doesn't look right and I don't know how it got that way.

  4. #4
    Join Date
    Dec 2004
    Location
    Moscow, Russia
    Posts
    346

    Default

    Please show you result images.
    You may view source code from another hair shaders (for example p_HairTK) how it works with rasterizer.
    Pavel Ledin

  5. #5
    Join Date
    Dec 2004
    Location
    Moscow, Russia
    Posts
    346

    Default

    In theory code scheme should be like this:
    Code:
    if(transparency && state->options->scanline != 'r')
    {
    	mi_trace_transparent(&trans_color, state);
    	result = inv_alpha * trans_color;
    }
    
    result += color * diffuse * alpha;
    
    if(state->options->scanline != 'r')
    	color_pass = color * alpha;
    
    mi_fb_get(state, color_pass_buf, get_color_pass);
    color_pass = get_color_pass * inv_alpha + color_pass;
    mi_fb_put(state, color_pass_buf, &color_pass);
    Ups, sorry, it was old post
    Last edited by Puppet; June 16th, 2011 at 14:17.
    Pavel Ledin

  6. #6
    Join Date
    May 2009
    Location
    Moscow,Russia
    Posts
    11

    Default

    Quote Originally Posted by Puppet View Post
    In theory code scheme should be like this:
    Ups, sorry, it was old post
    Anyway, in 3ds max 2011 and 2012 rasterizer calculates wrong transparency. (mr sa 3.8 working well, it seems this is max's bug)
    Royal Ghost | veda3d.com

  7. #7
    Join Date
    Dec 2004
    Location
    Marina Del Rey, California
    Posts
    2,915

    Default

    So please specify what versions we are talking about here.
    There are controls per-framebuffer which could possiblyl affect the calculations.

    Also, if you are going to be using mi_fb_get, your shader network layout and calling order may matter. Ie, you'd probably want to make sure that there is a valid value representing the object layer behind the transparency.
    Barton Gawboy
    Training and Special Projects, NVIDIA ARC
    LAmrUG Forum Originator

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •