Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by onelove · Feb 05, 2013 at 05:25 AM · graphics

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 ....

Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image robertbu · Feb 05, 2013 at 06:31 AM 0
Share

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.

avatar image onelove · Feb 05, 2013 at 06:53 AM 0
Share

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

alt text

untitled-1.jpg (377.3 kB)
avatar image onelove · Feb 05, 2013 at 02:53 PM 0
Share

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
avatar image onelove · Feb 05, 2013 at 02:54 PM 0
Share

}

         // 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;
 }
avatar image onelove · Feb 05, 2013 at 02:58 PM 0
Share

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

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges