-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added experimental.pixelShaderImagePath (#14073)
I realize I might be one of the few developers that care about custom shader support in terminal but I thought it's worth proposing it and see what you think. This is to support custom shaders with custom textures. I was thinking of exposing the background image to the shader but that felt complicated after looking into it. I have tested exploratively. I think the texture loader is possible to unit test so that is a possible improvement. The error reporting (as with other custom pixel shader code) is not very good. That is also an area that I could improve upon. I do think the risk of adding this is rather low as the new code is only executed when experimental.pixelShaderImagePath is set. ### Details Only added to the Atlas engine. Instead I load the texture using WIC into a shader resource view. When binding shader resources I test for presence of custom texture and bind it to register t1. The image loading code was found in [the D3D Texture documentation]. It's a mouthful but seems rather robust. Tested setting: "experimental.pixelShaderImagePath" 1. Tested not specifying it. 2. Tested setting it. 3. Tested changing it (the changes are picked up) 4. Tested invalid path 5. Tested a custom shader that made use of the custom texture. [the D3D Texture documentation]: https://learn.microsoft.com/en-us/windows/win32/direct3d11/overviews-direct3d-11-resources-textures-how-to Co-authored-by: Mike Griese <[email protected]> Co-authored-by: Leonard Hecker <[email protected]>
- Loading branch information
1 parent
8a1e8ac
commit 0ba680a
Showing
21 changed files
with
250 additions
and
61 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Demo shader to show passing in an image using | ||
// experimental.pixelShaderImagePath. This shader simply displays the Terminal | ||
// contents on top of the given image. | ||
// | ||
// The image loaded by the terminal will be placed into the `image` texture. | ||
|
||
SamplerState samplerState; | ||
Texture2D shaderTexture : register(t0); | ||
Texture2D image : register(t1); | ||
|
||
cbuffer PixelShaderSettings { | ||
float Time; | ||
float Scale; | ||
float2 Resolution; | ||
float4 Background; | ||
}; | ||
|
||
float4 main(float4 pos : SV_POSITION, float2 tex : TEXCOORD) : SV_TARGET | ||
{ | ||
float4 terminalColor = shaderTexture.Sample(samplerState, tex); | ||
float4 imageColor = image.Sample(samplerState, tex); | ||
return lerp(imageColor, terminalColor, terminalColor.a); | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.