Created
February 4, 2019 02:43
-
-
Save equinox2k/a6a456aefb0b1688b93ac72e903e2b34 to your computer and use it in GitHub Desktop.
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
| Texture2D ShaderTexture : register(t0); | |
| SamplerState Sampler : register(s0); | |
| cbuffer PerObject: register(b0) | |
| { | |
| float4x4 ViewMatrix; | |
| float2 TextureSize; | |
| int Emboss; | |
| float Unused1; | |
| }; | |
| struct VertexShaderInput | |
| { | |
| float4 Position : SV_Position; | |
| float2 TextureUV : TEXCOORD0; | |
| }; | |
| struct VertexShaderOutput | |
| { | |
| float4 Position : SV_Position; | |
| float2 TextureUV : TEXCOORD0; | |
| }; | |
| VertexShaderOutput VSMain(VertexShaderInput input) | |
| { | |
| VertexShaderOutput output = (VertexShaderOutput)0; | |
| output.Position = mul(input.Position, ViewMatrix); | |
| output.TextureUV = input.TextureUV; | |
| return output; | |
| } | |
| float4 PSMain(VertexShaderOutput input) : SV_Target | |
| { | |
| float2 step = float2(1.0f, 1.0f) / TextureSize; | |
| float2 blv = float2(input.TextureUV.x - step.x, input.TextureUV.y - step.y); | |
| float2 trv = float2(input.TextureUV.x + step.x, input.TextureUV.y + step.y); | |
| float3 color = float3(0.5f, 0.5f, 0.5f); | |
| color -= ShaderTexture.Sample(Sampler, blv).rgb; | |
| color += ShaderTexture.Sample(Sampler, trv).rgb; | |
| float level = (((color.r + color.g + color.b) / 3.0f) - 0.5f) * 2.0f; | |
| float value1 = Emboss == 1 ? 0.0f : 1.0f; | |
| float value2 = Emboss == 1 ? 1.0f : 0.0f; | |
| if (level > 0) | |
| { | |
| return float4(value1, value1, value1, abs(level)); | |
| } | |
| return float4(value2, value2, value2, abs(level)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment