# tsukinokaze

Member

32

128 Neutral

• Rank
Member
1. ## I'd like to make a nes style game, good way to start?

Something like RPG Maker is the way to go. If you are experienced with programming (you said you are not) and really want to make a real NES rom you will find info's here: NES Tutorial Zophar's Domain, best emu/console resource out there imo When you need tiles, either make them yourself, or find a friend who can make them: Pixel Art Tutorial
2. ## Backgrounds

There is this one thread about sprites: here@gamedev. Also for Backgrounds i recommend those.
3. ## Best sorting method for particle systems

I always used insertion sort. It doesn't need any more space and as already said particle positions normally don't change much from one frame to another and insertion sort is fast with almost sorted data. As a matter of fact depending on the pivot element of quicksort, quicksort might be much slower with already sorted data (worst case O(n²)).
4. ## Rendering into a texture?

I suggest Glee for extensions. That's what i'm using. If you want to write everything yourself, maybe this helps, but it costs some time.
5. ## 2D array traversal

I think arrays are saved in c++ in ram like this { {0, 1, 2}, {3, 4, 5}, {6, 7, 8} } a[0] = {0, 1, 2} a[1] = {3, 4, 5} but i don't know, if it's faster or slower to go through them one way or the other. If there is a faster way it's possibly: for( int x = 0; x < 3; x++ ) for( int y = 0; y < 3; y++ ) a[x][y] = i; Just test both ways and look which is faster. If you are familiar with pointers you can check the order using this code: //create and fill 3x3 array with numbers from 0-8 int a[3][3]; int i = 0; for( int x = 0; x < 3; x++ ) { for( int y = 0; y < 3; y++ ) { a[x][y] = i; i++; } } //create pointer integer pointer and point to that array int * m = (int *)&a; //go through array // pointers are fun^^ for( int i = 0; i < 9; i++ ) std::cout << " " << m << " "; hope that helps
6. ## glsl multi pass lighting problem

You can render the scene once for each light and add the result using the Accumulation buffer.
7. ## Very quick question. (Sorting)

I'm no sorting pro, so it's just a suggestion made from theory not praxis. If it's almost sorted, how about gnome sort isn't that fast for those types of tasks?
8. ## Question about implementing surface appendants (things like bullet holes etc.)

There was a post about that here.

Well there is this start here guide on gamdev.net^^ DirectX and OpenGL are just two different ways to talk to the graphics card. Choose the one with the better sounding name and buy a beginners book for it. I think books are better for beginners than learning with online tutorials. Oh, and you should learn 3D mathematics at some point. Browse the books section of gamedev.net for tips.
10. ## Which AI site's are best?

I liked generation5. But it has been quiet there for some years. You may still find some interesting things there.
11. ## Cartoon rendering...

There is NeHe's lesson 37 http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=37 But i think they do it without shaders. And in the Book "More OpenGL programming" in chapter 6 they present toon shading. As pfefferkeks said the color is not so difficult to handle. What i found more difficult to do was to draw the outlines. I liked this approach: When a model is loaded that needs outlines, i compute all edges and store them together with the normal vectors of their two adjacent triangles in an array. Now each frame i test for each edge if one of its normal vectors points into the camera direction and the other does not. If so, you have to draw this edge. But there may be better approaches out there...^^
12. ## Game Maps

I always use a self created map format. It's just a text file that is loaded with c++ code. The advantage is that you can directly specify a format that fulfills your needs, and you can easily change things in a text editor.
13. ## Physics Algorithms

In this forum's faq point 15 may interest you. Especially this.
14. ## Normal Mapping Problem

Ok, i tried using my own Matrix. The result looks somewhat better, but still not all polygons react right. And there is another thing, gl_LightSource[0].position.xyz changes when moving the camera. As it is a directional light, i need its real values, not the changed ones. Is there a way to get them without using uniforms? Btw, looking over normal mapping shaders in the web a lot of them look much simpler than mine, maybe i should start from the scratch again... EDIT: the changed stuff: In the c++ prog: void DrawStaticMeshes() { for( each object ) { glPushMatrix(); glTranslatef( object->spaceData->position.x, object->spaceData->position.y, object->spaceData->position.z ); glRotatef( object->spaceData->orientation.x, 1.0f, 0.0f, 0.0f ); glRotatef( object->spaceData->orientation.y, 0.0f, 1.0f, 0.0f ); glRotatef( object->spaceData->orientation.z, 0.0f, 0.0f, 1.0f ); //NEW NEW NEW NEW NEW: //compute rotation matrix for normal mapping if( object->staticMeshPtr->hasNormalMap ) { mat4 rotmat, mx; mx.Identity(); mx.Rotatef( object->spaceData->orientation.x, 1.0f, 0.0f, 0.0f ); rotmat.Rotatef( object->spaceData->orientation.y, 0.0f, 1.0f, 0.0f ); rotmat = rotmat * mx; mx.Identity(); mx.Rotatef( object->spaceData->orientation.z, 0.0f, 0.0f, 1.0f ); rotmat = mx * rotmat; float mat[9]; mat[0] = rotmat.m[0]; mat[1] = rotmat.m[1]; mat[2] = rotmat.m[2]; mat[3] = rotmat.m[4]; mat[4] = rotmat.m[5]; mat[5] = rotmat.m[6]; mat[6] = rotmat.m[8]; mat[7] = rotmat.m[9]; mat[8] = rotmat.m[10]; shaderStaticMeshes.SendUniformMat3( "rotMat", mat ); } DrawStaticMesh( object->staticMeshPtr ); glPopMatrix(); } } in the vsthe new vs: // static mesh vertex shader .... per pixel lighting / no normal mapping!! #version 110 uniform int type; uniform mat3 rotMat; //NEW NEW NEW varying vec3 sunVec; varying vec3 halfAngle; varying vec3 normal; void main() { vec3 pos = vec3( gl_ModelViewMatrix * gl_Vertex ); normal = gl_NormalMatrix * normalize( gl_Normal ); if( type == 2 ) { mat3 xmat = rotMat; normal = rotMat * normalize( gl_Normal ); //tmp vec3 tangent = xmat * normalize( gl_MultiTexCoord1.xyz ); vec3 binormal = cross( normal, tangent ); mat3 tSM = mat3( tangent, binormal, normal ); //vec3 sunPos = gl_LightSource[0].position.xyz; //vec3 eyeDir = tSM * normalize( -pos ); sunVec = tSM * ( -normalize( vec3( 1.0, 0.0, 0.0 ) )); //gl_LightSource[0].position.xyz //sunVec = -normalize(gl_LightSource[0].position.xyz); //halfAngle = normalize( eyeDir + sunVec ); } else { sunVec = -normalize( gl_LightSource[0].position.xyz ); halfAngle = normalize( normalize( -pos ) + sunVec ); } gl_TexCoord[0] = gl_MultiTexCoord0; gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; }
15. ## Normal Mapping Problem

Hi, im trying to implement normal mapping but i get strange results. As im relatively new with shaders maybe i just misunderstood something. Currently im only experimenting with diffuse lighting and normal mapping. There is one directional light (1.0, 0.0, 0.0) and the non-normal-mapped objects work fine. The Problem is that on the normal mapped objects the diffuse lighting changes when moving the camera and i don't know why. EDIT: It looks right when the camera looks directly onto the normal mapped polygon. Note: type = 2 means normal mapping enabled The Vertex Shader: #version 110 uniform int type; varying vec3 sunVec; varying vec3 halfAngle; varying vec3 normal; void main() { vec3 pos = vec3( gl_ModelViewMatrix * gl_Vertex ); if( type == 2 ) { vec3 normal = gl_NormalMatrix * normalize( gl_Normal ); vec3 tangent = gl_NormalMatrix * normalize( gl_MultiTexCoord1.xyz ); vec3 binormal = cross( normal, tangent ); mat3 tSM = mat3( tangent, binormal, normal ); //vec3 sunPos = gl_LightSource[0].position.xyz; //vec3 eyeDir = tSM * normalize( -pos ); sunVec = tSM * ( -normalize( gl_LightSource[0].position.xyz )); //sunVec = -normalize(gl_LightSource[0].position.xyz); //halfAngle = normalize( eyeDir + sunVec ); } else { normal = normalize( gl_NormalMatrix * gl_Normal ); sunVec = -normalize( gl_LightSource[0].position.xyz ); halfAngle = normalize( normalize( -pos ) + sunVec ); } gl_TexCoord[0] = gl_MultiTexCoord0; gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; } The Fragment Shader: #version 110 uniform sampler2D diftex; uniform sampler2D nortex; uniform int type; uniform int lightsnum; varying vec3 sunVec; varying vec3 halfAngle; varying vec3 normal; void main() { vec4 color; vec4 xcol; vec3 nnorm; color = texture2D( diftex, gl_TexCoord[0].st); if( color.w == 0.0 ) discard; if( type == 2 ) { nnorm = texture2D( nortex, gl_TexCoord[0].st ).xyz; nnorm = vec3( 2.0 ) * ( nnorm - vec3( 0.5 ) ); } else { nnorm = normal; } nnorm = normalize( nnorm ); float sunDif = max( dot( normalize(sunVec), nnorm), 0.0 ); float sunSpec = pow( max( dot( nnorm, normalize(halfAngle) ) , 0.0 ), 32.0 ) * (gl_FrontMaterial.shininess / 64.0 ); color.xyz *= //( gl_LightModel.ambient + ( gl_LightSource[0].diffuse.xyz * sunDif ); //( gl_LightSource[0].specular.xyz * sunSpec ) ); gl_FragColor = color; } The Programm Draw Code(pseudocode/shortened): void Draw() { //lights glEnable( GL_LIGHTING ); float lpos[] = { 1.0, 0.0, 0.0, 0.0 }; glLightfv( GL_LIGHT0, GL_POSITION, lpos ); float ldif[] = { 1.0, 1.0, 0.0, 1.0 }; glLightfv( GL_LIGHT0, GL_DIFFUSE, ldif ); float lspe[] = { 1.0, 1.0, 1.0, 1.0 }; glLightfv( GL_LIGHT0, GL_SPECULAR, lspe ); //camera glLoadMatrixf( cam.m.m ); //draw sky //check visibility //draw meshes glEnable( GL_LIGHTING ); DrawStaticMeshes(); //see below //draw even more stuff } void DrawStaticMeshes() { for( each object ) { glPushMatrix(); glTranslatef( object->spaceData->position.x, object->spaceData->position.y, object->spaceData->position.z ); glRotatef( object->spaceData->orientation.x, 1.0f, 0.0f, 0.0f ); glRotatef( object->spaceData->orientation.y, 0.0f, 1.0f, 0.0f ); glRotatef( object->spaceData->orientation.z, 0.0f, 0.0f, 1.0f ); DrawStaticMesh( object->staticMeshPtr ); glPopMatrix(); } } Thanks in advance :)