- Home /
how can i add opacity lines to a double sided shader script?
i have been through every forum and nothing, the idea is that i got the double sided plane to work, bit since its hair for a character i would like to also use an opacity map to define the strands, please help ....
If the front and back of the plane look the same, then you can get away with using a single sided plane with a shader with culling turned off. This will allow you to use any number of shaders that support transparency.
i am not the greatest at javascript, and i have managed to find a shader that works, but now this shader doesnt have double sided, now i guess its the same question ins$$anonymous$$d of adding transparency to the current shader i would like to add 2 sided .....
take a look at the hair facial hair and jacket, the three of them need doublesided ....the hair just needs the doublesided feature , as well as the jacket ....both shaders ....please help
im trying to post the code i have so far, but its too long ....so im going to try to copy and paste it in parts, i found this code online ...is there anyway to add the Cull off to it
Properties { _Color ("$$anonymous$$ain Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0) Shininess ("Shininess", Range (0.01, 1)) = 0.078125 $$anonymous$$ainTex ("Base (RGB) Spec (A) ", 2D) = "white" {} _Bump$$anonymous$$ap ("Bumpmap (RGB) Trans (A)", 2D) = "bump" {} }
Category {
Tags {Queue=Transparent}
Alphatest Greater 0
Fog { Color [_AddFog] }
ZWrite Off
Color$$anonymous$$ask RGB
// ------------------------------------------------------------------
// ARB fragment program
#warning Upgrade NOTE: SubShader commented out; uses Unity 2.x per-pixel lighting. You should rewrite shader into a Surface Shader.
/*SubShader {
Pass {
//Name "BASE"
Tags {"Light$$anonymous$$ode" = "Always" /* Upgrade NOTE: changed from PixelOrNone to Always */}
Blend SrcAlpha One$$anonymous$$inusSrcAlpha
Color [_PPLAmbient]
SetTexture [_$$anonymous$$ainTex] {constantColor [_Color] Combine texture * primary DOUBLE, previous * primary}
// calculate transparency for ambient pass from bump alpha
SetTexture [_Bump$$anonymous$$ap] {Combine previous, texture}
}
Pass {
Blend SrcAlpha One$$anonymous$$inusSrcAlpha
//Name "BASE"
Tags {"Light$$anonymous$$ode" = "Vertex"}
Lighting On
$$anonymous$$aterial {
Diffuse [_Color]
Emission [_PPLAmbient]
Specular [_SpecColor]
Shininess [_Shininess]
}
SeparateSpecular On
CGPROGRA$$anonymous$$
// Upgrade NOTE: excluded shader from OpenGL ES 2.0 because it does not contain a surface program or both vertex and fragment programs. #pragma exclude_renderers gles #pragma fragment frag #pragma fragmentoption ARB_fog_exp2 #pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
uniform sampler2D _$$anonymous$$ainTex, _Bump$$anonymous$$ap;
half4 frag (v2f_vertex_lit i) : COLOR {
half4 texcol = tex2D( _$$anonymous$$ainTex, i.uv );
half bumpcol = tex2D( _Bump$$anonymous$$ap, i.uv ).a;
half4 c;
c.rgb = ( texcol.rgb * i.diff.rgb + i.spec.rgb * texcol.a ) * 2;
c.a = bumpcol * i.diff.a;
return c;
}
ENDCG
}
// Pixel lights
Pass {
Blend SrcAlpha One
Name "PPL"
Tags { "Light$$anonymous$$ode" = "Pixel" }
CGPROGRA$$anonymous$$
// Upgrade NOTE: excluded shader from DX11 and Xbox360; has structs without semantics (struct v2f members uv$$anonymous$$,uv2,viewDirT,lightDirT) #pragma exclude_renderers d3d11 xbox360 #pragma vertex vert #pragma fragment frag #pragma multi_compile_builtin_noshadows #pragma fragmentoption ARB_fog_exp2 #pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
#include "AutoLight.cginc"
struct v2f {
float4 pos : SV_POSITION;
LIGHTING_COORDS
float3 uv$$anonymous$$; // xy = UV, z = specular $$anonymous$$
float2 uv2;
float3 viewDirT;
float3 lightDirT;
};
uniform float4 _$$anonymous$$ainTex_ST, _Bump$$anonymous$$ap_ST, UNITY_LIGHT$$anonymous$$O$$anonymous$$_A$$anonymous$$BIENT_ST;
uniform float _Shininess;
v2f vert (appdata_tan v)
{
v2f o;
o.pos = mul (UNITY_$$anonymous$$ATRIX_$$anonymous$$VP, v.vertex);
o.uv$$anonymous$$.xy = TRANSFOR$$anonymous$$_TEX(v.texcoord,_$$anonymous$$ainTex);
o.uv$$anonymous$$.z = _Shininess * 128;
o.uv2 = TRANSFOR$$anonymous$$_TEX(v.texcoord,_Bump$$anonymous$$ap);
TANGENT_SPACE_ROTATION;
o.lightDirT = mul( rotation, ObjSpaceLightDir( v.vertex ) );
o.viewDirT = mul( rotation, ObjSpaceViewDir( v.vertex ) );
TRANSFER_VERTEX_TO_FRAG$$anonymous$$ENT(o);
return o;
}
uniform sampler2D _Bump$$anonymous$$ap;
uniform sampler2D _$$anonymous$$ainTex;
uniform float4 _Color;
float4 frag (v2f i) : COLOR
{
float4 texcol = tex2D( _$$anonymous$$ainTex, i.uv$$anonymous$$.xy );
// get normal (and transparency factor) from the normal map
float4 bump$$anonymous$$ap = tex2D(_Bump$$anonymous$$ap, i.uv2);
half transparencyFactor = bump$$anonymous$$ap.a;
float3 normal = bump$$anonymous$$ap.rgb * 2 - 1;
half4 c = SpecularLight( i.lightDirT, i.viewDirT, normal, texcol, i.uv$$anonymous$$.z, LIGHT_ATTENUATION(i) );
c.a = transparencyFactor;
return c;
}
ENDCG
}
}*/
// ------------------------------------------------------------------
// Radeon 9000
#warning Upgrade NOTE: SubShader commented out because of manual shader assembly
/*SubShader { Cull off
UsePass "Transparent/Specular/BASE"
// Pixel lights with 0 light textures
Pass {
Blend SrcAlpha One
Name "PPL"
Tags {
"Light$$anonymous$$ode" = "Pixel"
"LightTexCount" = "0"
}
CGPROGRA$$anonymous$$
// Upgrade NOTE: excluded shader from OpenGL ES 2.0 because it does not contain a surface program or both vertex and fragment programs. #pragma exclude_renderers gles #pragma vertex vert #include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
float2 uv2 : TEXCOORD3;
float3 lightDirT: TEXCOORD2;
float3 halfDirT : TEXCOORD1;
};
uniform float4 _$$anonymous$$ainTex_ST, _Bump$$anonymous$$ap_ST;
v2f vert(appdata_tan v)
{
v2f o;
o.pos = mul (UNITY_$$anonymous$$ATRIX_$$anonymous$$VP, v.vertex);
o.uv = TRANSFOR$$anonymous$$_TEX(v.texcoord,_$$anonymous$$ainTex);
o.uv2 = TRANSFOR$$anonymous$$_TEX(v.texcoord,_Bump$$anonymous$$ap);
TANGENT_SPACE_ROTATION;
o.lightDirT = mul( rotation, ObjSpaceLightDir( v.vertex ) );
float3 viewDirT = mul( rotation, ObjSpaceViewDir( v.vertex ) );
o.halfDirT = normalize( normalize(o.lightDirT) + normalize(viewDirT) );
return o;
}
well first of, this is a partial part of the script, its way too long ...but the results are amazing with the alpha ...and bump ....now if only i could get double sided working ...it be awesome ..please help ...if you need the full code let me know ... ill find a way to share it ...considering it works amazingly ...just the double sided part is missing .....i know this might sound stupid, but i also dont know if this is c# or javascript
Your answer
![](https://koobas.hobune.stream/wayback/20220613092151im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Issue with UV mapping on voxel faces 0 Answers
Having a Sprite's position be different to it's prefab's 0 Answers
Unity Browser game. ok on desktop, weird dark stripes on notebook 0 Answers
Is it possible to make a game look good without third-party programs? 1 Answer
How to make a cleaning effect similar to the one in Dumb Ways to Die with C#? 0 Answers