Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


DwarvesH

Member Since 12 Jun 2013
Offline Last Active Jan 29 2015 05:27 AM

Topics I've Started

Is there a way to draw super precise lines?

27 January 2015 - 09:34 AM

So I'm creating a top down/2.5D/polygons + 2 top down camera game.

 

I snap the polygons to a grid but the game is not pixely.

 

I would also like to add borders to walls. How I did this is drawing the walls a second time, but this time with lines. 

 

But I have found that the rasterizer does not behave exactly as it does for filling polygons as it does for drawing lines. Randomly the end points are not draw, especially for horizontal lines.

 

One can see this in screenshots if you zoom in a bit:

https://dl.dropboxusercontent.com/u/45638513/sprite15.png

https://dl.dropboxusercontent.com/u/45638513/sprite16.spr.png

 

The outlines look a bit rounder at corners.

 

Is there a way to get DirectX to fill the exact border of a triangle with a line? In a portable way?

 

Or maybe I'm overthinking things and shouldn't really care about one pixel.

 


How to properly switch to fullscreen with DXGI?

16 January 2015 - 09:13 AM

So i finally managed to create a stable Hello World for DirectX 11 (for some reason 10 and 11 never wanted to cooperate with me).

 

Yet most of the basic functionality is not working as expected.

 

For starters switching to fullscreen. All the documentation and other posts on the Internet say that DirectX 10/11 is so easy and low maintenance compared to 9 and just let DXGI take care of everything. Well, things are finicky to say the least.

 

So for starters, I would like to get DXGI resolution fullscreen switching to work as expected.

 

Here is the scenario:

1. I have a RenderForm class that creates a window. Specifying WS_POPUP is key for the behavior I am experiencing:

handle = CreateWindowEx(WS_EX_APPWINDOW, L"D3D10WindowClass", aTitle.c_str(), WS_CLIPSIBLINGS | WS_CLIPCHILDREN 
		| WS_POPUP /*WS_OVERLAPPEDWINDOW*/, 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, nullptr, nullptr, hInstance, nullptr);

2. To better test everything, I am running in "fake" fullscreen mode, so the window has no frame and has the same dimensions as my desktop. I get a FPS of 670.

 

3. I switch to fullscreen mode with DXGI (Alt-Enter). I get 630 FPS. Normally one expects FPS to go up when switching to fullscreen. The swap chain when created has the flag for mode switching. Without ti, if I change from a less than native resolution to fullscreen, I get ugly artifacts I have never seen before.

swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;

If I create the swap chain in fullscreen mode directly, I get 1370 FPS. The framerate is almost double compared to when I start in fullscreen mode. But that is not the extent of the problems. If I switch from this initial fullscreen mode to windowed, I get a white screen. If I switch back again I get the 630 fullscreen mode, the original high performance one being lost.

 

I do have code to handle window resize the swap chain, but because of WS_POPUP it is never called. If I create the window with WS_OVERLAPPEDWINDOW, things go to hell. The fullscreen window content is all squashed horizontally in the middle of the screen.

 

I could upload the code, but I think it is better to determine the correct way to handle going to fullscreen with DXGI before and try it out to see how that behaves. 


Porting from DirectX9 to DirectX10 questions

05 September 2014 - 07:15 AM

Hi everybody!

 

So I am at my third or fourth attempt at porting my base application from DirectX9 to DirectX10 and while this is going better than the rest, I'm still having tons of problems.

 

I managed to get basic rendering working, but not I need to allow for the possibility of changing the device settings.

 

So here are a few questing:

 

1. How do you "recreate" the device?

 

In DX9 you could change render targets and sucks, but generally you had to reset you device.

 

In DX10 I think you can use swapChain.ResizeBuffers for simple cases, like user window resize. That fails silently for me, so I guess I need to clear up some resources.

 

I did dome Googleing and found that I need to Dispose all the resources created when the swap chain was created.

 

This works fine, but I was wondering how to manage a lot of render targets. The engine can use anywhere from 1 to around 10 for a full suite of effects. Should this be done with the swapchain or should one keep the swap chain buffer count low and manage render targets manually.

 

Secondly, how to really "Recreate" the device? Like when changing MSAA mode? All my attempts to recreate the swap chain resulted in the display driver crashing. And how to handle going from fullscreen to windowed with or without render target size change?

 

2. Effect is a lot weirder in DX10. Should I update my engine to use vertex and pixel shaders instead of effects?

 

3. Font.DrawText ruins the device context. I tried setting device.Rasterizer.State and device.OutputMerger.DepthStencilState at the beginning of the draw function but this is not enough. I temporarily fixed this by using Sprite and calling Begin/End with a parameter so it backs up the device state, but it would be better if I could set all device context variables so that rendering works without the use of Sprite.

 

4. DX9 was using BGRA colors and DX10 uses RGBA colors?


Terrain stitching micro seams

08 April 2014 - 01:16 AM

I am experiencing a weird phenomenon. 

 

I have implemented large scale terrain that is divided into chunks of various resolutions/LOD. When two different LOD chunks are near each other, I do stitching once on the CPU to fix the seam. The way I do it is it take two points from the higher resolution chunk that align up to the lower one and compute their average height. Then I set the middle vertex height to that average and apparently this fixes all discontinuities between chunks.

 

But something is amiss. It seams hat my simple average is not up on par with the way the hardware rasterizer triangles and sometimes a single pixel wide hole appears. These come and go as you move the camera around, often staying only for one frame.

 

http://dl.dropboxusercontent.com/u/45638513/ter08.png

 

In the above image I was lucky enough to capture two of the fleeting seams near each other. The red line is the LOD discontinuity. The two seams are circled in red. As I move around the camera, white pixel come and go, all found on the discontinuity line. Otherwise, when the pixels don't show up, there are no seams.

 

Any idea how to fix this? My far plane is pretty far away, may have something to do with it.

 

The only idea I have is to add extra triangles in that "seam".

 

Thank you!

 

 


Oh no, not this topic again: LH vs. RH.

03 April 2014 - 06:38 AM

So I'm porting my game over from XNA (RH) to SharpDX (LH or RH, LH traditionally)  and have finally arrived to the last phase: the terrain. Once this is done porting finally be behind me!

 

And here is where LH or RH really causes major changes. For terrain I needed to do a ton of adjustment, even having to transpose the terrain only for physics.

 

In the past I did not mind switching from RH to LH. I had to use different matrices and swap the Z in position and normals at mesh load and things where pretty much done.

 

But recently I noticed that logically LH does not not make that much sense. Everything from applying a 2D grid on top of the 3D world to mapping mathematical matrices to world positions to drawing mini maps is a lot more intuitive using RH. Especially mapping of matrices. In programming you often have an (x, y) matrix that is represented as y rows of x columns. This maps intuitively to right handed. You need to put element (0, 0) at you coordinate system's origin and map Y to Z (assuming your world is not centered; even if it is, just subtract an offset).

 

LH on the other hand is more difficult to map. Especially since you often need to transform things from one space into another in your head.

 

Are there any good reasons to use LH other than DirectX has traditionally used it and it may make integrating things from DirectX easier?

 

I'm really torn between the two. But if I switch back to RH it must be done now.


PARTNERS