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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Butterfly transparency not working :( (possibly shader related?)

Discussion in 'General Graphics' started by JustJeff, Apr 14, 2015.

  1. JustJeff

    JustJeff

    Joined:
    Feb 16, 2015
    Posts:
    84
    Something's going weird with my butterfly... The texture works fine with the unlit transparent shader, but only the 2 faces pictured are rendered. I'm using this double-sided shader from a butterfly on the asset store but with a different animated mesh since the animation wouldn't work in unity 5. I made this texture by taking the one left-wing , doubling the width, and mirroring it over and I deleted all white space in paint.net and I'm using it with the shader below, also from the store. Do the 2D projected lines of the detail onto what should be the transparency area suggest a shader issue or something wrong with the texture I made out of the one-wing texture? I tried it as both PNG and TIFF.

    Deselecting "transparency from alpha" makes the projected line areas flooding the rest of the planes a transparent white. I've tried making the "main color" 0,0,0,0 and tried making it 255,255,255,0 and with the last coordinate 255 and it affects the opacity of the entire texture. I attached my butterfly texture too... I'm not sure if I need to manually add in a layer or what :/. I wish there was a way to just define an RGB value to use as clear and just fill in around the butterfly with some nasty shade of pink or green heh.

    Please help :) I'm especially curious as to what those outward projected bars of the colors are symptomatic of. Thanks in advance!



    1. Code (CSharp):
      1. Shader "Double Sided Butterfly" {
      2. Properties {
      3.     _Color ("Main Color", Color) = (1,1,1,1)
      4.     _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
      5. }
      6.  
      7. SubShader {
      8.     Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
      9.     Cull Off
      10.     LOD 200
      11.  
      12. CGPROGRAM
      13. #pragma surface surf Lambert alpha
      14.  
      15. sampler2D _MainTex;
      16. fixed4 _Color;
      17.  
      18. struct Input {
      19.     float2 uv_MainTex;
      20. };
      21.  
      22. void surf (Input IN, inout SurfaceOutput o) {
      23.     fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
      24.     o.Albedo = c.rgb;
      25.     o.Alpha = c.a;
      26. }
      27. ENDCG
      28. }
      29.  
      30. Fallback "Transparent/VertexLit"
      31. }
      32.  
     

    Attached Files:

  2. JustJeff

    JustJeff

    Joined:
    Feb 16, 2015
    Posts:
    84
    Aww crap... meant for this to go in general graphics because I don't think this is for sure a shader thing. Can a mod please move it?

    P.S. Here's the butterfly with the double-shader without transparency from alpha selected under texture import options: