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

Texture filtering on normal and specular maps

10 posts in this topic

Hey, I have a quick question about my normal and specular maps causing really bad texture artifacts at a distance.

Here's some pictures of the problem. (ignore the weird blue lights, was messing with glow lights in my shader)

 

http://inferno.codebrainshideout.net/Images/hangemhigh%201.png

http://inferno.codebrainshideout.net/Images/hangemhigh%202.png

 

Should I look into anti aliasing or anistropic filtering? Or do I need to filter the maps in my glsl shader?


Here is my GLSL fragment shader as well, it's a mess right now, I know :P

http://inferno.codebrainshideout.net/modelShader.frag

Relevant code is inside of the if(useNormal) { }

 

Thanks : )

Edited by newObjekt
0

Share this post


Link to post
Share on other sites

For starters, it looks like you are just simply using bilinear filtering for those texture maps.  Before you can use anisotropic filtering, you got to have trilinear filtering enabled (which is mipmapping).  Are you creating mipmaps for your normal and specular maps?  Do that first, then use anisotropic filtering.  Antialiasing isn't going to help with this.

 

I wrote an example on how to use anisotropic filtering, but that HDD crapped out and I might have lost it for good =(

 

Shogun.

2

Share this post


Link to post
Share on other sites

You should definitely mipmap, use trilinear filtering, but in addition to that you should renormalize the normal map lookup result before putting it into your lighting calculation.

2

Share this post


Link to post
Share on other sites
Yeah it looks simply like you're not using mipmapping, so when the texture is shrunk by more than 2x, bilinear filtering (which blends 4 texels) won't be able to stop it from shimmering.
2

Share this post


Link to post
Share on other sites

Alright I've got mipmap generation and Anistrophic filtering working and it's given very nice results.

 

http://inferno.codebrainshideout.net/Images/mipmaps%20a.png

 

Though I've noticed an odd issue. At extreme angles textures seem to turn completely black. I think this might be a specular problem? I'm not sure.

 

http://inferno.codebrainshideout.net/Images/mipmaps%20b.png - Wall at a normal angle.

http://inferno.codebrainshideout.net/Images/mipmaps%20c.png - Wall at a extreme angle.

 

Additionally I don't know what mhagain meant by "renormalize" the normal maps. Is that the same as calculating the tangent and binormal and applying those to the normal map?

 

-edit-

It's not a specular problem. It's a problem the tangent and binormals I think. I disabled normal maps but left specular maps enabled and the black faces effect was gone. But I noticed that the specularity was completely gone at the angles that caused the black faces.

Edited by newObjekt
0

Share this post


Link to post
Share on other sites

"Renormalize" means you take the new value and normalize it (i.e. give it a length of 1). Essentially:

distance = sqrt(x*x + y*y + z*z);
x /= distance;
y /= distance;
z /= distance; 

Well, you get the idea. Or you could just call normalize on the value within the pixel shader and let it do the job for you (though it burns up some more cycles in the GPU code).

1

Share this post


Link to post
Share on other sites

I note from your fragment shader code that you're already doing this, so nothing to worry about here.

 

vec3 tnormal = 2.0 * getTex(1, gl_TexCoord[0].st).rgb - 1.0;
tnormal = normalize (tnormal);
1

Share this post


Link to post
Share on other sites

I ended up solving my own problem with the "triangles turning completely black" problem. I had sunLocation set as a vec4 but was accidentally doing glUniform3f to send the coords to GLSL. Changed it and it fixed the problem.

 

Thanks for the help. :)

Edited by newObjekt
0

Share this post


Link to post
Share on other sites

So I've gotten some pretty good results by making changes to how normals and stuff are calculated.

http://inferno.codebrainshideout.net/Images/specular%20n%20stuff.png

Does this look alright to you guys?

 

I also would really like to make the specular light change based on the angle the player is looking at things from.

I was thinking

 

vec3 vertexNormal;

vec3 lightDirection;

vec3 cameraDirection;

 

vec3 a = reflect(lightDirection, vertexNormal);

float shininess = pow(max(dot(a, cameraDirection), 2);

 

But I don't know how to get the camera direction and I don't know if the GLSL reflect works like that.

Edited by newObjekt
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