// Copyright (C) Microsoft Corporation. All rights reserved. // On update: build, rename & replace OutlineEffect.cso // OutlineEffect.hlsl #define D2D_INPUT_COUNT 2 #define D2D_REQUIRES_SCENE_POSITION #include "D2d1effecthelpers.hlsli" float2 resolution; uint isSingleColor; uint isHighContrastEnabled; float4 highContrastColor1; float4 highContrastColor2; // Gradient stops for curve static const float4 colorOne = float4(0.0, 0.47, 0.83, 1.0); // RGBA - DiscoveryAccentBlue static const float4 colorTwo = float4(0.71, 0.49, 0.97, 1.0); // RGBA - DiscoveryAccentPurple static const float4 colorThree = float4(0.96, 0.3, 0.44, 1.0); // RGBA - DiscoveryAccentPink static const float4 colorWhite = float4(1.0, 1.0, 1.0, 1.0); // RGBA - Standard white color static const float4 colorEmpty = float4(0.0, 0.0, 0.0, 0.0); // Empty (fully transparent) pixel D2D_PS_ENTRY(main) { // 0: Blur mask for the outline // 1: Original object mask float2 fragCoord = D2DGetScenePosition().xy; if (D2DSampleInputAtPosition(0, fragCoord).a == 0.0) { // If the blur mask was empty here, then the output should be empty return colorEmpty; } if ((D2DSampleInputAtPosition(0, fragCoord).a != 0.0) && (D2DSampleInputAtPosition(1, fragCoord).a != 0.0)) { // If both the blur and the original were showing, the output should be empty return colorEmpty; } else { if (isSingleColor) { if (isHighContrastEnabled) { return highContrastColor2; } else { return colorWhite; } } else { if (isHighContrastEnabled) { return highContrastColor1; } else { // Compute gradient factor: 0 at curve, 1 at bottom of screen float position = fragCoord.y / resolution.y; // Normalized position from 0 to 1 if (position < 0.8f) { // Use colorOne for the first 80% of the screen return lerp(colorOne, colorTwo, position / 0.8f); } else { // Use colorTwo for the last 20% of the screen return lerp(colorTwo, colorThree, (position - 0.8f) / 0.2f); } } } } }