• 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
1
Question by JonManatee · Jan 18, 2011 at 04:21 AM · terraincullingrenderwithshader

Terrain Culled in RenderWithShader

I have an issue where my terrain is being culled inappropriately when used with a buffer I am constructing with the RenderWithShader functionality. The camera is created and then disabled immediately. Each frame I call this in OnPreCull:

Camera cam = shaderCameraObject.camera;
cam.CopyFrom (camera);
cam.backgroundColor = Color.black;
cam.clearFlags = CameraClearFlags.SolidColor;
cam.cullingMask = clipLayer.value;
cam.targetTexture = boatCullBuffer;
cam.RenderWithShader(shader, "CullBuffer");
Shader.SetGlobalTexture("_CullBuffer", boatCullBuffer);

So the camera has the same farClip as my main camera (I've debugged to confirm this). Here's a shot of the main camera's view:

alt text

And then here is a shot of the RenderWith Shader (Terrain should render completely green):

alt text

Any Thoughts? Why is the culling happening inappropriately?

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 Jean-Fabre · Jan 24, 2011 at 10:56 AM 0
Share

Could you make a screen shot of the terrain in wireframe, depending on the zoom and relative size of the faces, it could have an impact.

avatar image Bunny83 · Jan 25, 2011 at 09:30 AM 0
Share

Are you sure that your shader you're using for RenderWithShader is working correctly? Try to use a different shader and check the result (rendertexture). Can you post the shader you use? And does this happens with other geometrie? (something other than terrain). Like $$anonymous$$ said, give us a screen shot with wireframe or a simpler scene that have the same issue.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Bravini · Jan 22, 2011 at 12:57 AM

your snippet is being called on the OnPreCull? the RenderWithShader function doesn't calls OnPreCull http://unity3d.com/support/documentation/ScriptReference/Camera.RenderWithShader.html so your CopyFrom is probably not being applied. Try calling it from somewhere else.

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 JonManatee · Jan 22, 2011 at 02:39 AM 0
Share

I don't think that's right, because this is attached to the $$anonymous$$ain Camera, the one rendering the top image. Which IS calling OnPreCull. The second camera on shaderCameraObject is being told to RenderWithShader() which will not call OnPreCull(), but that is irrelevant to the $$anonymous$$ain Camera. To be sure, I changed the code to LateUpdate and it did not fix the problem.

avatar image Bravini · Jan 22, 2011 at 02:59 AM 0
Share

could you upload a scene package with just the relevant components?

avatar image
-2

Answer by Jeston · Jan 24, 2011 at 09:47 AM

Edit: Ooops, nm I misread the question sorry

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

No one has followed this question yet.

Related Questions

Make a simple tree 1 Answer

Terrain Performance on Shaded Terrain 0 Answers

Lightmapped Terrain not providing normals to PostProcessing Shader. 2 Answers

Moving Terrains causes severe lag, why? 1 Answer

How to turn off backface culling for terrains? 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