Archived

This topic is now archived and is closed to further replies.

Headhunter

Clipping untransformed vertice

Recommended Posts

Headhunter    122
Hi ! You surely know untransformed vertice ?? You specifiy their position in screencoordinates, the z-coordinate is not needed... But these damn vertice are NOT clipped by Direct3D, that means you have to do it by hand, else you''ll get some nasty display errors.... I''ve already asked in some other forums but they could not help me ... Thx 4 help :-)

Share this post


Link to post
Share on other sites
Julian008    122
do your own clipping:
search for Sutherland & Hodgman-Algorithm

> NOT clipped by Direct3D

this depends on your videocard - i tested it on a TNT2 and i hadn''t have any problems

> I''ve already asked in some other forums

i know

Share this post


Link to post
Share on other sites
S1CA    1418
quote:
Original post by Headhunter

Hi !

You surely know untransformed vertice ??
You specifiy their position in screencoordinates,
the z-coordinate is not needed...

But these damn vertice are NOT clipped by Direct3D,
that means you have to do it by hand, else you''ll get
some nasty display errors....

I''ve already asked in some other forums but they
could not help me ...

Thx 4 help :-)



The Z coordinate *is* needed if you want the Z buffer to be updated correctly and the clipping to work.

The RHW component should also be set to a sensible value if you want texturing and vertex colour iteration to be done properly.


In D3D, if you want to clip pre-transformed vertices (vertices with an RHW value), you *must* set a valid projection matrix. Finally you enable the clipping renderstate.

When you ask D3D to clip pre-transformed vertices (those with an RHW [a.k.a. D3DTLVERTEX]), it back transforms them from screen space into camera space then performs the clipping. This is why the projection matrix *must* be set correctly!

You should be warned though - the back transformation is slow (i.e. it''s going to cost the same as it would to just use the full T&L pipe to go from object/world space).

If this is just for sprites, doing the screen clipping yourself is easy. If the sprites need to be rotated you''ll need to add more polygons - you''ll find source code to do this in most old software rasterisers and theory in a decent text book.

Modern graphics cards also have what''s known as a "Guard Band Area" - this is an imaginary border around your render target surface. The guardband screen might be 2048x2048 while your render target might be 640x480 - you could still draw polygons with coordinates up to 2048x2048 without the need to do any clipping. Check the caps flags for the adapter - using the guard band area is the best way to get massive performance benefits.


--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
Headhunter    122
Hi !

@Julian :
Fate, So sehn wir uns wieder .... Die welt ist klein :-)

>>this depends on your videocard - i tested it on a
>>TNT2 and i hadn''t have any problems
Well, the docu sais they ARE NOT GURANTE (f*** word,
) means THEY ARE NOT ALWAYS clipped.
And I want to be safe....


@S1CA
>>The Z coordinate *is* needed if you want the
>>Z buffer to be updated correctly and the clipping to work.
>>The RHW component should also be set to a sensible
>>value if you want texturing and vertex colour iteration to
>>be done properly.
I know... but for drawing the vertice itself, it is irrelevant ;-)


>>In D3D, if you want to clip pre-transformed vertices
>>(vertices with an RHW value), you *must* set a valid
>>projection matrix. Finally you enable the clipping renderstate.
1: Projection matrix is ok ! Works fine for 3d
2: Which renderstates do you mean ??? I haven''t found any

>>If this is just for sprites, doing the screen clipping yourself is
Well, infact it is for a tileengine in DX8... but that''ll
be the same as for sprites

>>Modern graphics cards also have what''s known as a "Guard Band Area"
That is cool !! I''ll check it out

Share this post


Link to post
Share on other sites
S1CA    1418
a) The back projection will need the Z and RHW to both be correct for the clipping to be correct.

b) The D3DRS_CLIPPING render state is the one you want.

c) The viewport should also be correctly set.

--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
peckerpeck    100
A bit trivial of a question, but for clarity...

So the reason in my 3d scene that my FPS jumps up (I''m
not doing any clipping, manually or D3D) when the
majority of the objects are offscreen is b/c they
just don''t have to be rasterized?

i.e. they go all the way down the pipeline until the
rasterization?

Share this post


Link to post
Share on other sites
S1CA    1418
Yep, if you have the clipping renderstate disabled (i.e. no D3D clipping) and you aren''t doing any clipping yourself, *IF* the graphics card has a guard band area, anything which goes into that area doesn''t have to be clipped OR rasterised.

Clipping can be a major performance hit, so turning it off unless absolutely necessary is a good thing to do.

Avoiding rasterisation gives less of a perf. boost, but it still is good - if something is in the guardband you avoid: the Z test, the alpha test, the stencil test, the pixel blend, the frame buffer blend, texel fetches etc.

if you go past the guard band or the card doesn''t have one, then you''ll have problems (rendering artifacts, even crashes).



--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
Headhunter    122
Hi again !

>>Clipping can be a major performance hit
I know, and of course I do a simple BBox against the
screen to see whether the object will be visible..

>>you go past the guard band or the card doesn''t have one,
>>then you''ll have problems (rendering artifacts, even crashes).
i get rendering artefacts all over the screen) and my
mouse "swims" :-)
imagine your mouse got _very_ drunk and you try to control it
, that''ll descibe it best *gg*

Do you know any links for clipping ???

Share this post


Link to post
Share on other sites