tiny-cuda-nn icon indicating copy to clipboard operation
tiny-cuda-nn copied to clipboard

Input range to a HashGrid

Open amitabe opened this issue 1 year ago • 4 comments

Hi,

What range should the input be in if I'm using the HashGrid encoding? Let's say I have the following sinppet:

config = {
     "encoding": {
        "otype": "HashGrid",
        "n_levels": 16,
        "n_features_per_level": 2,
        "log2_hashmap_size": 19,
        "base_resolution": 16,
        "per_level_scale": 2.0,
    }
}
encoding = tcnn.Encoding(3, config["encoding"])

Then, I want to apply this encoding on a vector x:

x = torch.tensor([[a, b, c]]).cuda()
y = encoding(x)

So, my question is - in what range a,b,c should be in? Should it be in [0,1]? In PyTorch grid_sample it expects the input to be in [-1,1], so is that the case in here to?

I can't find the answer to it anywhere in the documentation or the code, but I might have missed it.

Thanks

amitabe avatar Aug 30 '23 06:08 amitabe

Bumping this question

amitabe avatar Sep 19 '23 09:09 amitabe

I also had this question and tried to find out the answer. I think the input range should be [0, 1] according to #286.

costrice avatar Oct 28 '23 08:10 costrice

This actually works for any input since the hash mapping is from the real plane to a fixed number of hash entries (hence the hash collision). My tests showed that using [0,1] or [-1,1] has no difference

txdai avatar Nov 17 '23 22:11 txdai

Is there any way to change the location + size of the hashgrid, e.g. to [-10, 3] (along each coordinate) while leaving its resolution the same? This is useful when dealing with pre-defined scenes that often have different extent and are not necessarily centered at origin.

treder avatar May 03 '24 16:05 treder