Sign in to follow this  

Help with Floating-point Textures used as a Vertex Texture

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

Hi everyone, I'm trying to render world position data to a floating-point texture, and read the data from a vertex shader in another render pass to construct geometry procedurally. I am having trouble with the texture because it seems to clamp all my values to 0.0f and 1.0f. This is how I declare my fp32 texture:
pd3dDevice->CreateTexture(baseWidth, baseWidth, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A32B32G32R32F, D3DPOOL_DEFAULT, &positionTexture, NULL);
positionTexture->GetSurfaceLevel(0, &positionSurface);
In my vertex buffer, I pack in the positions that I want to be computed into the normal field of each vertex, and then render it out using the following Effect:
//------------------------------------
struct vertexInput {
    float3 Position	: POSITION;
    float3 Normal	: NORMAL;
};

struct vertexOutput {
    float4 HPosition    : POSITION;
    float4 Diffuse      : COLOR0;
};

//------------------------------------
vertexOutput VS_TransformDiffuse(vertexInput IN) 
{
    vertexOutput OUT;
    OUT.HPosition = float4( IN.Position, 1.0f );
    OUT.Diffuse = float4( IN.Normal.xyz, 1.0f );
    return OUT;
}

//-----------------------------------
float4 PS_Textured( vertexOutput IN): COLOR
{
    return IN.Diffuse;
}

//-----------------------------------
technique strippedFFP
{
    pass p0 
    {		
		VertexShader = compile vs_1_1 VS_TransformDiffuse();
		PixelShader  = compile ps_1_1 PS_Textured();
    }
}
After the texture is rendered, I'll set it to D3DVERTEXTEXTURESAMPLER0 with the following sampler states:
pd3dDevice->SetSamplerState(D3DVERTEXTEXTURESAMPLER0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);				
pd3dDevice->SetSamplerState(D3DVERTEXTEXTURESAMPLER0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
pd3dDevice->SetSamplerState(D3DVERTEXTEXTURESAMPLER0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
pd3dDevice->SetSamplerState(D3DVERTEXTEXTURESAMPLER0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
pd3dDevice->SetSamplerState(D3DVERTEXTEXTURESAMPLER0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
The result is that my position values (in each channel) is clamped to 0.0f to 1.0f. Am I doing anything wrong? Thanks in advance. Edit: To make things clearer, I'm using Nvdia 6600GT with Direct X 9.0c. [Edited by - Nisaus on January 9, 2006 1:37:23 AM]

Share this post


Link to post
Share on other sites
You're compiling using the vs_1_1 and ps_1_1 profiles which will cause your colour values to be clamped (IIRC). Use vs_2_0 and ps_2_0 instead. If you're going to be using a vertex texture you'll need to use the vs_3_0 profile.

Share this post


Link to post
Share on other sites

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