Sign in to follow this  

Point sprites scaling issue

This topic is 4108 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, I'm trying to render some point primitives and I am having problems getting them to scale with the view. The problem is, the point sprites always occupy a fixed number of pixels even though I have set POINTSCALEENABLE to true. I have tried a number of different things but I just can't get this to work. Here's the code that I am using: Vertex structure: struct myVertex { D3DXVECTOR3 pos; D3DXVECTOR3 normal; }; #define D3DFVF_MYVERT (D3DFVF_XYZ | D3DFVF_NORMAL) Render states: technique RenderScene { pass P0 { VertexShader = compile vs_2_0 vsPoint(); PixelShader = compile ps_2_0 psPoint(); CullMode = NONE; ZEnable = TRUE; AlphaBlendEnable = FALSE; PointSize = 100; PointScaleEnable = TRUE; PointSpriteEnable = TRUE; PointScale_A = 0; PointScale_B = 0; PointScale_C = 1; } } So when I render a point using the above setting, I get a point sprite of 100x100 pixels. I zoom in and out, but the point sprite remains in tact at 100x100 pixels. Any ideas? p.s., I 've also tried to set the render states using the SetRenderState() function without any success. Thanks in advance.

Share this post


Link to post
Share on other sites
Quote:
From SDK on D3DCAPS9:
MaxPointSize
Maximum size of a point primitive. If set to 1.0f then device does not support point size control. The range is greater than or equal to 1.0f.

If you need scalable point sprites you can try making a software device or a mixed mode device. For mixed mode, render everything else using hardware, switch to software to render point sprites, and switch back to hardware. You can also use this when you absolutely need a higher vertex shader model for a few things (or your entire game). I'm pretty sure the rasterizer part is fine, it's just preparing the triangles from point data that's not supported.

You can also check the caps to see if PSIZE as a valid FVF code on your card and put the size directly into the vertex data if supported.

Share this post


Link to post
Share on other sites
doesn't sound like a very good solution :-/ I'm using a GeForce 7800. Everything is supported and this should work entirely on the hardware just fine.
Of course there's the obvious workaround of using screen aligned quads instead of the point primitives, but for that I'd have to change a good bit of my code which currently uses fixed size point primitives. I just need to make them scalable :-/

Share this post


Link to post
Share on other sites
I don't think you can use the Fixed Function Point Sprite size calculations when using Shaders. You'll need to implement the same functionality in your own VS, and output a PSize from the shader, with the correct size. The DX SDK Docs describe in good detail the exact calculations the FFP does, so copying the exact behaviour shouldn't be a problem.

Hope this helps.

Share this post


Link to post
Share on other sites

This topic is 4108 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this