• Content count

  • Joined

  • Last visited

Community Reputation

156 Neutral

About DudeMiester

  • Rank

Personal Information

  1. Over a Decade on GameDev.net! Wow!

    I came back to this site on a whim recently. In fact, I had forgotten this blog even existed. I don't come here often anymore, because I've been quite busy as of late. Still, GDNet has a special place. It's where I first learned about matrices, for example. Without it, I may never of had the interest to pursue my undergraduate degree, and study math/physics/CS as seriously as I have. Years later, I may not be going into game development as a career, but I have a pretty nice Silicon Valley job nonetheless. But maybe one day I'll accept a job offer in the field, and do some interesting things there. Exciting times, in any case. If you asked me 10 years ago if I would ever achieve what I have, I would probably have said, "Of course!" Such is the naivety of youth. I appreciate the enormity of the task better now. Still, if not for the inspirations then, many of which can be traced back to here, I may not have persevered as I did. I'm happy to see the site is still quite active, and within its members, I hope there are many more successes taking shape.
  2. Physical Pool

    Hello everyone, This is the final project I, Darryl Barnhart, did as the final project for my recent game programming diploma at Humber College. It's a 3D fairly physically accurate pool simulation with some nice rendering. The physics and rendering are custom, written on my own using OpenGL, C++, GLEW and Sony's vector math library (found at the Bullet Physics website). This technical stuff is what I enjoy, mainly. Gameplay wise, I've only implemented eight ball, and not all the detailed rules about fouling and simultaneous contacts. The pockets are a total hack, implemented as sensor volumes (touch the gold ball and it's pocketed), because I didn't have the time to add either CSG or mesh collision to my physics engine (just spheres/boxes/rays). The vast majority of the work below has been done in only the past two months, you see. Still, it's reasonably fun. When I get a place to host the installer, I'll update this thread. In the mean time, if you want a copy email me at darryl@dbarnhart.ca. It's just under 8MB, so it should be fine for most mail services. The UI is nicely animated thanks to Clutter and MX. You can see a custom carousel menu I wrote below. Here's a few screenshots: Gameplay Placing the cueball for the break Options menu Main menu (the balls rain in when the program starts)
  3. the best ssao ive seen

    I actually see very little difference between the two in terms of the visual patterns. It may just be an effect of the bilinear filtering.
  4. the best ssao ive seen

    Perhaps it's because in OpenGL z values will have the opposite sign (ex: p.z)?
  5. the best ssao ive seen

    I just noticed there's an error in my code. Here's a new and simplified version: float sample(vec2 coords, float offsetFactor, vec3 basePosition, vec3 baseNormal) { float nonlinearDepth = texture2D(sceneDepth, coords).r; if(nonlinearDepth==1) return 0; //Not necessary, but can improve performance vec3 position = worldPosition(coords, nonlinearDepth); vec3 displacement = position - basePosition; //multiply the maximum by a value less than 1 to smooth the AO more. float radius = clamp(dot(displacement, baseNormal), 0, sampleRadius*offsetFactor); float distanceSqr = dot(displacement, displacement); float occlusion = 1-sqrt(distanceSqr/(distanceSqr + radius*radius)); return occlusion; } With this correction, the haloing underneath the spheres is much reduced. Enough for my purposes, anyways. Still, I was thinking about your halo reduction method, but because I'm using spheres I imagine it won't work so well. However, I'm thinking if you store at each pixel a curvature factor, you can reasonably approximate the closest point to the occluded pixel. You could use a geometry shader with adjacency to compute the approximate curvature at each vertex, which is then interpolated. I'm thinking 1/radius of a sphere approximating the local curvature, which can be set to 0 for planes and made negative for indents. Darryl Barnhart www.dbarnhart.ca [Edited by - DudeMiester on March 25, 2010 10:44:31 PM]
  6. the best ssao ive seen

    So I was working on my own SSAO method, and I read this thread. Then I realized I could improve mine in a number of ways. In particular, I based my sampling pattern on ArKano's and used the notion of occluding discs. However, I use occluding spheres whose radius is limited in such a way as to prevent the self-occlusion of planes. I require this, because I'm doing a pool table, and I need interacting spheres and flat surfaces to look correct. Incidentally, it also diminishes the banding when under-sampling due to extreme close-ups. I also work directly with the non-linear depth buffer. I have an efficient way of reconstructing the world space position from the non-linear depth, presuming the near plane is symmetrical. I have yet to code an edge aware blur, so please excuse the noise. The essential code follows the images. All together now: Reconstructing world space position: //Darryl Barnhart //www.dbarnhart.ca vec3 viewDelta(vec2 screenSpaceCoords) { screenSpaceCoords = 2*screenSpaceCoords-vec2(1); return vec3(screenSpaceCoords/vec2(projection[0][0], projection[1][1]), -1); } float worldDepth(float nonlinearDepth) { return projection[3][2]/(1.0-2.0*nonlinearDepth-projection[2][2]); } vec3 worldPosition(vec2 coords, float nonlinearDepth) { return viewDelta(coords)*-worldDepth(nonlinearDepth); } Note that -z is the forward direction. The SSAO: //Darryl Barnhart //www.dbarnhart.ca const float sampleRadius = 0.011; float sample(vec2 coords, float offsetFactor, vec3 basePosition, vec3 baseNormal) { float nonlinearDepth = texture2D(sceneDepth, coords).r; if(nonlinearDepth==1) return 0; vec3 position = worldPosition(coords, nonlinearDepth); vec3 displacement = position - basePosition; float distanceSqr = dot(displacement, displacement); float distance = sqrt(distanceSqr); vec3 direction = displacement/distance; float radiusFactor = dot(direction, baseNormal); if(radiusFactor<0.001) return 0; //Ignore samples behind the surface float radius = radiusFactor*sampleRadius*offsetFactor; float occlusion = 1-distance*inversesqrt(distanceSqr + radius*radius); return occlusion; } //Take for samples rotated by 90 degrees each float fourSamples(vec2 baseCoords, vec2 baseOffset, float offsetFactor, vec3 basePosition, vec3 baseNormal) { baseOffset*=offsetFactor; float result=0; result+=sample(baseCoords+vec2( baseOffset.x, baseOffset.y), offsetFactor, basePosition, baseNormal); result+=sample(baseCoords+vec2( baseOffset.y, -baseOffset.x), offsetFactor, basePosition, baseNormal); result+=sample(baseCoords+vec2(-baseOffset.x, -baseOffset.y), offsetFactor, basePosition, baseNormal); result+=sample(baseCoords+vec2(-baseOffset.y, baseOffset.x), offsetFactor, basePosition, baseNormal); return result; } void main() { vec2 coords = gl_FragCoord.xy*screenSizeInv; float nonlinearDepth = texture2D(sceneDepth, coords).r; vec3 position = worldPosition(coords, nonlinearDepth); vec3 normal = normalize(texture2D(sceneNormals, coords).xyz); vec2 randomDirection = normalize(2*texture2D(randomTexture, coords/screenSizeInv.x/64.0).xy-vec2(1)); vec2 axisOffset = randomDirection*sampleRadius/-position.z; vec2 angleOffset = vec2(axisOffset.x-axisOffset.y, axisOffset.x+axisOffset.y)*(sqrt(2.0)/2); float occlusion = 0; occlusion+=fourSamples(coords, angleOffset, 0.25, position, normal); occlusion+=fourSamples(coords, axisOffset, 0.5, position, normal); occlusion+=fourSamples(coords, angleOffset, 0.75, position, normal); occlusion+=fourSamples(coords, axisOffset, 1.0, position, normal); gl_FragColor.r = clamp(1-occlusion/(occlusion+1), 0, 1); } I still have one issue that you can see in the screenshots. When looking directly into very narrow crevices, like those between the ball and the table, the occlusion lightens at the narrowest part. I think that's what's referred to as "halo", and best I can tell, nothing can be done about it except more sampling. Anyways, I have another idea for SSAO that I want to try. A lot of the slowness comes from reading from far away parts of the depth texture, not cache friendly. Also, proper ambient occlusion should take into account the entire scene, so an alleyway off a street becomes darker. I figured you could build a mipmap pyramid of the depth and normals, compute SSAO starting somewhere near the top, then progressively refine it by using the lower resolution and more global AO levels to modulate the higher resolution levels. You only need to sample the neighbouring pixels on each pass, so the cache will like it, and both global and local occlusion are captured. I doubt it would require any blur afterwards either. Still, I'm not sure how fast it would be in the end. Any thoughts? Darryl Barnhart www.dbarnhart.ca
  7. Improved the Photon Mapping

    So I've managed to smooth the lighting out by using many fewer photons (3000 from 100,000), while giving each photon a much larger area of influence (~10x larger). To do this, I added a geometry shader that generates scaled screen aligned sprites, because the built in point sprites have a maximum size. I fixed the lack of illumination of corners by having each photon act as two lights, incoming and outgoing, within its area of influence. I've also changed the falloff of each photon to approximate a Gaussian distribution using [(1-x^2)/(1+x^2)]^2 (see a graph from WolframAlpha). Notice that it becomes zero after a finite distance along the x-axis, which prevents discontinuities at the edge of a photon's range of influence. This is what it looks like now:
  8. OpenCL

    So I've been playing around with OpenCL the last couple of weeks. I wrote a 500,000 element particle system with HDR bloom and a photon mapper, pictured here: As you can see, I'm in dire need of a better way to do final gather, haha. This was just a hack job over a weekend, of course. Right now I'm just rendering each photon contact as a point light, which is just under 100,000 in total. As a result, it's only ~10fps. Lots of room for improvement. The OpenCL code for doing the bounces Of course, this being a new technology there are a lot of caveats. First, OpenGL interop is tricky to get working. Don't forget to pass the OpenGL context and OS device handle to OpenCL! When sharing multiple buffer objects, I found OpenCL refused to function correctly, saying it was out of resources. Instead, I just lumped all the data to be shared into one giant VBO/cl_mem object, and it was mostly OK. Still, with large buffers (e.g. 500,000 particles) the OpenCL kernel seems to eventually give up and stop running after a while. I have no idea why. Finally, uploading images directly seems to be a problem, but if you create the image and then copy the data separately, it seems to be fine. This in on Nvidia, mind you. I hear ATI is much better.
  9. Going Ons in Education

    Yeah, for my graphics I'm going to write a real time photon mapper, probably using OpenCL. For my overall capstone project, I'm working on a NPC dialogue system where the NPCs have emotion and memory. No fixed dialogue trees or graphs, but actual thought processes to select responses from a specified list. It's basically how Mass Effect gives the player a set of choices based on emotional tone, except giving those same sort of options to the NPC as well.
  10. Going Ons in Education

    Recently I was at a presentation where one of the senior technical artists of Crytek spoke. I had a chance to talk with him one on one afterwards about the kind of programmer a place like Crytek was looking for. For R&D, first on the list was a Masters degree in a technical field, which is not surprising, though this can be overlooked in the exceptional case of a mind-blowing portfolio. For less core engine development, a Bachelors is the standard, but a community college graduate with an excellent portfolio would still be seriously considered. I had similar responses when I spoke with owners of local independent Toronto studios at my local IGDA chapter. On this basis, I'm very seriously considering continuing my education after I finish my 3 year diploma at Humber College. In the interest of well roundedness, and to pursue my non-game interests, I'm thinking of doing something business related for my undergraduate degree, probably commerce, and a Masters of computer science after. I do realize it's not always easy to get into graduate school, and taking an undergraduate degree not directly related doesn't help. However, I can get letters of recommendation from a variety of professors I know, who have PhDs in fields such as physics, computer science and theoretical chemistry. I'm hoping that will offset the less technical nature of, say, a commerce degree. Although, one of my current professors who specializes in quantum physics suggested that it is possible to go straight into a Masters degree without a Bachelors in certain exceptional circumstances. I'm flattered my prof thinks I'm skilled enough to even consider it, but I'm not sure it would be right for me even if I could. There's two problems here. First, I want to get some non-computer education and I really love business, securities and trade. Commerce seems ideal for this very strong secondary interest of mine. I'm not so passionate about it that I want to do an all-out MBA (though who knows what the future holds), so I think a Bachelors would be the best way for me to experience the field. At the same time, I'm 23 now and while I should qualify for 2 years of credits between my diploma and previous university experience, I would be 25 by the time I graduated. Assuming 2 years for a Masters, that's 27 before I'm in the workforce full-time. Granted, at that point I would make a significant amount of money, but I'm also as impatient as I am stubbornly persistent. I want to get into the meat of the business and start contributing something valuable. I know I already can, though more education will help of course. I'm not totally decided on this issue. I'm going to an open house at one of the universities I'm interested in this weekend. Maybe they will persuade me. In the mean time, I've become the student federation rep of the game programmers at Humber. I'm working to improve the course, it's rigour, co-ordinate with clubs and art students, and plan some sort of demoscene style event. I have my final year courses and projects on top of that (though I'm happy to say my mid-term average is a solid 93%). I'm also keeping up on my self-interest studies into math, reading my books, my ACM subscriptions and newsletters, going to the IGDA meetings, and working on a programming contest. I also have the SIGGRAPH 2009 DVD set in the mail. I'm glad I got my smartphone, otherwise I'd never be organized enough to do it all. Quite busy.
  11. Technical Books

    The interesting thing I find about C++ is that when you really leverage it's capabilities in OOP, metaprogramming and embedded DSLs, the code ends up looking more procedural. For example, once you create some decently sophisticated linear algebra classes with overloaded operators and expression templates, the code reads like they were primitive types, while having the same or better performance (see Blitz++). What I like the most about the C/C++ philosophies is the idea that you don't pay for what you don't use, and that most the "language" is the library. That's what makes these kind of high performance abstractions possible. Like you say, it also means that you can make some really ugly C++ code if you have a strange compulsion to always use every language facility and trick. Library writing is its own art.
  12. Technical Books

    Thanks :D Yeah, this is the first time I've really decided to take a serious approach to blogging, so I'm just happy that it doesn't suck, haha! I just glanced at the TOC for Expert C, and I like what I see. (Another annoyance: Amazon.ca often doesn't have "look inside the book" when Amazon.com does, so I have to check every book on both sites.) Although, I didn't start programming when I was 8, but 12 (nearly 23 now). Although, I started with C++, templates and all, so I suppose that counts for bonus points, lol. However, I'm extremely tired right now, so I'll have to give it a more thorough consideration later. You are right that I'm a self-learner. I became that way in elementary and high school, because the education system just couldn't keep pace with me. I got into a prestigious engineering school (University of Waterloo), but unfortunately after so many years of getting A+ effortlessly, I seriously lacked the self-discipline for such a program. So I ended up leaving, and now I'm studying game programming at Humber College in Toronto. It's been a winding road, and has come with a lot of debt. Now I can't afford to go back to university, so I have no choice but to self-study to achieve the education I desire. For the same reason, I really can't afford to buy a book for only 2 brilliant chapters right now. I'm hoping though, once I get a job after graduating, I can do a math degree by distance or part time somewhere. That would be awesome! I really want to get a masters degree in something someday, but I know it won't be anytime soon. PS: I know what you mean about books that make you think. I subscribe to the Communications of the ACM, and that is great for doing this. Although, often an article or book will make me start thinking, and suddenly I'll think of an idea that has nothing to do with it, haha! It's just the state of mind I suppose. I have a thought, since I come up with many more ideas than I can implement, to start posting them here. Maybe someone will turn one into a new technique or successful organization. Either way, I think it could make for interesting discussion.
  13. Technical Books

    Some say they are without merit in this digital age, but I find that for highly technical topics they are still useful. True, you can read many papers and presentations online and acquire the same information, but that takes more time. A good book offers the same information in a condensed form. Yes, some there are survey papers out there that serve a similar purpose, but they are not as expansive as a good textbook, and you can't always find one that suits your interest. Not to mention the fact that books work without power, computers and even come with their own screen! :P Of course, products like Kindle are bridging this gap, but not everyone has access to that (i.e. Canadians like myself) and many speciality books are not available on it. Therefore, I believe books are still a worthy investment. With that in mind, I'm trying to build a list of books I would like to have in my personal collection. I'm looking for texts that are comprehensive in their topic, but not so broad that they can only half-explain things. Certainly, they can be superficial if there are prerequisite concepts to a given topic and there isn't enough pages to explain them, but they should be intentionally so. They should defer these ideas to other materials that treat them directly and with the depth required, and give recommended reading. If a book starts going past 1000 pages, the author is likely isn't doing this and is probably getting carried away. Such a treatise may never really be finished in the author's lifetime (call it Donald's Dilemma). It's a noble goal, but ultimately yields something less like a book and more like a blunt weapon. I prefer a book that treats a manageable set of topics, and does it well. I also want the book to be to the point, only including examples when they are the best way demonstrate an important concept or note a non-obvious application. This doesn't mean the book is dense and unapproachable, only that it recognizes your ability to reason with and creatively apply the ideas it discusses. The point of a book is to learn from it. A barrage of examples only encourages rote memorization and wastes paper. I neither want a book that assumes you know everything already by using opaque and ultra-dense terminology. I can read scholarly journals for that sort of masochistic indulgence. :P What I really want is a book that keeps me thinking by building up new ideas at a brisk pace. I believe a good technical book should also be reference worthy. I don't care for a collection of best practises, common sense and opinion, because that can be found freely online in massive quantities. More easily, it can simply be deduced. Even if your thoughts are backed by hard data, just say what it means instead of waxing lyrical about it... Well, unless you're writing "Coding Practises in Iambic Pentameter", haha! Of course, I make exceptions if the book is a particularly compelling, definitive or authoritative collection of subjective discussions. The most important thing, I don't want a book that shies away from abstracts. I need to know the fundamental principals and abstract concepts that are behind any given technique or idea. That's how I remember and learn things. My mind is like a vast network of concepts that I sample and compose into concrete ideas and methods. I don't expect the book to explain them all, just say what they are please. It annoys me to no end how many engineering textbooks simply state "do it this way", show a few examples to prove it works, and move on. Another one I often see is, "The reasons it is done this way are obvious." Is it so hard to simply note the ideas they are building upon? Here's a concrete example of what I mean: I was reading about linear recurrence relations with constant coefficients in an engineering math book I have. One of the steps in solving them involves finding the roots of the characteristic polynomial. It shows you how to do it for 2nd order recurrences, but it doesn't state why you are using those roots or any other significance they have. After some thought, I realized that it was because using these roots you can split the constants in the recurrence up, such that you can rearrange and remove a variable from the relation. Doing this repeatedly to remove all but one variable will solve it. I reasoned that this process could probably be condensed using linear algebra constructs. A look at Wikipedia confirmed this, and revealed to me the relationships between recurrence relations, eigenvalues/vectors and linear differential equations. This is a powerful association that improves both my understanding and recall of these ideas. However, I must note that relying on Wikipedia is unacceptable for advanced topics, because it's often impenetrable, disorganized, incomplete and confusing. Eventually I can parse it, but it takes an excessive amount of time. This is why I want to get some good books, to save time. My engineering math textbook could have done this if it just said something like, "Such-and-such property of polynomial roots enables rearranging the recurrence to remove a variable. See this-and-that for details." That is what I want the book I read to do. I want it to help me see the "big picture". Far too often in technical education is the rote memorization of basic rules and mechanics stressed. I believe that one needs to bind these mechanics together with the abstract concepts and transforms that connect them. This shouldn't be done "in the future when you know everything", it has to be reinforced each day. If one starts with a few basic mechanics and attaches them to a larger conceptual framework, retention and interest will be far greater. I find the current state of technical education is like showing someone all the parts of a car one at a time, but neither the car itself nor each part's place in it. It's absurd. In any case, my present interests lie primarily in computer graphics and physics, math, software engineering and management, and general computer science. I'm looking for the most definitive and/or informative texts in these areas. I have a high standard because I don't have much money to spend. The books I've bought so far are:Real Time Rendering by Akenine-MollerReal Time Collision Detection by Christer EricsonAll the Mathematics You Missed: But Need to Know for Graduate School by Thomas GarrityI chose these because they seem to be held in high regard, and they cover a very interesting but focused range of topics. I must also say that the Morgan Kauffman Series in Computer Graphics seems to be very interesting as a whole. As for the list of books I still want, I'm developing it on my Amazon Wishlist. Be aware that I added a bunch of books recently, so it needs some trimming right now. I may move the list to some other medium at some point, so I can include freely available books and important papers also. One problem I have making this list is that there is no technical library or book store near where I live (Brampton, Ontario). I have to go about an hour to Toronto by transit to the University of Toronto's engineering library, and I can't take out any books because I'm not a student. I'm also too busy with work and such that I can only practically go out there on weekends. It's not easy for me to view and evaluate them before buying. For the most part, I end up relying on the opinions of others, reviews, and the pages I can see on Amazon or Google Books. Also, I mainly use Amazon's recommendations to explore what's out there. Compounding this is the fact that I don't have enough associates or friends with the same technical interests. I am not in university or graduate school, nor am I ever likely to be. Neither do I have any degrees, though I've done 2 years of a 3 year college diploma. However, I don't think that's an excuse not to self-educate myself at a high level, and I seem to manage just fine. MIT's open courseware is also helpful with this. Plus, regardless of your background, continuous learning is a must! My question for the readers of this blog is simple: Are there any? :P Seriously though, what books for computer graphics/physics, math and software engineering do you recommend and why? What do you think of my thoughts here? Are there any books, articles or papers you know of that fit what I'm looking for?
  14. Becoming a Visible Minority

    Well, it is the main Mormon temple for the the entire GTA, so within those millions of people I'm sure there are a great many of their followers. However, my understanding was that the reason it was built in Brampton and not Toronto proper was because they thought, "If we build it, they will come [to Brampton]." Some came, but nothing near what they imagined, as Brampton is less than 2% Mormon from the demographics I've seen. You're talking only maybe a couple thousand amongst almost half a million people.
  15. [SOLVED] "Shuffle" problem

    Using an iterative method to resolve contacts can help here. Basically, you run through the contact solver 10 times or so to reduce these errors. You can also try an LCP solver, check out David Baraff's papers on this: http://www.cs.cmu.edu/~baraff/pbm/pbm.html and "Fast contact force computation for nonpenetrating rigid bodies" which can be found here: http://www.cs.cmu.edu/~baraff/papers/index.html It's written for 3D in mind, but I'm certain you can simplify it for 2D. Also look at Box2D, which uses the iterative approach. It's open source, so you can see how they did it. http://box2d.org/