Sign in to follow this  
robydx

texture shader

Recommended Posts

I wrote this texture shader sampler2D tex1:register(s0); float4 Main(float3 pos : POSITION, float3 size : PSIZE) : COLOR { return float4(pos*pos,1)+tex2D(tex1,pos.xy); } it disassemble like this // Parameters: // // sampler2D tex1; // // // Registers: // // Name Reg Size // ------------ ----- ---- // tex1 s0 1 // tx_1_0 mul r0.xyz, vPos.xyz, vPos.xyz it's not possible to use texture in texture shader?

Share this post


Link to post
Share on other sites
what's "texture shader"? You mean "pixel shader"? Of couse you can, pixel shader can take data interpolated from vertex shader and use texture sampler. Take a look at Ms DirectX 9 SDK.

Share this post


Link to post
Share on other sites
The SDK has many examples of shaders including how to interpolate textures accross surfaces etc. Check out the SDK and if you havnt got it installed then you can get it from msdn.microsoft.com

ace

Share this post


Link to post
Share on other sites
no, boy,
it's not pixel shader but texture shader
the instruction filltexture permit to create a texture using a particular type of shader.

The step is:
create empty texture
create a texture shader
(is a shader that has position and psize as input and color as output)
use filltexture to execute the shader on the texture

is more helpfull to create lookup map, it works also with cubetexture and volumetexture

the only things that doesn't work is using the texture
anyhelp?

Share this post


Link to post
Share on other sites
To answer your question - nope, you can't use the current texture to fill a texture using a texture shader. I assume this is because texture shaders are only emulated using CPU and system memory, so there is no access to the currently set device texture.

A nifty workaround if you want to change textures of the same size is to write a pixel shader that does what you want. Create a rendertarget texture of the same size as the texture you want to fill and set it as the rendertarget. Now set the PixelShader and Texture, and draw a square using Transformed Vertices (see D3DFVF_XYZRHW) that covers the whole screen and has UV coords from 0, 0 to 1, 1.
Then, to update your texture use GetRenderTarget and StretchRect to copy the data across.

You could also use Multiple render targets (Effects buffers) etc. Plenty of info floating around about that on Google

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