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 ohlin · Dec 16, 2014 at 10:27 AM · shadertexturetransparencytranslucent

Adding transparency to a 2 texture blending shader...noobie.

Im new to messing with shaders and pieced this one together, but now im having trouble adding translucency to this....How would I get the 2 textures to be blendable but also have a slider or something that makes the blended outcome translucent?

  Shader "Custom/My ToonShader Test1" {
 Properties {
 _Lookup ("BRDF Color Ramp", 2D) = "gray" {}
 _MainTex ("Texture", 2D) = "white" {}
 _Detail ("Texture", 2D) = "white" {}
 _Blend ( "Blend", Range ( 0, 1 ) ) = 0.5
 _RimPower ("Rim Power", Float) = 1.4
 _RimColor ("Rim Color (RGB) + Intensity (A)", Color) = (0.0,0.0,0.0,1.0)
 _SColor ("Shadow Color", Color) = (0.0,0.0,0.0,1)
 _LColor ("Highlight Color", Color) = (0.5,0.5,0.5,1)
 }
 SubShader {
 Tags { "RenderType"="Opaque" }
 LOD 200
 Pass
 {
 SetTexture[_MainTex]
 SetTexture[_Detail]
 {
 ConstantColor ( 0, 0, 0, [_Blend] )
 Combine texture Lerp( constant ) previous
 }
 }
 CGPROGRAM
 #pragma surface surf Lookup
 sampler2D _MainTex;
 sampler2D _Lookup;
 float _Blend;
 sampler2D _Detail;
 float4 _LColor;
 float4 _SColor;
 float _RimPower;
 float4 _RimColor;
 struct Input
 {
 float2 uv_MainTex;
 float4 screenPos;
 float2 uv_Detail;
 float3 pos : POSITION0;
 float3 viewDir;
 };
 half4 LightingLookup (SurfaceOutput s, half3 lightDir, half3 viewDir, half atten)
 {
 float NdotL = dot(s.Normal, lightDir);
 float NdotV = dot(s.Normal, viewDir);
 float2 lookupUV = float2(NdotV*.8, NdotL * 0.5 + 0.5);
 float3 exitRadiance = tex2D(_Lookup, lookupUV).rgb;
 float4 c;
 c.a = s.Alpha;
 #ifndef USING_DIRECTIONAL_LIGHT
 lightDir = normalize(lightDir);
 #endif
 half d = dot (s.Normal, lightDir)*0.5 + 0.5;
 half3 ramp = tex2D(_Lookup, float2(d,d)).rgb;
 ramp = lerp(_SColor, _LColor, ramp);
 c.rgb = s.Albedo * _LightColor0.rgb * ramp * (exitRadiance * (atten * 2));
 return c;
 }
 void surf (Input IN, inout SurfaceOutput o)
 {
 float2 screenUV = IN.screenPos.xy / IN.screenPos.w;
 screenUV *= float2(1,1);
 half4 mainTex = tex2D (_MainTex, IN.uv_MainTex);
 o.Albedo = mainTex.rgb;
 o.Alpha = mainTex.a;
 fixed4 t1 = tex2D( _MainTex, IN.uv_MainTex);
 fixed4 t2 = tex2D( _Detail, screenUV)*2;
 o.Albedo = lerp( t1, t2, _Blend);
 //Rim Outline
 half rim = saturate( dot(normalize(IN.viewDir), o.Normal) );
 o.Albedo *= 1.0f - (step(rim, _RimPower) * (1.0f-_RimColor) * _RimColor.a);
 }
 ENDCG
 }
 Fallback "Diffuse"
 }
  
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by kapstok666 · Dec 16, 2014 at 11:42 AM

I don't know wether you're familiar with scripting but I suggest to use the Strumpy Shader Editor: https://www.assetstore.unity3d.com/en/#!/content/456 It is a way to 'visually' script a shader. This shader editor is another extension to your Unity editor and generates the code for you. Maybe this'll help you out ;)

Comment
Add comment · Show 3 · Share
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 ohlin · Dec 17, 2014 at 11:23 PM 0
Share

I need the code...but I will try strumpy. I'll just have to rebuild my shader in strumpy.

avatar image MrSoad · Dec 17, 2014 at 11:31 PM 0
Share

@kapstok666 (+1) thank you for the info and link, and it's free, fantastic!!!

avatar image kapstok666 · Dec 18, 2014 at 02:30 PM 0
Share

ohlin, you know the code is being generated by the shader editor right? So you have the shader code in a file in unity anyway.

You're welcome, $$anonymous$$rSoad :)

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Transparency and texture atlases, shader calls affecting performance? 2 Answers

Making a cutout semi-transparent? 1 Answer

HDRP, should I use transparent or opaque alpha clipping for foliage texture? 0 Answers

Pages overlapping problem 1 Answer

How can i shader transparent Objects together? 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