Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,43 @@ When reviewing documentation, do the following:
- Read the documentation on the wiki located in [this git repository](https://github.com/microsoft/DirectXTK.wiki.git).
- Report any specific gaps in the documentation compared to the public interface.

## Code Change Rules

- Make precise, surgical changes that **fully** address the request. Don't modify unrelated code, but ensure changes are complete and correct.
- Don't fix pre-existing issues unrelated to your task. However, if you discover bugs directly caused by or tightly coupled to the code you're changing, fix those too.
- Update documentation if it is directly related to the changes you are making.
- Always validate that your changes don't break existing behavior.

### Linting, Building, Testing

- Only run linters, builds and tests that already exist. Do not add new linting, building or testing tools unless necessary for the task.
- Use the smallest targeted test, build, or lint command that covers the changed behavior. When related targeted selectors use the same runner, include them in one invocation; escalate to full-suite or baseline runs only when targeted validation shows they are needed.
- Documentation changes do not need to be linted, built or tested unless there are specific tests for documentation.

### Using Ecosystem Tools

- Prefer ecosystem tools (package managers, scaffolding, refactoring tools, linters) over manual changes.
- Install packages only when changing dependencies or after a missing-dependency failure.

### Code Commenting Style

- Only comment code that needs a bit of clarification. Do not comment otherwise.

## Release Process

The release process is documented in the [release skill](.github/skills/release/SKILL.md). Invoke the `release` skill for step-by-step guidance when performing a release.

## CoPilot Skills

The project includes published CoPilot skills for developers:

- **Release-Process**: Guide for performing the DirectX Tool Kit release process. Invoked when asked to help with releasing a new version, publishing packages, or updating ports. See [Release Process skill](.github/skills/release/SKILL.md) for details.
- **directxtk-usage**: Provides usage guidance for the DirectX Tool Kit for DX11 library. Located in the `skills/directxtk-usage/` directory.
- **directxtk-tutorial**: Provides an interactive tutorial which can create a project, add the toolkit, and implement features in a step-by-step fashion. Located in the `skills/directxtk-tutorial` directory.

To use these skills in the Copilot CLI:

```bash
/skills list
/skills search directxtk
```
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ set(LIBRARY_SOURCES
Src/DDSTextureLoader.cpp
Src/DebugEffect.cpp
Src/DGSLEffect.cpp
Src/NPREffect.cpp
Src/DGSLEffectFactory.cpp
Src/DirectXHelpers.cpp
Src/DualPostProcess.cpp
Expand Down Expand Up @@ -150,6 +151,7 @@ set(SHADER_SOURCES
Src/Shaders/AlphaTestEffect.fx
Src/Shaders/BasicEffect.fx
Src/Shaders/DebugEffect.fx
Src/Shaders/NPREffect.fx
Src/Shaders/DGSLEffect.fx
Src/Shaders/DGSLLambert.hlsl
Src/Shaders/DGSLPhong.hlsl
Expand Down
4 changes: 4 additions & 0 deletions DirectXTK_Desktop_2022.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<ClCompile Include="Src\CommonStates.cpp" />
<ClCompile Include="Src\DDSTextureLoader.cpp" />
<ClCompile Include="Src\DebugEffect.cpp" />
<ClCompile Include="Src\NPREffect.cpp" />
<ClCompile Include="Src\DGSLEffect.cpp" />
<ClCompile Include="Src\DGSLEffectFactory.cpp" />
<ClCompile Include="Src\DirectXHelpers.cpp" />
Expand Down Expand Up @@ -179,6 +180,9 @@
<None Include="Src\Shaders\DebugEffect.fx">
<FileType>Document</FileType>
</None>
<None Include="Src\Shaders\NPREffect.fx">
<FileType>Document</FileType>
</None>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{E0B52AE7-E160-4D32-BF3F-910B785E5A8E}</ProjectGuid>
Expand Down
6 changes: 6 additions & 0 deletions DirectXTK_Desktop_2022.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@
<ClCompile Include="Src\DebugEffect.cpp">
<Filter>Src</Filter>
</ClCompile>
<ClCompile Include="Src\NPREffect.cpp">
<Filter>Src</Filter>
</ClCompile>
<ClCompile Include="Src\PBREffectFactory.cpp">
<Filter>Src</Filter>
</ClCompile>
Expand Down Expand Up @@ -352,6 +355,9 @@
<None Include="Src\Shaders\DebugEffect.fx">
<Filter>Src\Shaders</Filter>
</None>
<None Include="Src\Shaders\NPREffect.fx">
<Filter>Src\Shaders</Filter>
</None>
<None Include="Src\Shaders\PixelPacking_Velocity.hlsli">
<Filter>Src\Shaders\Shared</Filter>
</None>
Expand Down
4 changes: 4 additions & 0 deletions DirectXTK_Desktop_2022_Win10.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<ClCompile Include="Src\CommonStates.cpp" />
<ClCompile Include="Src\DDSTextureLoader.cpp" />
<ClCompile Include="Src\DebugEffect.cpp" />
<ClCompile Include="Src\NPREffect.cpp" />
<ClCompile Include="Src\DGSLEffect.cpp" />
<ClCompile Include="Src\DGSLEffectFactory.cpp" />
<ClCompile Include="Src\DirectXHelpers.cpp" />
Expand Down Expand Up @@ -189,6 +190,9 @@
<None Include="Src\Shaders\DebugEffect.fx">
<FileType>Document</FileType>
</None>
<None Include="Src\Shaders\NPREffect.fx">
<FileType>Document</FileType>
</None>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{E0B52AE7-E160-4D32-BF3F-910B785E5A8E}</ProjectGuid>
Expand Down
6 changes: 6 additions & 0 deletions DirectXTK_Desktop_2022_Win10.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@
<ClCompile Include="Src\DebugEffect.cpp">
<Filter>Src</Filter>
</ClCompile>
<ClCompile Include="Src\NPREffect.cpp">
<Filter>Src</Filter>
</ClCompile>
<ClCompile Include="Src\PBREffectFactory.cpp">
<Filter>Src</Filter>
</ClCompile>
Expand Down Expand Up @@ -352,6 +355,9 @@
<None Include="Src\Shaders\DebugEffect.fx">
<Filter>Src\Shaders</Filter>
</None>
<None Include="Src\Shaders\NPREffect.fx">
<Filter>Src\Shaders</Filter>
</None>
<None Include="Src\Shaders\PixelPacking_Velocity.hlsli">
<Filter>Src\Shaders\Shared</Filter>
</None>
Expand Down
4 changes: 4 additions & 0 deletions DirectXTK_Desktop_2026.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<ClCompile Include="Src\CommonStates.cpp" />
<ClCompile Include="Src\DDSTextureLoader.cpp" />
<ClCompile Include="Src\DebugEffect.cpp" />
<ClCompile Include="Src\NPREffect.cpp" />
<ClCompile Include="Src\DGSLEffect.cpp" />
<ClCompile Include="Src\DGSLEffectFactory.cpp" />
<ClCompile Include="Src\DirectXHelpers.cpp" />
Expand Down Expand Up @@ -189,6 +190,9 @@
<None Include="Src\Shaders\DebugEffect.fx">
<FileType>Document</FileType>
</None>
<None Include="Src\Shaders\NPREffect.fx">
<FileType>Document</FileType>
</None>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{E0B52AE7-E160-4D32-BF3F-910B785E5A8E}</ProjectGuid>
Expand Down
6 changes: 6 additions & 0 deletions DirectXTK_Desktop_2026.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@
<ClCompile Include="Src\DebugEffect.cpp">
<Filter>Src</Filter>
</ClCompile>
<ClCompile Include="Src\NPREffect.cpp">
<Filter>Src</Filter>
</ClCompile>
<ClCompile Include="Src\PBREffectFactory.cpp">
<Filter>Src</Filter>
</ClCompile>
Expand Down Expand Up @@ -352,6 +355,9 @@
<None Include="Src\Shaders\DebugEffect.fx">
<Filter>Src\Shaders</Filter>
</None>
<None Include="Src\Shaders\NPREffect.fx">
<Filter>Src\Shaders</Filter>
</None>
<None Include="Src\Shaders\PixelPacking_Velocity.hlsli">
<Filter>Src\Shaders\Shared</Filter>
</None>
Expand Down
2 changes: 2 additions & 0 deletions DirectXTK_GDKW_2022.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@
<ClCompile Include="Src\CommonStates.cpp" />
<ClCompile Include="Src\DDSTextureLoader.cpp" />
<ClCompile Include="Src\DebugEffect.cpp" />
<ClCompile Include="Src\NPREffect.cpp" />
<ClCompile Include="Src\DGSLEffect.cpp" />
<ClCompile Include="Src\DGSLEffectFactory.cpp" />
<ClCompile Include="Src\DirectXHelpers.cpp" />
Expand Down Expand Up @@ -469,6 +470,7 @@
<None Include="Src\Shaders\ToneMap.fx" />
<None Include="Src\Shaders\PBREffect.fx" />
<None Include="Src\Shaders\DebugEffect.fx" />
<None Include="Src\Shaders\NPREffect.fx" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
Expand Down
6 changes: 6 additions & 0 deletions DirectXTK_GDKW_2022.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@
<ClCompile Include="Src\DebugEffect.cpp">
<Filter>Src</Filter>
</ClCompile>
<ClCompile Include="Src\NPREffect.cpp">
<Filter>Src</Filter>
</ClCompile>
<ClCompile Include="Src\PBREffectFactory.cpp">
<Filter>Src</Filter>
</ClCompile>
Expand Down Expand Up @@ -354,6 +357,9 @@
<None Include="Src\Shaders\DebugEffect.fx">
<Filter>Src\Shaders</Filter>
</None>
<None Include="Src\Shaders\NPREffect.fx">
<Filter>Src\Shaders</Filter>
</None>
<None Include="Src\Shaders\PixelPacking_Velocity.hlsli">
<Filter>Src\Shaders\Shared</Filter>
</None>
Expand Down
2 changes: 2 additions & 0 deletions DirectXTK_GDK_2022.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
<ClCompile Include="Src\CommonStates.cpp" />
<ClCompile Include="Src\DDSTextureLoader.cpp" />
<ClCompile Include="Src\DebugEffect.cpp" />
<ClCompile Include="Src\NPREffect.cpp" />
<ClCompile Include="Src\DGSLEffect.cpp" />
<ClCompile Include="Src\DGSLEffectFactory.cpp" />
<ClCompile Include="Src\DirectXHelpers.cpp" />
Expand Down Expand Up @@ -291,6 +292,7 @@
<None Include="Src\Shaders\ToneMap.fx" />
<None Include="Src\Shaders\PBREffect.fx" />
<None Include="Src\Shaders\DebugEffect.fx" />
<None Include="Src\Shaders\NPREffect.fx" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
Expand Down
6 changes: 6 additions & 0 deletions DirectXTK_GDK_2022.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@
<ClCompile Include="Src\DebugEffect.cpp">
<Filter>Src</Filter>
</ClCompile>
<ClCompile Include="Src\NPREffect.cpp">
<Filter>Src</Filter>
</ClCompile>
<ClCompile Include="Src\PBREffectFactory.cpp">
<Filter>Src</Filter>
</ClCompile>
Expand Down Expand Up @@ -354,6 +357,9 @@
<None Include="Src\Shaders\DebugEffect.fx">
<Filter>Src\Shaders</Filter>
</None>
<None Include="Src\Shaders\NPREffect.fx">
<Filter>Src\Shaders</Filter>
</None>
<None Include="Src\Shaders\PixelPacking_Velocity.hlsli">
<Filter>Src\Shaders\Shared</Filter>
</None>
Expand Down
4 changes: 4 additions & 0 deletions DirectXTK_Windows10_2022.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
<ClCompile Include="Src\CommonStates.cpp" />
<ClCompile Include="Src\DDSTextureLoader.cpp" />
<ClCompile Include="Src\DebugEffect.cpp" />
<ClCompile Include="Src\NPREffect.cpp" />
<ClCompile Include="Src\DGSLEffect.cpp" />
<ClCompile Include="Src\DGSLEffectFactory.cpp" />
<ClCompile Include="Src\DirectXHelpers.cpp" />
Expand Down Expand Up @@ -191,6 +192,9 @@
<None Include="Src\Shaders\DebugEffect.fx">
<FileType>Document</FileType>
</None>
<None Include="Src\Shaders\NPREffect.fx">
<FileType>Document</FileType>
</None>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{f4776924-619c-42c7-88b2-82c947ccc9e7}</ProjectGuid>
Expand Down
6 changes: 6 additions & 0 deletions DirectXTK_Windows10_2022.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@
<None Include="Src\Shaders\DebugEffect.fx">
<Filter>Src\Shaders</Filter>
</None>
<None Include="Src\Shaders\NPREffect.fx">
<Filter>Src\Shaders</Filter>
</None>
<None Include="Src\Shaders\PixelPacking_Velocity.hlsli">
<Filter>Src\Shaders\Shared</Filter>
</None>
Expand Down Expand Up @@ -347,6 +350,9 @@
<ClCompile Include="Src\DebugEffect.cpp">
<Filter>Src</Filter>
</ClCompile>
<ClCompile Include="Src\NPREffect.cpp">
<Filter>Src</Filter>
</ClCompile>
<ClCompile Include="Src\PBREffectFactory.cpp">
<Filter>Src</Filter>
</ClCompile>
Expand Down
95 changes: 94 additions & 1 deletion Inc/Effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ namespace DirectX
// Vertex color setting.
DIRECTX_TOOLKIT_API void __cdecl SetVertexColorEnabled(bool value);

// Texture setting.
// Texture settings.
DIRECTX_TOOLKIT_API void __cdecl SetTextureEnabled(bool value);
DIRECTX_TOOLKIT_API void __cdecl SetTexture(_In_opt_ ID3D11ShaderResourceView* value);

Expand Down Expand Up @@ -878,6 +878,99 @@ namespace DirectX
std::unique_ptr<Impl> pImpl;
};

//------------------------------------------------------------------------------
// Built-in shader for non-photorealistic rendering (cel shading, Gooch shading).
class NPREffect : public IEffect, public IEffectMatrices, public IEffectLights
{
public:
enum Mode : uint32_t
{
Mode_Cel = 0, // Cel (toon) shading
Mode_Gooch, // Gooch shading
};

DIRECTX_TOOLKIT_API explicit NPREffect(_In_ ID3D11Device* device);

DIRECTX_TOOLKIT_API NPREffect(NPREffect&&) noexcept;
DIRECTX_TOOLKIT_API NPREffect& operator= (NPREffect&&) noexcept;

NPREffect(NPREffect const&) = delete;
NPREffect& operator= (NPREffect const&) = delete;

DIRECTX_TOOLKIT_API ~NPREffect() override;

// IEffect methods.
DIRECTX_TOOLKIT_API void __cdecl Apply(_In_ ID3D11DeviceContext* deviceContext) override;

DIRECTX_TOOLKIT_API void __cdecl GetVertexShaderBytecode(
_Out_ void const** pShaderByteCode,
_Out_ size_t* pByteCodeLength) override;

// Camera settings.
DIRECTX_TOOLKIT_API void XM_CALLCONV SetWorld(FXMMATRIX value) override;
DIRECTX_TOOLKIT_API void XM_CALLCONV SetView(FXMMATRIX value) override;
DIRECTX_TOOLKIT_API void XM_CALLCONV SetProjection(FXMMATRIX value) override;
DIRECTX_TOOLKIT_API void XM_CALLCONV SetMatrices(FXMMATRIX world, CXMMATRIX view, CXMMATRIX projection) override;

// Material settings.
DIRECTX_TOOLKIT_API void XM_CALLCONV SetDiffuseColor(FXMVECTOR value);
DIRECTX_TOOLKIT_API void XM_CALLCONV SetSpecularColor(FXMVECTOR value);
DIRECTX_TOOLKIT_API void __cdecl SetSpecularThreshold(float threshold, float smoothing);
DIRECTX_TOOLKIT_API void __cdecl DisableSpecular();
DIRECTX_TOOLKIT_API void __cdecl SetAlpha(float value);
DIRECTX_TOOLKIT_API void XM_CALLCONV SetColorAndAlpha(FXMVECTOR value);

// Light settings.
void XM_CALLCONV SetLightDirection(int whichLight, FXMVECTOR value) override;
DIRECTX_TOOLKIT_API void __cdecl EnableDefaultLighting() override;

static constexpr int MaxDirectionalLights = 1;

// Texture settings.
DIRECTX_TOOLKIT_API void __cdecl SetTextureEnabled(bool value);
DIRECTX_TOOLKIT_API void __cdecl SetTexture(_In_opt_ ID3D11ShaderResourceView* value);

// Shader mode setting.
DIRECTX_TOOLKIT_API void __cdecl SetMode(Mode mode);

// Cel shading setting.
DIRECTX_TOOLKIT_API void __cdecl SetCelShaderBands(int bands);

// Gooch shading settings.
DIRECTX_TOOLKIT_API void XM_CALLCONV SetGoochCoolColor(FXMVECTOR value, float alpha = 0.25f);
DIRECTX_TOOLKIT_API void XM_CALLCONV SetGoochWarmColor(FXMVECTOR value, float beta = 0.25f);

// Rim lighting settings.
DIRECTX_TOOLKIT_API void XM_CALLCONV SetRimLightingColor(FXMVECTOR value);
DIRECTX_TOOLKIT_API void __cdecl SetRimLightingPower(float power);
DIRECTX_TOOLKIT_API void __cdecl SetRimLightingIntensity(float strength);
DIRECTX_TOOLKIT_API void __cdecl SetRimLightingRange(float start, float end);
DIRECTX_TOOLKIT_API void __cdecl DisableRimLighting();

// Vertex color setting.
DIRECTX_TOOLKIT_API void __cdecl SetVertexColorEnabled(bool value);

// Normal compression settings.
DIRECTX_TOOLKIT_API void __cdecl SetBiasedVertexNormals(bool value);

// Instancing settings.
DIRECTX_TOOLKIT_API void __cdecl SetInstancingEnabled(bool value);

private:
// Private implementation.
class Impl;

std::unique_ptr<Impl> pImpl;

// Unsupported interface methods.
DIRECTX_TOOLKIT_API void __cdecl SetLightingEnabled(bool value) override;
DIRECTX_TOOLKIT_API void __cdecl SetPerPixelLighting(bool value) override;
DIRECTX_TOOLKIT_API void XM_CALLCONV SetAmbientLightColor(FXMVECTOR value) override;
DIRECTX_TOOLKIT_API void __cdecl SetLightEnabled(int whichLight, bool value) override;
DIRECTX_TOOLKIT_API void XM_CALLCONV SetLightDiffuseColor(int whichLight, FXMVECTOR value) override;
DIRECTX_TOOLKIT_API void XM_CALLCONV SetLightSpecularColor(int whichLight, FXMVECTOR value) override;
};

//------------------------------------------------------------------------------
// Abstract interface to factory for sharing effects and texture resources
class DIRECTX_TOOLKIT_API IEffectFactory
Expand Down
Loading
Loading