guycalledfrank / bakery-issues

Bug tracker for Bakery
4 stars 0 forks source link

how do you add volume lighting to a hlsl in urp? #56

Closed laurentopia closed 3 years ago

laurentopia commented 3 years ago

as much as i like graph shader, most powerful shaders out there are hlsl. so how do I add volume lighting to that, is there a block I can copy paste and do my own lighting mixing?

guycalledfrank commented 3 years ago

All useful functions are inside BakeryDecodeLightmap.hlsl. If you have a basic HLSL shader that outputs some color/texture, you can #include "BakeryDecodeLightmap.hlsl" and use my function:

void BakeryVolume_float(float3 posWorld, float3 normalWorld, out float3 sh)

There is also a more advanced function with specular support:

void BakeryVolumeSpec_float(float3 posWorld, float3 normalWorld, float3 viewDir, float smoothness, float3 albedo, float metalness, out float3 diffuseSH, out float3 specularSH)

Additional parameters are:

laurentopia commented 3 years ago

Thanks you! And does BakeryVolumeSpec_float turn into BakeryVolume_float if specularSH isn't used (meaning the compiler strips out the extra computetion)? (Could you add that in the doc so it doesn't get lost in github?)