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 KristofferH · Jul 15, 2018 at 11:40 AM · shaderlabshader writingambient lightvertexcolor

Manipulate the Global Ambient light in a shader?

I want to write my own shader that doesn't use the GI solutions in Unity (not baking lightmaps, nor the Pre-computed Real-time GI), I only want to use the Gradient or Ambient Color in the Environment Lighting.

What I want to do is to multiply the Ambient color with the vertex color of the mesh (the vertex color is the baked ambient occlusion from the 3D software I make the mesh in), before Unity adds the lighting together.

I have tried this method, using the unity_AmbientSky and multiply it with the vertex color from the Input struct and adding it to the Albedo.

 void surf (Input IN, inout SurfaceOutputStandard o) {
     fixed4 c = _Color + unity_AmbientSky * IN.vertexColor.r;
     o.Albedo = c.rgb;
 }

The problem with this method is that I don't really modify the lighting, but rather I manipulate the Albedo color, and if so I might as well just paint the lighting and AO into the albedo texture from the start. Or do I missunderstand how the void surf() function actually works? I mean where in the shader does unity do the lighting stuff? A very basic Surface Shader does automatically handle light, shadows and GI/ambient without I having to add or multiply the Albedo with the lighting, so where does a Surface Shader do the "lighting stuff" and how do I interfere with it? Because I don't want to take the Albedo color, add the Ambient color multiplied with the vertex color and then Unity adds the Ambient color again as part of it's built in lighting pass. But I don't know how the shader pipeline works here. But my point is: I don't want to change the albedo color of the material, I want to manipulate the global Ambient color before it is added to the final screen pixel color. Check out this blog post about how to multiply the AO pass in post-production when rendering with offline renderers (like mental ray) The Joy of a little "Ambience"... it might explain this a bit clearer, with image examples.

I want Unity to take care of the direct lighting, and using Surface Shader (rather then Lambert, or Unlit) for taking care of shadows, reflection, specular, emission, and so on.

I'm mostly want to use this for mobile and VR, so I suppose the Forward Rendering path is the one I'm going for, or the new Scriptable Render Pipeline in Unity 2018.

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 marchall_box · Dec 27, 2020 at 04:57 PM

Im dealing with the same problem. Did you get any luck with it?

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.

Follow this Question

Answers Answers and Comments

87 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

Related Questions

How to adapt this shader into a transparent one (alpha blend) 0 Answers

Cutout Shader with Vertex Color (always black) 0 Answers

A Cg shader semantic problem 2 Answers

Shader - What is float3.xy? 1 Answer

Shaderlab Multiple Texture Layers 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