Разбираюсь с шейдингом...
Радостно передрал Twist2D шейдер из Cg Tutorial oт Nvidia
http://http.developer.nvidia.com/CgTuto ... ter03.htmlНедоработки:
1. Не понял как можно полезно применить в игре.
2. Недеформированный объект рисует почему-то все-равно...
3. Не добавил пока текстуру
Скрытый текст:
- Код: Выделить всё
Shader "Twist2D and VertexLit" {
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 ("Shininess", Range (0.01, 1)) = 0.7
_MainTex ("Base (RGB)", 2D) = "white" {}
_Twisting ("Twisting", Range(0.01,1)) = 0.0
}
SubShader {
Pass {
Material {
Diffuse [_Color]
Ambient [_Color]
Shininess [_Shininess]
Specular [_SpecColor]
Emission [_Emission]
}
Lighting On
SeperateSpecular On
SetTexture [_MainTex] {
Combine texture * primary DOUBLE, texture * primary
}
}
Pass {
Blend One One
CGPROGRAM
#pragma vertex vert
#include "UnityCG.cginc"
uniform float _Twisting;
struct appdata {
float4 vertex : POSITION;
float4 normal : NORMAL;
float4 color : COLOR;
};
struct v2f {
float4 pos : POSITION;
float4 color : COLOR;
};
v2f vert (appdata v) {
v2f o;
float angle = _Twisting * length(v.vertex);
float cosLength, sinLength;
sincos(angle, sinLength, cosLength);
o.pos[0] = cosLength * v.vertex[0] + -sinLength * v.vertex[1];
o.pos[1] = sinLength * v.vertex[0] + cosLength * v.vertex[1];
o.pos[2] = 0;
o.pos[3] = 1;
o.color = v.color;
return o;
}
ENDCG
}
}
Fallback Off
}