Nothing Renders - Why?

00:17
Sun
24
May 2015

Nothing Renders - Why?

"I have a blank screen" or "nothing is rendered" is probably the most frequent bug in graphics programming. It's also quite hard to debug because there are many possible causes. Graphics pipeline is compilated, so there are multiple things that can be wrong at each stage. Few years ago I've written a short article about this, in Polish, titled Nic nie widaŠ. This is translation of that article. It provides a list of questions you should ask yourself while considering the most frequent reasons for why nothing appears on the screen. It is dedicated for Direct3D 9, but it can also be applied to OpenGL (only some things are named differently) and, to some degree, to newer graphics API-s.

It's black

First of all, please clear your background to some color other than black, e.g. gray or blue. Maybe your geometry is rendered, but it is black. It is a frequent bug, especially if you have lighting enabled (and it is enabled by default) while you didn't setup any lights.

Matrices

Are you sure you correctly setup all matrices - world, view and projection? Did you create them using correct functions? Is the camera located in the right place and looks in the desired direction? Maybe your object is in the same position as camera or behind the camera, which is pointing backward?

Position

Is the size and position of your object correct? Is your object too close or too far from the camera, relative to the minimum and maximum Z value set in projection matrix? Isn't it too small to be visible?

Errors

Do all the calls to DirectX functions return a value meaning success? Do you even check that value? Please also launch "DirectX Control Panel", enable Debug Layer for your application and analyze Output for any error or warning messages.

Vertex Format

Do you use correct vertex format? Did you define a structure describing your vertex correctly and compatible with the FVF/vertex declaration that you use? Are all the fields in the correct order and of the right type? Do you tell DirectX what vertex format you want to use by calling SetFVF/SetVertexDeclaration before rendering?

Draw Call

Do you pass correct parameters to the rendering function? In the most basic case, all offsets should be 0 and "stride" is the size of your vertex structure, in bytes, like sizeof(SMyVertex). Do you pass correct number of primitives to render?

Buffers

Do you fill your vertex and (optional) index buffer correctly? Do they have correct number of elements? Do you fill all of them? If you use transformed coordinates XYZRHW, the RHW component should be set to 1.0 and never to 0.0.

Alpha Channel

Maybe your geometry is totally transparent. Is the alpha channel set to maxium (1.0 or 0xFF, depending on type) and not to minimum in all of these: vertices, texture, material (only if you use lighting)?

Backface Culling

Maybe the triangles you want to render are ignored as "back facing" the camera, because they have wrong winding (clockwise or counterclockwise)? Try to disable backface culling to check that.

States

Did you setup blending on all texture stages correctly? Did you correctly setup all rest of the states of graphics pipeline? Maybe the problem appears only when you render some objects in a specific order? That means states set before rendering one object remain in the pipeline and break rendering of the next one.

Advanced Effects

If you use some advanced rendering features, your graphics card may not support them. Set reference software rasterizer during creation of the device object (D3DDEVTYPE_REF instead of HAL). Your program will run very slowly, but everything should be drawn as expected. Query device object for capabilities of your GPU (device caps).

Z-Buffer

If you use depth buffer, remember to clear it as well, together with backbuffer. In 3rd parameter of Clear function bitwise OR following flag: D3DCLEAR_ZBUFFER. Without it, you won't see anything on the screen or you will see artifacts. Value to clear Z-buffer to is 1.0f (not 0.0f).

Finally, there are ways you can actually debug how data and state look like on subsequent stages of the graphics pipeline while this bugged draw call is executed, using Graphics Diagnostics in Visual Sudio or other GPU debugging tool.

See also: How not to render 3D graphics: 40 ways to get a blank black screen

Comments (1) | Tags: directx rendering | Author: Adam Sawicki | Share

Comments

曲美
2015-09-24 05:11:41
催淫カプセル:http://www.okkanpo.com/Product/245.html
ok漢方:http://www.okkanpo.com/
アフリカ超人:http://www.okkanpo.com/Product/571.html
街頭覇王睾丸素カプセル:http://www.okkanpo.com/Product/652.html
徳国公牛:http://www.okkanpo.com/Product/657.html
壮根精華素:http://www.okkanpo.com/Product/336.html
壮根精華素 6錠入り:http://www.okkanpo.com/Product/158.html
超強 黒倍王:http://www.okkanpo.com/Product/187.html
リドスプレー :http://www.okkanpo.com/Product/155.html
精力剤:http://www.okkanpo.com/catalog/energy.html
漢方薬:http://www.okkanpo.com/catalog/kanpou.html
中絶-避妊薬:http://www.okkanpo.com/catalog/hininn.html
紅蜘蛛:http://www.okkanpo.com/product/167.html

威哥王:http://www.okkanpo.com/product/8.html
三體牛鞭:http://www.okkanpo.com/product/437.html
V26:http://www.okkanpo.com/product/324.html
勃起促進:http://www.okkanpo.com/catalog/penis-erectile.html
五便宝:http://www.okkanpo.com/product/222.html
天天素:http://www.okkanpo.com/product/360.html
淫インモラル:http://www.okkanpo.com/Product/495.html
インモラル:http://www.okkanpo.com/Product/477.html
蔵八宝:http://www.okkanpo.com/Product/445.html
新一粒神:http://www.okkanpo.com/product/444.html
SEX DROPS:http://www.okkanpo.com/product/88.html
女性用媚薬:http://www.okkanpo.com/catalog/Aphrodisiac.html
女用媚薬:http://www.okkanpo.com/catalog/Aphrodisiac.html
RU486:http://www.okkanpo.com/Product/398.html
三体牛鞭:http://www.okkanpo.com/product/437.html
妖姫:http://www.okkanpo.com/Product/479.html


D5原液:http://www.okkanpo.com/product/63.html
三體牛鞭:http://www.okkanpo.com/product/437.html
三便宝:http://www.okkanpo.com/Product/395.html
セックスドロップ:http://www.okkanpo.com/product/277.html
曲美:http://www.okkanpo.com/product/371.html
精力剤:http://www.okkanpo.com/catalog/energy.html
中絶薬:http://www.okkanpo.com/catalog/Interruption.html
滋養強壮:http://www.okkanpo.com/catalog/Nutrition.html
ペニス増大:http://www.okkanpo.com/catalog/Penis-increase.html
プロコミルスプレー:http://www.okkanpo.com/product/191.html
蟻力神:http://www.okkanpo.com/product/159.html
巨人倍増:http://www.okkanpo.com/product/133.html
絶對高潮:http://www.okkanpo.com/product/245.html
リドスプレー:http://www.okkanpo.com/product/155.html
紅蜘蛛:http://www.okkanpo.com/product/167.html
狼1号:http://www.okkanpo.com/Product/99.html
三鞭粒:http://www.okkanpo.com/product/436.html
狼1号:http://www.okkanpo.com/Product/99.html
男宝:http://www.okkanpo.com/Product/237.html
夜夜堅:http://www.okkanpo.com/Product/35.html
壮天根:http://www.okkanpo.com/Product/194.html

Post comment

Nick *
Your name or nickname
E-mail
Your contact information (optional, will not be shown)
Text *
Content of your comment
Calculate *
(* - required field)
STAT NO AD [Stat] [Admin] [STAT NO AD] [pub] [Mirror] Copyright © 2004-2016 Adam Sawicki
Copyright © 2004-2016 Adam Sawicki