How to add a lightmap?

Node-based Shader Editor
mossman
Posts: 40
Joined: Sun Dec 10, 2017 3:58 pm

How to add a lightmap?

Post by mossman »

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 1150 times
User avatar
Ricardo Teixeira
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm

Re: How to add a lightmap?

Post by Ricardo Teixeira »

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!
mossman
Posts: 40
Joined: Sun Dec 10, 2017 3:58 pm

Re: How to add a lightmap?

Post by mossman »

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 effect
achieved effect
achieved.jpg (21.65 KiB) Viewed 18255 times
The desired effect:
Desired effect
Desired effect
desired.jpg (24.11 KiB) Viewed 18255 times

Thanks
User avatar
Ricardo Teixeira
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm

Re: How to add a lightmap?

Post by Ricardo Teixeira »

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!
mossman
Posts: 40
Joined: Sun Dec 10, 2017 3:58 pm

Re: How to add a lightmap?

Post by mossman »

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.74 KiB) Viewed 18250 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.79 KiB) Viewed 18250 times
Thanks
User avatar
Ricardo Teixeira
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm

Re: How to add a lightmap?

Post by Ricardo Teixeira »

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!
mossman
Posts: 40
Joined: Sun Dec 10, 2017 3:58 pm

Re: How to add a lightmap?

Post by mossman »

Thanks Ricardo!
User avatar
Amplify_Borba
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: How to add a lightmap?

Post by Amplify_Borba »

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.34 KiB) Viewed 18217 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!
mossman
Posts: 40
Joined: Sun Dec 10, 2017 3:58 pm

Re: How to add a lightmap?

Post by mossman »

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.31 KiB) Viewed 18212 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.3 KiB) Downloaded 1828 times
User avatar
Ricardo Teixeira
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm

Re: How to add a lightmap?

Post by Ricardo Teixeira »

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!
Post Reply