Sign in to follow this  

[CANCELED] VS 3.0, PSIZE fails

Recommended Posts

Hi, I have a very simple PointSprite shader which works in vs_2_0 mode. When moving to vs_3_0, the PSIZE out param seems to be ignored.
float4x4 WorldViewProj : WORLDVIEWPROJECTION;
float4 UserPosition : POSITION;

struct Vs_out
    float4 Position  : POSITION;
    float4 Color : COLOR0;
    float Size : PSIZE;

Vs_out Transform(
    float4 Position  : POSITION , 
    float4 Color : COLOR0 ){
    Vs_out Out = (Vs_out)0;
    // Distance from Player
    float dx = Position.x - UserPosition.x;
    float dz = Position.z - UserPosition.z;
    float dist = dx*dx + dz*dz;
    Out.Position = mul(Position, WorldViewProj);
    Out.Color = Color / (dist * 20.0 + .3);
    Out.Size = 34.0 / Out.Position.z;
    // Out.Size = 0.0; //Or whatever 
    return Out;

technique Tech
    pass P0
        vertexshader = compile vs_3_0 Transform();
        pixelshader  = NULL;

            Device.RenderState.DestinationBlend = Blend.One;
            Device.RenderState.PointSpriteEnable = true;
            Device.RenderState.PointScaleEnable = true;

            Device.RenderState.ZBufferEnable = false;
            Device.RenderState.AlphaBlendEnable = true;

            Device.SetTexture(0, partsTexture);
            Matrix worldViewProj = Device.Transform.View * Device.Transform.World * Device.Transform.Projection;
            effect.SetValue("WorldViewProj", worldViewProj);
            effect.SetValue("UserPosition",  new Vector4(center.X, 0f, center.Z, 0f));

                Device.VertexFormat = CustomVertex.PositionColored.Format ;
                Device.DrawUserPrimitives(PrimitiveType.PointList, N_PARTICLES, partsVertices);

The particles seems to have a constant enormous size, for any value of Out.Size (even 0.0). When i set Device.RenderState.PointSize in my app, it works well. On which points are models 2.0 and 3.0 different ? Thanks. [Edited by - raytaller on June 7, 2006 11:23:35 AM]

Share this post

Link to post
Share on other sites

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