Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Chetzy · Jun 25, 2018 at 03:56 PM · scripting problemshadershadersshader programmingshader writing

Shader Color

enter code hereHi, im doing a game with toon shader but the colors of the shader are to opaque, I want to get intensity in the colors but i dont know how to do this in the shader, please help me. Here is the code:

 Shader "ToonDeferredShading" {
 Properties {
     _LightTexture0 ("", any) = "" {}
     _LightTextureB0 ("", 2D) = "" {}
     _ShadowMapTexture ("", any) = "" {}
     _SrcBlend ("", Float) = 1
     _DstBlend ("", Float) = 1
 }
 SubShader {
 
 // Pass 1: Lighting pass
 //  LDR case - Lighting encoded into a subtractive ARGB8 buffer
 //  HDR case - Lighting additively blended into floating point buffer
 Pass {
     ZWrite Off
     Blend [_SrcBlend] [_DstBlend]
 
 CGPROGRAM
 #define UNITY_BRDF_PBS BRDF_Unity_Toon
 #pragma target 3.0
 #pragma vertex vert_deferred
 #pragma fragment frag
 #pragma multi_compile_lightpass
 #pragma multi_compile ___ UNITY_HDR_ON
 
 #pragma exclude_renderers nomrt
 
 #include "UnityCG.cginc"
 #include "UnityDeferredLibrary.cginc"
 //#include "UnityPBSLighting.cginc"
 #include "UnityStandardUtils.cginc"
 #include "UnityGBuffer.cginc"
 #include "UnityStandardBRDF.cginc"
 #include "UnityStandardBRDFCustom.cginc"
 
 sampler2D _CameraGBufferTexture0;
 sampler2D _CameraGBufferTexture1;
 sampler2D _CameraGBufferTexture2;
         
 half4 CalculateLight (unity_v2f_deferred i)
 {
     float3 wpos;
     float2 uv;
     float atten, fadeDist;
     UnityLight light;
     UNITY_INITIALIZE_OUTPUT(UnityLight, light);
     UnityDeferredCalculateLightParams(i, wpos, uv, light.dir, atten, fadeDist);
 
     light.color = _LightColor.rgb * atten;
 
     // unpack Gbuffer
     half4 gbuffer0 = tex2D (_CameraGBufferTexture0, uv);
     half4 gbuffer1 = tex2D (_CameraGBufferTexture1, uv);
     half4 gbuffer2 = tex2D (_CameraGBufferTexture2, uv);
     UnityStandardData data = UnityStandardDataFromGbuffer(gbuffer0, gbuffer1, gbuffer2);
 
     float3 eyeVec = normalize(wpos-_WorldSpaceCameraPos);
     half oneMinusReflectivity = 1 - SpecularStrength(data.specularColor.rgb);
 
     UnityIndirect ind;
     UNITY_INITIALIZE_OUTPUT(UnityIndirect, ind);
     ind.diffuse = 0;
     ind.specular = 0;
 
   half4 res = UNITY_BRDF_PBS (data.diffuseColor, data.specularColor, oneMinusReflectivity, data.smoothness, data.normalWorld, -eyeVec, light, ind);
     return res;
 }
 
 #ifdef UNITY_HDR_ON
 half4
 #else
 fixed4
 #endif
 frag (unity_v2f_deferred i) : SV_Target
 {
     half4 c = CalculateLight(i);
     #ifdef UNITY_HDR_ON
     return c;
     #else
     return exp2(-c);
     #endif
 }
 
 ENDCG
 }
 
 
 // Pass 2: Final decode pass.
 // Used only with HDR off, to decode the logarithmic buffer into the main RT
 Pass {
     ZTest Always Cull Off ZWrite Off
     Stencil {
         ref [_StencilNonBackground]
         readmask [_StencilNonBackground]
         // Normally just comp would be sufficient, but there's a bug and only front face stencil state is set (case 583207)
         compback equal
         compfront equal
     }
 
 CGPROGRAM
 #pragma target 3.0
 #pragma vertex vert
 #pragma fragment frag
 #pragma exclude_renderers nomrt
 
 #include "UnityCG.cginc"
 
 sampler2D _LightBuffer;
 struct v2f {
     float4 vertex : SV_POSITION;
     float2 texcoord : TEXCOORD0;
 };
 
 v2f vert (float4 vertex : POSITION, float2 texcoord : TEXCOORD0)
 {
     v2f o;
     o.vertex = UnityObjectToClipPos(vertex);
     o.texcoord = texcoord.xy;
 #ifdef UNITY_SINGLE_PASS_STEREO
     o.texcoord = TransformStereoScreenSpaceTex(o.texcoord, 1.0f);
 #endif
     return o;
 }
 
 fixed4 frag (v2f i) : SV_Target
 {
     return -log2(tex2D(_LightBuffer, i.texcoord));
 }
 ENDCG 
 }
 
 }
 Fallback Off
 }
 
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
0

Answer by callebo_FK · Jun 26, 2018 at 06:26 AM

What do you mean the colors are too opaque? Do you want it to be transparent? Can you show example images of what you have and explain further what you want?

What have you tried so far?

Comment
Add comment · Show 1 · 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 Chetzy · Jun 26, 2018 at 03:36 PM 0
Share

I only want more vivid colors and instensity because the actual colors of the shader are so dark and boring, in a few moments i show you images for best explicacion and thank you

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

201 People are following this question.

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

Related Questions

How to add Emission to my custom shader? 2 Answers

Shader: Modify XY Position of Texture 0 Answers

Adding a clip() to the default shader? 0 Answers

Shader - What is float3.xy? 1 Answer

Drawing silhouette shader 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