In many games there Is section as customize character that you can make your own character.I always love to know how can I make something like It.
Even old game have this feature? but how ?
For Implementing It I need accurate separation for communating between values and facial parts size. So first I made multiple height-map based on facial parts for modifying by vertex shader and work correctly but this method Isn't optimal.can I Implement It just by one texture?
then I tried by using colorful mapping texture for detecting facial parts, but I have problem for getting color values from mapping texture In my shader code.
mapping texture:
My problem Is that my vertex shader Isn't match with my mapping texture.for example If I change _NoseLength
other parts will changes.how can I tell to vertex shader which part is nose,forehead,lip,cheek,... In my colorful mapping.
Here Is my Shader Code:
Shader "Custom/Extrude" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_ModTex ("Vertex Modify", 2D) = "white" {}
_NoseLength ("NoseLength ", Range(-0.05,0.01)) = 1.0
_LipSize ("LipSize ", Range(-0.05,0.01)) = 1.0
_CheekBones ("CheekBones ", Range(-0.05,0.01)) = 1.0
_ForeHead ("ForeHead ", Range(-0.05,0.01)) = 1.0
_EyeSize("EyeSize", Range(-0.05,0.01)) = 1.0
}
SubShader {
Tags { "RenderType"="Opaque" "Queue" = "Transparent"}
Cull off
CGPROGRAM
#pragma surface surf Lambert vertex:vert
#pragma target 3.0
sampler2D _MainTex;
sampler2D _ModTex;
uniform fixed _NoseLength;
uniform fixed _LipSize;
uniform fixed _CheekBones;
uniform fixed _ForeHead;
uniform fixed _EyeSize;
struct Input {
float2 uv_MainTex;
};
void vert(inout appdata_full v) {
float4 lipSize = tex2Dlod(_ModTex, float4(v.texcoord.xy, 0, 0)).g;//Green
float4 nose = tex2Dlod(_ModTex, float4(v.texcoord.xy, 0, 0)).b; //Blue
float4 eye = tex2Dlod(_ModTex, float4(v.texcoord.xy, 0, 0)).r; // Red
float2 cheek = tex2Dlod(_ModTex, float4(v.texcoord.xy, 0, 0)).rg; // Yellow
float2 forehead = tex2Dlod(_ModTex, float4(v.texcoord.xy, 0, 0)).rb; // Purple
v.vertex.y += _LipSize * lipSize;
v.vertex.y += _NoseLength * nose;
v.vertex.y += _EyeSize * eye;
v.vertex.y += _CheekBones * cheek;
v.vertex.y += _ForeHead * forehead ;
}
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}