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: goodgrid.jpg (image)

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! ^^

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.