This was a pretty fun assignment that didn't end up being too tricky to do, but there was a bit of debugging to figure out some issues. All of the coding itself was pretty simple, I pretty much just duplicated my DepthPass and did the same thing for my ShadowPass except from the lights view instead of the camera's. And.... that was pretty much it. Changing the light from a point light to a directional light was surprisingly easy and the movement ended up working identically as before except that instead of updating a position, I just update the direction (and the position is calculated from the direction). The most challenging was setting up the WorldToLightTransform since I just copied what my WorldToViewTransform was doing. Once I double checked with your instructions, however, D3DXMatrixLookAtLH() worked perfectly.
The fragment shader code was a little trickier to figure out since I had to make sure to sample from the right texel of the shadow map to compare against the texel of the mesh's texture (since they're in different spaces.) Talking with Derick, Sherly, and Chris really helped with this.
The end result of this assignment is quite possibly the coolest yet. Seeing shadows working is really awesome.
Here's what the scene looks like:
And here's the shadow map as seen in PIX:
Link to code: http://www.eng.utah.edu/~jthummel/graphics/ThummelGraphicsAssignment12.zip
Showing posts with label graphics. Show all posts
Showing posts with label graphics. Show all posts
Thursday, April 25, 2013
Thursday, April 11, 2013
Graphics Write-Up #10 and #11
#10
This was a very interesting and moderately challenging assignment. Getting the depth pass up and working wasn't too bad, but figuring out all the issues that cropped up from doing so took more time. I had a really interesting issue where slices of my spheres weren't showing up (making it look kinda like a watermelon). Additionally, when the meshes moved half of the sphere would vanish like this (Ignore the black sphere in the middle, it's supposed to be like that):
Left:
Up:
This was a very interesting and moderately challenging assignment. Getting the depth pass up and working wasn't too bad, but figuring out all the issues that cropped up from doing so took more time. I had a really interesting issue where slices of my spheres weren't showing up (making it look kinda like a watermelon). Additionally, when the meshes moved half of the sphere would vanish like this (Ignore the black sphere in the middle, it's supposed to be like that):
Left:
Right:
Up:
Moving the meshes down did the same thing, but also completely removed the floor. IN the end, this turned out to be caused because of the order I was making calls. I was doing the Depth pass, then updating the meshes, and then doing the normal draw pass. The striped watermelon effect was caused by the natural rotation of the spheres, and the half spheres being removed was from moving them. Since the depth was being captured and then changed, pixels were failing the depth test and being removed. The easy fix was to of course do the mesh update first, before anything else.
An additional change I made to make the code a bit nicer was turning the creation of Fragment and Vertex shaders into a method. This allowed me to set up the correct shaders to use for the depth pass, and was later useful on the next assignment when I had to use more new shaders.
Here's what my Depth pass and the depth buffer of Pix look like side by side:
My depth pass:
PIX's Depth Buffer:
Here's the scene itself with the soft blending edges:
#11
This was a very easy assignment since it was so similar to the previous two. New textures and a surface, setting them at the right place, all it really was was adding transparency to the opaque bucket. Drawing the quads was a simple matter of going back to the first assignment and pulling the code into the current project. This was a sort enough assignment I actually ended up writing all the code without testing it and then was pleasantly surprised when everything worked just as I hoped it would.
Despite its ease, it was still a really cool assignment learning how to set up a UI.
Here's the latest version of what my scene looks like:
Code can be found here:
Thursday, March 21, 2013
Graphics Write-Up #9
This was a pretty interesting assignment on both sections. The environment map was much easier of the two, especially since pretty much everything to get it working was done inside of the fragment shader. In the first picture below you can see it clearly reflected in both the spheres on the sides as well as the floor. I also went and changed my specular lighting to use the correct view position, using the camera's actual position instead of taking it out of the 4x4 matrix. It was really cool to see this working in the scene. I imagine that in the case of an outdoor scene, the environment map would be mirroring the sky-box.
Getting the render target working was more challenging. It's also one of the cooler things we've done so far visually. I ran into a few issues that were mostly related to my previous code structure as opposed to the current assignment, but once I'd fixed those, everything worked pretty smoothly. Most of the troubles with this section was just making sure to put all the calls and change the render target in the correct locations. Oh, one issue I had was trying to get both of the above to work with normal mapping in addition. It might be working now that I've fixed a few other issues I ran into, but initially it wasn't working for some reason. I'm going to look into that more once I have time since it shouldn't be messing up.
Here's what it looks like:
Here's PIX:
Link to code: http://www.eng.utah.edu/~jthummel/graphics/ThummelGraphicsAssignment9.zip
Getting the render target working was more challenging. It's also one of the cooler things we've done so far visually. I ran into a few issues that were mostly related to my previous code structure as opposed to the current assignment, but once I'd fixed those, everything worked pretty smoothly. Most of the troubles with this section was just making sure to put all the calls and change the render target in the correct locations. Oh, one issue I had was trying to get both of the above to work with normal mapping in addition. It might be working now that I've fixed a few other issues I ran into, but initially it wasn't working for some reason. I'm going to look into that more once I have time since it shouldn't be messing up.
Here's what it looks like:
Here's PIX:
Link to code: http://www.eng.utah.edu/~jthummel/graphics/ThummelGraphicsAssignment9.zip
Wednesday, March 6, 2013
Graphics Write-Up #8
This weeks assignment was one of the easiest we've had in a while, which was nice. Changing the Maya exporter was just a matter of seeing how the normals were done and then doing the same thing for the tangents and bitangents. Of course, changing that meant the MeshBuilder had to change, but that was a simple fix to how the data was read in, after that all the binary code didn't need any modifications since it's all just more vertex data.
Writing the new shaders also wasn't bad since it was just reading in the new values and modifying the normal based off of them. The most time intensive part of this assignment was simply making all the new files and loading them into the Lua file so that they're copied.
This was easily the most visually impressive task we've done yet, the normal mapping looks really awesome.
Here's what it looks like with normal mapping! The left cube is with specular lighting, although you can't really tell with this screenshot.
Link to code: http://www.eng.utah.edu/~jthummel/graphics/ThummelGraphicsAssignment8.zip
Writing the new shaders also wasn't bad since it was just reading in the new values and modifying the normal based off of them. The most time intensive part of this assignment was simply making all the new files and loading them into the Lua file so that they're copied.
This was easily the most visually impressive task we've done yet, the normal mapping looks really awesome.
Here's what it looks like with normal mapping! The left cube is with specular lighting, although you can't really tell with this screenshot.
Link to code: http://www.eng.utah.edu/~jthummel/graphics/ThummelGraphicsAssignment8.zip
Thursday, February 28, 2013
Graphics Write-Up #7
Getting the transparency working was awesome, the binary alpha in particular is really sweet. It was also cool to see how big of a difference sorting the transparent objects back to front made. You'd inherently think it shouldn't matter at all (since you can see through them!), but when I was drawing them front to back since that's the way I ordered them in my scene file, you could only see the one in front. It really drove home the lesson.
Now that I'm looking at the 2nd screenshot below I should probably put the Render state code inside it's own PIX event just so it looks a little nicer, but I'll do that for next week since I don't want to go re-upload the code.
I also made sure to go back and fix all the little errors I'd made after getting feedback on Assignment 5. 6 will still have the same issues since it was submitted before then unfortunately. Summing them up: I normalized the incoming normals to my fragment shaders so specular lighting is working at last. I also took out my hard coded debugging specular exponent value and now pull it directly from the material as opposed to the scene file. And.... I think that's everything that was wrong....
PIX events with only one Opaque and Transparent:
PIX events showing Opaque and Transparent expanded:
What it looks like now:
Link to Code: http://eng.utah.edu/~jthummel/graphics/ThummelGraphicsAssignment7.zip
Friday, February 22, 2013
Graphics Write-Up #6
Once again, this graphics assignment wasn't particularly challenging, but it did take a bit longer than I'd expected. As of class yesterday I'd pretty much finished and had Maya models loading into my renderer. However, for some reason only certain meshes were working, my original cubes worked fine and the new cone and soccer ball worked fine, but my torus didn't load at all. This proved to be the most difficult part of the assignment as I'd never worked with binary files before.
I knew that I was writing the file out correctly, or at least I was pretty confidant I was since at first I didn't know how to convert a binary file into hex to verify it. Once I got that working it became clear that I was indeed writing the file out correctly. That left reading the file back in as the only issue. This seemed rather confusing, though, as it was clearly working with some of the meshes already. I tried using a cylinder instead of a torus, but it failed to work as well. After talking to Cody during the break in class he helped me spot the error I'd made in my file reader.
The other section of the assignment, sorting all the PIX calls, was very easy, although it's been quite a while since the last time I wrote a sorting algorithm. I didn't know at the time how to nest the calls, and now that I think about it I should have done that for this submission, but since we're going to be modifying it slightly during the next assignment I'll just make sure to do it then.
Oh. I also think there's something wrong with my specular lightning, but I haven't gotten feedback on the last assignment so I'm not sure. All attempts I've made at "fixing" it have done nothing at all though.
Here's the sorted PIX events broken down so that Effect is at the top of the tree, followed by Material and then finally the Entity.
I knew that I was writing the file out correctly, or at least I was pretty confidant I was since at first I didn't know how to convert a binary file into hex to verify it. Once I got that working it became clear that I was indeed writing the file out correctly. That left reading the file back in as the only issue. This seemed rather confusing, though, as it was clearly working with some of the meshes already. I tried using a cylinder instead of a torus, but it failed to work as well. After talking to Cody during the break in class he helped me spot the error I'd made in my file reader.
The other section of the assignment, sorting all the PIX calls, was very easy, although it's been quite a while since the last time I wrote a sorting algorithm. I didn't know at the time how to nest the calls, and now that I think about it I should have done that for this submission, but since we're going to be modifying it slightly during the next assignment I'll just make sure to do it then.
Oh. I also think there's something wrong with my specular lightning, but I haven't gotten feedback on the last assignment so I'm not sure. All attempts I've made at "fixing" it have done nothing at all though.
Here's the sorted PIX events broken down so that Effect is at the top of the tree, followed by Material and then finally the Entity.
Friday, February 15, 2013
Graphics Write-Up #5
This assignment ended up taking longer than I expected it would, but overall it wasn't terribly complex. Most of the work this time around was just making all the new files, but it was really awesome to see the scene load perfectly after setting all of that up.
Getting the ambient lighting in was simple, but the specular lighting proved to be more challenging. I got the correct equation in, but the light still wasn't showing up for some reason. After going into PIX it was revealed that this line in the fragment shader:
float3 specularLight = pow( saturate( dot(R, V) ), specularExponent );
was resulting in 0, which would obviously mean that there's not going to be any specular light. I talked with Sherly about this issue and she said that the same thing was happening with her 8 vertex cube, but that her 24 vertex cube worked fine. So I made a new mesh for a 24 vertex cube so that each face could have its own normal and poof, it worked just fine. I wasn't able to figure out why it doesn't work with the 8 vertex cube, but since it is working on the 24 vertex, at least I know my specular lighting calculations work.
Even though we didn't need a screen shot for this weeks submission, it feels weird to post a blog about a graphics assignment without a picture. So here's my cubes with specular lighting in. Unfortunately it's really hard to get a good shot with the rotating cubes. The front and right side cubes are all using specular lighting, although only the 2nd and 4th are using the 24 vertex mesh.
Link to code: http://www.eng.utah.edu/~jthummel/graphics/ThummelGraphicsAssignment5.zip
Getting the ambient lighting in was simple, but the specular lighting proved to be more challenging. I got the correct equation in, but the light still wasn't showing up for some reason. After going into PIX it was revealed that this line in the fragment shader:
float3 specularLight = pow( saturate( dot(R, V) ), specularExponent );
was resulting in 0, which would obviously mean that there's not going to be any specular light. I talked with Sherly about this issue and she said that the same thing was happening with her 8 vertex cube, but that her 24 vertex cube worked fine. So I made a new mesh for a 24 vertex cube so that each face could have its own normal and poof, it worked just fine. I wasn't able to figure out why it doesn't work with the 8 vertex cube, but since it is working on the 24 vertex, at least I know my specular lighting calculations work.
Even though we didn't need a screen shot for this weeks submission, it feels weird to post a blog about a graphics assignment without a picture. So here's my cubes with specular lighting in. Unfortunately it's really hard to get a good shot with the rotating cubes. The front and right side cubes are all using specular lighting, although only the 2nd and 4th are using the 24 vertex mesh.
Link to code: http://www.eng.utah.edu/~jthummel/graphics/ThummelGraphicsAssignment5.zip
Sunday, February 10, 2013
Graphics Write-Up #4
This assignment was brutal. In the end I logged a total of 15 hours on it. 10 of those hours were trivial file parsing code, which was incredibly dull and boring. The other 5 hours were at least more interesting.
Setting up the light color and intensity was very easy. I implemented this first before doing anything else so I could see if it was working. I also did the depth buffer at this point, although I obviously was unable to test it with a single cube. Once I had the file parsing working, I then had to figure out how to change the code so that multiple objects could be drawn instead of just one.
This was probably the most interesting part of the assignment since I had to really go through all of the code and understand exactly what it was doing. The code changes really weren't that bad though. Instead of using a single m_scene object I just made an array of them and looped as necessary. Initially all I did was wrap the Update, Load, and Release in for loops based on the number of entities in the scene, but this just resulted in a black screen.
After a bunch of struggling and use of PIX, Sherly helped a bunch by telling me that parts of Update could only be called once, which obviously makes sense. So I took out the clearing, BeginScene, and EndScene and I finally had three cubes working.
The end result is awesome. Now all we have to do to add more objects to the scene is change/add files and the program *should* do the rest of it.
Thursday, January 31, 2013
Graphics Write-Up #3
This week was considerably easier than the past weeks. There were a few stumbling points however. This was the largest one:
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
{ 0, 24, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
{ 0, 32, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
In the end, COLOR had to be moved to the end since I wasn't sure how large it was and thus how much to offset the next data by. (In retrospect, calling sizeof on the type would have worked too). The light itself was working after implementing it like the camera, although it felt like it wasn't actually moving. Changing the increments from 1 to 10 helped improve that though, which makes sense since the light needs to change a lot for it to have a noticeable impact.
The only other stumbling block was setting up the UVs. I initially did it with 0,0 at the bottom left and it looked horrible and you couldn't tell what the texture was supposed to be. I messed around with the UVs for a while trying to figure out what was going on, but then Shrly explained that in DirectX the origin is actually the upper left.
Another slightly odd issue was attempting to call a variable in the FragmentShader texture. For some reason that just doesn't work.
I love that the light isn't actually lighting things up, but instead darkening things. It's like an anti-light!
Camera is still on WASD and the Cube is on the arrow keys.
Light Controls:
I - Up
J - Left
K - Down
L - Right
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
{ 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
{ 0, 24, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
{ 0, 32, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
In the end, COLOR had to be moved to the end since I wasn't sure how large it was and thus how much to offset the next data by. (In retrospect, calling sizeof on the type would have worked too). The light itself was working after implementing it like the camera, although it felt like it wasn't actually moving. Changing the increments from 1 to 10 helped improve that though, which makes sense since the light needs to change a lot for it to have a noticeable impact.
The only other stumbling block was setting up the UVs. I initially did it with 0,0 at the bottom left and it looked horrible and you couldn't tell what the texture was supposed to be. I messed around with the UVs for a while trying to figure out what was going on, but then Shrly explained that in DirectX the origin is actually the upper left.
Another slightly odd issue was attempting to call a variable in the FragmentShader texture. For some reason that just doesn't work.
I love that the light isn't actually lighting things up, but instead darkening things. It's like an anti-light!
Camera is still on WASD and the Cube is on the arrow keys.
Light Controls:
I - Up
J - Left
K - Down
L - Right
P.S. In case it isn't obvious from our almost identical write-ups, Jason and I worked together on this assignment (as with previous ones).
Thursday, January 24, 2013
Graphics Write-up #2
Wow! That was certainly a crazy assignment. Part of the issue was that Joe had given us an absolutely massive assignment that was due Tuesday so I didn't actually start working on this one until Wednesday. Coding wise, we hadn't covered how to write the viewToProjected transform so that was the most challenging aspect I think. In general, I understood all the concepts since we covered them very well in class, but putting down those concepts into working code was more challenging than I anticipated. If we hadn't had the video of the class to go over your code multiple times I doubt I would have finished this assignment in time.
Another more challenging section of the code was getting the vertexBuffer and the indexBuffer to communicate, but Jason K and I thought we'd figured it out and then you confirmed it in an e-mail so that was great. Additionally getting the camera created was very easy, but actually getting it to work as a camera wasn't as obvious. Once I figured out it was just how you set up the transform everything made a lot more sense.
Oh, I also got the triangle count and vertex count into the file so that now no values are hard coded into the code, which I'm really happy about. A big future change to make will be to get everything out of the same file and into separate files. I wanted to do that this assignment, but there just wasn't enough time.
Camera Controls:
W: Up
A: Left
S: Down
D: Right
Cube Controls:
Arrow Keys
Link to code: http://eng.utah.edu/~jthummel/graphics/ThummelGraphicsAssignment2.zip
Thursday, January 17, 2013
Graphics Write Up 1
File Format:
For my file format I went with something I'd used in the past when working on my 3D reconstruction program and also just because it makes a lot of sense. It's simply an x, y pair per line grouped into lines of three for a triangle with a blank line to separate the triangles visually. One change I would like to make to the format is including the number of triangles to draw in the first line since right now I just hard-coded that value, which is really bad practice.
Shader Modifications:
Since some of the default shader manipulation used sin and cos to do interesting things I went on to try and see what tan would do and was not disappointed. So now both my coloring and position are using tangent calculations, which I feel looks really cool especially since the movement clearly distinguishes the two triangles.
Additional Stuff:
Figuring out the correct order to draw the triangles in was certainly very interesting. I'd initially gone counter-clockwise, which didn't work, and then changing to clockwise ended up working perfectly. However, one of the guys I was working with had both of his triangles clockwise as well and they weren't working, which didn't seem to make sense. In the end we decided it was because I was beginning both of my triangles in the same location, the upper left and corner of the rectangle. We're not entirely sure if that was it in the end, but it does work.
Another thing that was confusing, but easy to fix, was only drawing a single triangle. After going through the code again I found the logic where it decided how many triangles to draw and changed it to 2. As I said above, this clearly isn't the best solution to this and I'd prefer to be reading in the first line of the file to figure out how many triangles need to be drawn.
The last thing that took a bit of work was setting up the MeshBuilder tool. It probably would have been easiest to completely copy the TextureBuilder tool and then just rename everything, but instead I created a new project and then copied each file over individually. As a result my project properties weren't correctly set up and so I went through all of those and tried to set them up. In the end I missed one, which messed up some of the Windows specific code, but a quick Google search fixed that. I'm also glad I went through this way since it really helped to learn how all the dependencies worked and where everything was being loaded in from.
Pix Screenshots:
Code to this first assignment can be found here: http://www.eng.utah.edu/~jthummel/graphics/
For my file format I went with something I'd used in the past when working on my 3D reconstruction program and also just because it makes a lot of sense. It's simply an x, y pair per line grouped into lines of three for a triangle with a blank line to separate the triangles visually. One change I would like to make to the format is including the number of triangles to draw in the first line since right now I just hard-coded that value, which is really bad practice.
Shader Modifications:
Since some of the default shader manipulation used sin and cos to do interesting things I went on to try and see what tan would do and was not disappointed. So now both my coloring and position are using tangent calculations, which I feel looks really cool especially since the movement clearly distinguishes the two triangles.
Additional Stuff:
Figuring out the correct order to draw the triangles in was certainly very interesting. I'd initially gone counter-clockwise, which didn't work, and then changing to clockwise ended up working perfectly. However, one of the guys I was working with had both of his triangles clockwise as well and they weren't working, which didn't seem to make sense. In the end we decided it was because I was beginning both of my triangles in the same location, the upper left and corner of the rectangle. We're not entirely sure if that was it in the end, but it does work.
Another thing that was confusing, but easy to fix, was only drawing a single triangle. After going through the code again I found the logic where it decided how many triangles to draw and changed it to 2. As I said above, this clearly isn't the best solution to this and I'd prefer to be reading in the first line of the file to figure out how many triangles need to be drawn.
The last thing that took a bit of work was setting up the MeshBuilder tool. It probably would have been easiest to completely copy the TextureBuilder tool and then just rename everything, but instead I created a new project and then copied each file over individually. As a result my project properties weren't correctly set up and so I went through all of those and tried to set them up. In the end I missed one, which messed up some of the Windows specific code, but a quick Google search fixed that. I'm also glad I went through this way since it really helped to learn how all the dependencies worked and where everything was being loaded in from.
Pix Screenshots:
Subscribe to:
Posts (Atom)




















