How to add a lightmap?

Node-based Shader Editor

How to add a lightmap?

Postby mossman » Mon Feb 26, 2018 9:36 am

Hello,

I don't apply a lightmap properly to a vertext/fragment shader.

I make this simple shader to test. (attatched to this post)

Please any help?

Thanks
Attachments
Unlit.zip
(2.25 KiB) Downloaded 285 times
mossman
 
Posts: 40
Joined: Sun Dec 10, 2017 3:58 pm

Re: How to add a lightmap?

Postby Ricardo Teixeira » Mon Feb 26, 2018 11:16 am

mossman wrote:Hello,
I don't apply a lightmap properly to a vertext/fragment shader.
I make this simple shader to test. (attatched to this post)
Please any help?
Thanks



Hello,

Thank you for getting in touch, we would be happy to help.

What's the intended effect?

The Lightmap decode node simply accesses the required per-object information and allows you to derive some information, as we do with custom lighting but, unfortunately, without additional steps/tools, you cannot rewrite Unity lightmaps.

Thanks!
Sales & Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm

Re: How to add a lightmap?

Postby mossman » Mon Feb 26, 2018 12:55 pm

Hello Ricardo,

The inteded effect is apply to my shader de lightmap generated by Unity. I want not rewrite Unity lightmaps.


The achieved effect:
achieved.jpg
achieved effect
achieved.jpg (21.73 KiB) Viewed 6650 times


The desired effect:
desired.jpg
Desired effect
desired.jpg (24.17 KiB) Viewed 6650 times



Thanks
mossman
 
Posts: 40
Joined: Sun Dec 10, 2017 3:58 pm

Re: How to add a lightmap?

Postby Ricardo Teixeira » Mon Feb 26, 2018 1:53 pm

mossman wrote:Hello Ricardo,
The inteded effect is apply to my shader de lightmap generated by Unity. I want not rewrite Unity lightmaps.
The achieved effect:
achieved.jpg

The desired effect:
desired.jpg

Thanks


Using the Unlit shader you shared, the lightmap should be visible immediately after pressing play. Is that not the case?

Thanks!
Sales & Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm

Re: How to add a lightmap?

Postby mossman » Mon Feb 26, 2018 2:47 pm

The result of the shared shader is the achieved effect image. All the surface of the mesh is dark and some part are more dark than others.

If I created a simple unlit shader with a tint color like this material.
material.PNG
material.PNG (12.8 KiB) Viewed 6645 times


And then I will bake the lightmap from the Lightning panel with this settings the lightmap doesn't affect the simple unlit shader.
lightning.PNG
lightning.PNG (34.9 KiB) Viewed 6645 times


Thanks
mossman
 
Posts: 40
Joined: Sun Dec 10, 2017 3:58 pm

Re: How to add a lightmap?

Postby Ricardo Teixeira » Tue Feb 27, 2018 2:39 pm

Hello,

Thank you for sharing additional details.

We'll run a few more tests on our side and get back to you as soon as possible.

Apologies for the inconvenience.
Sales & Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm

Re: How to add a lightmap?

Postby mossman » Tue Feb 27, 2018 8:55 pm

Thanks Ricardo!
mossman
 
Posts: 40
Joined: Sun Dec 10, 2017 3:58 pm

Re: How to add a lightmap?

Postby Amplify_Borba » Wed Feb 28, 2018 3:45 pm

Upon investigating this situation, we came to conclude that this is not an ASE related issue, the lightmap ST calculations must be done manually since the ST variables do not use the termination "_ST", and instead drop the "_" in favor of only "ST", so an automatic ST variable is being used that does not match the right variable.

Please refer to the following screenshot as a working solution.

Lightmap.png
Lightmap.png (141.87 KiB) Viewed 6612 times


Do note that you must select the proper UV channel in the Vertex Texcoord node!

Please let me know if this helps, thanks!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: How to add a lightmap?

Postby mossman » Thu Mar 01, 2018 11:33 am

Thanks Ricardo.

I test your solution but now the result is that all cubes with this shader are full white.
Captura.PNG
Captura.PNG (6.35 KiB) Viewed 6607 times


I attatched the new version of the shader.

In the Vertex Texcoord node I selected the UV channel 1 and in the Texture Sample node (unity_Lightmap) I selected the UV set 1.
Attachments
Unlit2.rar
(2.31 KiB) Downloaded 357 times
mossman
 
Posts: 40
Joined: Sun Dec 10, 2017 3:58 pm

Re: How to add a lightmap?

Postby Ricardo Teixeira » Thu Mar 01, 2018 12:35 pm

mossman wrote:Thanks Ricardo.
I test your solution but now the result is that all cubes with this shader are full white.
Captura.PNG

I attatched the new version of the shader.
In the Vertex Texcoord node I selected the UV channel 1 and in the Texture Sample node (unity_Lightmap) I selected the UV set 1.


Hello,

You will have to remove the underscore character from the Texture Sample node property name.

Image

Use unity_Lightmap instead of _unity_Lightmap.

Looking forward to your feedback.
Sales & Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm

Next

Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 6 guests