From 83f79ed5eea2b3ceae6758b1e9269b8e82a23854 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Wed, 13 Aug 2014 01:04:28 -0700 Subject: [PATCH] Updated Post Processing Shaders (markdown) --- Post-Processing-Shaders.md | 125 +++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/Post-Processing-Shaders.md b/Post-Processing-Shaders.md index 6249add..7ee0ce6 100644 --- a/Post-Processing-Shaders.md +++ b/Post-Processing-Shaders.md @@ -180,6 +180,131 @@ Takes the OptionName that was defined in the configuration ```c++ float3 colour_boost = GetOption(SKY_COLOR); ``` +## Sample Shader +--- +```c++ +/* +[configuration] +[OptionBool] +GUIName = Skylight Bevel Shader +OptionName = BEVEL +DefaultValue = true + +[OptionRangeFloat] +GUIName = Skylight Amount +OptionName = SKYLIGHT_AMOUNT +MinValue = 0.0 +MaxValue = 1.0 +StepAmount = 0.05, +DefaultValue = 0.5 +DependentOption = BEVEL + +[OptionRangeFloat] +GUIName = Sky Color +OptionName = SKY_COLOR +MinValue = 0.0, 0.0, 0.0 +MaxValue = 1.0, 1.0, 1.0 +StepAmount = 0.05, 0.05, 0.05 +DefaultValue = 0.1, 0.1, 0.5 +DependentOption = BEVEL + +[OptionRangeFloat] +GUIName = Base Color +OptionName = BASE_COLOR +MinValue = 0.0, 0.0, 0.0 +MaxValue = 1.0, 1.0, 1.0 +StepAmount = 0.05, 0.05, 0.05 +DefaultValue = 0.0, 0.0, 0.1 +DependentOption = BEVEL + +[OptionRangeFloat] +GUIName = Ground Color +OptionName = GROUND_COLOR +MinValue = 0.0, 0.0, 0.0 +MaxValue = 1.0, 1.0, 1.0 +StepAmount = 0.05, 0.05, 0.05 +DefaultValue = 0.1, 0.4, 0.1 +DependentOption = BEVEL + +[OptionBool] +GUIName = Sharpen +OptionName = SHARPNESS +DefaultValue = true + +[OptionRangeFloat] +GUIName = Sharpness Amount +OptionName = SHARPNESS_VALUE +MinValue = 0.0 +MaxValue = 10.0 +StepAmount = 0.5 +DefaultValue = 1.5 +DependentOption = SHARPNESS + +[OptionBool] +GUIName = Color Boost +OptionName = COLOR_BOOST +DefaultValue = true + +[OptionRangeFloat] +GUIName = Color Boost Red +OptionName = RED_BOOST +MinValue = 0.0 +MaxValue = 5.0 +StepAmount = 0.1 +DefaultValue = 1.0 +DependentOption = COLOR_BOOST + +[OptionRangeFloat] +GUIName = Color Boost Green +OptionName = GREEN_BOOST +MinValue = 0.0 +MaxValue = 5.0 +StepAmount = 0.1 +DefaultValue = 1.0 +DependentOption = COLOR_BOOST + +[OptionRangeFloat] +GUIName = Color Boost Blue +OptionName = BLUE_BOOST +MinValue = 0.0 +MaxValue = 5.0 +StepAmount = 0.1 +DefaultValue = 1.0 +DependentOption = COLOR_BOOST +[/configuration] +*/ + +void main() { + float3 curr = Sample().xyz; + + if (OptionEnabled(SHARPNESS)) + { + float3 s0 = SampleOffset(int2(-1, -1)).xyz; + float3 s1 = SampleOffset(int2( 1, -1)).xyz; + float3 s2 = SampleOffset(int2(-1, 1)).xyz; + float3 s3 = SampleOffset(int2( 1, 1)).xyz; + float3 blur = (curr + s0 + s1 + s2 + s3) / 5; + curr = curr + (curr - blur) * GetOption(SHARPNESS_VALUE); + } + + if (OptionEnabled(BEVEL)) + { + float mid = dot(curr, float3(0.33, 0.33, 0.33)); + float top = dot(SampleOffset(int2(0, 1)).xyz, float3(0.33, 0.33, 0.33)); + float bot = dot(SampleOffset(int2(0, -1)).xyz, float3(0.33, 0.33, 0.33)); + float upw = ((top - mid) + (mid - bot)) / 4 + 0.5; + float3 col = mix(GetOption(SKY_COLOR), GetOption(GROUND_COLOR), upw); + float3 shde = mix(GetOption(BASE_COLOR), col, clamp(abs(upw * 2.0 - 1.0) * 1, 0.0, 1.0)); + curr = curr + shde * GetOption(SKYLIGHT_AMOUNT); + } + + if (OptionEnabled(COLOR_BOOST)) + curr = curr * float3(GetOption(RED_BOOST), GetOption(GREEN_BOOST), GetOption(BLUE_BOOST)); + + /* Done */ + SetOutput(float4(curr, 1.0)); +} +``` ## Translations --- **TBD** \ No newline at end of file