PDA

View Full Version : Animated textures



NecroDOME
15-03-2005, 03:46 PM
Questing about animated textures...

I'm currently thinking about the fastest way to make a dynamic animated texture.

my idea:
1: Create a texture
2: Render an other texture over it (convyorbelt for example)
3: render more textures over it (even with multi textureing)
4: render texture (i created) to my world
5: I also can render that texture to another texture :)

so, its dynamic, but is there an other or faster way to do so ??

Clootie
15-03-2005, 06:20 PM
It's the way to do. But it's recommended to actually have 2 textures:
[1 frame] Render to (texture 1) and "forget" about it. Render your scene using (texture 2)
[2 frame] Swap textures. So render to (texture 2) and render you scene using (texture 1).
[3 frame] see frame 1

This way you let your GPU/driver more possibility to avoid "locking" in single frame.

NecroDOME
15-03-2005, 10:17 PM
Ok.... i'll get it a litte... but should I use 2 textures also when i'm making a texture with an u,v transformation ? like "streaming" lave/water for example?

Clootie
16-03-2005, 06:54 PM
It depends on what are you understanding by "streaming". But if you lock/render to texture each frame when double buffering it is a good way.

NecroDOME
16-03-2005, 10:10 PM
I have created a texture:


D3DXCreateTexture(FScreen.Device,
Width,
Height,
0,
D3DX_DEFAULT,
D3DFMT_A8R8G8B8,
D3DPOOL_MANAGED,
Textures[ Index ].Texture)


Im trying to render on the texture:


if Succeeded( Textures[Index].Texture.LockRect( 0, lr, nil, 0 ) ) then
begin

if Succeeded( Textures[Index].Texture.GetSurfaceLevel(0, Surface) ) then
begin

FScreen.Device.SetRenderTarget(0, Surface);
SetTexture(0); // set texture 0 (temp)

// create vertex buffer
SetVertexBuffer(256, 256, 0, 0, 0, 1, 1, 0, 1, 1);



FScreen.Device.SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
FScreen.Device.SetStreamSource(0, FTempVertexBuffer, 0, sizeof(D3DFVF_TEXTURE_VERTEX));
FScreen.Device.SetFVF(D3DFVF_TEXTURE_VERTEX);
FScreen.Device.DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);

end;

// Finally unlock...
Textures[Index].Texture.UnlockRect(0);
end;

but it's not renderd on the texture it self but on the main surface of my rendering...

Sly
16-03-2005, 10:27 PM
You can apply a transformation matrix to a texture. Much more efficient than rendering to a texture.

Here is an example of it.
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/graphics/programmingguide/FixedFunction/Textures/coordinates/texturecoordinatetransforms.asp

NecroDOME
17-03-2005, 01:00 AM
Thnxz...

But i want it to work cause in the future i want to render some things to a texture (for interactive (camera) screen or for example)

[edit] :!:

My problem is: Iam unable to create a render target


if Succeeded( D3DXCreateTexture(FScreen.Device,
Width,
Height,
1,
D3DUSAGE_RENDERTARGET,
D3DFMT_A1R5G5B5,
D3DPOOL_MANAGED,
Textures[ Index ].Texture) ) then


when i replace D3DUSAGE_RENDERTARGET with D3DX_DEFAULT its all OK but i can't render on it cause it's not a render target... please need help!!!

Clootie
18-03-2005, 08:45 PM
Install DirectX Debug Runtime !!!
You can't create D3DPOOL_MANAGED rendertarget only D3DPOOL_DEFAULT.

This one works:
// Create the blank texture
Result:= pd3dDevice.CreateTexture(1, 1, 1,
D3DUSAGE_RENDERTARGET,
D3DFMT_A16B16G16R16F,
D3DPOOL_DEFAULT,
g_pTexScratch, nil);
if V_Failed(Result) then Exit;