Instantly share code, notes, and snippets.
This is essentially just theoriginal Minimal D3D11 codebase with 8x MSAA added. However, since MSAA only smooths triangleedges and does not affect textured surface interiors, texturing is removed to isolate and make the effect of MSAA clearer.
In short there are two parts to it: 1)Create andrender to an MSAA texture rather than your typical rendertarget/framebuffer (note: the depth buffer mustmatch), and 2) [Resolve](https://gist.github.com/d7samurai/d74299f8bcadcb9cb0686
Plain 2D rendering in D3D11, without the distracting feature set of acomplete sprite renderer and allowingarbitrarily placed triangle vertices with absolute pixel coordinate positioning (there's reallyno need for the sometimes confusing complication of a full-on projection matrix pipeline for UI and 2D games). Like theoriginal Minimal D3D11, this one uses a canonical 1:1TRIANGLELIST vertex buffer with input layout, so no fancy manual custom buffer fetching and in-shader instan
Plain 2D rendering in D3D11, without the distracting feature set of acomplete sprite renderer and allowingarbitrarily placed triangle vertices with absolute pixel coordinate positioning (there's reallyno need for the sometimes confusing complication of a full-on projection matrix pipeline for UI and 2D games). Like theoriginal Minimal D3D11, this one uses a canonical 1:1TRIANGLELIST vertex buffer with input layout, so no fancy manual custom buffer fetching and in-shader in
Minimal D3D11 sprite renderer: basic back-to-front sprite rendering reference code with example sprite sheet animation logic. As usual: Complete, runnable single-function app. No modern C++ / OOP / obscuring cruft.
Swap out the sprite sheet with a font atlas for alightweight GUI / text renderer. Clip individual sprites and glyphs by offsettingscreenPos andatlasPos to top left corner of visible area and adjustingsize accordingly (all values in pixels):
sprite.screenPos.x +=17;sprite.screenPos.y +=10;
A minimal Direct3D 11 implementation of "antialiased point sampling", useful for smooth fractional movement and non-integer scaling of pixel art AKA "fat pixel" aesthetics.
Also view below side-by-side point sampling comparison onYouTube (video is zoomed in to counter implicit downsampling & compression artifacts and make aa effect more apparent) or check out the originalShadertoy.
The actual sampler is set to bilinear filtering (the default D3D11 sampler state) in order to utilize single texture-read hardware interpolation, then emulating point sampling in the shader and applying AA at the fat pixel boundaries. Use withpremultiplied alpha textures* and keep a one pixel transparent border around each sprite/tile.
A quick side exercise to see how little code one can get away with to put that RGB triangle on screen using D3D11 (without bending over backwards with trickery). This is a complete app in < 40 LOC (including the HLSL).
For more.. elaborate.. D3D11 reference code, seethe original Minimal D3D11,Minimal D3D11 pt2 andMinimal D3D11 pt3
An elaboration onMinimal D3D11 pt2, adding shadowmapping and incorporating various improvements and alternative approaches to the rendering setup, such as manual vertex fetching, samplerless texture lookup, null shader depth map rendering and procedurally generated texture and instance data.
As before, this is intended to be an an "API familiarizer" - anuncluttered Direct3D 11 setup & basic rendering reference implementation, in the form of a complete, runnable Windows application contained in a single function and laid out in a linear, step-by-step fashion. No modern C++ / OOP / obscuring cruft, only ~190 LOC.View on YouTube
Follow-up toMinimal D3D11, adding instanced rendering. As before: An uncluttered Direct3D 11 setup & basic rendering primer / API familiarizer. Complete, runnable Windows application contained in a single function and laid out in a linear, step-by-step fashion. No modern C++ / OOP / obscuring cruft.
The main difference here is that the hollow cube is rendered usingDrawIndexedInstanced (which saves a lot of vertices compared to the original, so model data is now small enough to be included in the source without being too much in the way), but also all trigonometry and matrix math is moved to the vertex shader, further simplifying the main code.
Each instance is merely this piece of geometry, consisting of 4 triangles:
..which is








