Jump to content
  • Advertisement

darc koder

Member
  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

100 Neutral

About darc koder

  • Rank
    Newbie
  1. I'm trying to implement frustum cull techinque in the vertex shader itself. What i'm trying to do is, only pass those vertices to the pixel shader which lie in the frustum cone. But the problem is i dont know how to get the number of polygons drawn so as to see if the technique is working or not, whenever i move the camera. I'm using a really fast GPU so i dont think a few polygons will affect the fps count so i don think i can use fps count so as to check the performance gain What i wanna know is there any function or technique to query the number of polygons or tris drawn on the screen. I'm working in C++ using DirectX and HLSL.
  2. darc koder

    A Useless Project

    Ok, so this is my first. I'm writing without thinking, so it may get a bit irrational. I joined this forum. in 2010, March i guess. I was working on my final year project - it was a GUI in OpenGL for Box 2D physics engine, and i came here seeking help. Like we all are. So anyways i got my answers, and i vanished from this site like for more than a year and a half. In that time i finished my graduation in May 2010, i was a Computer Science student at GGSIPU in Delhi. Since then i'm trying to get myself in game industry as a programmer. People say i've failed and i should get a job in IT industry and start making money for myself. But i'm not done yet. There are no major game studios in my country. Sorry. . . there are none. And so i have decided to do a masters course in Game Development. Some of you may say its quite unnecessary , that it wont help, or i'll get overqualified, or i should try to get into some game studio and start working my way up in the industry. But the way i see it, without any experience in game programming i wont get in anywhere. When i say no experience. Its a grey area. I made a game using C++ in DOS in my second year. It was a rubbish imitation of Snakes there were no levels, no walls and you have to eat yourself to put yoursef out of misery. Then again i worked on a sample game for Gameloft in C++ and OpenGL and almost got in for a job as a porter but i couldnt join. Then i made a cheap imitation of Tetris as Indiagames wanted to see my aptitude in game programming so that they can hire me as a platform developer. Again i almost got the job but i didnt join because of a reason which i wrote here will annoy some people at Indiagames. And i really dont wanna have that on my back. Indiagames happened right after i started work on own game engine-ish engine. It was september, of this year and it was a really slow day. I couldnt apply for fall semester for next 2 months . If i get in, semester wont start for other other 10. All i had this useless idea which i can work on. I started with my old friend C++. Pulled out some of my old projects so that i dont have to write the mundane code for running a window. Done. Now i want to use a graphics API. I wanted to go 3D this time. Because its cool. And tough. I like tough. I could have started with OpenGL but dont know why i found myself downloading DirectX SDK. Strange, but it must have felt right when i took the decision. Anyways. Now i have to learn it from the scratch. How hard can it be? A quick search at google and i struck gold 'Introduction to 3D Game Programming in DirectX 9.0C: A Shader Approach'. From my previous projects i knew what i've to do. Make a window and start a rendering environment. Done. Now we need to draw some polygons on the screen. This can get a bit tricky with DirectX. With OpenGL you can its easy to setup out pipline matrices but with DirectX it not that easy. And since when done Microsoft started making it easy on us. Enough on picking up with Bill Gates. With world, view and projection matrices done. Its time for vertex and index buffers. Perviously worked with OpenGL which was not such pain in the ass when it came for drawing polygons. And i worked only with 2D. So the concept of index and vertex buffers was a bit trickey. But after a while i got to inderstabd the concept. Initial test was just to draw some 2D polugons to test our directx environment and the real time game loop. Now it was time for 3D. With projection matrix set for perspective view and few hours with the vertex and index buffers i learned a very good lesson. You can never get the all the faces of a cube right in one go if oyu are dealing with index and vertex buffers manually. It felt really weird rotating a black cube with world matrix. After years and years FPS games i wanted to "wasd" and mouse controls too. Looking up in be book i found how to set up DirectInput controls. Easy. Now how het in first person mode. Must be some witchcraft with the matrices. About that time Indiagames came in and i had leave city for the interview. Three days after i came back form a 5 day trip, i was still stuck with the fps problem. And there was another thing. I still havent had a name for the thing i was working on. In summers i worked on a project with afriend of mine on C# asp.net and SQL server. Itspurpose was to make a simple web page to write data into a SQL database with no knowledge that any database exsisted. Easy. But none of us knew C# or how to write Stored Procedures. So in that project we wrote most crazy variable names. And we names that project Uselessness. My project was then christned "A Useless Project". But it still didnt solve my problem. This time the book came to rescue. I read somewhere that i need to change the view matrix in order ot move the camera. Ok. Time for some clever programing. Rotatating the view matrix with moise and strafing with keyboard input. Doesnt sound that tricky unless your previously know that you have to rotate and move i the other direction than you are actually wanna go or you'll end up with reversed controls. Both for keyboard and mouse. Having dealt with that it was time to fly around that black cube. I got bored now. I needed more geometry to fly around. You cant just write entries for vertex and index buffers for a whole scene. Time for some meshes and the book again. I know i'm not an artist and i dont have time to make meshes in Maya or 3DS Max. So it'll take some X meshs from DirectX samples and Frank Luna samples. Thank you very much. Now i'll need to deal with textures too. And since i dont know how to render a mesh with textures i'll take help from the book. It says here a perfect recipe for showing textures meshed without putting much pressure on the cpu is to use HLSL. And there is more, you need to import the mesh in to your own vertex format which will handle textures too. Adding to misery your own effect file. A major code cahnge prehaps. Buffers have to go, vertex format needs to be changes. need to write mesh loading code and class to handle world transformations of the mesh. Then write code loading the effect file. Handles to get techniques and pass matrices, texture and vectors to the effect. Writing the effect itself and understanding the code. And in the end writing mesh rendering function so that we can use data from mesh pass it on to the effect file for rendering. And we are done. Time to fly around in the dark. Wait. Someone turned off the lights. More coding for the lights. I'll stick to directional lights for now. But wait mesh looks a bit plain. Ok . Need normals. Updating mesh loading function to generate normals, changing the vertex format, passing all normals to effect and Blinn Shading to smooth out unlit areas. Shift+F5 again and it looks good. Time to fly again. [media][/media] After showing to the world i've stolen a mesh form directx samples and used in my engine time to journey on. What now more lights. Mode code change. Adding structures for point and spotlights. Rendering no meshes to how their position in the scene or their direction. Passing values to the shader. Calculating individual color values by each light and adding it in the end. Wait, i dont wanna use the same mesh again. This time stealing it form the samples from the book. A mesh with pillars. This will do. Turning on all the light sources and making a video. Scene looks terrible. I dont care. [media][/media] The more i look the more unrealistic it looks. Seems like pillars are hanging in air. My younger brother stading behind me asking me why are there no shadows. Click. So i dont know nothing about shadows. Trying to find some code to steal. Found a sample that came along with sdk. This shadow volume sample with a pointlight source will do. Stealing the code and adding into the project dont seem that difficult. More code modifiaction. Passing mesh info to shadow class so that it can make shadow mesh. Time to change shader. Wait there is a problem here. In my shader i transformed input verticies with world martrix but the sdk sample multiplies it with world view matrix. Well changing the code wont have much effect i guess. It's a disaster this build. there is no shadow mesh on the screen and when i move artifacts fill the whole screen. May be i did something wrong. Starting with a fresh build and changing the whole code again, i can see problem in shader. Input vertex should be a float4 but i wrote float3. Having fixed that another go at the code. But this time the whole shadow mesh moves with the as i fly around. After hours of fiddleing out with the code i can see the problem. Need to transform the position of the pointlight with view matrix before passing it to the shader. Fix run. [media][/media] But there is a problem again. Before start rendering the code builds the whole shadow mesh which is cpu bound and it takes a lot of time. One solution is to write the mesh onto a file ads save it so that its not build again and again. The second is to use some other shadow algorithm. I dont have time to make change the code again and no time ti fiddle with the code to write it into a file. I'll save the trouble for later. Yet another thing. Right now shadows are generated for point lights and even if the light does not illuminate the mesh it still casts a shadow. Ohk. We dont need to show those parts of the shadow mesh which are out of the defined radius of point light. But the thing is it does not give correct shadow mesh.But doesnt matter we will be changing the shadow algorithm afterwards. Coming to spotlights. along with the radius cull of shadow mesh we meed to cull the shadowm much which is outside the frustum of the soptlight. Slight tweak in shader and it runs too. [media][/media] Well i'm thinking now to make a level editor. I'm tired of hard coding all meshs at their respective place. But still textres still looks flat. Going through the book, in the chapter that discusses advance texturing there was somthing about normal mapping. A quick read solves the problem. But the thing is i've used the same mesh again and again and i dont have normal maps for new mesh which i stole from book sample. Googleing the solution, its easy to generate cheap normal maps in photoshop using nvidia's normal map plugin. In not time normal maps are ready. But its not that easy. The mesh only have texture information associated with each subset. Need to find a way to load normls maps for associated texures. Thinking hard, the solution is that each normal map has the same name as the texture it is associated to but with a slight variation. Normal map has "_nm" agumented to its file name. when ever a texture is loaded whith the mesh, the corrosponding code searches for the agumented filename and loads the normal map. After that it is passed to that shader isn the same way as the texture. The mesh loader function is too changed so as to autogenerate the tangents and binormals. New vertex is written so as to pass vertex and binormals to the shader. For light calculations the normals from the normal map is used insted of the normals passed in the vertex format. And we have a bumpy ride. [media][/media] All basic rendering functionality are implemented. Now its time to make a level editor. Well time to find some books and steal some more code. Till the next Update
  3. Hi, I'm trying to use multiple techniques in my fx file. I've written two different techniques one just for Ambient light and the other one is for all other light types. Vertex Shader is the same for bith techniques but pixel shader is different. technique TexAmbientTech { pass T0 { vertexShader = compile vs_3_0 TexLightVS(); pixelShader = compile ps_3_0 TexAmbientPS(); } } technique TexLightTech { pass P0 { vertexShader = compile vs_3_0 TexLightVS(); pixelShader = compile ps_3_0 TexLightPS(); } } Now the problem is no matter which technique do i specify the program uses only that technique that occours first. Suppose if i want to use TexLight Techinique and do effect->SetTechnique("TexLight"); still TexAmbient is being used. I cant figure out the problem. Can anyone please tell me what am i doing wrong? Regards
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!