Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

phong666

D3DXFillTextureTX() using texture shaders in HLSL

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

Hello, has anyone a working code sample to create a pixel shader in HLSL and use it as texture shader to fill textures? I''d like to give this shader some additional parameters like constants and input textures. What is the difference between the tx_0 and tx_1 profile? Where can I find an example? Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
Look at the soucecode to EffectEdit - but basically there are 2 parts to creating a procedural texture in HLSL

1) Create the actualy routine. All functionfillers can take up to 2 parameters. The first one is POSITION, and the second is PSIZE. All texture routines return a float4. If you are using a format that doesn''t have 4 channels, then set the others to 0 (they will be ignored anyway)., A texture fill routine might look like:

float4 Noise(float3 pos : POSITION, float3 size : PSIZE) : COLOR
{
return noise(pos);
}

2) Fill it, this might look something like:

LPD3DXBUFFER ShaderCode,Errors;


D3DXCompileShaderFromFile("file.fx", NULL, NULL, "main", "tx_1_0", &ShaderCode, &Errors,NULL)

D3DXFillTextureTX(MyTexture, ShaderCode->GetBufferPointer(), NULL, 0);

Share this post


Link to post
Share on other sites
Thanks for your help,

one last thing: how can I access other textures within texture shaders? The constant table lists only vector4 objects.

Is it possible to bind a texture by Device->SetTexture(0, texture) to the first sampler stage and then access via HLSL?
I don''t know the binding semantic if this is possible.

Thanks in advance

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

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!