- Home /
Grid Projector only for up-facing normals
I want to project a grid on a terrain surface, but only for the parts that are fairly flat. (especially not on walls and steep parts)
For this, I would like to check in the fragment shader if the normal is up-facing via the dot product.
However, I feel that I do not understand well enough how the projectors work to implement it. Can someone point me to a source describing projetors better? Or push me in the right direction with the shader??
All help is appreciated! :) :)
Answer by AlvinHerawan · Oct 30, 2012 at 11:56 AM
If what I have in mind is that same as what you are trying to achieve, then I would rather fake the grids that I am trying to project. Here's what I think I will do:
Create another terrain surface mesh/polygon by duplicating the existing terrain in my 3D software (Max, Maya, etc).
Shift this duplicate upward.
Delete the unwanted polygons (the steep parts).
Import this duplicate to Unity.
Create an image (in photoshop or illustrator) that looks like the grids that you are trying to 'project'.
Import this image to Unity.
Create a new material Assets>Create>Material.
Name it 'Grids'.
Change the Shader into "Transparent/Diffuse".
Apple the image created at #5 to the Texture slot.
Adjust the Tiling x and y accordingly to fit into the proportion of your model.
You could also adjust the 'brightness' by changing the Alpha of this material.
I hope I am guessing what you are trying to achieve correctly and I hope this helps.
Great suggestion, thanks a lot.
I think I will keep the grid projector but let the artists separate the terrain mesh into two layers. It is better to give them more control anyway, deciding by normal might not always be the best solution.
Not exactly what you suggested, but you gave me the right idea. :)
If I should want to have a custom texture for the grid, than I will use your approach. At the moment using the projector looks fine. :)