• 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 senad · Oct 29, 2012 at 10:46 PM · terrainshadersshader programmingprojectors

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! :) :)

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

1 Reply

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

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:

  1. Create another terrain surface mesh/polygon by duplicating the existing terrain in my 3D software (Max, Maya, etc).

  2. Shift this duplicate upward.

  3. Delete the unwanted polygons (the steep parts).

  4. Import this duplicate to Unity.

  5. Create an image (in photoshop or illustrator) that looks like the grids that you are trying to 'project'.

  6. Import this image to Unity.

  7. Create a new material Assets>Create>Material.

  8. Name it 'Grids'.

  9. Change the Shader into "Transparent/Diffuse".

  10. Apple the image created at #5 to the Texture slot.

  11. Adjust the Tiling x and y accordingly to fit into the proportion of your model.

  12. 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.

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 senad · Oct 30, 2012 at 04:03 PM 0
Share

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. :)

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

Terrain surfaceshader, or terrain shader supporting multiple lights - need example 0 Answers

A custom Unlit (Transparent)Shader is giving black edges on the top with a 2D sprite renderer ? 1 Answer

Is there any way to do a Clip() in the vertex shader rather than fragment shader? 1 Answer

Modifying the depth buffer of an image effect? 0 Answers

Displace and show normals in fragment shader 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges