Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

okonomiyaki

Sky- I can only get 8bit using Yann's method

This topic is 5714 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Why is it that I don't have problems with any other aspect of game programming yet except with the sky -_- A while back I implemented a techinque suggested by Yann in the cloud thread (http://www.gamedev.net/community/forums/topic.asp?whichpage=5&pagesize=20&topic_id=86024) that takes advantage of pixel shaders to create clouds. The basis of the technique (or my version of it, not much different than the one suggested) is that I create a texture and fill in the red values with with 4 Perlin Noise octaves. I then fill in the alpha channel with 4 more perlin noise octaves (say octaves 5-8). For future reference, this is how I am going to calculate the final resultant color for each pixel. You load in that last texture. Lets call the red channel r, and the alpha a. Think of perlin noise, and the equation is: finalc = r+(a*.0625); Now I create another texture. This is a lookup texture. I go through each pixel and calculate what finalc *would* be at each pixel. Basically I plugin in (x,y) as (a,r) in the above equation, plug that result in the exponentiation function (255-pow(.97,x)*255) and record the result in the alpha channel. I load in both of those textures, respectively in the following fashion: tex t0 texreg2ar t1, t0 mov r0.a, t1.a Now we have added all the octaves together and exponentiated them. The problem? I'm loading every possible finalc into that final alpha channel, bottlenecking my possible colors from 0 to 255. How can I expand this to at least 16 bit? An example of my current program can be seen here, it looks pretty nice except for the 8bit part of it: Screenshot Edit: Yann explains it a LOT better at the bottom of the sky thread I posted.. 2 Edit: Yann, I know you explained how to get at least 16 bit at the bottom of that thread, but I didn't understand how it would bring about 16bit. wouldn't the lookup texture still be bottlenecked by the 8bit channel of the stored values? [edited by - okonomiyaki on April 21, 2003 1:37:52 AM] [edited by - okonomiyaki on April 21, 2003 1:39:47 AM]

Share this post


Link to post
Share on other sites
Advertisement
I only want to ask. Why do you want to have more than 8 bits on the final stage? The precision of _visible_ color buffer is usualy only 8 bits.

The precision of nv20-nv25 pixel unit is also only 8 bits. You can not get more.

Share this post


Link to post
Share on other sites
Hmm, there is something pretty weird with your screenshot. You mentioned, that you used 8 octaves, but your shot looks like 2 or 3.

About that precision issue: there is no way to increase the value''s resolution after the lookup, at least on anything below FX/9700. But that''s not really needed either. The problem is not the value you get out of the lookup function, but either the lookup function itself, or the input values.

Normally, you get precision problems when adding higher octaves with very small amplitude. The dynamic range isn''t large enough to handle the very small values. Without the exponential function, those values would not really contribute to the image, but the exponential function remaps their ranges, and their contribution. You''ll always get a few precision artifacts on 8/9bit precision hardware (GF3/4). But your problems are pretty extreme.

First, I would suggest readjusting your perspective, sky projection, tiling and amplitudes. There is something really weird going on currently. Try to adjust it, so that the highest octave covers a few pixels at most. You will still get 8bit artifacts, but since the higher octaves are much more compressed, it will not be that noticeable.

To get even less artifacts, you might have to use a 3D lookup texture, and distribute the octaves even more. But in your case, I think the problem lies in the frequency and amplitude distribution of your octaves.

Hmm. A few questions: what is the resolution of your lookup texture ? Did you use floating point math to initially compute it ? Can you post a screenshot with only the first 4 octaves (5-8 being zero), ie. only the red channel is used as lookup ?

Share this post


Link to post
Share on other sites
My lookup texture is 256x256. Yes, I used floating point initially, then multiplying by 255 and converting to int.
A screenshot of the first four octaves:
http://www.animeimaging.com/directx/4octaves.JPG

Actually, I played around with a lot of the parameters as you suggested. It turns out that you are right (well duh) I need a lot higher frequency, and it helped with the 8bit artifacts too:
http://www.animeimaging.com/directx/newscreen.JPG

Here a newer version (after playing with the parameters) of the first 4 octaves:
http://www.animeimaging.com/directx/4octaves_new.JPG


It still needs a lot of work, but as I keep adjusting the values I can see where something can come about. I also adjusted the perspective values as you mentioned and I'm trying to get those right as well. Does it still look so weird? hehe
Thanks a lot for the post. It helped much.

As a sidenote, come to think of it, how the heck would it be more than 8bit? It's just the alpha channel, the highest it gets is 8bit. One channel cannot be more, can it? The reason something is 24bit color is becase the three rgb channels each have 8bits (values 0-255). But we aren't mixing colors here, just adjusting one value. The only way to get more than 8 bit would be.. to exponentiate the first 4 octaves and the second 4 octaves separately (lookup separately), then add then with weighted factors in the pixel shader? I don't know if that would turn out right mathematically. I don't think it should come to think of it. But something like that with the extra step after lookup would have to be done, ne.

[edited by - okonomiyaki on April 23, 2003 2:48:28 AM]

[edited by - okonomiyaki on April 23, 2003 2:49:26 AM]

Share this post


Link to post
Share on other sites
okonomiyaki : a bit OT question : Your clouds are animated, right? How do you generate perlin noise to be tileable? I just can''t get this to work. I tried using 4 samples then interpolating it but then it looks way to symetric. And what is your original noise texture size (the one used for octaves 1-4)?

You should never let your fears become the boundaries of your dreams.

Share this post


Link to post
Share on other sites
quote:
Original post by _DarkWIng_
okonomiyaki : a bit OT question : Your clouds are animated, right? How do you generate perlin noise to be tileable? I just can't get this to work. I tried using 4 samples then interpolating it but then it looks way to symetric. And what is your original noise texture size (the one used for octaves 1-4)?



Yes, they are fully dynamic. I had a lot of trouble with generating tileable noise myself. I gave up on it and tried doing it without tiling textures but you cannot get any detail at all when stretching a texture over the whole sky. So I tried looking around for different techniques of tiling and came upon this page: http://students.vassar.edu/mazucker/code/perlin-noise-math-faq.html. I don't know how I didn't see it before (it's the very first result of a "tiling perlin noise" google). At the bottom is has a section on "seamlessly tiling noise" that gives a great technique on producing tilable textures. It worked great for me, albeit a lot slower to produce, I didn't care because I can just save the textures and load them up later (prerendering so speed doesn't matter to me). At least for the initial sky, it's prerendered so the loading time is minimal. Basically it takes the slope of the "graph" and morphs the output so that the ouput at 0 ends up matching the output at w (same with h) and it looks seamless! It takes a lot more noise() calls though..

My texture size for the 1-4 octaves is 512. It's stretched to the final 1024x1024 texture though, and I don't notice any real differences, as the filtering would be doing what any noise generating algorithm would be doing at that small level: interpolating (because it's only my first four octaves, it doesn't get that low yet).


[edited by - okonomiyaki on April 23, 2003 9:38:13 AM]

Share this post


Link to post
Share on other sites
Update:
Darkwing, I made the initial textures 256x256. There was no need for any larger.

I've been playing around with the parameters a LOT... I think there was a lot more in here (in my... your implementation) than I ever exepcted. Look at my new screenshot:


It's getting a lot better. How is the perspective looking? I think it might look weird because the clouds aren't shaded at all.. or maybe it is weird in the first place :/ I played around with it a little more too though and I think it looks alright now.

I still am getting artifacts if you look at the top of the screenshot where the clouds are close to you, and when it's moving in game it's very visible, ugh. Any more suggestions on how to improve it?

Oh, and I finally did implement a volumetric lookup texture. I made it 12 octaves too. 3 textures (now 256x256 textures) of 4 octaves each. I would just store the 3 sets of octaves in different channels of one texture, but I want the ability to slide around the textures differently for animation. But it rips the alpha value of each texture into a final texture (into the RGB channels) and then does a texreg2rgb into the volumetric texture (256x256x8 like you suggested, seems to work ! ) the depth of 8 is the final set of octaves (9-12) anyway so it only modifies it a tiny bit so great precision isn't necassary. Thanks!


[edited by - okonomiyaki on April 23, 2003 3:25:58 PM]

Share this post


Link to post
Share on other sites
That last screenshot looks pretty good... but it looks very, uh... flat, if you know what I mean. Probably has to do with the shading, as you said.

Share this post


Link to post
Share on other sites
Thanks Santa
Yeah, it''s definitely flat because it''s not shaded. I''m trying to work on that. I just want simple scattering but unfortunately I have no idea where to start I know calculus quite well so I have confidence that I can understand it (in fact I do understand the concept) I just have no idea how to implement it.
But yeah, I''m happy with the way they look! The 8bit artifact is much less noticable with the higher octaves added to it.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!