An elaboration on Minimal 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](https://gist.github.com/d7samurai/abab8a580d0298cb2f34a44eec41d39d#file-shader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma once | |
| // | |
| // Magic Ring Buffer | |
| // https://gist.github.com/mmozeiko/3b09a340f3c53e5eaed699a1aea95250 | |
| // | |
| // Sets up memory mapping so the same memory block follows itself in virtual address space: | |
| // | |
| // [abcd...xyz][abc...xyz] | |
| // |
Follow-up to Minimal 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 using instancing (which saves a lot of vertices compared to the original, so geometry 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.
In this case, each instance is merely this piece of geometry, consisting of 4 triangles:
[![instance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma once | |
| #include <stdint.h> | |
| // pcg32_next() implementation matches pcg_engines::oneseq_xsh_rr_64_32 | |
| // NOTE: use this only for compatibility with 32-bit architectures | |
| // otherwise prefer using pcg64.h implementation with 128-bit state | |
| typedef struct { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // example how to set up D3D11 rendering on Windows in C | |
| #define COBJMACROS | |
| #define WIN32_LEAN_AND_MEAN | |
| #include <windows.h> | |
| #include <d3d11.h> | |
| #include <dxgi1_3.h> | |
| #include <d3dcompiler.h> | |
| #include <dxgidebug.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define COBJMACROS | |
| #define NOMINMAX | |
| #define WIN32_LEAN_AND_MEAN | |
| #include <windows.h> | |
| #include <d3d11.h> | |
| #include <stdint.h> | |
| #include <string.h> | |
| #include <intrin.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma once | |
| namespace YourNamespace | |
| { | |
| struct Routine | |
| { | |
| // Current "waiting time" before we run the next block | |
| float wait_for = 0; | |
| // Used during `rt_for`, which repeats the given block for X time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // NOTE Compile without fast math flags. | |
| /* | |
| This is free and unencumbered software released into the public domain. | |
| Anyone is free to copy, modify, publish, use, compile, sell, or | |
| distribute this software, either in source code form or as a compiled | |
| binary, for any purpose, commercial or non-commercial, and by any | |
| means. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Shader "CustomPBRShader" | |
| { | |
| Properties | |
| { | |
| [NoScaleOffset] _Albedo("Albedo", Color) = (1.0, 1.0, 1.0, 1.0) | |
| [NoScaleOffset] _Metalness("Conductivity", Range(0.0, 1.0)) = 0.0 | |
| [NoScaleOffset] _Roughness("Roughness", Range(0.0, 1.0)) = 0.0 | |
| [NoScaleOffset][HDR] _RadianceMap("RadianceMap", CUBE) = "" {} | |
| [NoScaleOffset][HDR] _IrradianceMap("IrradianceMap", CUBE) = "" {} | |
| } |
- 2011 - A trip through the Graphics Pipeline 2011
- 2013 - Performance Optimization Guidelines and the GPU Architecture behind them
- 2015 - Life of a triangle - NVIDIA's logical pipeline
- 2015 - Render Hell 2.0
- 2016 - How bad are small triangles on GPU and why?
- 2017 - GPU Performance for Game Artists
- 2019 - Understanding the anatomy of GPUs using Pokémon
NewerOlder
