texture shader

Started by
4 comments, last by robydx 18 years, 8 months ago
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?

http://www.notjustcode.it

DirectX tutorial

Advertisement
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.
[ILTUOMONDOFUTURO]
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
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?

http://www.notjustcode.it

DirectX tutorial

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
you confirmed my suspect, I'll use standard render to surface.
thank you so much

http://www.notjustcode.it

DirectX tutorial

This topic is closed to new replies.

Advertisement