Results 1 to 8 of 8

Thread: Animated textures

  1. #1
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Animated textures

    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 ??
    NecroSOFT - End of line -

  2. #2

    Animated textures

    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.
    There are only 10 types of people in this world; those who understand binary and those who don't.

  3. #3
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Animated textures

    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?
    NecroSOFT - End of line -

  4. #4

    Animated textures

    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.
    There are only 10 types of people in this world; those who understand binary and those who don't.

  5. #5
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Animated textures

    I have created a texture:

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

    Im trying to render on the texture:

    [pascal]
    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;[/pascal]

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

  6. #6

    Animated textures

    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/de...transforms.asp

  7. #7
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    Need help ASAP

    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

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

    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!!!
    NecroSOFT - End of line -

  8. #8

    Animated textures

    Install DirectX Debug Runtime !!!
    You can't create D3DPOOL_MANAGED rendertarget only D3DPOOL_DEFAULT.

    This one works:
    [pascal] // 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;[/pascal]
    There are only 10 types of people in this world; those who understand binary and those who don't.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •