Performing some experiments with Perlin Noise, I've been looking for a suitable (and reasonably fast) repetitive noise function. As almost all my work was based on the article written by Hugo Elias I've decided not to use the function presented there and to go on my own. RNG algorithm (discussed here) was only one of my achievements during this research. But (for all those, who did not have anything in common with Perlin Noise) what I needed was a "repetitive" pseudo random number generator ("repetitive" - an algorithm which returns always the same "pseudo random" value for a given input value in 1D or for a given pair of input values in 2D). Here's the final function I wrote:
Results are shown in Perlin0.jpg. I've tried with only one ROL, but it seems to be not enough (results, shown in Perlin1.jpg, build a noticeable pattern - what's not the point of the noise function).
Presented function may be easily converted to return floating point values (range 0.0 - 1.0 or any other) - just as in floating point version of RNG algorithm. Hopefully - it will be usefull for one of you ;)
Cheers, Mikael
Noise2D PROC intX:DWORD, intY:DWORD
push EBX
push EDX
mov EAX,00BB38435h
mul intX
mov EBX,EAX
mov EAX,03619636Bh
mul intY
add EAX,EBX
pop EDX
pop EBX
push ECX
mov CL,AL
rol EAX,CL
mov CL,AL
rol EAX,CL
mov CL,AL
rol EAX,CL
pop ECX
ret
Noise2D ENDP
Results are shown in Perlin0.jpg. I've tried with only one ROL, but it seems to be not enough (results, shown in Perlin1.jpg, build a noticeable pattern - what's not the point of the noise function).
Presented function may be easily converted to return floating point values (range 0.0 - 1.0 or any other) - just as in floating point version of RNG algorithm. Hopefully - it will be usefull for one of you ;)
Cheers, Mikael
nice work, MikaelC. This is certanly one of the topics I always wanted to
work on, but never got time to do it. Btw, what about your code style, what
happened to the spaces ? :)
Dom
work on, but never got time to do it. Btw, what about your code style, what
happened to the spaces ? :)
Dom
Nice to hear that it was a bit usefull. But what about my code style? I've always been using tabs instead of spaces (AFAIR) ;) Well - honestly - I'm a little bit pedantic about the code layout (lenght of names, indents, aligments, a.s.o.) - and this could be a real pain in ... sometimes ;)
Cheers.
Cheers.
which compiler takes pushEBX instead of push EBX ?
regards, dom
regards, dom
Seems, that I've lost the point... Did I write "pushEBX" or did I eat a space anywhere? :sad:
Oh it is just that IE does not display tabs properly. Try taking a looking at this page in IE. ;)
hehe a display error???? (like FF with aarabic and related accents ;)).
Oh it is just that IE does not display tabs properly. Try taking a looking at this page in IE.
Supposed so, but wasn't sure ;) Because of FF, I don't use IE anymore...
Hi, a little new arround here, but a few years ago I wrote a random number generator which uses only modulo and addition (If the limit you choose for your values is 8, 16, 32 bits then the modulo goes away of course).
Problem is I've no long got the code - It was lost in a disk crash a few years ago, but the algorythm goes like this:
1) Seed a 17 value array with pseudo random numbers.
2) Set two pointers pointing to slots 0 and 10
3) When a number is read, read the values at the two pointers, place it at the first pointer, inc pointers (Wrapping round at the end of the array), and return the calculated value.
This produced some very impressive results for me (I was writing a game which required a large number of random values) and it appears to be very, very fast.
YMMV.
Problem is I've no long got the code - It was lost in a disk crash a few years ago, but the algorythm goes like this:
1) Seed a 17 value array with pseudo random numbers.
2) Set two pointers pointing to slots 0 and 10
3) When a number is read, read the values at the two pointers, place it at the first pointer, inc pointers (Wrapping round at the end of the array), and return the calculated value.
This produced some very impressive results for me (I was writing a game which required a large number of random values) and it appears to be very, very fast.
YMMV.
Haga, do you mean sth like:
; rArray - 17 elements initialy set to (hardcoded?) random values
; rOffset0 - pointer #1 (initialy set to [00])
; rOffset1 - pointer #2 (initialy set to [10])
random PROC USES EBX ECX
mov EBX,
mov ECX,
mov EAX,
add EAX,
inc EBX
inc ECX
mov [00],EAX
cmp EBX,17
jnz @F
xor EBX,EBX
@@:
cmp ECX,17
jnz @F
xor ECX,ECX
@@:
mov ,EBX
mov ,ECX
ret
random ENDP
Haga, do you mean sth like:
; rArray - 17 elements initialy set to (hardcoded?) random values
; rOffset0 - pointer #1 (initialy set to [00])
; rOffset1 - pointer #2 (initialy set to [10])
random PROC USES EBX ECX
mov EBX,
mov ECX,
mov EAX,
add EAX,
inc EBX
inc ECX
mov [00],EAX
cmp EBX,17
jnz @F
xor EBX,EBX
@@:
cmp ECX,17
jnz @F
xor ECX,ECX
@@:
mov ,EBX
mov ,ECX
ret
random ENDP
Almost (please bear in mind that I am still learning X86 ASM, when I wrote this, it was in 6502 ASM), but the line
mov [00],EAX
should be
mov , EAX
I think.
(I'm at work at the moment, and I don't have my compiler stuff with me, but it looks right)
Oh, and there is no point hardcoding the initial p'rands unless you want predictable p'rands out of this function. You could use a slower function to seed this, read from the time stream, grab a chunk of stack ... something that is not predictable. if you then run the function a random number of times (Say, wait for the user to hit a key), then you get to a pretty non-predictable p'rand set, which stands up to Chi^2 testing reasonably well (At least, it beat the rnd functions back when I first wrote it).
Haqa...
Just taking a look, the pair of inc's needs to be after the mov [...],eax:
Otherwise, each time round the loop you end up with the same results (ISTR)
Haqa...
mov EAX,
add EAX,
mov ,EAX
inc EBX
inc ECX
cmp EBX,17
Otherwise, each time round the loop you end up with the same results (ISTR)
Haqa...
Almost (please bear in mind that I am still learning X86 ASM, when I wrote this, it was in 6502 ASM), but the line
mov [00],EAX
should be
mov , EAX
I think.
Yes, it should (I've just noticed that you've written "place it at the first pointer" not "place it at the first slot"). And this means, that:
Just taking a look, the pair of inc's needs to be after the mov [...],eax
The inc'es shall be placed after the store ;)
Cheers.
Ok, took me a while, but I finally worked the bugs out, and created static... hehe :)
Is the attached what you were looking for?
Ok, and then when I get the right RAP file... oops
Left click = start static...
Right click = stop static...
Is the attached what you were looking for?
Ok, and then when I get the right RAP file... oops
Left click = start static...
Right click = stop static...