• 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

Bump mapping

5 posts in this topic

I was playing around with bump maps today, trying to get a result without the TBN basis, and got the following. The first image is a low res mesh and the second a higher res mesh.


The edges are quite prominent though, but I think it would look fine in a scene with dynamic tessellation. Any ideas on how I could smooth out those edges?

[code]float4 PS(VS_OUT pIn) : SV_Target
float duv = 1.0f * ( 1.0f / 512.0f );
float f = 0.09f;
float g = 0.05f;
float3 n = pIn.normalW;
float thisbump = gSpecMap.Sample( gTriLinearSam, pIn.texC ).x;
float rightbump = gSpecMap.Sample( gTriLinearSam, pIn.texC + float2( duv, 0 ) ).x;
float upbump = gSpecMap.Sample( gTriLinearSam, pIn.texC + float2( 0, duv ) ).x;

float3 tangent = normalize( ddx( pIn.posW ) );
float3 bitangent = normalize( ddy( pIn.posW ) );

float3 thisPos = pIn.posW + n * thisbump * f;
float3 rightPos = ( pIn.posW + g*tangent ) + ( n * rightbump * f );
float3 upPos = ( pIn.posW + g*bitangent ) + ( n * upbump * f );

float3 pnormal = normalize( cross( rightPos - thisPos, upPos - thisPos ) );

float3 LightDir = normalize( float3( 1, 1, 0 ) );
return dot( LightDir, pnormal );

Share this post

Link to post
Share on other sites
With the edges, you mean those 5 or 6 vertical "lines" over the sphere? My guess is that the normals aren't smoothed.
- Smooth the normals (for each vertex, check which other vertices are on the same location. Then calculate the average normal over them. IF their normals match within a certain degree (use dotProduct to check equality)
- Calculate the tangents / biTangents over the model as you usually do, with the smoothed normals this time.
- Render the object as you are already doing


Share this post

Link to post
Share on other sites
Does "without the TBN basis" mean that you are using ddx/y(texCoords) in the pixel shader to get the tangents?
If yes:
From my experience smoothing the normals and building an orthonormal TBN with the smoothed normals will help a bit in this case, but since the triangles ARE flat and the the ddx/ys ARE constant across a triangle some hard transition will remain.
You have to smooth out the tangents to get rid of that and that is probably best done by simply precomputing a tangent frame, like spek suggested.

Share this post

Link to post
Share on other sites
Sorry i haven't actually read your code, but I thought you might be interested in this other thread on bump-mapping without a TBN:

[edit]I guess your hard edges are caused by deriving your tangents from the rate-of-change in the position (which does not curve). You might be able to derive a tangent from the either the rate-of-change in the normal, or using the normal and the rate-of-change in the UVs?

Share this post

Link to post
Share on other sites
Thats an interesting paper. I wonder why developers havn't taken up to using that approach instead of sticking with the TBN basis and normal maps. I mean it requires a LOT less storage, and seems cheaper for animation too as you have less data to transform.

Share this post

Link to post
Share on other sites
[quote name='hick18' timestamp='1302204687' post='4795616']
Thats an interesting paper. I wonder why developers havn't taken up to using that approach instead of sticking with the TBN basis and normal maps. I mean it requires a LOT less storage, and seems cheaper for animation too as you have less data to transform.

It has a lot of strengths and weaknesses to it. I see it as an excellent addition to one's bag of tricks.
Anyway, it is slowly beginning to make it's way into production and is also now implemented in Blender 2.57 which is available for download:


It's used both in the off-line renderer and in the glsl 3D view renderer which means the bump you see in 3D view is the same as what you see in the final renderer (impact wise).
It's also available during texture paint which allows you to paint bump maps straight onto the 3D model (or texture) and then view the lit result in real-time as you paint.

The primary issue with this method is that, for textures, the texture filtering is not great on older cards (and some vendors). And as you take the derivative of the filtered signal
it affects results more then when you sample a texture of precomputed derivatives such as a normal map (essentially).

The other issue is that a normal map has components always in -1;1 range regardless of amplitude. For a bump map it's an issue to get both big low curvature hills and low frequency detail into the same bump map.

That being said you're correct that there are also lots of advantages. No tangent space, works under any kind of deformation and it's an easy drop-in.
It also works well with proceduralism, mirrored textures (without effort). For textures in BC4 you're only using 4 bits per texel and still getting relatively good quality.
It works trivially under adaptive tessellation. It's highly practical and will become more useful as texture filtering gradually gets better.

I even did a version that operates as a post-process (but not for blender). Works very well. During in-process (rasterization) I output the depth, interpolated vertex normal and the height.
In the post-process I compute the derivative of the surface position analytically (exact) since ddx and ddy is not available and since numerical approximation isn't good enough
for the derivative of the surface position. For the height on the other hand it is so I compute the derivative of the height by looking at a 3x3 neighborhood.

I'm using sobel basically but before doing so I bleed/lerp the center height into the neghbor height using the difference of the view-space Z.
The blend value is essentially t = exp(-K * abs(Zdiff)); This bleed is just a temp in the calculations I don't actually modify the height values in the main buffer.
This bleed is to make it fail gracefully when the neighboring pixels aren't connected to the center pixel.
As I was saying I don't use this numerical approximation for the derivative of the surface position because it needs to be more precise. So I compute it the exact way.

It's a little complicated to explain but I hope the overall idea is coming across. Works well anyway.

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