SlightlyMad / VolumetricLights

Volumetric Lights for Unity
BSD 3-Clause "New" or "Revised" License
2.05k stars 304 forks source link

Noise Texture should be 8 channel #14

Open jjxtra opened 7 years ago

jjxtra commented 7 years ago

Save a bunch of GPU memory, set the 3D texture format to A8. When sampling the texture, be sure to do a .a, i.e.

tex3Dlod(noiseTexture, float4(x,y,z,-999.0)).a

SlightlyMad commented 7 years ago

Does that work yet? Did you try? It didn't work when I tried it about a year ago.

jjxtra commented 7 years ago

I tried your NoiseVolume.bytes in my own shader and created the 3D texture like so and it worked using .a with tex3Dlod:

//... snip loading code Texture3D t = new Texture3D((int)width, (int)height, (int)depth, TextureFormat.Alpha8, false); t.filterMode = FilterMode.Bilinear; t.wrapMode = TextureWrapMode.Repeat; //... snip loading code

inline float CalculateFogNoise3D(float3 pos, float3 rayDir, float rayLength, float scale, float3 velocity) { float n = 0.0; rayLength = min(10.0, rayLength); float3 step = rayDir (rayLength (1.0 / FOG_NOISE_3D_SAMPLE_COUNT)); for (int i = 0; i < FOG_NOISE_3D_SAMPLE_COUNT; i++) { n += tex3Dlod(_NoiseTexture3D, float4((pos scale) + (_Time.x velocity), -999.0)).a; pos += step; }

return n * (1.0 / FOG_NOISE_3D_SAMPLE_COUNT); }

-- Jeff

On Wed, May 31, 2017 at 7:35 AM, Michal Skalsky notifications@github.com wrote:

Does that work yet? Did you try? It didn't work when I tried it about a year ago.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/SlightlyMad/VolumetricLights/issues/14#issuecomment-305188176, or mute the thread https://github.com/notifications/unsubscribe-auth/ABNoGGyrsi40D53vA0nqnCOz3-cuwrGvks5r_WyMgaJpZM4NpjDd .