Page 1 of 2

How to add a lightmap?

PostPosted: Mon Feb 26, 2018 9:36 am
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

Re: How to add a lightmap?

PostPosted: Mon Feb 26, 2018 11:16 am
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!

Re: How to add a lightmap?

PostPosted: Mon Feb 26, 2018 12:55 pm
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.jpg
achieved effect
achieved.jpg (21.73 KiB) Viewed 6595 times


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



Thanks

Re: How to add a lightmap?

PostPosted: Mon Feb 26, 2018 1:53 pm
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!

Re: How to add a lightmap?

PostPosted: Mon Feb 26, 2018 2:47 pm
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.8 KiB) Viewed 6590 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 6590 times


Thanks

Re: How to add a lightmap?

PostPosted: Tue Feb 27, 2018 2:39 pm
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.

Re: How to add a lightmap?

PostPosted: Tue Feb 27, 2018 8:55 pm
by mossman
Thanks Ricardo!

Re: How to add a lightmap?

PostPosted: Wed Feb 28, 2018 3:45 pm
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.87 KiB) Viewed 6557 times


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

Please let me know if this helps, thanks!

Re: How to add a lightmap?

PostPosted: Thu Mar 01, 2018 11:33 am
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.35 KiB) Viewed 6552 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.

Re: How to add a lightmap?

PostPosted: Thu Mar 01, 2018 12:35 pm
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.