• 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
wallacekcy

Anti-aliasing Techniques

6 posts in this topic

I have recently made a fabric renderer which procedurally generates textures of the fabric at the micro-level using GLSL shaders. However, this approach suffers from heavy texture aliasing when the view is zoomed out from the object.

Here's my question, can anyone please give me a point in direction to some of the most popular approaches to handle aliasing with anisotropic procedural textures?

Your help would be appreciated, thanks!
1

Share this post


Link to post
Share on other sites
You can use the derivative functions, ddx & ddy, to determine a mip level to perform antialising of per pixel data. Heres some example code that simulates antialiasing, from an line renderer. Not directly portable to your case, as it assumes the inputs are layed out how its expecting; but the concept of derivative distance is the same.

float antialias(float2 texcoord, float2 edge)
{
float derivativex = ddx(texcoord).x;
float derivativey = ddy(texcoord).x;
float derivativeLength = sqrt(derivativex*derivativex + derivativey*derivativey) * 2;
float antialiasedEdge = saturate((1.0-abs(edge.x)) / (derivativeLength + 0.00001f));
return antialiasedEdge;
}
1

Share this post


Link to post
Share on other sites
many image based anti-aliasing methods handle all kinds of aliasing not just edges

look into FXAA:

[url="http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf"]http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf[/url]
1

Share this post


Link to post
Share on other sites
It's a very common problem without any easy fix. The sure-fire way to solve it is to shade in texture space, generate mip-maps, and then map that onto the polygons. Obviously, this is expensive since you'll essentially be supersampling for any surface not using the top mip level. You can also supersample directly in the shader, but that doesn't put you in any better position than shading in UV space. Screen-space/temporal anti-aliasing techniques can help somewhat, but they're nothing but a band-aid.

What you really want to do figure out how to reformulate your algorithm as a function of LOD, such that you don't end up with high-frequency aliasing as your shading rate decreases. This is the concept driving techniques like LEAN/CLEAN mapping, which are for antialiasing specular highlights on normal maps. They essentially use the variance of normals in a normal map figure out how to handle normal map details when they transition from being macro-level to micro-level, which they do by modifying the parameters to their BRDF (high normal variance turns into high roughness).
1

Share this post


Link to post
Share on other sites
You've got three main categories:
1) Analytical -- use derivatives (dfdx/dfdx) to avoid outputting high frequency details in the first place. This is what mip-maps do for regular texturing.
2) Super sampling -- either render at a higher resolution, or evaluate your procedural function multiple times per pixel, then average/filter the results.
3) Post processing -- use a filter after the fact, such as FXAA/MLAA/SMAA/etc.
1

Share this post


Link to post
Share on other sites
for procedural content, those conventional methods often don't work well, as you don't have continuous functions (dFdx/dFdy) and post processing is just a cheap fake that works to some degree on static images that suffer from a few jaggy edges, not a procedural generated image (which is rather like noise), while super sampling is quite expensive on one side (e.g. 16x the bandwidth), and on the other it does not give you the adaptive sample rate that you need (just <=16), while wasting a lot of time in areas that don't need SSAA.
The best way to deal with that is to loop inside the shader several times for a particular fragment, in an optimal case you'd reduce noise in every loop cycle and break out of the loop based on the divergence.

if you have something like this
[code]
vec4 ProceduralTexture(vec3 pos)
{
...magic
return color;
}
vec4 main(..){return ProceduralTexture(WorldPos);}
[/code]
you'd transform the main function to something like
[code]
vec4 main(..)
{
vec4 DeltaToNextPixelX = dFdx(WorldPos)*0.5f;
vec4 DeltaToNextPixelY = dFdY(WorldPos)*0.5f;
vec4 Color=0;
int loop Count=0;
do
{
vec4 LastColor=Color;
Color += ProceduralTexture(WorldPos+DeltaToNextPixelX*randf()+DeltaToNextPixelY*randf());//randf shall return 0.f to 1.f
Count++;
if(Count>4)//at least 4 samples
{
vec4 Delta = LastColor/(Count-1)-Color/Count;
if(length(Delta)<0.1)//0.1 is our noise treshold
break;
}
}while(true); //or set a limit e.g. Count<128
return Color/Count;
}[/code]
(just an example, you shall implement a smarter threshold function, this one can lead to noise in some cases).
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