• Advertisement
Sign in to follow this  

[HLSL] Pointsprite texture coords?

This topic is 4357 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

I'm porting my particle classes to HLSL. Everything is going fine, except I just cannot find a single source on forums/google how to get the proper texture coordinates! And that, for example, RenderMonkey uses some kind of 3DS model as particle type isn't very comforting either. I'm sure it should be possible, multiplying 1.0 to some value for example. Does anyone have some advice? Remember: I'm using pixelshaders (HLSL). I know how to do it with the 'old' FVF method :).

Share this post


Link to post
Share on other sites
Advertisement
I'm reasonably surprised that no one replied. I guess it really is an unknown thing in DirectX. Do we have to go back to textured quads again for using texture coordinates properly in HLSL? I just can't believe that's the way things should be.

Share this post


Link to post
Share on other sites
Okay, for the record, I found the problem. Seems it was 'quite' simple.

POINTSPRITEENABLE = true;

Has to be put in the effect file. Then texture coordinates are generated perfectly. So, something like this:


VS_OUTPUT VS_Particle_main(float4 Pos: POSITION)
{
VS_OUTPUT Out;

//Multiply with VWP.
Out.Pos = mul(Pos, view_proj_matrix);

Out.vPos = Pos.xz;

return Out;
}

float4 PS_Particle_main(float2 vPos: TEXCOORD0) : COLOR
{
//Simply return texture:
return tex2D(sampler_Particle, vPos);
}

technique Particle
{
pass Normal
{
AlphaBlendEnable = true;
AlphaTestEnable = false;
SrcBlend = ONE;
DestBlend = ONE;

POINTSPRITEENABLE = true;
POINTSIZE = 2.0f;
POINTSIZE_MIN = 20.0f;
POINTSIZE_MAX = 30.0f;

VertexShader = compile vs_1_1 VS_Particle_main();
PixelShader = compile ps_1_4 PS_Particle_main();
}
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement