Noise Questions
category: code [glöplog]
Quote:
Optimus: what plasma algorithm do you use?
Basically, it's more than just adding plasmas randomly, it has to be more precise and tweaked to work. I add different octaves recursively and double the frequency and half the height after every step.
float color = 0;
for (int i=1; i<=k; i++)
{
color += sin(x * i) / i + sin(y * i) / i + sin(z * i) / i;
}
Something like that. Can be other more complex sine function inside, just an example. Sometimes I use similar think to precalculate a texture in CPU, sometimes I use it in realtime on GPU. Maybe it's slower than the above noise function because of sine and loop, I don't know.
raizor, I have sent him an email, to find answers.
Bartoshe, cool. I look forward to finding out the answer :)
Bartoshe: Now that I'm digging into the code, you're right, the number 37 and 17 are numbers that have to do with the texture generation.
IQ is so smart to point that I hardly able to reverse engineer his code, but if look in the texture you will see that the following is always true:
Img[x,y].r == Img[x+37,y+17].g
IQ did this to achieve a Red (only) 3D LUT with and Red+Green 2D Texture - a really smart trick.
Note that both the Blue and Alpha are not used (don't know why he generated it).
I think that as long as you make sure that the above rule preserves you can use a simple rand()%255 or whatever...
Optimus: I'm really not a noise freak... but basically, I think that Perlin noise gained so much respect due to it's output quality that is archived due to good interpolations, smoothing and noise octaves...
My last post wasn't exactly to the point of this thread - note to self: read entire thread before posting :)
IQ is so smart to point that I hardly able to reverse engineer his code, but if look in the texture you will see that the following is always true:
Img[x,y].r == Img[x+37,y+17].g
IQ did this to achieve a Red (only) 3D LUT with and Red+Green 2D Texture - a really smart trick.
Note that both the Blue and Alpha are not used (don't know why he generated it).
I think that as long as you make sure that the above rule preserves you can use a simple rand()%255 or whatever...
Optimus: I'm really not a noise freak... but basically, I think that Perlin noise gained so much respect due to it's output quality that is archived due to good interpolations, smoothing and noise octaves...
My last post wasn't exactly to the point of this thread - note to self: read entire thread before posting :)
ok, that's fine. I will try this, tomorrow...(serious bug fixes in Dead Deer for Macosx compatibility and shadermodel3 integration)
Ok, i see you want the same noise as IQ uses, but why not going with SimpleXnoise ?
You said you need it for Texture-Generation...this algorithm is still not too suitable for realtime-calculations, but faster than calculating some complete Perlin-noise!
The Code by Heikki Törmälä even comes with Generate()-Functions for 1D, 2D and 3D-noise!
Simple X Noise in c#
You said you need it for Texture-Generation...this algorithm is still not too suitable for realtime-calculations, but faster than calculating some complete Perlin-noise!
The Code by Heikki Törmälä even comes with Generate()-Functions for 1D, 2D and 3D-noise!
Simple X Noise in c#
just for completeness, visy pointed you to simplexnoise already before i did, also here´s what wiki has about it:
Simplex_noise
Simplex_noise
for this noise texture :
im.ptrImageDATAS=(char*) malloc(256*256*4);
for (y=0;y<256;y++)
for (x=0;x<256;x++)
{
int r=rand()%255;
adr=x+y*256;
im.ptrImageDATAS[adr*4+0]=r;
im.ptrImageDATAS[adr*4+2]=(char)255;
im.ptrImageDATAS[adr*4+3]=(char)255;
}
for (y=0;y<256;y++)
for (x=0;x<256;x++)
{
adr=x+256*y;
adr2=((x+37)%255)+256*((y+17)%255);
im.ptrImageDATAS[4*adr2+1]=im.ptrImageDATAS[4*adr+0];
}
it gives:
it has no more symetry and for negative values it gives artefacts again, but the positive side of the rendering (considering the split) gives good results.
the shader's random function:
random(vec4 x)
{
p = floor(x);
f = fractionnal(x);
f = f*f*(vec4(3.0,3.0,3.0,3.0)-2.0*f);
uv.xy = p.xy + f.xy +vec2(37.0,17.0)*p.zz;
uv.zw = pszero.xx;
uv.xy = (uv.xy + vec2(0.5,0.5))/256.0;
a = sample(0,uv);
a.xy = 2.0*a.xy - vec2(1.0,1.0);
a.x = mix(a.y, a.x, f.z);
a.xyzw = a.xxxx * 1.12;
a;
};
im.ptrImageDATAS=(char*) malloc(256*256*4);
for (y=0;y<256;y++)
for (x=0;x<256;x++)
{
int r=rand()%255;
adr=x+y*256;
im.ptrImageDATAS[adr*4+0]=r;
im.ptrImageDATAS[adr*4+2]=(char)255;
im.ptrImageDATAS[adr*4+3]=(char)255;
}
for (y=0;y<256;y++)
for (x=0;x<256;x++)
{
adr=x+256*y;
adr2=((x+37)%255)+256*((y+17)%255);
im.ptrImageDATAS[4*adr2+1]=im.ptrImageDATAS[4*adr+0];
}
it gives:
it has no more symetry and for negative values it gives artefacts again, but the positive side of the rendering (considering the split) gives good results.
the shader's random function:
random(vec4 x)
{
p = floor(x);
f = fractionnal(x);
f = f*f*(vec4(3.0,3.0,3.0,3.0)-2.0*f);
uv.xy = p.xy + f.xy +vec2(37.0,17.0)*p.zz;
uv.zw = pszero.xx;
uv.xy = (uv.xy + vec2(0.5,0.5))/256.0;
a = sample(0,uv);
a.xy = 2.0*a.xy - vec2(1.0,1.0);
a.x = mix(a.y, a.x, f.z);
a.xyzw = a.xxxx * 1.12;
a;
};
note that it seems that when the xscreen value over the middle of screen gives good results. in fact with a texgen of rand()%256 it given like left part.
actually with TLM advice the screen is split.
actually with TLM advice the screen is split.
hArDy: I would want to know why rgba=rand()%255 do not work. why g=r[+37,+17] give an half image with the shader of clouds and fixed texture random() function.
the correct code to generate such a noise with two prime numbers for base :
for (y=0;y<256;y++)
for (x=0;x<256;x++)
{
adr=x+256*y;
img[adr].r=rand()&255;
img[adr].g=0;
img[adr].b=0;
img[adr].a=0;
}
for (y=0;y<256;y++)
for (x=0;x<256;x++)
{
adr=x+256*y;
adr2=((x+37)&255)+256*((y+17)&255);
img[adr2].g=img[adr].r;
}
37 and 17 for Noisy shader toy !
for (y=0;y<256;y++)
for (x=0;x<256;x++)
{
adr=x+256*y;
img[adr].r=rand()&255;
img[adr].g=0;
img[adr].b=0;
img[adr].a=0;
}
for (y=0;y<256;y++)
for (x=0;x<256;x++)
{
adr=x+256*y;
adr2=((x+37)&255)+256*((y+17)&255);
img[adr2].g=img[adr].r;
}
37 and 17 for Noisy shader toy !
in my first attempt to generate this noise texture, I use % instead of &...
thread closed.
thread closed.
So you MODuloed instead of ANDed, nice typo! I guess you aren´t the only coder whom that happened to, given those two chars are next to each other on a standard keyboard! But exactly that is why i always try to code my own stuff from ground up...the understanding of what is going on is there...like all of the time, from the beginning to the end. I simply hate using other peoples code; first thing i did when i got suggested to use "mathf.lib" was looking into it, what it is doing! I even hate DirectX and OpenGL, but not using it would be a dumb idea i guess...like software-rendering on CPU in 2013! hehe.
If it would have been your code, you would have spotted the typo in a matter of seconds i guess!
If it would have been your code, you would have spotted the typo in a matter of seconds i guess!
I'm releasing a D3D10.1 version of the .NED player because it's faster to use 10.1 than 9c in nowadays computers. do you understand why ?
I do invent pixel shaders to draw panties to a naked woman, it was mixing mapping for the panties and gouraud shading for the body.
corporation or sectarism ?
Contrarianism maybe. An orange pixel revolts and goes against the next generation. He doesn't like chat menus in games. Shaded even.
residue
residue goes equal with me &| barti ;)
Barti: A REAL OFFER here:
If you want to join TRSI please contact me at "hardy@trsi.de" ;) Just forget about Nooon, its History, you´re the only active member left, better join the real collective, finally!
Barti: A REAL OFFER here:
If you want to join TRSI please contact me at "hardy@trsi.de" ;) Just forget about Nooon, its History, you´re the only active member left, better join the real collective, finally!
Barti, your talent hasn't gone unnoticed. I was in fact, considering forming a totally new demogroup, consisting of eeer, me and my cat. The name of the new group would be "bad programmers". As in, well, "We're bad and proud of it". interested by the idea? Would you like to join up for the cause?
And we can add Sotsoft too. For abstract graphics and screaming sounds!
my cat's role would be as the sample generator.
That would rock!
BUMP
first of all, hArDy, I did not know if you guys smoke weed. it's important. and then, I'm only planning to port Dead Deer to D3D10 actually, I do not know if I want to produce a demo, anyway. I'm associal, it's not an illness, and even if I visit pouet, I'm more physicist than a demomaker...
yes, NoooN is history, and TRSI is something like a logo I do copy for me...
yes, NoooN is history, and TRSI is something like a logo I do copy for me...