# Point Sprite Size into World Space

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

## Recommended Posts

Hi, I made a Vertex Shader for my point sprites, but since im changing their sizes, I need to scale them acording to worldspace insted of screen space? Anyone know how to do that? [Edited by - MetaKnight on December 15, 2004 8:42:10 AM]

##### Share on other sites
If I'm reading this correctly, you should be able to simply pass in the worldMatrix into the vertex shader and use that (in addition to the worldViewProj matrix, of course).

##### Share on other sites
Yeah I tried every matrix and the matviewproj, when I use them it just ends up making the points smaller as I get closer, it should be getting bigger.

Im only setting ->SetRenderState(D3DRS_POINTSPRITEENABLE,TRUE);
is there anything else I should set? Even though im making my own sizes?

##### Share on other sites
perhaps if you include the vertex shader code it'll be easier to pinpoint the problem ;)

##### Share on other sites
Oh okay, here is is:
[Source]float4x4 matViewProjection;float4x4 matView;float4x4 matWorld; sampler2D maintex;float Time;  struct vertexInput {    float3 position : POSITION;    float4 tex1 : TEXCOORD0; // velocity for each point};struct vertexOutput {    float4 Position		: POSITION;	float4 COUT: COLOR0;	float Point : PSIZE;  // this is the size};//------------------------------------vertexOutput VSP(vertexInput IN) {    vertexOutput OUT;    IN.position += IN.tex1*Time ;    OUT.Position = mul( float4(IN.position , 1.0) , matViewProjection);    OUT.Point = mul(5,matWorld); // here's where the problem is with scaling    OUT.COUT = float4(1,1,1,1);    return OUT;}

##### Share on other sites
Oh, well in this case you should not need to be using any of the transform matricies for the scaling. The location will use that, but the scale doesn't.

So just use normal multiplication. If you need to scale them relative to their distance you will have to also know the location of the "eye" or camera, which you must pass in from the core program. Then some simple math to find the distance (need to know some trig here) -- then just use

Out.Point = absoluteScaling * distanceScaling;// Absolute can be whatever size you want, depending on how big you want them to appear; distance is what you just calculated between eye and point

EDIT: A good link if you want some background on this stuff is HERE

##### Share on other sites
Ah yeah, it seems the matrix doesnt seem to help at all for scaling

In the end i got this eqation to find out the scale:

S s = Vh * Si * sqrt(1/(A + B * De + C *( De2 )))

That works perfectly! , thanks rjackets!

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5
JoeJ
19

• 11
• 14
• 9
• 10
• 12
• ### Forum Statistics

• Total Topics
633003
• Total Posts
3009830
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!