VkVolume icon indicating copy to clipboard operation
VkVolume copied to clipboard

distance_map.comp: One of the planes of the map is all black

Open bednik opened this issue 3 years ago • 2 comments

Hello there, me again! I noticed when I ported this compute shader to Unity that one of the planes in the 3D texture is all black. I fixed it by storing the initial value (gi1jk) in the output's initial position. I'm not sure if that's the correct way of doing it, but I thought I could mention it here :)

In Unity, I added this line: OutMap[position] = ByteToFloat[uint2(prev, 0)];, which is basically storing gi1jk in the output before starting the for loops.

Adding a couple of images to explain better:

image image

bednik avatar Jun 10 '22 13:06 bednik

Hmm, I'm not seeing this occurring on any of the test images. Could you see if it happens when you run your image through this codebase, in case there is a typo in your port?

LDeakin avatar Jun 10 '22 23:06 LDeakin

Looking at the code it doesn't look like a typo, but I'll try running it through your application sometime next week! I'm afraid my problem might be a bit weirder 😅

HLSL, at least with Unity, doesn't support loading byte (or uint) data from textures, so it will always be a float between 0 and 1. The way I "fixed" that was by making a byte texture consisting of the values 0-255 that I could use as a lookup-table with [distance, 0] as coordinates when storing the distance, and when loading from the input image I would multiply the value by 255 and then floor it. It's possible that there are some rounding errors that come from this.

bednik avatar Jun 11 '22 09:06 bednik