Tag Info

Hot answers tagged

36

I'll give you the "simple" version and let someone else fill you in on the details if you're interested :). There are basically two ways to model 3D objects. The first is one you don't see a lot of in games, and it involves using precise, mathematically defined curves to define the shape of an object. Using this method, the level of detail is (practically ...


16

HDR techniques allows you to simulate a greater range of detail than you can view on screen than with traditional lighting/textures. You can compare it to how the eye behaves when exposed to different amounts of light - when there's too much light the eye lets less light in so things are still in your visible range. When there is not enough light, the iris ...


15

I think the main optimization you can make, is based on the fact that not every cube will actually need all 24 vertices. In fact, the only cubes that need 24 vertices are the ones that are floating in midair, which is probably a rare occurrence. In general, only generate quads for the faces that are in contact with air. This means that if two cubes are ...


14

When one talks about OpenGL and D3D "features," one could be referring to either: the feature sets supported by hardware that the graphics API exposes, or the feature sets of the API itself that don't really relate to the hardware. For example, a programmable tessellation pipeline is something the hardware generally has to support (let's ignore, for the ...


13

When multiple render targets are bound, they can each be written to individually by the pixel shader -- it isn't (necessarily) the case that all render targets will get the same image. You could write only the red component into one output, only the blue into another, et cetera. This is used when implementing deferred rendering for example: position, ...


11

The ID3D11Buffer references an actual chunk of memory that holds your data, whether it's a vertex buffer, constant buffer, or whatever. Constant buffers work the same way as vertex buffers and other kinds of buffers. Namely, the data in them isn't accessed by the GPU until it actually renders the frame, so the buffer has to remain valid until the GPU is ...


11

You should usually prefer to use the D3D11 API, because it introduced downlevel feature level support that allows you to target 9, 10 or 11 level features using the same (D3D11) API. This means cleaner, more compact code so long as you don't have to support XP (and thus need to use the actual D3D9 API as well). If you choose to require D3D11-level features, ...


10

In the D3D11 parlance A buffer is a type of resource that contains data in various formats. Buffers are used to create textures (a buffer of texel data), meshes (buffers of vertex data with corresponding buffers of index data) and so on. A view an interpretation of some resource or buffer. Buffers are stored in generalized memory formats to facilitate ...


9

The warnings are informing you of live (unreleased) objects, as you've discovered. Releasing the objects you retain references to is the proper way to clean them up, but you have to release the right objects. There are several ways you can get help tracking down which objects are being retained and from there you can follow the lifetime of those objects ...


9

The effect functionality was refactored. It's fundamentally the same set of operations, you just have more control over them -- similar to how the D3D10+ interface redesign does mostly the same stuff as the 9 API, but affords you a more direct model of the hardware or driver to work with. The cost of this change to you is more verbosity in your code; more ...


9

Actually that "while loop" that you wrote there is the source of your problem. GetMessage puts your application to sleep until a message arrives. This is good for GUI applications but obviously is not good for games. The right way of doing the game loop is using PeekMessage instead so that your application is not put to sleep and can just keep spinning. ...


9

Yes, a game engine will in general have a variety of different shaders. The typical pattern is: While initializing the engine and loading the game world, prepare all the shaders you will use for rendering. By "prepare" I mean load them into memory, compile them if necessary, and do all the ID3D11Device::CreatePixelShader and similar calls to get the D3D ...


8

Misunderstood the question, see the comments. You basically have three choices: Throw an exception Return an error code and use an out parameter to return the actual value Call an error callback Exceptions: Very simple to implement, however they might incure a huge performance and/or memory impact, even during normal execution, depending on the ...


8

need to handle rendering large astral bodies from extreme distances Consider the scale of the Solar System. 8 planets, and we're currently on one. Our closest neighboring planet, Venus, is almost the same size as Earth. Yet, it is so far away from the Earth that it appears as nothing more than just another star in the sky. Jupiter is the largest planet ...


8

You have to create the threads yourself, using your threading library of choice (boost, C++11 async, Windows threads, etc). The idea is that you will create several threads and split up your CPU rendering work amongst them. Each thread uses a D3D11 deferred context to accumulate all the D3D11 commands (state changes, draw calls, etc.) it wants to execute. ...


7

DirectX 11 is a much cleaner and much more powerful API than DX9 without any legacy fixed function stuff. It also allows to use DX9 and DX10 class hardware through "Level 9" and "Level 10" with the same interface. Furthermore, you can render the same scene more efficiently than with DX9. This results in higher framerate or better visuals on the same ...


7

Taken from Wikipedia, too: there aren't many differences. Strictly speaking, OpenGL is usually slightly behind Direct3D in terms of features, because the standardisation takes time. However, many of these features are available as OpenGL vendor-specific extensions first, then in the standard itself after some time. Compute shaders are available in GLSL ...


7

I'm pretty certain this has to do with Texture addressing. If you could post the sampler state part of your shader then I'd could rule that out. Also is this a texture atlas (many used images stored in 1 texture)? Texture addressing handles regions outside of the 0.0 to 1.0 range. When filtering other than point is applied the rendered texture will use ...


7

If you only need per-face normals, and if your texcoords for a face are strictly 0/0, 0/1, 1/0, 1/1 (or similar to suit your layout) then you can construct a cube with 8 verts and either 30 (strip with restart) or 36 (list) indexes. Fetch the normals and texcoords using a constant array lookup based on SV_VertexID in your vertex shader. Doing this means ...


7

No, at least in D3D11 it is not possible to change the size of a buffer or texture after it's been allocated. You would have to release the old buffer and create a new one (which is inadvisable to do often, as it can hurt performance). It's okay to only use part of a vertex buffer, so if you know the maximum size your data will be, I'd allocate the buffer ...


6

When you invoke Map with D3D11_MAP_WRITE_DISCARD, Direct3D considers the whole buffer contents invalid and will replace it with the data that exists inside the memory that the new data buffer points at when invoking Unmap. Your problem is that instead of copying your data into the memory that Direct3D provides to you when you map the buffer, you instead ...


6

This is a tricky question because you don't have complete control over whether a vertex buffer is stored in VRAM or main RAM. The driver makes that decision for you based on the usage and CPU access flags specified when you create the vertex buffer. Generally speaking, buffers with default and immutable usage will be stored in VRAM; those with staging ...


6

Instead of D3DXVec3Unproject() use XMVector3Unproject(). It accpet float parameters for viewport: XMVECTOR XMVector3Unproject( [in] XMVECTOR V, [in] float ViewportX, [in] float ViewportY, [in] float ViewportWidth, [in] float ViewportHeight, [in] float ViewportMinZ, [in] float ViewportMaxZ, [in] XMMATRIX Projection, [in] XMMATRIX ...


6

A given shader model exposes a particular set of registers to HLSL; these registers are underlying hardware registers on the GPU, like CPU registers, but have more refined scopes (for example, there are registers dedicated to holding samplers). Registers are where all your data is stored during the execution of your shader (with the exception of data, like ...


6

Because the alternative is worse. There's a set-constant-buffer function for each major shader type because it is often desirable to have a completely different set of constants for each (and also, because one does not necessarily utilize every type of shader in all scenarios). It's usually the case that each stage of the shader pipeline does a drastically ...


6

D3D10 core didn't have a mesh class; you're probably thinking of ID3DX10Mesh, which is actually part of the D3DX API. D3DX itself was wholly deprecated with Windows 8. The relevant math bits were moved into another library. The higher-level utility interfaces, like mesh, were not ported. The API was removed because it was a continuation of the evolving ...


5

Think of feature levels as rulesets defining what hardware abilities of a video card you are allowed to use. So when you create a D3D11Device with D3D_FEATURE_LEVEL_9_3, you can still benefit from "software" D3D11 features which happen on driver and API level without involving hardware, such as better multi-threaded rendering, but your D3D11-capable video ...


5

Depends what you want to use it for. If you just want to play with new features and learn stuff, go right ahead! Whatever you do will be useful in the future. If you're aiming to sell software, and want to have a large target market, it might not be the best move right now. According to steam hardware survey, only about 5% of users have dx11-capable ...


5

When rendering with multisampled anti-aliasing, a coverage value is computed for each fragment; this coverage value is based on the fraction of the pixel that would be covered by the fragment based on the triangle that created the fragment. The net result is that the edges of the triangle are anti-aliased. Because the coverage is based ultimately on what the ...


5

I think your overall approach is fine, assuming that everything works. I recommend ignoring your performance concerns until you can show that performance is bad (I got the impression that performance is a personal concern and not yet a technical one). Your shader base class/interface MapData has a problem because it is an abstraction (there is no single way ...



Only top voted, non community-wiki answers of a minimum length are eligible