D3D11 vs GL line rasterization

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


User avatar
bishopnator
Gnome
Posts: 388
Joined: Thu Apr 26, 2007 11:43 am
Location: Slovakia / Switzerland
x 18

D3D11 vs GL line rasterization

Post by bishopnator »

I noticed that with default settings of the D3D11, the lines are rendered quite differently compared to OpenGL.

Here is the D3D11 rendering:
Image

And here is the GL3Plus rendering:
Image

The D3D11 renders the lines with not always 1px thickness which doesn't look as good as in OpenGL. I check online why there are those differences and D3D11 renders the lines as lines or as quads depending on the rasterizer settings which is explained e.g. here.
Image

Theoretically, it is possible to setup the rasterizer in D3D11 according to the main window (1st created) - if it has multisampling enabled, the rasterizer has also enabled the multisampling, otherwise it is set to false. Now it is always set to true in D3D11RenderSystem::_hlmsMacroblockCreated.

Does it sound ok? Is it a good idea to play with this setting? The MS documentation has following statement about the flag:

Because of the differences in feature-level behavior and as long as you aren’t performing any line drawing or don’t mind that lines render as quadrilaterals, we recommend that you always set MultisampleEnable to TRUE whenever you render on MSAA render targets.

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5576
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1411

Re: D3D11 vs GL line rasterization

Post by dark_sylinc »

Line rasterization has become an after thought on modern APIs and OgreNext doesn't support it very well either for this reason.

It is also not guaranteed to look the same on different GPU HW either.

OpenGL has historical tweaks due to its heavy use in CAD software. Using quads to render lines is also the recommended approach.

User avatar
bishopnator
Gnome
Posts: 388
Joined: Thu Apr 26, 2007 11:43 am
Location: Slovakia / Switzerland
x 18

Re: D3D11 vs GL line rasterization

Post by bishopnator »

I thought about using something like:

Code: Select all

rasterDesc.MultisampleEnable = mPrimaryWindow != nullptr && mPrimaryWindow->isMultisample();

In the D3D11RenderSystem::_hlmsMacroblockCreated. I didn't check the return value of isMultisample, but I hope, it returns false if I don't use "FSAA" option in the window creation parameters.

I will definitely try it on my side, even if it wouldn't be integrated in ogre-next, I definitely need nice 1px lines in D3D11 as in OpenGL (even if the rasterization is not 100% identical). I am writing the library which is meant for CAD-like applications and I don't want to limit the API just to OpenGL.

User avatar
bishopnator
Gnome
Posts: 388
Joined: Thu Apr 26, 2007 11:43 am
Location: Slovakia / Switzerland
x 18

Re: D3D11 vs GL line rasterization

Post by bishopnator »

Seems to work. The D3D11 rendering has significantly nicer lines in the sense of CAD rendering:
Image

And it activates only if FSAA is inactive which I believe is active in the most common use in ogre-next so there shouldn't be any regressions for other users.