2016-04-28 3 views
0

Also habe ich diesen Shader, den ich versuche zu flimmern, also lasse ich den Emissionswert zwischen 0 und hin und her gehen 1, aber es funktioniert nur, wenn ich auf das Material klicke oder im Editor blättern. Ich kann das nicht herausfinden, bitte helfen Sie?Beim Aktualisieren der Ausgabe eines Shaders wird nur aktualisiert, wenn ich in den Editor klicke. [Unity]

Ich überprüfte etwas ähnliches, aber es wird immer noch nicht funktionieren, also bitte helfen.

Renderer renderer; 
Material material; 
float emission; 

// Use this for initialization 
void Start() { 
    renderer = GetComponent<Renderer>(); 
    material = renderer.material; 
} 

// Update is called once per frame 
void Update() { 

    emission = Mathf.PingPong (Time.time, 1f); 
    Color color = Color.red; 

    Color finalColor = color * Mathf.LinearToGammaSpace (emission); 
    material.SetColor ("_EmissionColor", finalColor); 

} 

Antwort

0

i ein Problem gelöst, wie Sie Bitten teilen Sie Ihre Shader uns dank

versuchen Mathf.sin (time.time) Pingpong zu bekommen vielleicht Ihr Problem

Gelöst

oder Verwendung Schlag Shader

Shader "Custom/Emition" { 
    Properties { 
     _MainTex ("Albedo (RGB)", 2D) = "white" {} 
     _EmissionColor ("Bright", Float) = 1.0 
    } 
    SubShader { 
     Tags { "RenderType"="Opaque" } 
     LOD 200 
     pass { 
     CGPROGRAM 

     #pragma vertex vert    
     #pragma fragment frag 

     #include "UnityCG.cginc" 


     uniform float _EmissionColor; 
     sampler2D _MainTex; 
     struct vertexInput { 
      float4 vertex : POSITION;   
      float2 texcoord : TEXCOORD0; 
     }; 

     struct vertexOutput { 
      float4 pos : SV_POSITION; 
      float2 uv : TEXCOORD0; 
     }; 


     vertexOutput vert(vertexInput input) 
     { 
      vertexOutput output; 
      output.pos = mul(UNITY_MATRIX_MVP, input.vertex); 

      output.uv = input.texcoord; 
      return output; 
     } 

     float4 frag(vertexOutput input) : COLOR 
     { 
      fixed4 c = tex2D (_MainTex , input.uv) ; 



      /// change blow line 


      return c* float4(_EmissionColor,1,1,1); 

     } 
     ENDCG 
    } 
    } 
    FallBack "Diffuse" 
} 
+0

Fragment Shader ist sicher und nicht ansteckend –

Verwandte Themen