Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by Lord Ned · Nov 06, 2015 at 01:42 PM · unity5surface shaderlightmapssurfaceshaderwhy

Using the Lightmap UV texcoords in a Unity 5 Surface Shader?

This seems like a really simple thing to do, but is apparently not as easy as I thought.

I wish to use a surface shader which uses the "Standard" lighting model (to get access to U5's new PBR lighting, etc, etc.). I want to use a surface shader so that I get lighting, lightmap sampling, etc. all for 'free' and don't have to implement them. Basically, this shader should be indistinguishable from things already shaded using "Standard".

I would like to use the static lightmap UV texture coordinates in my surface shader. I want to use them to sample an unrelated texture, and depending on the result of that sample, modify the surface color or other properties.

I have found that I can texture sample unity_Lightmap (using say, the main UVs) and it will show the lightmap texture for the object. However, all attempts to get access to the Lightmap UVs have failed.

I tried directly accessing the unity_LightmapST uniform, and while it compiles, it seems to have a value of 0 for all pixels.

The documentation says that for the Surface Shader Input structure, "Texture coordinates must be named “uv” followed by texture name (or start it with “uv2” to use second texture coordinate set).". However, attempts to get this to sample the lightmap uvs (and not the 2nd uv set of the models) have failed.

I tried using the TEXCOORD1 semantic in the Input structure, but this appears to be ignored.

Shader Sourcecode Here. I am applying this to a mesh which has "Lightmap Static" checked, and has lightmaps generated for that mesh. The lightmap UVs for this mesh can be seen here, and you can see how it does not interpolate the color based on the X position of the lightmap UVs.

Thanks!

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
0

Answer by the_dark-eye · Sep 07, 2017 at 11:20 AM

Up ! I have the same issue thanks..

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Specular vs. Emission in Surface Shader? 2 Answers

uv-space to screenSpace in surface shader 0 Answers

How to not require normals in a surface shader 1 Answer

Access GameObject position and model position in surface shader? 0 Answers

How can I use a "Specular" property with surface shaders using the Standard lighting model? 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