Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am doing volumetric raycasting and curently working on depth jitter. I have 3D position on ray and want to sample 2D noise texture to jitter the depth.

Function for converting (or hashing) 3D position to 2D have to produce absolutely different numbers for a little changes (especialy because i am sampling in texture space so sample values differs very very little) and have to be "shader-wise" - so forget about branches, cycles etc.

I'm looking forward for yours nice and fast solutions.

share|improve this question
    
It's not perfect but you couldn't you just modify ray length based on the texture coords of the position you hit? –  tm1rbrt Feb 8 '11 at 18:40
    
@tm1rbrt I don't hit anything, volumetric raycasting samples through volume (like 3D array) and gathering data. And i have texcoords and they are the values which i want to hash. But great idea for regular raycasting. –  Notabene Feb 8 '11 at 19:23
1  
I solved this very easily at the end. I just shift the ray origin in a ray direction by a noise texture (if i need just one sample, i can use output texture coords for sampling noise). It is easy and working. But the question is still very interesting, though. –  Notabene Feb 8 '11 at 19:31

1 Answer 1

I'm not sure it is quite what you are looking for, but this article on spatial hashing is interesting (and has some HLSL code as well): perfect spatial hashing.

share|improve this answer
    
Something a little more useful might be to make a pair of value-noise 3D texture (i.e., a pure random value at each texel--instead of, say, Perlin noise), and sample them both using your 3D position. Using different scalings on the texture coordinates you can change the period of sampling one each, and that could be useful. (rereading your last comment it seems like you may have already done something like this) –  ChrisE Feb 8 '11 at 21:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.