Noticias

¡RECUERDA QUE SI ERES UN NUEVO USUARIO, DEBES PRESENTARTE PARA PODER PUBLICAR MENSAJES! | TENEMOS CANAL OFICIAL DE TELEGRAM: t.me/unity3dspain

Sader Decal NormalMap

Iniciado por brok, Enero 13, 2018, 11:44:25 PM

Tema anterior - Siguiente tema
Hola chicos, estoy intentando hacer un shader decal con normal map pero no da resultado ¿alguna idea?:
 

Shader "Custom/Decal" {
  Properties {
   _Color ("Main Color", Color) = (1, 1, 1, 1)
   _MainTex ("Base (RGB)", 2D) = "white" {}
   _BumpMap ("Bumpmap", 2D) = "bump" {}
   _DecalTex ("Decal (RGBA)", 2D) = "black" {}
      }
   
   SubShader
   {
       
   Tags {
         "RenderType" = "Opaque"
         "Queue"="Transparent"
         "IgnoreProjector"="True"
         "RenderType"="Transparent"
         }
     
   Pass
   {
       
      BindChannels {
         Bind "Vertex", vertex
         Bind "normal", normal
         Bind "texcoord", texcoord0 // main uses 1st uv
         Bind "texcoord1", texcoord1  // decal uses 2nd uv
      }
         
 
       
       SetTexture [_MainTex]
      {
         constantColor [_Color]
         Combine texture * constant
      }
         
      SetTexture [_DecalTex]
      {
             combine texture lerp (texture ) previous
      }
 
   }
       
   CGPROGRAM
   #pragma surface surf Lambert
   struct Input
   {
      float2 uv_MainTex;
      float2 uv_BumpMap;
      float2 uv_DecalTex;
   };
   sampler2D _MainTex;
   sampler2D _BumpMap;
   sampler2D _DecalTex;
   void surf (Input IN, inout SurfaceOutput o)
   {
      o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
      o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
   }
   ENDCG
}
    Fallback "Diffuse"
       
}

 
 
 

Shader "Custom/Decal" {
  Properties {
   _Color ("Main Color", Color) = (1, 1, 1, 1)
   _MainTex ("Base (RGB)", 2D) = "white" {}
   _BumpMap ("Bumpmap", 2D) = "bump" {}
   _DecalTex ("Decal (RGBA)", 2D) = "black" {}
      }
   
   SubShader
   {
       
   Tags {
         "RenderType"="Opaque"
         "Queue"="Geometry+1"
         "ForceNoShadowCasting"="True"
         "Queue"="Transparent"
         "IgnoreProjector"="True"
         "RenderType"="Transparent"
         }
     
   LOD 200
   Offset -1, -1
       
   CGPROGRAM
   #pragma surface surf Lambert
   struct Input
   {
      float2 uv_MainTex;
      float2 uv_BumpMap;
      float2 uv_DecalTex;
   };
   sampler2D _MainTex;
   sampler2D _BumpMap;
   sampler2D _DecalTex;
   void surf (Input IN, inout SurfaceOutput o)
   {
      o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
      o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
      half4 c = tex2D (_DecalTex, IN.uv_DecalTex);
      o.Albedo = c.rgb;
      o.Alpha = c.rgba;
   }
   ENDCG
}
    Fallback "Diffuse"
       
}

 
Ya se ve el decal pero no funciona la trasparencia y también quiero que se fusione con el nomal map

para la tranparencia
 
tienes puesto:
 
o.Alpha = o.rgba;
 
deveria ser:
 
o.Alpha = c.a;




   
Cita de: Igor date=1516280944para la tranparencia
         
         
            tienes puesto:
         
         
            o.Alpha = o.rgba;
         
         
            deveria ser:
         
         
            o.Alpha = c.a;
         
      
   

      Ya probe asin y no funciono pr eso le puse rgba, pero gracias.
   

[/quote]
 
 

Etiquetas: