• 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 Murcho · Dec 01, 2009 at 01:37 AM · shaderterrainrenderwithshader

Lightmapped Terrain not providing normals to PostProcessing Shader.

I'm currently running a edited version of the DepthNormal encoding PostProcessing shader, and when trying to use it with a terrain using lightmapped based lighting, it creates this log message every frame:

Shader wants normals, but the mesh doesn't have them UnityEngine.Camera:RenderWithShader(Shader, String) UnityEngine.Camera:RenderWithShader(Shader, String) DepthBugTesting:OnPreRender() (at Assets\Skunkwerks Assets\Shaders\DepthBugTesting.cs:51) UnityEditor.EditorGUIUtility:RenderGameViewCameras(Rect, Rect, Boolean, Boolean) UnityEditor.EditorGUIUtility:RenderGameViewCameras(Rect, Rect, Boolean, Boolean) UnityEditor.GameView:OnGUI() System.Reflection.MonoMethod:InternalInvoke(Object, Object[]) System.Reflection.MonoMethod:InternalInvoke(Object, Object[]) System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) System.Reflection.MethodBase:Invoke(Object, Object[]) UnityEditor.HostView:Invoke(String) UnityEditor.DockArea:OnGUI()

[....\Runtime\Filters\Mesh\LodMesh.cpp line 1061]

I've also tried setting up the shader with the default builtin shader provided on the Unity site (the one I originally edited from) and it also produces this error, however when setting up the camera with the new "Camera.depthTextureMode" settings, which uses this shader internally, it doesn't cause this error.

Can anyone shed some light on why this might be happening, or any way of getting around this error, as we need to use an edited version of the DepthNormals encoding Post Processing 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

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Aras · Dec 01, 2009 at 04:25 PM

Like Jonas said, lightmapped terrain does not build normals in the mesh for efficiency reasons (it does not need them at runtime). The only exception is, when Camera.depthTextureMode is Depth+Normals, in that case it builds the normals because they are needed.

Currently there's no way to manually force terrain to always provide normals. Can you explain your use case? (e.g. maybe Camera.depthTextureMode would just work for you?)

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 Murcho · Dec 01, 2009 at 11:15 PM 0
Share

We are using a shader which is basically transparent cutout with culling turned off, and two Post Processing shaders that use the normal/depth buffer. In order for the objects that use that shader to render into the depth buffer properly, we need to use an edited version of the Camera - DepthNormalTexture texture to accommodate the lack of culling. Thanks for confir$$anonymous$$g my suspicions on this problem. Would it be possible to put a manual check for this in future versions of Unity? Should I put a request for it on the Feedback site?

avatar image Aras ♦♦ · Dec 02, 2009 at 08:12 AM 0
Share

Yeah, a request on feedback.unity3d.com seems appropriate.

avatar image
0

Answer by jonas-echterhoff · Dec 01, 2009 at 08:40 AM

As the terrain gets it's lighting information from the lightmap, it does not need any normals, so the engine skips calculating those in lightmapped mode. Can you switch to vertex or realtime lighting modes?

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 Murcho · Dec 01, 2009 at 10:49 AM 0
Share

We can, however the performance boost from having a lightmapped terrain would be nice. Currently the scene we're running tops out at around 3000 draw calls and we're looking for any way to try and optimize. $$anonymous$$y main question was the fact that it doesn't cause these errors to be called when using the Camera.depthTexture$$anonymous$$ode with the shader, so is there some way of adding that functionality to the manual replacement shader calls?

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

No one has followed this question yet.

Related Questions

How to turn off backface culling for terrains? 1 Answer

Adding layers to Unity Terrain ( 4, 8, 14) 1 Answer

How to correctly access and use terrain texture tiling from custom terrain shader? 0 Answers

How do you turn off terrain blending? 1 Answer

HDRP Terrain Shader issues in Standalone Build Only 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