• 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 Arnaud1602 · Feb 05, 2015 at 10:30 AM · shader

CandelaSSRR in Unity 5

CandelaSSRR works out-of-the-box in Unity 5 ( at least in deferred mode ), but all surfaces are at maximum reflectivity regardless of the alpha parameter. How to make it work with the standard shader ?

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
Best Answer

Answer by Arnaud1602 · Feb 05, 2015 at 10:31 AM

The reason why everything is shiny is that the output alpha buffer is always all white (as can be seen in the frame debugger and the alpha of the scene view).

This is due to the way Unity resolves the GBuffers : UNITY_BRDF_PBS() always outputs 1 to the alpha channel.

Steps to fix this :

  • Download the Unity 5 shaders that match your beta version (mine is 21)

  • Copy DefaultResourcesExtra/StandardSpecular.shader, CGIncludes/UnityStandardCore.unity and DefaultResourcesExtra/Internal-DeferredShading.cginc anywhere in your Assets/ folder.

  • Rename all of them with a "_Custom" prefix (not sure if really needed)

  • Make the deferred renderer output the alpha channel : at the very end of UnityStandardCore_Custom.cginc, remplace

    outDiffuse = half4(s.diffColor, 0.0);

with

 outDiffuse = half4(s.diffColor, s.alpha)


  • Make your Custom Standard Shader use this function instead of the built-in one : in StandardShader_Custom.shader, remplace

    Shader "Standard (Specular setup)"

with

 Shader "Standard (Specular setup), Set Alpha"

and

 #include "UnityStandardCore.cginc" // There are 5 occurrences of this line, all must be replaced

with

 #include "UnityStandardCore_Custom.cginc"


  • Make Unity use your own copy of Internal-DeferredShading.inc : Render settings -> Deferred -> Custom -> Pick your custom .shader

  • Replace

    Blend [_SrcBlend] [_DstBlend] // Line 16 in beta 21

with

 Blend [_SrcBlend] [_DstBlend], Zero SrcAlpha

and

 half4 res = UNITY_BRDF_PBS (baseColor, specColor, oneMinusReflectivity, oneMinusRoughness, normalWorld, -eyeVec, light, ind); // Line 66 in beta 21
 return res;

with

 half4 res = UNITY_BRDF_PBS (baseColor, specColor, oneMinusReflectivity, oneMinusRoughness, normalWorld, -eyeVec, light, ind);
 res.a = gbuffer0.a;
 return res;
 
 
  • You should now be able to change the reflectivity of the material by changing the diffuse color's alpha; just make sure it uses your new custom standard shader.

A few notes

  • This may or may not interfere with occlusion, I'm not sure yet

  • I'm also not sure how it works with the transparent standard shader

  • In Unity 5 we now have access to the GBuffers, so Candela can skip doing their own pass and spare the fillrate (at least in deferred), so performance-wise, more modifications are needed.

Comment
Add comment · 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

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

19 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

Related Questions

How to force the compilation of a shader in Unity? 5 Answers

Glass Shader with Strumpy Shader Editor 1 Answer

Lightweight Render Shader not receive shadows 0 Answers

Is there any need of Shader Scripts in unity5 or PBS is enough? 1 Answer

Vertex displacement shader not working 2 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