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

Projected Grid Ocean undersampling

6 posts in this topic

So I've been implementing a projected grid ocean for our latest game and I ran into a what it seems, undersampling issue when I sample my displacement heightmaps. It seems that I can't tile the heightmaps a lot over the water surface - if I do so, the surface wobbles a lot. This leaves me with relatively big lumps of water of low amplitude. The heightmaps are 512x512 (I can't go much higher than that, the implementation is for iOS devices).

 

How do games like Assasin's creed and others fix this aliasing problem? I couldn't see it happening in their implementation and they have massive waves.

 

Here is my texture sampling code for the heightmap, if someone feels like helping smile.png

float dist = 0;
float3 ray = 0;
// calculate the water world space vertex position from the screen space quad
float3 waterWpos = reconstruct(v.vertex, dist, ray);
				
float fade = exp(-dist * _LodExponent);
float lod = _MaxLod * (1-fade);

// if _GridSize becomes too small, very obvious sampling artifacts occur
float4 tc = float4(waterWpos/_GridSize, 0, lod);
								
float4 texel = tex2Dlod (_HeightsTex, tc);
waterWpos = texel.r*_WaveHeight;

I have tried sampling the heightmap using a radial grid, however I have the same problem.

Any input is appreciated!

0

Share this post


Link to post
Share on other sites

One thing to note is that LOD is more than just a function of distance, the regular mipmap selection criteria usually use a derivated to figure out changes in screen space to select the correct mipmap/LOD. So using a distance based calculation will still introduce some aliasing.

0

Share this post


Link to post
Share on other sites
First thing I would try is sampling the heightmap multiple at different rates and do weighted blending on it.
Low frequency sampling will make the big waves while the higher frequences will add detail.
0

Share this post


Link to post
Share on other sites

@Yourself,

that was a good idea which I have already tried, unfortunately it didn't solve the problem. Moreover, it will be quite expensive to do that on lower end devices so it's not a direct solution I am afraid.

 

Another thing that I tried (I tried it even with a radial grid, I got a similar result), was to simply run a continous function like sin for the height as such:

height = 0.5 * sin (time + worldPos.x * factor);

which created horrible aliasing in the distance (see the following screenshot).

[attachment=22336:Screen Shot 2014-06-26 at 19.43.33.png]

 

The funny thing is that I recently ran the projceted grid demo from Johanson (http://fileadmin.cs.lth.se/graphics/theses/projects/projgrid/) and it doesn't suffer from such aliasing or issues. It may be worth saying that the unprojection is done in the CPU in his case, whereas in mine, I do it in the shader.

 

One thing that I was thinking could be to change the position of the projector camera to be closer to the plane. I will try that first thing tomorrow.

0

Share this post


Link to post
Share on other sites

Think of the displacement map as a 2D signal that's sampled by the projected grid. All sampling techniques, projected grid included, have to take into account aliasing. In order to fight it, follow these steps:

- Build, either at runtime or offline, a full mipmap chain of the displacement map. Experiment with different downsampling filters, like box filters, simple point filters (which can be OK for displacement maps) or more advanced ones.
-In the shader, calculate the derivatives of the displacement map texture coordinates with respect to the projected grid x,y coordinates. You have some options here: forward differencing, ddx and ddy (not applicable in my vertex shaders) or analitically. I'd suggest the last option. Please ask me for formulas if you get stuck.
-Fetch the displacement map by passing the derivatives (tex2Dgrad in DirectX).
-For procedural waves (sin, cos etc), exploit the derivatives to filter them out analitically.

You might want to add a parameter (in the [0,1] range) that multiplies the derivatives in order to let artists control the tradeoff aliasing vs detail in the scene.
Also, as described in the original projected grid paper, the projective camera does not necessarily match the main camera. By changing some of its parameters you can bias the sampling and, for example, add more detail in the distance.
Last, wobbling is inevitable if the projected grid is too coarse. What is the resolution of the screen and the projected grid in your application ? I suggest a ratio of less than 4 before the two.
 

0

Share this post


Link to post
Share on other sites

Hi Reitano,

 

I tried tex2Dgrad by calculating 3 world positions as such:

// _ScreenParams.xy = screenres (width, height)

float sizex = 1f/_ScreenParams.x * factor;
float sizey = 1f/_ScreenParams.y * factor;

float3 adj0 = reconstruct(v.vertex + float4(sizex, 0, 0, 0), dist, ray);
float3 adj1 = reconstruct(v.vertex + float4(0, sizey, 0, 0), dist, ray);
float3 waterVertex = reconstruct(v.vertex, dist, ray);
				
float2 ux = abs(adj0.xz - waterVertex.xz)*2;
float2 uy = abs(adj1.xz - waterVertex.xz)*2;

float4 texel = 	tex2Dgrad (_HeightsTex, tc, ux, uy);

Maybe I calculated the gradients wrong, this didn't have a good visual result. Could you help me out with the analytical approach equation?

 

The resolution of the screen varies (it's for iOS devices), but it ranges from 940x640 to 2048x1536. For the moment, I am using the max possible tesselation for the grid.

I also followed Johanson's paper, especially where he mentions to try and aim the projector camera to avoid looking at the horizon, so that vertices are not wasted. It could help a bit, as I can't see any visual artifacts in his original demo.

0

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