Thursday, November 3, 2011

Rendering to a texture

    Sometimes it is required to render to something else than the screen. This can be useful if we want to generate our own textures, save a screenshot or create shadows using shadow maps. After we render the image we can then use it as any other regular texture in our shaders. In this application we will replace the texture of the bottom-right corner of the image from the crate texture to a scene of the same cube on the main part of the screen only on a different color background.



Sunday, October 23, 2011

Projective Texturing

Sometimes we will need to apply a texture just like a projector would. This technique can help us create different effects like the Batman sign on the night sky or water caustics.


Monday, May 9, 2011

Environmental Reflections

Shiny objects in your game should be able to reflect the environment around them. Don't think that you can use a mirror technique everywhere, the reflections on a car will require a high number of directions to reflect so it will become almost impossible to compute them. We can use a cube map to simulate the reflections of the environment around the object. Cube mapping helps us because we don't need to actually reflect the items, we just have to do a texture look-up and that's it.




Wednesday, May 4, 2011

Loading a model with a custom effect

XNA allows us to use complex 3D models very easily, we just use the content pipeline and load a model into the game just like a texture. It will have everything it needs, vertex buffers, index buffers, bones, effects, textures. All we will have to do is set our effect parameters (for each effect in the mesh) and draw it. But by default the Model class uses one of the 5 build-in effects and as  I love shaders, I want to make it run with one of my own.

Tuesday, May 3, 2011

Creating a Sky Box

If your game is going to have a part that you play outside you will also need a sky. One of the most simple ways to get this is by simply using a cube map to create a sky box. What you will do is create a cube map that has all 6 faces mapped to a cube surrounding the player. Simple huh? Well it is and you should get results like this one:

Screenshot from the finished tutorial

Monday, May 2, 2011

Cube Mapping

Environmental reflections can be very expensive to compute, luckily we can use a cube map accomplish this.  Cube maps are textures that help us map the environment on a 3D object like so:

Environmental reflections on a skull

Sunday, May 1, 2011

Using the stencil buffer, rendering a stencil mirror

As we've seen the stencil buffer helps us to stop some pixels from ever being drawn to the screen, also the rasterizer is configurable in such a way that we can tell it how to draw geometry. In this short tutorial you will see how to combine these 2 to get a mirror effect.