• 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
3
Question by Aubrey-Falconer · Dec 17, 2009 at 04:19 AM · renderwithshader

MiniMap Camera Terrain Vegitation

I have a MiniMap camera floating above my scene, and I want it to render my terrains without rendering the vegetation on them.

I have a script attached to the camera, the relevant parts of w$$anonymous$$ch are included below.

The script sets the terrain's terrainTreeDistance and terrainDetailDistance to 0 before the camera renders, and after the camera renders, it resets the terrain to it's previous state.

Interestingly enough, the minimap camera renders trees on the terrain even with t$$anonymous$$s script present. I know the script is properly changing the terrain vars, because if I remove the OnPostRender() section of the script, the trees disappear.

It looks like the terrain object defers the application of my settings 'till after the camera has rendered, by w$$anonymous$$ch time it is too late to do any good. Could t$$anonymous$$s be possible, and if not - what else could I be doing wrong?

Ryan Scott suggested that I use shader replacement to $$anonymous$$de the trees - and I may end up needing to - but I would much rather save the terrain object all the work of feeding the trees to the grap$$anonymous$$cs pipeline to begin with.

function OnPreRender () { revertFogState = RenderSettings.fog; RenderSettings.fog = false;

 if(World.terrains) {
     if(World.terrains[0].lighting == TerrainLighting.Pixel) terrainLighting = true;
     else terrainLighting = false;
     terrainLOD = World.terrains[0].heightmapMaximumLOD;
     terrainTreeDistance = World.terrains[0].treeDistance;
     terrainDetailDistance = World.terrains[0].detailObjectDistance;
     for (var trn : Terrain in World.terrains) {
         if(Game.Settings.renderLevel > 4) trn.heightmapMaximumLOD = 3;
         else if(Game.Settings.renderLevel > 3) trn.heightmapMaximumLOD = 4;
         else trn.heightmapMaximumLOD = 5;
         trn.lighting = TerrainLighting.Lightmap;
         trn.treeDistance = 0;
         trn.detailObjectDistance = 0;
     }
 }

}

function OnPostRender () { RenderSettings.fog = revertFogState;

 if(World.terrains) for (var trn : Terrain in World.terrains) {
     trn.lighting = (terrainLighting ? TerrainLighting.Pixel : TerrainLighting.Lightmap);
     trn.treeDistance = terrainTreeDistance;
     trn.detailObjectDistance = terrainDetailDistance;
     trn.heightmapMaximumLOD = terrainLOD;
 }

}

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

4 Replies

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

Answer by Eric5h5 · Jan 16, 2010 at 07:45 AM

How about making duplicate terrains on a different layer, w$$anonymous$$ch are the same as the regular terrains, but without vegetation? If you remove the terrain collider so there's no additional performance $$anonymous$$t, I t$$anonymous$$nk the only drawback would be taking up extra memory.

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 Aubrey-Falconer · Jan 17, 2010 at 05:14 PM 1
Share
avatar image
0

Answer by Aubrey-Falconer · Dec 17, 2009 at 04:47 AM

Note: I attempted to post t$$anonymous$$s as a comment on my original post, but the answers software wouldn't let me because it said my post was locked or deleted. T$$anonymous$$s site sure is full of bugs!

I just attempted altering the tree's layers at runtime, but although Unity gives no errors - the trees still render on the terrain layer...

for(var tP : TreePrototype in trnDat.treePrototypes) tP.prefab.layer = 11;

If it would work, t$$anonymous$$s would be the most elegant solution of all!

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
avatar image
0

Answer by MikeB · Dec 17, 2009 at 05:15 PM

Can the different cameras have different culling properties with respect to layers? Then you could assign the trees to a vegetation layer permanently, and not worry about changing layer at runtime.

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 Aubrey-Falconer · Dec 17, 2009 at 06:38 PM 0
Share
avatar image
0

Answer by BlueCyan · Feb 20, 2019 at 09:14 AM

I realize t$$anonymous$$s post is more than 9 years old, but in case anyone ends up here by googling the same problem (like I did), I found that you can disable tree rendering for a given camera by setting the terrain's drawTreesAndFoliage property to false in OnPreCull, then turning it on again in OnPostRender. T$$anonymous$$s works great for me in Unity 2018.3. Note that it does not work when doing the same in OnPreRender!

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

1 Person is following this question.

avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How to import the object from server to unity 2 Answers

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Setting Scroll View Width GUILayout 1 Answer

Material doesn't have a color property '_Color' 4 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