Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

unlit transparent Color material occasionally flips normal and is 2 sided ?

Discussion in 'Editor & General Support' started by McSwan, Jun 17, 2014.

  1. McSwan

    McSwan

    Joined:
    Nov 21, 2013
    Posts:
    126
    Hi,

    Create a sphere, add a unlit transparent colored material with texture and rotate it in game. You can see through the sphere to the other side occasionally.

    I am creating a scratch it game.

    We have tried a few different methods of scratching and so far, changing the vertex alpha seems to be the fastest, and the only hope of giving reasonable tactile feed back to the user.

    However the unlit transparent color seems to be the only method of creating an object with vertex alpha. Is there a better way - for example designate the mesh as having vertex alpha, and be able to put any material on it ? Or just a basic vertex alpha with diffuse material shader that isn't 2-sided, and doesn't mess up the normals ?
     
  2. McSwan

    McSwan

    Joined:
    Nov 21, 2013
    Posts:
    126
    I created a new shader and copy pasted the unity transparent color material into it.

    I set the writeZbuffer to true. The visual artifacts were caused by this, and it looks like I can scratch 3D objects now.

    I think the material is designed to be 2-sided billboard shader, but seems to be the only shader that actually uses vertex Alpha.

    I think I need a fixed4 color: color in any scratching material.

    Also, I'll try googling how to turn off the backface rendering.
     
  3. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    You might want to grab shader forge, if you're not comfortable writing shaders.
     
  4. McSwan

    McSwan

    Joined:
    Nov 21, 2013
    Posts:
    126
    Hoping I could use all premade shaders. I have shader forge already. Haven't used it yet though...Pretty good idea.

    Commenting out
    // Cull Off
    seems to have fixed the back face culling. The raytrace would hit the back face of the object, and change vertex alpha of back of the 3d object.

    At least it works now, even If I can only put one material on it. If I need to add lighting etc. I'll crack open shader forge and see how I go.