DecodeDirectionalLightmap

Node-based Shader Editor

DecodeDirectionalLightmap

Postby b0kkie » Mon Feb 18, 2019 3:51 pm

Hi,

I am wondering if there is a way to use DecodeDirectionalLightmap in ASE.
I want to use a ramp in a custom lighting shader with directional lightmap support.
For this reason I'm baking a directional lightmap, but I am having trouble implementing this ASE.
I want to do a dot product between the directional lightmap and normal direction to drive the ramp.

Hope someone could point me in the right direction.

Cheers,
J

p.s.

I found this information, to give an idea.
https://catlikecoding.com/unity/tutoria ... g/part-16/
4.3 using direction
b0kkie
 
Posts: 5
Joined: Thu Jun 22, 2017 3:23 pm

Re: DecodeDirectionalLightmap

Postby Amplify_Borba » Tue Feb 19, 2019 3:34 pm

Hello, thank you for getting in touch and for your support!

Since we do have a custom node for the Decode Lightmap, it does make sense to also offer the one you've requested as well, so we've set up a Shader Function that I'm attaching to this post:

DecodeDirectionalLightmap.unitypackage
(1.19 KiB) Downloaded 390 times


We did this using a Custom Expression node, you may double click the function in order to see how it was set up.

Please let us know if this helps and if you have any further questions, 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: DecodeDirectionalLightmap

Postby b0kkie » Wed Feb 20, 2019 9:38 pm

Thank you so much for the help.

Only wondering how to implement this. I figured I would multiply this with my albedo texture.
Like you would multiply the albedo and light attenuation and light color after the ndotl in custom lighting.
decodelightmap gives a proper attenuation as you would expect where decodedirectionallightmap does not give the same result as I hoped. This is something i suspect related to unity and not ASE.

I will have to dig a bit deeper and hope to find a way of having baked lighting with custom lighting.
b0kkie
 
Posts: 5
Joined: Thu Jun 22, 2017 3:23 pm

Re: DecodeDirectionalLightmap

Postby Amplify_Borba » Thu Feb 21, 2019 2:53 pm

No problem, happy to help!

Since Amplify Shader Editor generates Standard Surface shaders by default, the results should be exactly the same as if you were using an equivalent Unity shader ( we often set up simple ASE and Unity shaders to test this ourselves ).
If you manage to confirm that the ASE generated standard shaders are producing an outcome that differs from Unity's, please let us know and we'll investigate it on our side.

Regarding the lightmap data, I believe that you'd have to multiply it by the final result of your texture data.

Please let us know if you have any further questions, thank you!
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: DecodeDirectionalLightmap

Postby b0kkie » Thu Feb 21, 2019 5:40 pm

Hi,
I've played around a bit and decided to take apart the decodedirectionallightmap function.
Atleast as I found in the UnityCG.cginc. It works perfectly and is identical to standard shader with baked lighting.

The problem however arises when I add a realtime light. It creates issues as seen from the screenshots.
With custom lighting I've seen you multiply the light attenuation and lightcolor at the end, however this
does not work for me in this case.
Would it be possible to get this to work both with baked lights and realtime lights as it works in the standard shader?
Any tips would be greatly appreciated. Thanks again!
Attachments
image02.jpg
image02.jpg (171.26 KiB) Viewed 4286 times
image01.jpg
image01.jpg (179.83 KiB) Viewed 4286 times
b0kkie
 
Posts: 5
Joined: Thu Jun 22, 2017 3:23 pm

Re: DecodeDirectionalLightmap

Postby Amplify_Borba » Fri Feb 22, 2019 3:06 pm

It seems that you might have stumbled into a possible issue, I'll need to escalate this to the developer for further investigation.

Could you please share a simple sample so that we can examine it on our side using the exact same data as you?
You can share it privately through [email protected] if you prefer, thank you!
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: DecodeDirectionalLightmap

Postby b0kkie » Mon Feb 25, 2019 4:06 pm

Hi again thanks for assisting with this.
You can get the sample package below. I've shared it through google drive.
https://drive.google.com/file/d/1Grh9mc ... sp=sharing
If you need anything else let me know.

Cheers,
J
b0kkie
 
Posts: 5
Joined: Thu Jun 22, 2017 3:23 pm

Re: DecodeDirectionalLightmap

Postby Amplify_Borba » Fri Mar 01, 2019 6:11 pm

Thank you for taking the time to prepare a sample, I'll be sure to get back in touch as soon as we have any developments to share!
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: DecodeDirectionalLightmap

Postby Amplify_RnD_Rick » Wed Mar 06, 2019 2:22 pm

Hey b0kkie,

Ricardo (the ASE developer here). Again thank you so much for taking the time on preparing that amazing sample.

I took at it and those artifacts are there because you aren't correctly considering the point lights on your custom lighting calculations.

I've tweaked the sample you sent ( link over here ) so in the Forward Add pass ( when the point lights contribution are added ) it now applies a simple N.L and multiply it by both the point light color and attenuation.

Please let us know if you have further questions!
Amplify_RnD_Rick
 
Posts: 40
Joined: Wed Mar 01, 2017 6:33 pm

Re: DecodeDirectionalLightmap

Postby b0kkie » Tue Mar 12, 2019 9:37 am

Hi Ricardo,

Thanks a lot for helping out with this.
I've had a look at the tweaked example and it does work.
It combines the baked and realtime lighting as you pointed out with the forward add pass.
It's still giving me some issues but I have to investigate this myself first.

Thanks again for the help.
Cheers,
J
b0kkie
 
Posts: 5
Joined: Thu Jun 22, 2017 3:23 pm


Return to Amplify Shader Editor

Who is online

Users browsing this forum: Google [Bot] and 8 guests