Thursday, May 2, 2013

Graphics Assignment 13 - Cool Scene

Awwyeah! Check out my final assignment, my cool scene. So cool you might wanna zip your jacket up. :P

Stuff to check out:
- Awesome looking SkyDome
- Green 'alien' like water with reflections.
- Giant translucent floating orb with a wobble effect.

Here's my code:
Download code








Instructions:
- Use the arrow keys to move the camera and walk around.
- Move the directional light using W,A,S,D

Graphics Assignment 12

Woohoo! I have added shadows to my Renderer. Overall there wasn't much programming to do all I had to do is add a new Shadow technique, create a new render target for the Shadow map and make some changes to my shaders. The tricky part was getting the shadow effect to look right.

I had a lot of issues with my Shadows looking weird with my normal maps. I tried a lot of tweaking, added a faux pointlight and did all sorts of things. Turns out all I had to do reverse the lightDirection of the directional light, because of which I was getting the wrong dotProduct for calculating the diffuseLight. Yes, you were right JP. :P

Anyways, here is my assignment. Everything works and my shadows look awesome and so do my normal maps.
Download Code



Instructions:
- Use the arrow keys to move the camera and walk around.
- Move the directional light using W,A,S,D

PIX Screenshot of Shadow Map


Monday, April 15, 2013

Iterating and testing changes made to the code

With the way we have designed our system, testing out small changes for the Co-signers' alpha build is a huge pain. For every change you make, even if you're tweaking a float you have to fire up two instances of the game. Create a game, join the game from the other instance. Set up one instance as the hacker and the other as a pointman, and then test it out. We need to come up with some solution for this ASAP! Argh! :@

Friday, April 12, 2013

Graphics Assignment 11

After completing Assignment 10, this assignment was super easy. My scene looks so badass now. Another thing I'm glad about is my the way I manage my techniques , with which I can do multiple post-processing passes without making any changes to my renderer code and with a single effect file. 

Post-process effect
- Added vignette effect. Wish I had time to do something cooler. I have so many ideas, sigh.
- Added Doom hud texture.

Link to code



Screenshot:

Instructions:
- Use the arrow keys to move the camera and walk around like a boss.

- Move the sphere with soft intersections up and down using T and G.
- Move the light in the x and y plane using W,A,S,D
- Move the light forward and backward using R , F


Graphics Assignment 10

This assignment took more time than I expected mainly because I had to restructure a lot of my code. I also had this problem when I couldn't get the index of some of fragment shader uniforms. Apparently, because I was not using them in the operations in my shader code.

Anyways, everything works now. Here is the code.
Download

Screenshots:


ViewDepth texture


Major changes:
- Added another deferred pass for the soft intersections effect.
- My system now supports multiple techniques.

Instructions:
- Move the sphere with soft intersections up and down using T and G.
- Move the light in the x and y plane using W,A,S,D
- Move the light forward and backward using R,F
- Move the camera using the arrow keys.

GDC


Friday, March 22, 2013

Graphics Assignment 9

This assignment was pretty easy and I did not have any major problems completing it. There was a time when my objects would reflect everything even after setting the reflectivity to zero. I fixed that by negating the camera direction.

Here's the code.
Download

My effect turned out really cool. It starts of as a wobbly mass and slowly transforms into a sine wave of increasing frequency.





Instructions
- Move the light in the x and y plane using W,A,S,D
- Move the light forward and backward using R,F
- Move the camera using the arrow keys.


Changes:
- Modified the scene file format to hold the environment map.
- Modified the material format to hold reflectivity
- Added a new effect, vertex shader and fragment shader for the transparent wobbly effect.
- Made changes to the renderer flow so that the opaque entities are drawn first and rendered to a texture, which can be used by the translucent entities to perform interesting effects.

PIX Screenshot




Thursday, March 7, 2013

Graphics Assignment 8

This assignment was pretty cool and my meshes looks really awesome, especially the medieval looking cube.

Here's my code

Changes:
- Modified the vertex format, mesh file format, MayaExporter and MeshBuilder to add support for tangents and binormals.
- Made changes to the MayaExporter so that the mesh exported is left-handed.
- Modified the material format, to hold normal map texture.
- Changed vertex and fragment shader to calculate light based on the normal map.

Instructions
- Move the light in the x and y plane using W,A,S,D
- Move the light forward and backward using R,F
- Move the camera using the arrow keys.

Screenshot ( Man, that medieval wall texture looks awesome. ) 


Friday, March 1, 2013

Graphics Assignment 7

This assignment was really cool, I was always interested in implementing transparency and I had no idea it would be so easy. 

I did not have to make any major changes to my project which was awesome, because I was already storing RGBA values for everything since Assignment 2. 

Here's the assignment. Everything works.

Changes:
- Added a bunch of new fragment shaders, effects and materials for different kinds of transparency.
- Changed the format of the .effect file to add support for render state.
- Changed the format of the .material file to hold the object's uniform alpha value.
- Added two entity lists for opaque and translucent entities.
- Added a new sorting algorithm for sorting translucent entities based on their distance from the camera.

Controls are the same:
- Move the light in the x and y plane using W,A,S,D
- Move the light forward and backward using R,F
- Move the camera using the arrow keys.

Screenshot

PIX Screenshots



Gate 1

I was obviously disappointed that our game Ludology did not make it through because we had invested so much time into the game and had gotten attached to the idea.
I was also annoyed about the fact that I had spent so much time understanding CryEngine and had finally gotten a hang of CryEngine, and after all this I will have to work with Unity.
Moving on, I have decided to join the Co-signers team because I found their idea interesting from the very start and I personally think it is more fun than Vinyl. Also, the hacker side is to be made for the iPad and I thought it would be a good opportunity for me to be able to utilize my iOS development experience in porting it.

Friday, February 22, 2013

Graphics Assignment 6

This week's assignment was brutal. I'm glad that I finally got everything to work. The Maya Builder part was the easiest to do and the most rewarding, and I finished that part in a couple of hours. But the rest of the assignment was exhausting and took roughly 18 hrs to finish. I'm so exhausted I can barely type..

I had major problems with parsing Binary files ( I wasted a good 12 hrs on it), even though it is super easy and I got it to work with simple structs on a separate project. It was super annoying not being able to manually read the binary files. After some trial and error and tons of crazy errors I finally got it to work by reading each s_vertex individually, verifying it and then storing it in the vertex buffer.

Changes:
- Added the MayaExporter tool which exports my human-readable mesh format.
- MeshBuilder tool now reads the human-readable mesh file and outputs a binary file.
- Added binary file parsing to Mesh class. 
- Entities are now sorted based on effect and material.
- Vertex and Fragment shader are set only when effect changes.
- Texture and specular exponent are set only when the material changes.
- Added PIX events

Here's the assignment. Works in both Debug and Release mode.
Download Code

Oops, forgot to add a screenshot. Here it is..


Friday, February 15, 2013

Graphics Assignment 5

This assignment was really easy and I was able to whip it up in a couple of hours.


Changes:
- Changed the format of .scene file a little. You can now set the ambientLight of the scene and the attenuation factor of the point light.

- I calculate the newIntensity of light based on the attenuation factor like this:

float lightDistance = length( pointLight_position - i_position_world );
float newIntensity = saturate( pointLight_intensity - (lightDistance * attenuationFactor ) );

So the attenuation factor should be between 0 and 1. 0 being strongest and 1 being weakest i.e. no light.

- Created new fragment shader for specular lighting and made changes to the old one to add support for the attenuation factor, and created a corresponding effect file.

- Changed the format of .material file. You can now set the specularExponent of each material.

- Added a plane and some more cubes ( half of the cubes have only diffuse lighting and the rest have diffuse and specular lighting ).



Instructions:
- Move the light in the x and y plane using W,A,S,D
- Move the light forward and backward using R,F
- Move the camera using the arrow keys.


Notes:
I had no issues with this assignment but one, where the specular lighting was looking really bright and I realized that I forgot to multiply it by the light intensity.

Graphics Assignment 4


Woah, this assignment was colossal and took a lot of my time. I spent most of my time structuring my code and writing parsing code for the new file formats.


Changes:
- I have added a Scene class now, which contains the entities, light and camera. The Mesh class updates and draws itself. All the renderer does now is contain the scene and asks the scene to update and draw itself.
- I have added support for light color and intensity
- I have added 4 new file formats and this is how they look like:

Effect
technique name
{
               vs = filepath
               fs = filepath
               expectedTexture = type
}

Material
effect = filepath
texture = filepath

Entity

mesh = filepath
material = filepath

Scene
noOfEntities = n
Entities
{
               entity = filepath
               x =
               y =
               z =
               rotY =
}
{
               entity = filepath
               x =
               y =
               z =
               rotY =
}
{
               entity = filepath
               x =
               y =
               z =
               rotY =
}

Light
{
               x =
               y =
               z =
               r =
               g =
               b =
               intensity =
}
Camera
{
               x =
               y =
               z =
               rotY =
}


 Screenshots


PIX Screenshot

Instructions:
- Move the light in the x and y plane using W,A,S,D
- Move the light forward and backward using R,F
- Move the camera using the arrow keys.

Notes:
Hmm, problems I ran into..
- There was this issue when all my cubes were being drawn at the same position i.e. the position of the last updated cube. I fixed this later, I realized that I was overwriting the registers that the vertex shader uses to store its uniforms and made sure that I load the uniforms and then draw it immediately, and then load the next set of uniforms.

- I ran into this linker error on which I wasted a lot of my time. I always guard my headers but I was still getting the 'already defined' error. John helped me out with this later and it got fixed by making one of my variables extern and defining it in a seperate cpp file.


CryEngine


Friday, February 1, 2013

Graphics Assignment 3

Compared to last week, this week's assignment was really simple. It was mainly about adding textures and point lights to our project.

Here's my code
Download

Changes

- Changed the mesh file format to add support for uv coordinates and normals. Its new format is:

NoOfTriangles = n
NoOfVertices = n
NoOfIndices = n
Vertices
x , y , z  |   r , g , b, a   |  u , v  |  nX, nY, nZ
x , y , z  |   r , g , b, a   |  u , v  |  nX, nY, nZ
x , y , z  |   r , g , b, a   |  u , v  |  nX, nY, nZ
x , y , z  |   r , g , b, a   |  u , v  |  nX, nY, nZ
Indices
i1 , i2 , i3
i1 , i2 , i3

- Added a cPointLight class, which holds the point light's world position.

Instructions

- Move the light using W,A,S,D
- Move the camera using the arrow keys.

Check out my cool gameboy texture


PIX screenshot of texture


Notes
This week's assignment was simple because the concepts were really clear to me, I had dabbled with UVs and normals in an XNA project some months ago.
- The only confusing part was figuring out the right UVs for the vertices, since it's a 3D object.
- Apart from that everything went smoothly and the code runs perfectly in both Debug and Release mode. :D

Friday, January 25, 2013

Graphics Assignment 2


This week's assignment was really difficult. Even though, I had everything figured out in my head, I had no idea where to start from. Structuring the code was hardest part. I wasted most of my time studying up DirectX syntax and functions and looking up oversimplfied tutorials.
Enough of ranting, let's move to the code.

Here's is my code
Download

Changes:

- Changed the mesh file format to include Color and Indices.
The new format looks like this:

NoOfTriangles = n
NoOfVertices = n
NoOfIndices = n
Vertices
x , y , z |   r , g , b, a
x , y , z |   r , g , b, a
x , y , z |   r , g , b, a
x , y , z |   r , g , b, a
Indices
i1 , i2 , i3
i1 , i2 , i3

- Added an index buffer and changed the draw call to drawIndexedPrimitive.
- Added a cMesh class, which contains the cube's position and modelToWorld matrix, which transforms the model from Model space to World space. It also contains basic functions for moving around and rotating the mesh about the Y axis. (for now) 
- Added a cCamera class which holds the camera position and worldToView matrix, which transforms the model from World space to View space.
- I am creating the viewToProjected matrix (which transforms the model from View to Projected space , 3d to 2d representation of the model) in the cRenderer class for now.
- Added a LoadTransforms() function to the cRenderer class which loads all these matrices into the Vertex shader.
- Added a GetInput() function to the cRenderer class which gets the user input and moves the camera or cube accordingly.
- Made the Update and waitForShutdownThis non const, for now. This was really frustrating. I was constantly getting 'Conversion loose qualifiers' errors. 

Instructions:
- Move the cube using W,A,S,D.
- Move the camera using the arrow keys.

Screenshot of my funky cube


PIX Screenshots of Mesh Pre and Post Vertex Shader

Game Pitch

Here is a picture of me pitching my thesis game called Prey. 
It was my first time pitching a game and I'm glad that it went smoothly. The profs really liked my concept of having a low hanging dynamic FPS camera that simulates real motion, making you feel immersed in the character and the environment.

Friday, January 18, 2013

Graphics Assignment 1


This week's graphics assignment was simpler than I thought it would be. We were required to build our own mesh format, a mesh builder tool and make some changes to John Paul's vertex and fragment shader.

Here is the download link for my assignment. Download code

File/Mesh format
My file format looks like this:

NoOfTriangles = n
x , y
x , y
x , y
x , y
x , y
x , y

Here is my rectangle mesh for this assignment:

NoOfTriangles = 2
0.6 , -0.5
-0.6 , -0.5
-0.6 , 0.5
-0.6 , 0.5
0.6 , 0.5
0.6 , -0.5

Vertex shader
I changed the vertex shader so that the rectangle moves in a cool counter-clockwise fashion across the window. What I did is basically add a sine wave of the elapsed time to the input x position and subtract the input y position by a cosine wave of the elapsed time. Then I scaled the displacement down by a certain value, so that the rectangle moves inside the window.

Fragment shader
I added a cool negative image effect to the fragment shader, by subtracting 1 by the input color.

Here are a couple of screens:









PIX screenshot of Vertex shader




PIX screenshot of Fragment shader




Notes
I did not run into any problems with the programming part. But I had a hard time dealing with PIX, since I had never used it before and was absent for John's first lecture.

Prototype 4 : The Lurker's Cave


Overview:

The premise of this game is really interesting. It is 2.5 D worms style game where you play as the antagonist, a cave dwelling monster that is trying to protect itself from the explorers, by freezing them and trapping them. You must avoid light throughout the game and since the explorers carry flashlights, being near them for too long depletes your health. So your goal is to come up with tactical and sneaky ways of freezing them, before they find you and kill you.


My contribution:

- I developed a Player controller script from scratch, which essentially manages the core mechanics of the player like moving around, jumping and climbing.
- While playing around with the physics of the player, I implemented this really cool infinite ( yes, not double or triple, but infinite) jump mechanic which I am really proud of. We obviously had to set the maximum jumps to 2 for the game. But, this is something that I thought was really cool and I will probably use this in some of future projects.
- I integrated Alice’s 3D model for the monster into the game and with the player controller.
- I integrated the main camera with the player and fixed a lot of camera synchronization issues.
- I designed the lighting system for our level.

What I learned from this prototype and the positives and negatives of the process:

Positives:

- I got to work with an artist and for the first time ever got to add a completely textured 3D model into my game.
- We set up a SVN server for managing our code, which I think is a must have for every prototype.
- Alice’s model looked really cool and fit well with the theme of our game.
- All the programmers spent a lot of time working together in the lab, which was really productive.
- Our communication was great.

Negatives and What I would have done differently:

- Our game mechanics were pretty ambiguous and no one was willing to sit down and discuss them in detail, thinking it was a waste of time and that we should start working and then see how they work out. I pointed this out a lot of times but gave up in the end. This led to a lot of problems later when we had to merge the mechanics together, because everyone had different ideas about how the mechanics worked.
- Our producers thought it was a good idea to divide work based on roles ( UI programmer, mechanics programmer, etc ), which did not work out very well. Things got messy as some features overlap roles and we did not know how to split them. So we decided to divide the work based on features from further on.
- Unity is not really programmer friendly and when working with a team of 6 programmers, it can cause disasters. Merging the .scene files in Unity was a task in itself and caused a lot of issues.

Prototype 3 : Nemmi

Overview:

Nemmi is a top-down RPG whose goal is to help its players learn about the Shoshone language and culture, through fun gameplay.  It is basically a mash up between Pokemon and Skyrim. The premise is that, a Shoshone Chief Elder has discovered that monsters have been scattered throughout the region and because of this has made the Shoshone Spirits lost and restless. As the main character, your job is to go explore the region, solve puzzles, battle monsters to help put the Shoshone Spirits at peace once more. 



My contribution:

- This game was my idea, so naturally I was really excited about it and worked on a major part of the game.
- I developed the gameplay and AI entities like the Player Entity, Collectible Entity, Monster Entity and Non-Playable Character entities.
- I worked on the world and level design with Zeph. We also worked together on the artwork.
- I developed the NPC conversation system.
What I would have done differently:
- The only thing I’d like to change about this game is fighting system. My team wanted to implement a turn-based fighting system and I always wanted to make it real-time.
What I learned from this prototype and the positives and negatives of the process:
After making two prototypes, there’s not a lot you can learn from making another. So, honestly this was just another prototype for me.

Positives:

- We made a smart choice by choosing to work using the Actor-Entity model of programming, where in the Actor is a generic object and it’s behavior is modded by plugging in different Entity code.
- We set up and SVN server from merging and managing code.
- Implemented the Player Entity quickly.
- The  .TMX editor and parser in MelonJS was just awesome.
- We worked well together. Our communication was good.

Negatives:
- Our choice of engine was bad. We had to write code for the simplest things manually.
- The world’s TMX files got corrupted days before the presentation. We tried redoing as much as possible.
- And like always my team did not have an artist.