XNA Creators Club Online
Page 1 of 1 (9 items)
Sort Posts: Previous Next

[Graphics]SetData<?> on Texture format Rg32

Last post 1/22/2008 4:02 PM by DarthCheesiest. 8 replies.
  • 1/22/2008 2:06 PM

    [Graphics]SetData<?> on Texture format Rg32

    What value type to use, when i want to set data to this kind (Rg32) of texture?

     

    EDIT: Stright to point - i need to read texture coordinate data form sampling a texture - any advice? :)

     

     

  • 1/22/2008 2:35 PM In reply to

    Re: [Graphics]SetData<?> on Texture format Rg32

  • 1/22/2008 2:46 PM In reply to

    Re: [Graphics]SetData<?> on Texture format Rg32

    Yeah, i found that, but it just wont work... I used .Color format (just set r & g values) and it worked (ok 8bit but it worked :D) What should i do to read that texcoords form texture?
  • 1/22/2008 2:50 PM In reply to

    Re: [Graphics]SetData<?> on Texture format Rg32

    Can you post some code?
    XNA Framework Developer - blog - homepage
  • 1/22/2008 2:59 PM In reply to

    Re: [Graphics]SetData<?> on Texture format Rg32

    tex_UV = new Texture2D(graphics.GraphicsDevice, 2048, 2048, 0, TextureUsage.None, SurfaceFormat.Rg32);

    Microsoft.Xna.Framework.Graphics.PackedVector.Rg32[] UVdata = new Microsoft.Xna.Framework.Graphics.PackedVector.Rg32[2048 * 2048];

    for (int i = 0; i < 2048*2048; i++)
    {
    int x = i % 2048;
    int y = i / 2048;

    //Its just simple 0..1 here, but it will change
    UVdata[i] = new Microsoft.Xna.Framework.Graphics.PackedVector.Rg32((2048.0f / (float)x), (2048.0f / (float)y));
    }

    tex_UV.SetData<Microsoft.Xna.Framework.Graphics.PackedVector.Rg32>(UVdata);
  • 1/22/2008 3:29 PM In reply to

    Re: [Graphics]SetData<?> on Texture format Rg32

    That code looks right to me: what about this is not working?
    XNA Framework Developer - blog - homepage
  • 1/22/2008 3:51 PM In reply to

    Re: [Graphics]SetData<?> on Texture format Rg32

    I think you need to use something like

    UInt32[] UVdata

    UVdata[i] = new Microsoft.Xna.Framework.Graphics.PackedVector.Rg32((2048.0f / (float)x), (2048.0f / (float)y)).PackedValue;

    tex_UV.SetData<UInt32>(UVdata)

  • 1/22/2008 3:54 PM In reply to

    Re: [Graphics]SetData&lt;?&gt; on Texture format Rg32

    Answer
    Reply Quote
    Values i read in PS are incorrect - When i set it like that :

    float2 uvdata = tex2D(Sampler_uvdata, input.TextureCoordinate).rg;

    float4 color = 0.0f;
    color.rg = uvdata.rg;
    return color;

    it displays pure yellow image... (TextureUsage.AutoGenerateMipMap) or black (lol) when TextureUsage.None... ;(


    EDIT : DarthCheesiest -> still, the same :/


    EDIT2 : Im so happy and the error was simply stupid :D I found that i use 2048.0f / x but SHOULD use x / 2048... mm yeah... I wonder why it worked with .Color format O_o

  • 1/22/2008 4:02 PM In reply to

    Re: [Graphics]SetData<?> on Texture format Rg32

    I don't know then, I use pretty much the same thing, but with Rgba1010102
Page 1 of 1 (9 items) Previous Next