Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Render To Texture - Alpha Issues

Discussion in 'Shaders' started by DigitalSpit, Jun 25, 2010.

  1. DigitalSpit

    DigitalSpit

    Joined:
    Jun 25, 2010
    Posts:
    8
    Hello Unity Community!

    I´ve got a Problem witch is similar to this one:
    http://forum.unity3d.com/viewtopic.php?t=7597

    I Render an Object to a Texture with the Common Bumped Specular Shader. Now the alpha channel is really used to create Translucent, but it shouldn´t

    At the Topic above they postet a code witch will fill the alpha of the rendered Image, but i only want to see the object not the background.

    I got this problems in other Environments like Conitec 3DGS or XNA. But im an Artist and only want to see the things working, not bring them to work, thats not my job and i wasted to much time for that.

    There are guys whose job it would be, but thats beside the point.
     
  2. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    As an artist, your job includes understanding the tools and principles of your medium. Alpha channels are not just used for transparency. If you look at your scene view you can switch from RGB to Alpha view to see what is drawn to the frame buffer's alpha channel. In Unity, frame buffer alpha is used (by default) to store overbright information so that the fullscreen glow effect works.

    If, instead, you render to a rendertexture and then pass that to another shader, you need to respect the alpha channel's intended use, or ignore alpha entirely. In this case, you are using overbrightness information as transparency, and it doesn't look good. Render it with a non-transparent shader, and you'll see just the original colour information.
     
  3. DigitalSpit

    DigitalSpit

    Joined:
    Jun 25, 2010
    Posts:
    8
    I use the default Bumpmap Material, there should no transparency. The Alpha i was talking about is the SpecularMap.

    I also have an idea why that problem results.
    But i dont know how to change it.

    What do you mean with "ignore Alpha entirely", that sounds like what i´m looking for.
     
  4. Peter11

    Peter11

    Joined:
    Jun 13, 2010
    Posts:
    27
    I´m sory but I don´t know the answer for you problem but I wonder about that "render to texture" you wrote here. I know this technique cann be used for creating textures and also for creating normal maps. And that´s why I write here. I cann make this render to texture in 3ds Max. I was making noemal maps with this techniqu but can be this used in Unity? I mean can I create render to texture in Unity? And how should I give the normal maps to my object in Unity?
     
  5. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    yes you can create render textures in unity pro (and pro only) through code, just create it (class RenderTexture)
     
  6. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    Can you perhaps post a screen shot of the problem? I'm not sure exactly what your set up is.
     
  7. DigitalSpit

    DigitalSpit

    Joined:
    Jun 25, 2010
    Posts:
    8
    Thing is i can´t post something of the Project.
    But now i recognised the problem by setup the part by myself. I Uploaded that Screen.

    Sure, the target planes need to be Transperent and use the Alpha channel of the screen.

    Now i thought about rendering a 2nd time only with a solid color to use that result as the Alpha channel, but in my opinion its to indirect, is there a other way?

    @ Peter11
    There musn´t be any code, you can also create a "Render Texture" Asset in the Project Window and stick this into a Camera´s Target Texture.
     

    Attached Files:

  8. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    Can you explain what the set up is for that screen shot, what you expect to see and what you are actually seeing?
     
  9. DigitalSpit

    DigitalSpit

    Joined:
    Jun 25, 2010
    Posts:
    8
    In the editor View you see the Object witch is rendered by the Cameras with a Target Texture. In the Game View are 2 Planes with the Material applied in the Inspector.
    The Editor view is on Alpha mode witch represents a specular Texture.
    And i want to have the real shape of the object as Alpha, not includeing the SpecularMap.

    The Cube simply should be 100% Visible.
     
  10. DigitalSpit

    DigitalSpit

    Joined:
    Jun 25, 2010
    Posts:
    8
    Does Nobody have an Idea?
    Another way, can you tell me how i can change a Shader (in my case it is "Normal-BumpSpec.shader") so that the Output-Alpha is 1 , or higher if recommended?

    I tried it but nothing seem to be effecting anyting, i know the very basics of HLSL btw.
     
  11. tomvds

    tomvds

    Joined:
    Oct 10, 2008
    Posts:
    1,028
    You are rendering your plane with Transparent/Diffuse. If you don't want transparency on your plane, use Diffuse instead.
     
  12. DigitalSpit

    DigitalSpit

    Joined:
    Jun 25, 2010
    Posts:
    8
    I thought i explayned my problem clearly.
    There must be Transparency on the planes because i want the Cube to be cut-Out. But as you can see it hase holes like the grayscale image above. I only want to have a 100% White AlphaChannel at the cube.

    (Cue cut-Out, the cutout shader would work, but i think there might be artifacts at the edges)
     
  13. GamerVJ

    GamerVJ

    Joined:
    Apr 6, 2011
    Posts:
    7
    Hi,

    Did you find any solution or workaround of this porblem????

    -VJ
     
  14. HolBol

    HolBol

    Joined:
    Feb 9, 2010
    Posts:
    2,887
    Why don't you use a transparent cutout shader?
     
  15. DanTaylor

    DanTaylor

    Joined:
    Jul 6, 2013
    Posts:
    119
    Did you ever fix this? I am having the exact same problem!
     
  16. sysG

    sysG

    Joined:
    Jan 3, 2013
    Posts:
    8
    Hi, need to save alpha values from render texture canvas(blending of lots objects with the different alpha like painting brushes) to use in the analysis shader. So I think I have some problems with storing alpha. Camera shader material maybe? any suggestions for this?