8
votes
Accepted
How can I mark a pixel in the stencil buffer?
There are two ways to set the stencil buffer value in Direct3D 11, one of which is only available in Direct3D 11.3 (and Direct3D 12). I will split this answer into two parts accordingly.
Direct3D 11 ...
7
votes
"DirectX will only draw polygons with an [X,Y] from [-1,-1] to [1,1] and with a Z from 0 to 1.", What does this mean and how to work around it?
The range [-1 ; 1] x [-1 ; 1] x [0 ; 1] mentioned in the tutorial refers to the canonical view volume. It is the final coordinate space vertex data gets mapped to ...
6
votes
Accepted
How can I speed up this HLSL shader?
I can't see anything fundamentally wrong with the shader, but here are a few things I find commonly done wrong with deferred shading that you might be doing.
1: Drawing full screen lights. The beauty ...
5
votes
Getting data from the backbuffer D3D11 using Map
Your code doesn't use your created texture with D3D11_CPU_ACCESS_READ.
It creates a texture:
...
4
votes
Accepted
DX11 Handle Device removed
There are two places you can potentially get this scenario: When calling ResizeBuffers or Present and you get either ...
4
votes
Accepted
Color Correction in DirectX
Color correction is commonly done through post processing shaders. Basically first you render the scene to a framebuffer, then draw a fullscreen quad that has a shader that takes that framebuffer and ...
4
votes
Accepted
In game development, what aspects to consider when choosing a 32-bit architecture over a 64-bit architecture?
The most obvious thing to consider is that using a 32-bit architecture for your executable allows you to address about ~4gb of RAM on Windows while using a 64-bit architecture allows the program to ...
3
votes
DirectX11, how do I manage and update multiple shader constant buffers?
There seems to be a lot of confusion around the topic of needing to re-bind constant buffers after updating them.
As I'm learning about this myself I have seen a lot of topics and discussions with ...
3
votes
Sampling in the Compute Shader not working
You are sampling from the same location on the texture for every output, therefore the output is a single colour.
See the documentation for SampleLevel
A fix would look something like this:
...
3
votes
Is it ok to mix shader types?
Yes you can mix shaders, I have around 25 shaders that run per frame from terrain shaders using the full pipeline to post processing.
You are getting the crash because after you bind shaders to hull, ...
3
votes
Accepted
How do multiple shaders in a DirectX Engine work?
Might be misunderstanding your question but from the screenshot, it looks like you have a common library of functions to use with your three different shaders:
BasicEffect [VS, PS]
Brdf [VS, PS]
...
3
votes
Accepted
Passing Matrix to shader
Yes, there is no way to pass a float4x4 to an input description. By doing that you'd be passing a matrix for every vertex to your vertex shader. This is bad practice unless you need to bind a ...
3
votes
Direct3D11 Reading from (Static) Index Buffer
You really don't want to read from buffers because you never know where it is in the pipeline and you will normally end up with +20ms of GPU-CPU synchronization.
Even with a copy to a staging ...
3
votes
Accepted
Single pass separable gaussian blur problem
I'm not an expert in compute shaders, but it looks like the memory barriers you're using there say:
"Ensure all current writes in progress finish before proceeding to
the next step"
...while I ...
3
votes
How can you make custom direct3D11 calls in Unreal Engine 4?
I figured out a way to render to texture.
Create a new c++ component that has a UTextureRenderTarget* property
Create a render target in unreal. I followed the ...
3
votes
Accepted
Why do these DirectXMath functions seem like they return column-major matrics?
You posted a column-major version of the translation matrix for (1,1,-1):
1.0 0.0 0.0 1.0
0.0 1.0 0.0 1.0
0.0 0.0 1.0 -1.0
0.0 0.0 0.0 1.0
...
3
votes
Which DirectX Version to use for a low poly game?
You generally want to use the latest version that is compatible with your target platform. For most people that means DirectX11, since DirectX12 is not supported on versions of Windows (i.e. Windows 7)...
3
votes
Accepted
error X4016: SV_InstanceID semantic cannot be used with 10Level9 targets
TL;DR: Edit your shader compilation to use Shader Model 5.1 or later.
With the DirectX 12 API, there is no supported device to date that supports anything less than Direct3D Feature Level 11.0. ...
3
votes
Accepted
What actions should I perform in DirectX 11 to correctly process Alt+Tab?
ALT+TAB is generally handled through WM_ACTIVATEAPP and "FSE" games switch out/in of fullscreen mode based on this message.
With DXGI you can manually implement ...
3
votes
What actions should I perform in DirectX 11 to correctly process Alt+Tab?
Here is what I've found works. All of this information is probably scattered around the DXGI documentation on various disconnected pages; it's been a while since I've reviewed it.
For windowed modes (...
3
votes
Accepted
God rays shader - Trouble with sun position
In GLSL (like HLSL), a vec4 (float4 in HLSL) has three different ways to access its four values. You can use (rgba), or (xyzw), or (stpq). They're all identical to each other; Asking for ...
3
votes
Accepted
Constant Buffer Alignment issues
Review the HLSL cbuffer packing rules here: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-packing-rules
HLSL packing rules are similar to performing a #pragma pack 4 ...
3
votes
Accepted
Borderless windowed (fake fullscreen) mode doesn't cover the entire screen
It can only be attributable to human error. This sort of thing has cropped up before, and it has always been due to human error.
This was, of course, all my own fault.
I had some code for centering ...
3
votes
Accepted
How to sample a TextureCube texture
This doesn't work the way you're expecting because texture slots and sampler slots are decoupled in D3D10/SM4+. So unlike legacy code, you can have a texture at slot x, a sampler state at slot y (and ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
directx11 × 757c++ × 209
directx × 206
hlsl × 134
shaders × 85
textures × 61
sharpdx × 54
rendering × 35
c# × 31
3d × 24
graphics × 22
slimdx × 21
directx9 × 19
fragment-shader × 18
depth-buffer × 18
matrix × 17
windows × 17
vertex-buffer × 15
opengl × 14
directx10 × 14
2d × 13
shadow-mapping × 13
geometry-shader × 12
tessellation × 12
lighting × 11