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 Setzer22 · Dec 30, 2012 at 12:36 PM · gridmaptileprojector

Projecting a grid over a mesh

Hello everyone.

I'm having some problems trying to figure out how to project a grid over a mesh. To keep this simple, this is basically what I'm attempting to do: http://2.bp.blogspot.com/_EwDBFLRie5Q/SinU5hy0J2I/AAAAAAAAAHU/JyHdKz5SVjs/s1600-h/goodgrid.jpg

Projecting a grid over a terrrain but only where I want it to be projected, despite being parts of the same mesh (just like the picture).

This picture, as well as my initial idea on how to do this, comes from a topic in the unity forums where someone posted a script which did that creating the whole grid texture and using a small image where each pixel represented a tile (the black pixels represented where he didn't want to place a tile and the white ones, where there should be one). Then with a simple script, he got a plain grid texture and deleted the tiles which corresponded to the black pixels of his (let's call it) tiny alpha map.

I found this to be a really good idea and I preety much understand how to do it, but I've found several problems and I want to discuss this after I start scripting it.

So, first of all, I'm not really familiar with projectors, nor the documentation was able to provide any help with that (I'm starting to get used to this...) and my question is, how can I get a "clear" projection as it's done on the image above? And by clear I mean that all the examples of projectors I've seen make the textures you project "fade off" and smooth and thus, not resulting into anything like this grid.

My second question is quite more relevant to what I'm trying to accomlpish. In my game I'm planning to have large maps, let's say, 200x200 tiles of average. I don't think the method I saw of doing this (the same I did explain) would work nicely with a projector, as I would need a grid image as large as the grid I want to display, and this might be a problem, I've done some calculations, and I'd be easily going over 2000x2000 pixels textures, which I think might cause performance problems. Am I right with this?

Other than that, I think it might be important to mention that I'm not planning into using a small alpha map. Rather than that, I'll be using the array where I've got stored my map info as data and checking wether a map tile equals "null" or doesn't. I don't think this would cause much trouble but it might be useful to someone in order to answer this.

Thank you very much! ^^

Comment
Add comment · Show 1
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 Eric5h5 · Dec 30, 2012 at 08:21 PM 0
Share

A 2048x2048 texture is not a problem.

1 Reply

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

Answer by tomekkie2 · Dec 30, 2012 at 12:46 PM

To get an effect like that on the linked picture I would divide the whole mesh into the submeshes, basing on the average vertices y coordinates on the mesh triangles, and then would apply separate materials, with one of them containing the grid texture. In order to do that you need to use a shader capable to accomodate multiple textures like decal for the material containing the grid texture.

Comment
Add comment · Show 6 · 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 Setzer22 · Dec 30, 2012 at 12:59 PM 0
Share

Well, what I'm actually trying to accomplish is to display the gird on a given point only if I want to, and that condition is based on an input file (or an array in memory, I still don't know), not on the mesh vertices height. This would work on the picture i linked, but my map might be flat and I still would want to not display the grid on a given group of tiles, so I'm afraid this might not be what I'm looking for.

avatar image tomekkie2 · Dec 30, 2012 at 01:03 PM 0
Share

I think this should work this way as long as you can deter$$anonymous$$e the mesh triangles where you like this to happen and the mesh has a flat uv mapping

avatar image Fattie · Dec 30, 2012 at 02:26 PM 0
Share

Just as $$anonymous$$e says, basically use more than one texture, one way or another.

You know, the absolutely best way to do something like this could be with a ("slightly") modified shader that either adds or does not add the grid, depending on some value.

You'd need a shader expert though! :)

avatar image Setzer22 · Dec 30, 2012 at 03:32 PM 0
Share

Yes, I was thinking as well on modifying a shader but that might be a little tricky. I understand what you meant on the triangles method, and it might work as well. I'll keep investigating

avatar image Setzer22 · Dec 30, 2012 at 04:43 PM 0
Share

Well, I don't think I have the time right now to get myself into program$$anonymous$$g shaders. It seems like a whole new world to me, so I'll stuck into the other possibilities. Just to make it clear, would it be that costly to use a very big (and by big I mean 2000x2000) grid texture to cover the whole map with an ortographic projector? I've found a nice shader surfing the Unity forums which can easily help me to do the rest, but I'd need large texture files to make it work. To clear that even more, my grid texture isn't going to have any fancy effects, just black and white pixels for$$anonymous$$g a nice grid shape, I don't really need more than that. Also, creating that texture programatically is going to hurt any performance of my game? I'm not planning to modify this on runtime, just on load.

EDIT: Well, it seems I've been missing the obvious. If I don't need at all my grid to be generated at runtime, i could just set it in the scene and forget about programatically editing textures, i could even use paint. I don't think a couple of grid textures would hurt much the game's size more than this would have hurt performance. Until I find a good way to do this with shaders I'll stuck to the easy way. I'll mark this as answered

Show more comments

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

10 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

Related Questions

Alternative method to grid projection for a quad-tile game? 2 Answers

Programming an isometric (top down) grid 0 Answers

What is the best way to create 3D tile based levels in Unity ? 1 Answer

How can I compare two tilemaps by color? 1 Answer

Projector question for a Level Design Map 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