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 scottharber · Dec 19, 2014 at 12:36 PM · lightmappingbeastdecalambient occlusion

Lightmapping: Excluding materials from AO?

Hello,

I have a model which uses a custom alphablend shader to render decals on top of solid geometry. However, when I lightmap the geometry, the decal casts ambient occlusion onto the model beneath it.

Is there a way of preventing the decal from casting AO? For example, is there a shader constant that I can enable? I tried using the _Transmission attribute and including "Transparent" in the shader path/name, and while this uses the transparency to mask the AO, it doesn't remove it completely.

Comment
Add comment · Show 2
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 scottharber · Dec 30, 2014 at 01:57 PM 0
Share

Anyone? I can't be the only one to find this issue?

avatar image scottharber · Jan 07, 2015 at 10:06 AM 0
Share

Hello? Anyone?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Pangamini · Jan 07, 2015 at 10:37 AM

AO is rendered as a post process from the depth buffer. Decals usually render with depth bias (so in the depth buffer they appear closer to the camera), causing your problem. What you need to do is to use the bias when checking for depth, but not write the decal depth. You can change these properties in the shader that renders your decals.

Comment
Add comment · Show 5 · 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 scottharber · Jan 07, 2015 at 02:43 PM 0
Share

Hi Panga$$anonymous$$i,

How do I not write the decal depth? I tried adding "ZWrite Off" to the shader, but it had no effect on the lightmapping.

Here's the shader to explain what I mean.

 Shader "$$anonymous$$yShader/Transparent/$$anonymous$$yDecalShader" 
 {
     Properties
     {
         _$$anonymous$$ainTex( "RGB", 2D ) = "white" {}
     }
     SubShader {
         Fog { $$anonymous$$ode Off }
         Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
         Blend SrcAlpha One$$anonymous$$inusSrcAlpha
         ZWrite Off        
                         
         Pass {
             CGPROGRA$$anonymous$$
             #pragma vertex vert
             #pragma fragment frag
             #include "TheRestOfTheShader.cginc" 
             ENDCG
         }
     }
 }




avatar image Pangamini · Jan 07, 2015 at 06:30 PM 0
Share

$$anonymous$$y bad, i completelly missed the fact that you are talking about the lightmaps.... so are you creating decals as static objects before baking? (Otherwise i can't see how dynamic decals could cast static AO)

avatar image Pangamini · Jan 07, 2015 at 06:37 PM 0
Share

In which case, i can only think about souliton where decals are generated together with corresponing underlaying geometry UVs and applied the underlaying lightmap

avatar image scottharber · Jan 08, 2015 at 09:20 AM 0
Share

The decal and the underlying surface are part of the same model. The model is set as static.

avatar image Pangamini · Jan 08, 2015 at 11:03 AM 0
Share

Well i don't ha ve a ready solution then... but my assumption is that decal shouldn't be lightmap static, because that would mean it receives its own lightmap and casts lightmap shadows, while it's obvious that solution lies in a world where decals use the light information from the surface they are applied to. So that's the direction i'd go: make decals read the underlying lightmap data and apply it to itself

avatar image
0

Answer by scottharber · Jan 08, 2015 at 02:23 PM

Never mind. I found a solution by altering the placement of the decal.

Unity's lightmapper lets you place a decal between 0m and 0.00029m from a surface before it generates AO. Adding an offset to the decal shader prevents any Z fighting issues from such a close placement.

Comment
Add comment · Show 2 · 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 Pangamini · Jan 08, 2015 at 02:26 PM 0
Share

And will that apply lightmap to both the decal and underlying geometry?

avatar image scottharber · Jan 08, 2015 at 03:09 PM 0
Share

Yes. Since both are static, this will provide lightmaps for both meshes, but not generate AO between them as they are so close together.

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

27 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

Related Questions

Beast not creating lightmaps after a full scene bake 2 Answers

Beast lightmap ignores light culling mask and/or layers 2 Answers

Beast Lightmapper + Blending Shader 1 Answer

Single lightmap with day/night cycle 0 Answers

Scene Lighting prefabs and dynamic loading 1 Answer


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