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
2
Question by Setzer22 · Aug 05, 2014 at 05:29 PM · terraingraphicsgrid

Best way to project a grid onto unity terrain

I'm trying to produce exactly this effect (the grid over the terrain) with unity and the terrain editor:

alt text

The tiles need to be highlightable, so it needs to be somehow dynamic. Also, as you can see, I don't want all the terrain to be covered in hexagons, so I need to be able to select which hexagons are there.

I've tried with a projector, but projectors and unity terrain don't seem to behave well together: When approaching with a camera to the projected grid, some chunks just disappear, not covering all of the terrain. Unfortunately there doesn't seem to be a good way for the projector not to tile its pattern all over the mesh, so I feel like this isn't the way to go as all of the terrain would be covered in hexagons. There doesn't seem to be a good way to highlight tiles either.

Using a directional light with a cookie gives me even less control over the grid, as I can't even edit the shader to achieve a better effect (painting rather than lighting). I should mention I had to do that in order for the projector to project a grid, and not a grid-ish light/shadow. Taking all that into acount, I've also discarded this method.

I know this is doable (just see the pic), and I really doubt this can't be done with Unity, so I'd like to know what's the way to go, in a general way.

I just thought I could create a custom shader taking an array of integers encoding the grid I intend to render (I could pass it to the graphics card as a texture, for example), and just paint hexagons according to that in the fragment shader. But before digging into this I'd like to know all the possibilities I have as modifying unity's terrain shader is completely out of scope for me...

So that's my question: How would I go into creating that effect? No matter how, but I want it to be done and to do it right, no weird workarounds like creating a grid mesh. I'm just doing this for fun and learning purposes and I want to do it like that.

Thank you!

DISCLAIMER:

So far I've tried all I've seen around Unity forums, and there doesn't seem to be a single user that achieved this very effect, nor I could by trying what they did. So I'd like to kindly ask not to flag this as a duplicate with any of those posts or similar, I've really searched through the whole forums and answers page:

http://forum.unity3d.com/threads/grid-on-terrain-help.203872/

http://forum.unity3d.com/threads/terrain-grid.44365/

http://answers.unity3d.com/questions/442581/how-to-draw-a-grid-over-parts-of-the-terrain.html

http://answers.unity3d.com/questions/749161/project-an-hex-grid-on-a-non-flat-terrain.html

Sorry for the disclaimer and I will remove it upon request, but I've had bad experienxes with questions being unfairly flagged as duplicate so I prefer to do this beforehand.

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 ChiP · Aug 14, 2014 at 02:43 AM 0
Share

sorry, this is not an answer but more of a question. Have you found something yet? I'm trying to do the same thing and I looked everywhere and even asked on the forum(without replies) but I can't seem to find anything useful. $$anonymous$$y current approach is to use a square mesh(i don't have an hexagonal grid) for every tile and to change its vertices to adapt it to the terrain, the problem is that if i want the tiles and the terrain to not intersect, i have to make more subdivisions to the square and also to rise it a bit off the terrain. I don't really like the result cause it becomes somewhat heavy and also not so good looking.

avatar image robertbu · Aug 14, 2014 at 06:03 AM 0
Share

In the places I've seen hex-terrain-like settings, the underlying mesh is built off of vertices in a hex shape, and the resolution of the grid matches the size of the hex tiles. A terrain is a rectangular grid. You could write a script that creates a new hex mesh grid and use it in place of the terrain. Or you could have sections overlay the grid, but an overlay would not necessarily blend into the existing terrain at the edges.

0 Replies

· Add your reply
  • Sort: 

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

23 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

Related Questions

Create squares and draw them on terrain 1 Answer

Tree color variation 0 Answers

Weird ring-shaped artifact on terrain around camera 1 Answer

Objects visible through terrain 2 Answers

3D Terrain or Mesh Grid 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