- Home /
trying to modify this shader for hair.
Hi, i have been trying to find shaders close to the one i use in my game, basically it's a mobile shader, which has cutoff and softness for hair, and is a diffused shader. - the closest things i have come to find are:
Vegetation shaders, ( really great, has diffuse, but is extremely dark. )
transparent/cutout/diffuse soft edge, is ok, but it lacks, a lot. ( bad quality )
and lastly ( the current one i use ) -- CutoutMob shader. ( this is the best one i have found so far. ) found it a year ago, never really used it for hair, until i got tired of trying to find replacement shaders for the vegetation.
i don't have 20 bucks to spend on stuff in the asset store at the moment, or time to update to unity 5.1 ( it was a pain getting my project back to working order after upgrading to 4.6. ( current version )
the only problem is, this shader is showing the object, when it's not supposed to. ( when selected, and really apparent when looking at it in an different angle.)
this is a photo of what i'm talking about.
and here is the shader's script: ( Unaltered )
Shader "Custom/CutoutMob" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 200
CGPROGRAM
#pragma surface surf Lambert alpha noforwardadd
sampler2D _MainTex;
fixed4 _Color;
float _Cutoff;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
if (c.a > _Cutoff)
o.Alpha = c.a;
else
o.Alpha = 0;
}
ENDCG
}
Fallback "Diffuse"
}
i don't work with shaders a lot, i don't know what i would have to do, to get it to function correctly.
( basically, i don't want the head to show through the hair. )
and here is another side of the hair. ( full glory of the problem )
if anyone has any advise on how to make the shader, Not show the model's head, while keeping the Alpha cutoff, and diffuse the same, that would be great.
thank you for your time, -
Ownerfate.
To the point:
i don't want objects showing through the shader.
( the diffuse and cutoff are fine )
ok, i found this script, that was actually VERY VERY close to what i'm looking for, if no one can alter the current shader script, here is where i found the one i'm using now.
unity forum link: http://forum.unity3d.com/threads/hair-shader-with-kajiya-kay-specularity-and-proper-sorting.167762/
it's all the way at the bottom.
but here is the script:
Shader "Transparent/Double-Sided Vertex Lit" {
Properties {
_Color ("$$anonymous$$ain Color", Color) = (1,1,1,1)
_$$anonymous$$ainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}
SubShader {
Tags {"RenderType"="Transparent" "Queue"="Transparent"}
// Render into depth buffer only
Pass {
ZWrite On
Blend SrcAlpha One$$anonymous$$inusSrcAlpha
Color$$anonymous$$ask RGB
Cull off
$$anonymous$$aterial {
Diffuse [_Color]
Ambient [_Color]
}
Lighting On
SetTexture [_$$anonymous$$ainTex] {
Combine texture * primary DOUBLE, texture * primary
}
}
}
}
UPDATE / Edit
Only works well with certain meshes, not all. ( i'll keep looking )
i tried to post this yesterday, but i think the maintenance on the site affected the submit button.
but, what i found yesterday was a script similar to the one above, this doesn't have soft edge, even though it's a soft edge test.
it's ok, i'll use it for the time being, until i can find what i'm looking for.
Script:
i seem to not be able to post the script? the submit button does nothing after i post the script.