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

Normals question

5 posts in this topic

So I have had a strange happening that I can't figure out - its been a day and a half of me trying and so I though I would make a post to see if anyone had any insights.

 

Our team's artist has made several models in blender - lets just say a tile, a dwarf, a robot, and a bridge. When these items are rendered, the tile has light on the correct side and the other objects do not - they are lit in the back. My first reaction was to flip the normals on the objects and see if the light rendered on the correct side - it does. But - when I draw the normals they appear to be correct.. not sure whats going on. Here is an example - the first bridge is the normals before flipping, and the second is the normals after flipping. The light appears on the correct side after flipping.

 

(before flipping)

[attachment=23167:bridge1.png]

 

(after flipping)

[attachment=23168:bridge2.png]

 

So if the normals are simply incorrect - thats not a big deal. But the thing is that when I flip the normals by multiplying by negative 1 the result is not exactly correct either. I think that's because the normals need to be reflected over the model's vertical axis rather than flipped. If I do that then the specular lighting is correct. That is, if the normal is pointing from the model to the upper left like \, where the comma is the model, then the new orientation needs to be ,/ rather than '\ if that makes any sense at all.

 

I don't understand why blender would be exporting models with normals like this which makes me think it has to be a mistake in my code somewhere.

 

Could it have to do with the coordinate system of the normals? I use assimp for importing and generate normals when they aren't available, but all these models have normals available.

 

Any insights would be helpful, thanks

 

 

0

Share this post


Link to post
Share on other sites

What format are you using for Blender export? Do you create and export all the objects in the same manner? Are you flipping the normals in Blender, or in your program?

 

 

I use dae from blender - and I was flipping the normals within the engine. That is - I just went through all normals and multiplied by negative 1. There could be some difference in the export formatting from blender - but I don't think so since dae doesn't provide a huge range of exporting options. The artist said they made the bridge in the same manner they made the tiles.

 

 

 

 

Do you set the correct light direction in your shader? If you use a dot product between the normal and the light direction, do you remember to "flip" the light direction? That is, an object should be lit when the normal and light direction are opposing (i.e., the normal points in the direction of the light source).

 

 

Yes - I did flip the direction in the shader when dotting the normal and the direction - the shader code is below.

vec4 getLightInfluence(vec4 lWorldPos, vec3 norm, Material mat)
{
	vec3 worldPos = lWorldPos.xyz;

	vec4 ambientColor = vec4(light.color, 1.0f) * light.ambientIntensity;
	float diffuseFactor = dot(norm,-light.direction);

	vec4 diffuseColor  = vec4(0.0, 0.0, 0.0, 0.0);
	vec4 specularColor = vec4(0.0, 0.0, 0.0, 0.0);

	float shadowFactor = getShadowFactor(lWorldPos);
	if (diffuseFactor > 0) 
	{
	    diffuseColor = vec4(light.color, 1.0f) * light.diffuseIntensity * diffuseFactor;
            vec3 vertexToEye = normalize(camWorldPos - worldPos);
            vec3 lightReflect = normalize(reflect(light.direction,norm));
            float specularFactor = dot(vertexToEye, lightReflect);
	    specularFactor = pow(specularFactor, mat.specPower);
	    if (specularFactor > 0)
		specularColor = vec4(mat.specColor, 1.0f) * mat.specIntensity * specularFactor;
	}

	return ambientColor + shadowFactor*(specularColor + diffuseColor);
}

This is a deferred renderer, and this is the direction light shader which gets all positions, material properties, normals, etc from textures. The direction is passed through a uniform and I have made sure that this direction what it should be.

 

 

Have you tried to debug examining actual values which are imported, stuffed into the vertex buffer, sent to the shader and used in the shader? If not, why not?

 

 

Well - I did in the sense that the normals drawn in the picture are the imported normals. I just created another VBO with the positions and the positions + normals and drew in GL_LINES mode - the normals look okay so I'm not sure.

 

Update:

I think I may have found the cause of the problem.. It looks like the artist created a normal map texture for the grass tile and not for any of the other objects.. Let me investigate a bit further but I think the problem is that I put a check for the normal texture in the shader in the wrong place, so that no matter what it is multiplying the normal retrieved from the texture by the mat3(tangent, bitangent, normal) matrix..

 

What I mean is that the vec3 retrieved from the normal texture is initialized to 1,1,1, and if there was no normal texture I just left it as 1,1,1 however it should just send the normal along with no alterations if there is no normal texture I think

0

Share this post


Link to post
Share on other sites
Thanks for sharing the solution. Might I ask about the number of normals in your screenshots? It looks like you've got so many on your bridge supports that you can't actually see them. And the 'road' of the bridge, is that lots of flat polygons?
0

Share this post


Link to post
Share on other sites

Yeah there really is a lot of normals on the supports - but this model was unrefined and still has the original number of verts. I asked the artist to leave it high vert for now for testing purposes - I want to make sure all the vertex buffers and all my shaders can handle high vert objects. This bridge has 71,000 indices in to 60,000 verts/normals/tangents. Most of which reside in the chain supports.

 

We are making a hex tile map builder/editor which will can create plugins to go in to our game build and battle, which we are also working on. But anyways - the top of the bridge is fit to hexagons - as the picture below shows

 

[attachment=23179:scrn.png]

 

I hope that answers all your questions!

 

By the way - the bridge is obviously scaled incorrectly at this second - but thats no big deal - the bridge will likely be largely remade

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