Making Background for a 3D game

Hello guys,

I'm making a 3D game...well with a static CAMERA view...it would be in SPACE...and there's no movement on Z buffer, though its 3D.

But I would like to ask you for some suggestions how I should implement background stuff into this.

Well, presently I am doing it like:

I create a mesh(QUAD) in 3ds max and implement it into game as a sprite and set its Z position so it is further than other objects. But the problem is that I would like to have it USER-changeable - I mean...User can toggle between FullScreen/ windowed and switch resolutions and some other Dx stuff - so there is the problem.

I suppose, it would be better to create a QUAD following actual backbuffer dimensions.

Secondly, there's a problem with covering whole screen with whole background. When I push it further on Z-axis its smaller than whole screen - YES - I can make QUAD bigger, but isn't there any other solution - transforming it somehow to render on the whole screen

Also, I've heard about dissabling the Z-buffer for the mesh, but I haven't found anything how to do it and my tries failed.

THX.

Peto



Answer this question

Making Background for a 3D game

  • DirkW

    Your camera is part of the transformation chain and modifies the position of your vertices. That was the reason why I have written that you should set all transformation matrixes to an identity matrix. This will disable your camera for the background drawing.

    Maybe this old article can help you to understand this better: http://msdn.microsoft.com/library/en-us/directx9_c/The_Direct3D_Transformation_Pipeline.asp frame=true



  • MattPil29

    You can create your own fullscreen“ quad with projection space coordinates. This space is resolution independent. It ranged from -1 to 1 for X and Y and from 0 to 1 for Z. If you have coordinates in this space in your vertex buffer you have to make sure that they are not modified during vertex processing. If you use a vertex shader pass the coordinates direct from the input to the output register and set W to 1. If you use the fixed function pipeline you have to set all transform matrixes to an identity matrix.

    The usage of the Z-Buffer is controlled by some render states.
    D3DRS_ZENABLE, D3DRS_ZWRITEENABLE, D3DRS_ZFUNC

    You can find details about this states in the documentation. Look for “D3DRENDERSTATETYPE Enumerated Type“



  • ewhizz

    Well I think I have to have background further than Z=1, because I have 3D objects...

    Or do you think moving objects closer to camera, which is positioned at (0,0,-75), or further and letting BACKGROUND positioned on Z= 0 would make my QUAD independent on game resolution

    I have tried those RENDER STATES, but it was the same as without them.


  • Dark Angel

    If you move your quad outside this range it will be clipped. After the transformation all your 3D objects that you can see are in this range too. In the case you draw the background first you can disable the whole Z-Buffer. Set D3DRS_ZENABLE to FALSE for this draw call. To make sure that it your background image cover the whole screen your Quad have to go from (-1,-1,1) to (1,1,1).

  • remy_tache

    Are you sure but does it work also when I have my CAMERA set at (0,0,-75) and target at (0,0,0)

    I dont think so, QUAD with span you mentioned would be very small, unless my camera is positioned at (0,0,-1) I suppose.


  • Making Background for a 3D game