Results 1 to 6 of 6

Thread: DirectX Texture mapping

  1. #1
    Join Date
    Jun 2009
    Posts
    3,620

    DirectX Texture mapping

    Struggling a bit with the texturing in DirectX. Hope someone has come across similar issues. Note that the stuff works! It just looks awful ugly right now!

    I will draw out a list of triangles. I use CustomVertex.PositionColoredTextured[] type and put Tu/Tv mapping parameters as below

    Code:
                        if (count == 1)
                        {
                            triangleList[i].Tu = 0;
                            triangleList[i].Tv = 0;
                        }
                        if (count == 2)
                        {
                            triangleList[i].Tu = 0;
                            triangleList[i].Tv = 1;
                        }
                        if (count == 3)
                        {
                            triangleList[i].Tu = 1;
                            triangleList[i].Tv = 1;
                        }
    The triangles are drawn with
    Code:
    device.DrawUserPrimitives(PrimitiveType.TriangleList, triangleList.Length / 3, triangleList);
    The problem is that:
    • I have no idea how the triangle looks like. The forms may be different. An edge may be 20 cm, second 2 meters, third 3 meters. 1/1/1 or in other settings.
    • Today, the texture "ripped" and changed to fit the triangle shape. I would like ideally, the texture should be "tiles". Thats placed next to each other and thus never scaled or stretched differently. I want a smooth surface without edges, etc. Is this possible to achieve?


    Any ideas?

  2. #2
    Join Date
    Nov 2008
    Posts
    1,054

    Re: DirectX Texture mapping

    I do not know if this is correct, because sometimes I mix OpenGL and DirectX. In OpenGL, at least so it should only be triangleList.Length, but there is some uncertainty on my part whether this applies also in Direct3D.

    I go based on the way you use SlimDX and not managed DirectX? If not, switch to SlimDX. You can easily create a "world" based on vertex coordinate with its position. If only to be mapped directly from above, this will look okay. So set x and z on the Tu and Tv.

  3. #3
    Join Date
    Jun 2009
    Posts
    3,620

    Re: DirectX Texture mapping

    The drawing of triangles works 100%. I know this is not problem. I have used managed DirectX. I have also considered XNA. What is the reason why I should switch to SlimDX?

    Tu/Tv must be between -1 and 1. Or am I wrong? (Has missed a bit with that. T rowed it was 0-1, will test this tomorrow). Has anyone tried putting TuTv to actual positions. Got problems with this earlier today. But to investigate in the morning and see if I did something wrong

  4. #4
    Join Date
    Nov 2008
    Posts
    1,054

    Re: DirectX Texture mapping

    Ok. Managed DirectX is very outdated. SlimDX is simply where DirectX nowrap to .NET. Managed DirectX has a separate API similar to DirectX. It does not work under 64-bit, and has some problems (for example, turn off LoaderLockException to use DirectX.AudioVideoPlayback)

    Texture coordinates are mapped to 0-1, but you can decide how this should take place. (Whether it should repeat, or values less than 0 will be mapped to 0, etc. The default is repeat) Alternatively, you can even figure out the correct value between 0 and 1, but in theory this should be automatic.

    But look at SlimDX. The advantage then is that the Direct3D tutorials for C++ will be more or less correct for SlimDX.

    Note that Direct3D 10 and Direct3D 11 has gone completely away from programming without shaders (ie the so-called fixed function is not available). It is not a feature of Direct3D 10 for point sprites, for example, this is something you have to be made even with the Geometry Shader. But you also have the option to use Direct3D 9.0c SlimDX.

  5. #5
    Join Date
    Jun 2009
    Posts
    3,620

    Re: DirectX Texture mapping

    I am unfortunately dependent on the program CAN run on 64 bit. Not necessarily with 64 bit support but it must be executable.

    No place in DirectX which I can control the repeater (I've found this in OpenGL). Thus, the surface looks like a patchwork. No easy way to do this with Tu / Tv. Have tried modulo operations, but this is not correct. (I can make the assumption that the side edges is typically less than, for example. 2.5 meters)

    In terms of the last things you're talking about so this is a bit "abstract" for me so far. I a little Noob to DX/Graphics but has made a functional graphic that actually works. Now the goal is to get it to get a router here look than the early 90's games. But do not quite understand it here with texturing.

    If one has no good answer to the repeater/tiling question: Let's twist to it. Is there a better alternative? I have N number of points. These triangulated on the outside of the DX (this is with business logic to do). And I know what each texture triangle should have. How do I do this so that I get a smooth uniform surface. Are there other ways to use textures on?

  6. #6
    Join Date
    Nov 2008
    Posts
    1,054

    Re: DirectX Texture mapping

    Are you sure it's not just the scale that is crazy? If you create a surface that is 500 unit high, then the texture is repeated 500 times over the surface (if you set the coordinates as I wrote) then you can end up with only a moire pattern. The module should be straight, but it should not have any effect if the Direct3D already doing the job for you.

Similar Threads

  1. DirectX 9 and DirectX 10 support for crysis 2
    By The$Tourist in forum Video Games
    Replies: 5
    Last Post: 26-03-2011, 10:39 AM
  2. How to do texture mapping in Blender
    By Danel in forum Software Development
    Replies: 4
    Last Post: 04-12-2010, 01:44 AM
  3. What is UV Mapping
    By Zebaril in forum Windows Software
    Replies: 3
    Last Post: 30-09-2009, 06:04 PM
  4. Downgrade Directx 10 to Directx 9
    By BALLARI in forum Operating Systems
    Replies: 3
    Last Post: 21-08-2009, 10:39 AM
  5. Replies: 2
    Last Post: 08-04-2009, 02:01 AM

Tags for this Thread

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
  •  
Page generated in 1,714,020,230.31813 seconds with 17 queries