• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
KoldGames

Help with Smooth Gradient on Skydome

8 posts in this topic

Hello all! Now that I got my Skybox to render in Deferred Shading and Light Pre-Pass, the next thing on my list is creating a dynamic skydome (moving clouds, time of day, etc).  For time of day, I am going to use change the skydome's vertex colors.  But before I can do that, I would like to get a smooth gradient.  Here's what I have currently:

nfmv.png

xjbf.png

3z2r.png

 

As you can see, as I continue to look up, it fades from black to blue, but in some spots toward the top, there are dark lines.  I would like to get rid of those. I am currently calculating the vertex colors by calculating the distance between the camera's Y component and each vertex's Y component.  I then take that distance, multiply it by .1, and set the vertex color's XYZ to the BaseColor.[component] multiplied by the distance.

for (int i = 0; i < Dome.Meshes[0].VertexCount; ++i)
{
      float dist = roundf(Dome.Meshes[0].Vertices[i].Position.y - Camera->Position.y);

      dist *= 0.1f;

      Dome.Meshes[0].Vertices[i].Color.x = (BaseColor.x * dist);
      Dome.Meshes[0].Vertices[i].Color.y = (BaseColor.y * dist);
      Dome.Meshes[0].Vertices[i].Color.z = (BaseColor.z * dist);
}

Dome.Meshes[0].VertexBuffer.Update(Dome.Meshes[0].Vertices);

How would I get rid of those dark lines?  Is there a better way to do this? Thanks! :)

0

Share this post


Link to post
Share on other sites

Instead of using vertex colors, a fragment shader can easily calculate azimuth/zenith angle of each pixel, and based on those angles you could use math or texture sampling to get the color you want.

 

By doing this stuff in the fragment shader, the acutal geometry of the skydome/box in not very important as long as the geometry you do use will cover the parts of the screen the sky is covering.

2

Share this post


Link to post
Share on other sites

Have you thought about sampling a sky gradient texture instead ?
Something like this

 

Hey! That was the first thing I looked at, but decided not to do due to some memory leak issues with DirectTK.  Anyone else experiencing memory leaks when loading textures using DirectTK?  It increased the amount of memory leaks drastically.  I went from less than 20 leaks to over 140 after loading textures using DirectTK.

 

 

 


Instead of using vertex colors, a fragment shader can easily calculate azimuth/zenith angle of each pixel, and based on those angles you could use math or texture sampling to get the color you want.
 
By doing this stuff in the fragment shader, the acutal geometry of the skydome/box in not very important as long as the geometry you do use will cover the parts of the screen the sky is covering.

 

I will definitely check that out. Thanks smile.png I will reply here with results soon. 

Edited by KoldGames
0

Share this post


Link to post
Share on other sites

It may be that there are no dark lines in your gradent, and you've just got a 6bit-per-channel LCD and are seeing the mach bands illusion.

 

I can definitely see the bands on my LCD. Do you mean on your screen everything appears smooth, Hodgman?

 

Display quality aside, this is a general problem that can appear because in some situations 8 bit per channel still is not enough. Look for photoshop tutorials on how to get perfectly smooth gradients. If you have the banding problem, the only fix is to add dithering.

 

http://blog.chipotoole.com/2011/03/how-to-eliminate-gradient-banding-in.html

 

EDIT: ...or choose another color transition. Going from full blue to completely black gives you only 256 separate steps with a fairly high contrast. Spread that out over more than 256 pixels and you will get noticeable bands.

Edited by Madhed
1

Share this post


Link to post
Share on other sites

Hey guys! Thanks for the help.  I just wrote a quick pixel shader that outputs a gradient.  I don't know why I didn't just do this before.  I guess I was just hung up on using vertex colors.  Now to add Time of Day, stars, and other stuff! :D

e163.png

 


I can definitely see the bands on my LCD. Do you mean on your screen everything appears smooth, Hodgman?

 

I would like to know as well.  Also, does anyone else get leaks when using DirectTK to load textures?  If so, does anyone have a fix? Thanks! :)

0

Share this post


Link to post
Share on other sites


Display quality aside, this is a general problem that can appear because in some situations 8 bit per channel still is not enough

 

8-bit is really never enough (not if you are generating images at 8-bits, anyway) unless you are doing something like a 0 to 255 gradient that is 256 pixels wide. Dithering down from 16-bits+ to 8-bits is absolutely necessary to get gradients without banding. A more complex skydome texture would hide banding a little better.

2

Share this post


Link to post
Share on other sites

I can definitely see the bands on my LCD. Do you mean on your screen everything appears smooth, Hodgman?

In the bottom screenshot of the three, I can see a dark region in this area marked red:

d4TjzJ8.png

 

It looks like it's dark at the bottom, gets lighter, then gets darker in the region I've marked, then gets lighter again (obviously not in my copy, because I've drawn over it!)...

However, if you cut out a slice of that image and inspect the actual pixel values, this is not the case. The brightness only ever increases from dark at the bottom to light at the top. Our brains fool us and make us think that there is a light-to-dark gradient in the middle, because that area is actually a large solid colour with gradients on either side.

 

8bit precision is to blame wacko.png Dithering the gradient would likely help.

Edited by Hodgman
2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0