Unity Web Player. Install now!

Your browser does not support the Unity Web Player. Want to save the shader for later? Add it to a collection.

Add Shader To Collection

efectos de color y brillo manejados por animación


script:


private var selectionGridInt : int = 0;
private var selectionStrings : String[];
var lista:boolean;
private var level:int;
var materialItem:Material;
var itemColors:Color[];
private var tiempoAnim:float[];
var materialAnim:Animation;



function Start() {
selectionStrings = new String[16];
var i=0;
for (var level in selectionStrings) {
level="+"+i;
i++;
}
tiempoAnim = new float[16];
var j=0.0;
var h=0;
while (h<=15) {
tiempoAnim[h]=j;
j+=1.0/16.0;
h++;
}
levelEffect(0);
}



function OnGUI() {
if (GUI.Button (Rect (Screen.width - 110, 10, 100, 20), "Item Level")) lista=!lista;
if (lista) selectionGridInt = GUI.SelectionGrid (Rect (Screen.width - 110, 40, 100, 20*selectionStrings.length), selectionGridInt, selectionStrings, 1);
if (selectionGridInt!=level) levelEffect(selectionGridInt);
}



function levelEffect (lvl:int) {
level=lvl;

//brillo e.e
// Set up some state;
var estadoAnim : AnimationState=materialAnim["materialAnim1"];
estadoAnim.enabled = true;
estadoAnim.time = tiempoAnim[lvl];
// Sample animations now.
materialAnim.Play("materialAnim1");
materialAnim.Sample();
estadoAnim.enabled = false;

//color c:
//materialItem.color=itemColors[lvl];
Debug.Log("lvl: "+lvl+", tiempoAnim: "+tiempoAnim[lvl]);
}


shader:


Shader "Zurvive/Glow" {
Properties {
_Color ("Main Color", Color) = (1,1,1,0)
_SpecColor ("Spec Color", Color) = (1,1,1,1)
_Emission ("Emmisive Color", Color) = (0,0,0,0)
_Shininess ("Reflejo", Range (0.01, 1)) = 0.7



_OutlineColor ("Outline Color", Color) = (0,0,0,1)
_Outline ("Outline width", Range (0.002, 0.03)) = .005
_Size("Brillo Altura", Float) = 0.1

_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Pass {
Material {
Diffuse [_Color]
Ambient [_Color]
Shininess [_Shininess]
Specular [_SpecColor]
Emission [_Emission]
}
Lighting On
SeparateSpecular On
SetTexture [_MainTex] {
Combine texture * primary DOUBLE, texture * primary
}
}

Pass {
Name "OUTLINE"
Tags { "LightMode" = "Always" }
CGPROGRAM
#pragma vertex vert



struct appdata {
float4 vertex;
float3 normal;
};



struct v2f {
float4 pos : POSITION;
float4 color : COLOR;
float fog : FOGC;
};
uniform float _Outline;
uniform float4 _OutlineColor;
uniform float _Size;



v2f vert(appdata v) {

v2f o;

v.vertex.xyz += v.normal*_Size;

o.pos = mul(glstate.matrix.mvp, v.vertex);
float3 norm = mul ((float3x3)glstate.matrix.modelview[0], v.normal);
norm.x *= glstate.matrix.projection[0][0];
norm.y *= glstate.matrix.projection[1][1];
o.pos.xy += norm.xy * o.pos.z * _Outline;
//o.pos.x += norm.x * o.pos.z * _Outline;
//o.pos.y += norm.y * o.pos.z * _Outline;

o.fog = o.pos.z;
o.color = _OutlineColor;
return o;
}
ENDCG

//Color (0,0,0,0)
Cull Off
ZWrite On
ColorMask RGB
Blend SrcAlpha OneMinusSrcAlpha
SetTexture [_MainTex] { combine primary }
}
}

Fallback "VertexLit"
}

More information

Published1 year ago
StatusPrototype
CategoryAssets
Authorestantaya