Posts Tagged xna
Reconstructing Position from Depth for Fullscreen Quads
Posted by Michael in Programming, Tips, directx, xna on June 29, 2010
Recently I found an issue with an older article of mine that covered this topic, so I pulled it down until I could find the time to understand and fix the issue. After a bit of work I have fixed it and present this refresh.
The key to deferred rendering and other techniques is the ability to use a depth map to store world position. As we know a depth map consists of floating point values (optimally) and so normally we would use those values with our Clip Space coordinates and the Inverse of the ViewProjection matrix to get the position in World Space.
However there is another way to do this, and the big benefit is that it does not require a matrix multiplication to do so.
Presented by Crytek during a presentation on Atmospheric Scattering, this method uses just a Multiply + Add to get the position in World Space from our depth value at that point. To do this we need to get the far view frustum corners, in View Space, and pass them to the shader.
Status June 2010
Posted by Michael in Programming, directx, xna on June 17, 2010
Hi all, not dead.
Apologies for the lack of updates, I am in the process of finishing an internship required for my university course, and it is a challenge to find good time to tackle some XNA issues and write posts.
I am currently working on Directional light shadows for my engine, I have cascaded shadow maps implemented, and now I am just tackling some issues I have encountered, which is taking a while – I also need to find a good filtering method.
If I get bored of trying to fix those annoying issues, I will probably jump into re-implementing point lights, and spotlights, and write something about those.
Some housekeeping notes:
I encountered a pretty big issue with the “Reconstructing position from depth” technique, and I have taken that article down from the blog for now. At the moment my own code uses the old “Multiply my the Inverse of the View Projection matrix”, and probably will continue to until I have time to solve that problem.
I have also updated this blog to WordPress 3.0, so let me know if you encounter any issues.
Back to work.
[LPP] Ambient Lights
Posted by Michael in Programming, directx, xna on April 2, 2010
Ambient lights are used in modern games to fake the indirect illumination that exists in the real world. By adding a generally very weak light to the scene, we can avoid the 100% black shadows that really should not exist, all at a very low cost compared to proper indirect illumination or baked ambient light maps.
I have found that the simplest way to integrate these ambient lights into the Light Pre Pass system, and allow for other elements to change the lights throughout the game is to create a new light type that fits into the normal lighting model.
This is probably the simplest type out there, you just create a full screen quad and render it using a shader that writes the colour information directly to the light buffer. All we have to pass to the shader is the colour and intensity. (you could always pre-compute this, but beware of the byte->int32 auto promotion C# does)
XNA 4.0 – Reach/HiDef & My Article(s)
Posted by Michael in Programming, Xbox 360, xna on March 12, 2010
Shawn Hargreaves just posted this: http://blogs.msdn.com/shawnhar/archive/2010/03/12/reach-vs-hidef.aspx
I suggest you have a read through it if you are interested in the kinds of things I post on this blog, especially the Light Pre Pass technique.
One of the key parts of Shawn’s article are the changes that will be made to Render Targets, and the bucketing of the RenderTarget/Texture formats into the Reach and HiDef profiles.
It would be safe to say that future articles here will require the HiDef feature set. I make use of some of the Render Targets that do not exist in Reach, and while there may be a way to use a Reach Render Target, for the purposes of conveying the technique, I will not be adding extra code to support it. I may however note where alternatives can be used, and hint or mention how to use them.
I know I have previously used BGRA formats in my sample, and in future this will become RGBA, no big deal. I won’t change the 3.1 sample for now, but if I need to change other things to upgrade it to 4.0, then that will be “fixed”.
This shouldn’t be much of a problem, if you are going to be using the articles I plan to write, then you’ll have a computer that works with HiDef, or an XBOX.
As a side note, I no longer have a valid Creators Club subscription, so I have not tested the recent Light Pre-Pass article on the XBOX. If anyone has any issues let me know and I will try and look into it. I plan to get a premium subscription soon and test future articles on the XBOX.
Light Pre-Pass Round 2
Posted by Michael in Games, Programming, directx, xna on March 11, 2010
Those who have been following this blog know that I wrote an article about implementing a Light Pre-Pass renderer last year. Since then I have made numerous improvements and fixes as I have tried the system over different PC configurations.
This time around I will be including those changes into the implementation, and also releasing sample code for educational use. If you feel you have learned enough from the previous article, then feel free to skip this. For those new to the topic, please use this article instead of the older one.
An update on LPP + Sample
Posted by Michael in Programming, directx, xna on February 21, 2010
Hi everyone, first of all apologies for the delay. there has been quite a lot going on in my life, but I am working hard on getting the sample done. This time around I wanted to make sure I had a sample ready to go with the article, especially since the article will focus on the technique and theory and have little to no code – although I will certainly focus on XNA when it comes to mentioning issues and benefits to certain parts.
One of the main delays was getting the sample code out of my engine, and cleaning it up so it can be used as a learning tool. Unfortunately most of the code was hacked on as I fixed issues in the LPP renderer, and added features.
I have a fair bit of the article written, however recently I was implementing shadows and realised that I never thought about how they would integrate into the system, so I decided to rewrite my own renderer (which should not take long) and at the same time keep the code clean so it can serve as a sample as well.
This means I will probably also have Directional Light shadows in the sample. This then allows me to write about point lights, and spotlights later on, and include shadows for both.
So again, sorry for the delay, I am working hard to get it out soon.
As an aside, I noticed that Game Programming Gems is getting an 8th Edition, something I was not expecting, so with that, GPU Pro, and Game Engine Gems, I might be able to find some more cool things to write about.
Thank You for your patience.
Action Based Input Manager w/Events in XNA
Posted by Michael in Programming, xna on January 4, 2010
I recently completed an action based Input system for my own engine that allows me to create named actions which support the GamePad, Keyboard and Mouse.
The system uses events to notify the game of changes in input state, which makes it really easy to use, and the system supports XML serialisation so key assignments can be saved and loaded.
Supports:
- Thumbsticks (Analog)
- Triggers (Analog)
- GamePad Buttons (incl Trigger “Buttons”)
- Keyboard
- Mouse (Analog)
- Mouse Buttons
The system also supports Gamepad, Mouse and Keyboard assignments for each action, so you can support both the GamePad and Keyboard at the same time.
It also supports disabling of certain GamePads, so you can find the active GamePad and only accept input from that one, via a really simply array of booleans.
You can specify a single direction or axis for the Thumbstick and Mouse, so that the events will only be triggered if there is movement “up” on the Thumbstick.
You can download the InputManager and InputAction classes below:
Feel free to use these classes in your own project, although if you do make use of them, it would be nice to get a mention.
If you notice any problems, or have any suggestions/feedback, feel free to post them in the comments.
Note/Disclaimer:
This sample/code is provided as is. I am not responsible for any problems you may have, and you use the code at your own risk.
I am available to answer questions about the code through the comment system on this website – although this is not guaranteed.
This code was intended for personal use, however I have decided to share it with the community to help out newer developers.
Rewrite of LPP Article Planned
Posted by Michael in Programming, Xbox 360, directx, xna on December 12, 2009
I recently went about making the current Light Pre Pass system run on the XBOX 360, and had to fix some issues that appeared there. As a result, the next article to go up will be a rewrite with all of these fixes included. I should also be able to provide the sample code at the same time.
This time around I will cover Point, Ambient and Directional lights in the same post, as well as including information about an alternate light buffer format that allows for improved specular + per-material specular.
Expect this either during the weekend of 20-21st Dec, or shortly after that.
Unfortunately I could not test the code on the XBOX the first time around due to subscription issues, however everything is fine now, and I can and will test on both XBOX and my desktop PC beforehand. (Perhaps also other PC configs depending on who I can find online at the time, and what other machines I have on hand
)
Light Pre Pass in XNA: Basic Implementation
Posted by Michael in Programming, Xbox 360, directx, xna on December 1, 2009
NOTE: This article is now obsolete. An up-to-date sample and article can be found at http://mquandt.com/blog/2010/03/light-pre-pass-round-2/
In this part I will cover how to implement the basic form of the Light Pre Pass renderer, with support for point lights, and the basic Blinn-Phong shader, including Albedo texture support.
As this article is fairly advanced in nature, I have to make certain assumptions about my audience, so that I do not spend half my time explaining basics. Firstly, you should have an understanding of basic concepts such as Cameras, Fullscreen Quads (including how to render one) and rendering a mesh with custom effects.
This pretty much means that as long as you have done some 3D work before, you should be fine. It would be best if you also knew XNA, as I will be using that to write this implementation, however as long as you can translate from C# and get the basic idea, that should be enough.
As you can see from these requirements, this article is not aimed at beginners, and if you are looking for tutorials on how to get started with XNA for 3D development, I would recommend you visit some great sites such as:
Those sites will help you get started with XNA, and once you are familiar and comfortable with the concepts behind 3D graphics, you can return here to learn an advanced renderer implementation.
My focus in this article will be on the implementation of the renderer, as a result, I will not be referring to the implementation of cameras or scene graphs.
Now that the housekeeping is out of the way, we can begin.