PDA

View Full Version : DirectX Orthogonal camera or vertex with D3DFVF_XYZRHW?



lordzero
19-09-2007, 04:28 AM
Hello

what is better Orthogonal camera or vertex with D3DFVF_XYZRHW?

the both have the same performance and quality?

Greets

Mirage
19-09-2007, 08:35 AM
D3DFVF_XYZRHW should be faster a little because there is no any vertex processing (matrix calculations, shaders). Especially on old hardware without T&L.

lordzero
19-09-2007, 01:52 PM
D3DFVF_XYZRHW should be faster a little because there is no any vertex processing (matrix calculations, shaders). Especially on old hardware without T&L.

ah... thanks ;)

chronozphere
19-09-2007, 01:58 PM
That's true. It's faster to render using D3DFVF_XYZRHW but....

You have to do all the transformation yourself. I guess this requires a lot of buffer locks/unlocks, which isn't very good for performance. If you only want to render a few triangles/quads it's isnt a real problem, but when you want to render more complex scenes, you will notice a difference.

You shouldn't only look at the performance.. also look at the efficiency and difficulcy of an approach. :)

When you choose to use Orthogonal projection, you can use matrices for transformation. The actual transformation of the vertices takes place on the GPU (and not on the CPU). This is very efficient because now you can use the CPU for other stuff... like physics, AI etc etc...

You can also use D3DFVF_XYZRHW. You have to do the transformations on the CPU. If you only want simple things (2D, simple scene)... D3DFVF_XYZRHW can suffice. but when you want to rotate lot's of 3D geometry, i advice you to split op the workload between GPU and CPU. :)

So it basicly depends on what you want to achieve.

LP
19-09-2007, 04:32 PM
You have to do all the transformation yourself. I guess this requires a lot of buffer locks/unlocks, which isn't very good for performance. If you only want to render a few triangles/quads it's isnt a real problem, but when you want to render more complex scenes, you will notice a difference.
If you transform the vertices in CPU and then upload them, you still are using one lock/unlock. That is, you use the same bandwidth in both cases.

Also, have you made any benchmarks for this? When working on TMDC, we've noticed that you can do the transformation of thousands of vertices on P4 2.4 Ghz in Pascal code without any FPS degradation (in TMDC though we used SSE anyway).


You can also use D3DFVF_XYZRHW. You have to do the transformations on the CPU. If you only want simple things (2D, simple scene)... D3DFVF_XYZRHW can suffice. but when you want to rotate lot's of 3D geometry, i advice you to split op the workload between GPU and CPU. :)
You can use D3DFVF_XYZRHW for 3D? Now that's an original approach! :D

The only advantage of ortographic projection is that you can use vertex shader to modify your vertices.

Also, LordZero, I'm happy for your efforts on learning how Direct3D works, but isn't posting on three separate forums the same question (copy'n'paste) is a bit too much?

Mirage
19-09-2007, 04:32 PM
Of course there is no reason to use D3DFVF_XYZRHW for 3D. Only for 2D.
For sprites, for example, modification of vertices in vertex buffer and drawing all sprites in a single DIP (DrawIndexedPrimitive) will be a lot faster than setting a matrix and drawing each sprite with its own DIP.

chronozphere
19-09-2007, 07:42 PM
@Mirage:

hmm... that's an interesting approach. This could be a good option for 2D games. I was assuming that you would use multiple vertexbuffer, but that isn't neccesary for 2D because you dont have much geometry. The ammount of lock/unlock calls will than be low too. :razz: (once for each frame)

I recommended Ortho projection because simple things like moving and scaling a sprite, do not require the vertexbuffer to be locked/unlocked. But using only one VB solves this problem.. i think :)

lordzero
19-09-2007, 09:50 PM
but isn't posting on three separate forums the same question (copy'n'paste) is a bit too much?

i want get much opinions :P