De blob Ramp

|

To create a ramp in de blob I had to calculate what height the player should be based on their position along the ramp. This required interpolating the height value with X and then Z and then setting the players position to be at that height.

To achieve this I first check to see if the player had collided with the ramp, if so I cast a ray from the player straight down (to a set distance) to test if the player was on top of the ramp. If this was the case then I had to take the ramp dimensions and create a plane from them (ignoring height) and intersect the plane with the ray to find the exact x and z position of the player on the ramp. Then using the x and z positions I could interpolate across the ramp (started where the ramps height was 0) and find out what height the ramp was at the x and z intersection point, this returned the height offset that should be applied to the player to make them look like they were on the ramp.

De blob camera

|

The camera for the game takes two forms; firstly (and most prominently) it follows the player at a certain distance, rotating around the player when the mouse is moved left or right. It also determines the direction the player moves when they press forward (as the player always moves in the direction the camera faces).

Secondly when a player hits a target on a building the camera repositions itself to point at that building and spin round it. These was done by creating a spline around the building at a set position (when the target was hit) and getting the camera to follow the spline path until it returned to the start position, at which point it returned to original position behind the player.

To setup the camera was relatively simple, I specified a target as the players position, and set the cameras position to be a set distance away from the player and set the rotation to match the current mouse x movement.

Shader Debugging

|

I recently had a problem where my terrain went all black and I was unsure why, as I was applying a texture and lighting to the terrain through a shader. To track down the problem I looked up debugging shaders in PIX

before

To start I did a single frame capture of the app in pix to capture all the render calls done. With the information I could view what was rendered on that particular frame by viewing the render tab.

Right-clicking on the render brings up the option ‘debug this pixel’, I right click over the terrain section to ensure that I got a pixel that was part of the terrain and selected the option

2a

Doing this took me into the pixel shader code for the technique used for that pixel

3a

I then stepped through the code, observing variables in the disassembly for the line pointed at by the yellow arrow in the above image. I could then see that the RGB values of terrainTexSamp (stored in register r0) where near 0 (resulting in black), as shown in red in the registers window, this made me realise that the problem was with the texture. A quick check through my code and I found I had forgotten to actually set the texture for the technique.

4a

The corrected render is shown below

after