Jump to content

  • Log In with Google      Sign In   
  • Create Account


Shenjoku

Member Since 28 Aug 2006
Offline Last Active Sep 13 2013 06:22 PM
-----

Topics I've Started

Fringes around textures

26 April 2013 - 08:18 PM

I'm getting some strange fringes around some textures at specific sizes that I cannot figure out how to get rid of. I'm rendering the primitives to an off-screen surface then rendering the result of that texture on another primitive on the screen. The off-screen rendering supports MSAA but with or without it the problem persists. It doesn't seem to affect all textures either. If the texture is larger than 512 in either dimension then it doesn't have the problem.

 

You can see the fringes around the outside of the two textures in this screenshot. One is a solid white 311x100 JPEG and the other is a 152x95 PNG. The image format doesn't seem to matter, just the size. Whether or not the image has an alpha channel doesn't affect it either.

 

Attached File  RenderingError.png   130.83KB   34 downloads

 

I've tried debugging the problem in PIX and noticed that there is a bunch of garbage data around the textures, but even if I zero out the texture memory it doesn't get rid of it for some of them so I'm not sure what's going on there. You can see in the screenshot below that there's a bunch of white where there should be nothing but empty space to the right of the texture since it's only using 311x100 of the available space.

 

Attached File  PixTextureData.png   28.22KB   30 downloads

 

P.S. This is all with DirectX 9 btw.


DirectX 9 MSAA single-pixel thick line rendering problems

15 April 2013 - 04:36 PM

I'm having some strange issues rendering single-pixel thick lines with DirectX 9 and MSAA, but only on AMD cards. I'm already adjusting the coordinates to convert them from texels to pixels by subtracting 0.5, which works perfectly fine and fixes rendering bugs on NVIDIA cards, but when doing the same on a system using an AMD card the line ends up rendering partially transparent because it's being anti-aliased when it shouldn't be.

 

Here's some sample code to show yout how the coordinates are calculated and how the line is being rendered:

 

// v is the locked vertex data which contains two points and is using an FVF of D3DFVF_XYZ | D3DFVF_DIFFUSE.
//
// x,y,w,h is the position and size of the line. For one thickness lines, either w or h is zero depending on whether it's horizontal or vertical.
//
// kVertexModifier is used to convert from texel to pixel coordinates based on the documentation found here: http://msdn.microsoft.com/en-us/library/windows/desktop/bb219690%28v=vs.85%29.aspx
const float kVertexModifier = -0.5f;

if (h == 0.0f)
{
	x += kVertexModifier;
	w -= kVertexModifier;
}

if (w == 0.0f)
{
	y += kVertexModifier;
	h -= kVertexModifier;
}

v[0].mSet(fColor, x, y);
v[1].mSet(fColor, x + w, y + h);

// Rendering is done like the following:
device->SetFVF(fFVF);
device->SetStreamSource(0, fVertexBuffer, 0, fVertexSize);
device->DrawPrimitive(D3DPT_LINELIST, 0, 1);

 

I took some screenshots from a test project to show what the problem looks like. Pay attention to the border around the blue rectangle (you'll most likely have to view the full-size image and zoom in to be able to see it):

 

 This is how it looks on a machine with an NVIDIA card.

Attached File  one_thickness_correct.png   5.65KB   49 downloads

 

This is how it looks on a machine with an AMD card. Notice the border is very transparent compared to the other one.

Attached File  one_thickness_broken.png   5.05KB   51 downloads

 

I'm banging my head against a brick wall trying to figure out this problem, mainly because any fix that I figure out to make it work for AMD cards doesn't work for NVIDIA cards, and vice-versa. If anyone has any information or leads on how to fix this it would be greatly appreciated.


Rotated clipping

28 August 2012 - 05:33 PM

I need to implement clipping of primitives at any rotation but I'm unsure of how to do it. Currently I'm using IDirect3dDevice9::SetScissorRect to clip things, but that obviously won't work at any rotation. So my question to all of you is how do I clip using a rotated rectangle?

I've been searching for a while and found some people suggesting to use iDirect3DDevice9::SetClipPlane, but I'm not 100% sure how to use that or if it would be the best thing to use. The important thing to note is that the scene is not 3D at all, this is for a completely flat 2D application.

EDIT: Feel free to close this thread. Spent the whole day getting clipping planes to work, which works fine until I realized that clipping needs to use weird funky shapes so it got a LOT more complicated really fast. I did, however, find a free third-party library that handles clipping all sorts of things that I'm going to try to use when I have free time in the future. Library is called Clipper.

DirectX 9 Device Creation Failing

11 August 2012 - 02:49 PM

A client is having some issues trying to run our app on a Windows XP machine, wherein the device creation process is repeatedly failing. I don't have access to the computer yet so I know nothing about the hardware specs other than that they said, "The graphics card is rather new". I'm a little skeptical but that's a different problem Posted Image

They sent me a log and the error messages they're getting look like this:

Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
Direct3D9: (WARN) :driver set D3DDEVCAPS_TEXTURENONLOCALVIDMEM w/o DDCAPS2_NONLOCALVIDMEM:turning off D3DDEVCAPS_TEXTURENONLOCALVIDMEM
D3D9 Helper: Enhanced D3DDebugging disabled; Application was not compiled with D3D_DEBUG_INFO
Direct3D9: (WARN) :driver set D3DDEVCAPS_TEXTURENONLOCALVIDMEM w/o DDCAPS2_NONLOCALVIDMEM:turning off D3DDEVCAPS_TEXTURENONLOCALVIDMEM
Direct3D9: (ERROR) :Device cannot perform hardware processing. ValidateCreateDevice failed.
Direct3D9: (WARN) :driver set D3DDEVCAPS_TEXTURENONLOCALVIDMEM w/o DDCAPS2_NONLOCALVIDMEM:turning off D3DDEVCAPS_TEXTURENONLOCALVIDMEM
Direct3D9: (WARN) :driver set D3DDEVCAPS_TEXTURENONLOCALVIDMEM w/o DDCAPS2_NONLOCALVIDMEM:turning off D3DDEVCAPS_TEXTURENONLOCALVIDMEM

Direct3D9: (INFO) :======================= Hal SWVP device selected
Direct3D9: (INFO) :HalDevice Driver Style 8
Direct3D9: (ERROR) :Failed to create driver surface
Direct3D9: (ERROR) :Failed to initialize primary swapchain
Direct3D9: (ERROR) :Failed to initialize Framework Device. CreateDevice Failed.

Now I've been looking into the problem for a whlie and I can't seem to find any solid conclusions as to what is causing the problem. The device creation is indeed first trying to create with the D3DCREATE_HARDWARE_VERTEXPROCESSING, and then if that fails it's changing it to D3DCREATE_SOFTWARE_VERTEXPROCESSING and trying again, or at least it should be.

So can anyone shine some light on this problem? Is this just purely a hardware thing? I'll know more once I get a chance to check out the machine but for now I'm just trying to draw some conclusions so I know what to test out.

Getting the palette of a D3DFMT_P8 texture

30 June 2012 - 05:11 PM

I'm working on an application that needs to support using P8 textures, but the way it needs to use them is by converting them into a 32-bit ARGB image. To do this I need to somehow get the palette of the texture after it has been loaded, but I can't find anything after looking through the DirectX docs.

So, does anyone know how to get the palette of a texture? That's the last piece of the puzzle I'm missing.

PARTNERS