Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
2 captures
11 Jun 22 - 14 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 miszelfox · Aug 02, 2015 at 01:54 PM · shadermasknormalmapnormal mapbumpmap

Normal map mask

I am using glass distortion shader from standard assets. I would like to apply mask to normal map, but i don't know how. It's easy to make a mask for texture, but i don't know how to make it with normal maps. I could just apply a mask in external app like Gimp, but i want it to be applied at runtime, because i want to change normal map offset (animate it) without losing mask. I don't want transparency but just applying black&white/transparent texture to normal map to make it flat in certain places.

Example:

1) I have this normal map as input image: Click

2) I use this image as mask: Click

3) Generated normal map: Click

And then it just uses new normal map in output.

Here is a default shader: Click

Can anyone help mi with that?

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 LidorYo · Mar 03, 2016 at 01:58 PM 0
Share

Have you find a solution? I'm facing the same problem..

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Mar 03, 2016 at 03:32 PM

First of all your "normal map" texture isn't a normal map. It's a bumpmap. However Unity doesn't really use bumpmapping but normalmapping. The Unity editor usually converts imported bumpmaps into normalmaps. While a bumpmap is just a grayscale heightmap, a normal map contains actual normal vectors where each component of the vector is encoded in one of the color channels.

When a shader uses a normal map it will sample the normal map and use the unpacked vector as normal vector for lighting calculation. To "mask" a normal map at shader level you just need to do this in the fragment / surface shader:

  • grab the usual interpolated vertex normal (let's call it "N")

  • grab the unpacked sampled normal from the normal map (let's call it "M")

  • sample your "masking texture" to get a value between 0 and 1 (let's call it "i")

  • Lerp between "N" and "M" using "i"

  • normalize the result and use it as normal vector.

Comment
Add comment · 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
0

Answer by salamdaher0 · Feb 10, 2018 at 06:03 AM

@miszelfox , did it work? I am looking to make the same thing but I am not sure how to write it. do you have a sample code you can share? Thank you

Comment
Add comment · 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

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

25 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 avatar image avatar image

Related Questions

a shader or decal that only renders the normal map 0 Answers

Shader issue: Normal map from tangent to world space - Textures flipping? 0 Answers

Mobile Bumped Diffuse problem 1 Answer

Layering multiple Normal maps into one without blending in a Surface shader script 0 Answers

Two bump map shader 0 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