├── readme.md ├── no_csdn_magic.txt ├── Pretty Hip.hlsl ├── split alpha.hlsl ├── merge alpha.hlsl ├── merge alpha2.hlsl └── VHS Retro Video.hlsl /readme.md: -------------------------------------------------------------------------------- 1 | # Shader Stack. 2 | 3 | Some shader i write or translate. 4 | 5 | Be careful, each shader has diffierent license. -------------------------------------------------------------------------------- /no_csdn_magic.txt: -------------------------------------------------------------------------------- 1 | // magic file to keep your code away from gitcode/csdn/some fucking Chinese shit 2 | // 本文件仅用于防止垃圾爬虫网站爬取,不代表赞同相关立场。 3 | 4 | +1s 蛤蛤 苟利国家生死以 岂因祸福避趋之 5 | 习近平 毛泽东 药娘 mtf 大奶子 淫水 乳液狂飙 6 | 天安门 69 坦克 原神 7 | 反动 起义 这就是中国 中国人 8 | 文化大革命 台湾 香港 独立 自信 9 | 中国共产党 共产主义 邪教 10 | 法轮功 屠杀 11 | 华为 爱国 996 猝死 12 | 孙笑川 核废水泄露 爱国 13 | 就业率 底下 14 | -------------------------------------------------------------------------------- /Pretty Hip.hlsl: -------------------------------------------------------------------------------- 1 | // adapt from https://www.shadertoy.com/view/XsBfRW FabriceNeyret2's version 2 | uniform float4 ViewSize< 3 | bool automatic = true; 4 | >; 5 | uniform float4x4 ViewProj< 6 | bool automatic = true; 7 | >; 8 | 9 | uniform float4 Time< 10 | bool automatic = true; 11 | >; 12 | 13 | uniform float4x4 Random< 14 | bool automatic = true; 15 | >; 16 | 17 | struct VertFragData { 18 | float4 pos : POSITION; 19 | float2 uv : TEXCOORD0; 20 | }; 21 | 22 | VertFragData VSDefault(VertFragData vtx) { 23 | vtx.pos = mul(float4(vtx.pos.xyz, 1.0), ViewProj); 24 | return vtx; 25 | } 26 | 27 | float2 vertexMulMatrix(float2 v, float2x2 m) { 28 | return float2( 29 | v.x * m[0][0] + v.y * m[0][1], 30 | v.x * m[1][0] + v.y * m[1][1] 31 | ); 32 | } 33 | 34 | 35 | float4 PSDefault(VertFragData vtx) : TARGET { 36 | float2 Resolution = ViewSize.xy; 37 | float2 U=vertexMulMatrix(( vtx.pos -.5*Resolution )/Resolution.x,float2x2(1,1,-1,1))*.7 * 10.+5.; 38 | float2 F = frac(U); 39 | F = min(F,1.-F); 40 | float s = length( ceil(U) -5.5 ); 41 | float e = 2.* frac( ( Time.x - s*.5 ) / 4.) - 1.; 42 | float v = frac ( 4.* min(F.x,F.y) ); 43 | float4 output = lerp( float4(1,1,1,1), 44 | float4(107.0/255.0, 185.0/255.0, 161.0/255.0,1), 45 | smoothstep( -.05, 0., .95*(e < 0. ? v : 1.-v) - e*e) 46 | + s*.1 ); 47 | return output; 48 | } 49 | 50 | technique Draw 51 | { 52 | pass 53 | { 54 | vertex_shader = VSDefault(vtx); 55 | pixel_shader = PSDefault(vtx); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /split alpha.hlsl: -------------------------------------------------------------------------------- 1 | // Copyright 2022 Shugen002 2 | 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files 4 | // (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, 5 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 6 | // subject to the following conditions: 7 | 8 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | 10 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO 11 | // THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 12 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 13 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 14 | // DEALINGS IN THE SOFTWARE. 15 | 16 | // Version: 0.2 17 | 18 | // Usage: Load this file as shader in shader filter of Xaymar's OBS StreamFX Plugin. 19 | // (https://obsproject.com/forum/resources/streamfx-for-obs%C2%AE-studio.578/) 20 | // Suggest to apply this shader as a scene filter. 21 | 22 | // version history: 23 | // 0.1: initial release 24 | // 0.2: fix for premuliply alpha 25 | 26 | // Always provided by OBS 27 | uniform float4x4 ViewProj< 28 | bool automatic = true; 29 | string name = "View Projection Matrix"; 30 | >; 31 | 32 | uniform texture2d InputA< 33 | bool automatic = true; 34 | >; 35 | 36 | 37 | // ---------- Shader Code 38 | sampler_state def_sampler { 39 | AddressU = Clamp; 40 | AddressV = Clamp; 41 | Filter = Linear; 42 | }; 43 | 44 | struct VertData { 45 | float4 pos : POSITION; 46 | float2 uv : TEXCOORD0; 47 | }; 48 | 49 | VertData VSDefault(VertData vtx) { 50 | vtx.pos = mul(float4(vtx.pos.xyz, 1.0), ViewProj); 51 | return vtx; 52 | } 53 | 54 | float4 PSTemplate(VertData vtx) : TARGET { 55 | float2 uv = vtx.uv; 56 | if(uv.x <= 0.75){ 57 | float4 rgb= InputA.Sample(def_sampler, uv); 58 | rgb.r /= rgb.a; 59 | rgb.g /= rgb.a; 60 | rgb.b /= rgb.a; 61 | rgb.a = 1.0; 62 | return rgb; 63 | } 64 | else{ 65 | uv.x = uv.x - 0.75; 66 | float4 rgb1= InputA.Sample(def_sampler, uv); 67 | uv.x = uv.x + 0.25; 68 | float4 rgb2= InputA.Sample(def_sampler, uv); 69 | uv.x = uv.x + 0.25; 70 | float4 rgb3= InputA.Sample(def_sampler, uv); 71 | return float4(rgb1.a, rgb2.a, rgb3.a, 1.0); 72 | } 73 | } 74 | 75 | technique Draw 76 | { 77 | pass 78 | { 79 | vertex_shader = VSDefault(vtx); 80 | pixel_shader = PSTemplate(vtx); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /merge alpha.hlsl: -------------------------------------------------------------------------------- 1 | // Copyright 2022 Shugen002 2 | 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files 4 | // (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, 5 | // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 6 | // subject to the following conditions: 7 | 8 | // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | 10 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO 11 | // THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 12 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 13 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 14 | // DEALINGS IN THE SOFTWARE. 15 | 16 | // Version: 0.2 17 | 18 | // Usage: Load this file as shader in shader filter of Xaymar's OBS StreamFX Plugin 19 | // (https://obsproject.com/forum/resources/streamfx-for-obs%C2%AE-studio.578/) 20 | // and apply it to your source. 21 | 22 | // version history: 23 | // 0.1: initial release 24 | // 0.2: cleaned up code. 25 | 26 | // Always provided by OBS 27 | uniform float4x4 ViewProj< 28 | bool automatic = true; 29 | string name = "View Projection Matrix"; 30 | >; 31 | 32 | uniform texture2d InputA< 33 | bool automatic = true; 34 | >; 35 | 36 | 37 | // ---------- Shader Code 38 | sampler_state def_sampler { 39 | AddressU = Clamp; 40 | AddressV = Clamp; 41 | Filter = Linear; 42 | }; 43 | 44 | struct VertData { 45 | float4 pos : POSITION; 46 | float2 uv : TEXCOORD0; 47 | }; 48 | 49 | VertData VSDefault(VertData vtx) { 50 | vtx.pos = mul(float4(vtx.pos.xyz, 1.0), ViewProj); 51 | return vtx; 52 | } 53 | 54 | 55 | float4 PSTemplate(VertData vtx) : TARGET { 56 | float2 uv = vtx.uv; 57 | if(uv.x <= 0.25){ 58 | float4 rgb= InputA.Sample(def_sampler, uv); 59 | uv.x += 0.75; 60 | float4 rgb2= InputA.Sample(def_sampler, uv); 61 | rgb.a = rgb2.r; 62 | return rgb; 63 | }else if(uv.x <= 0.5){ 64 | float4 rgb= InputA.Sample(def_sampler, uv); 65 | uv.x += 0.5; 66 | float4 rgb2= InputA.Sample(def_sampler, uv); 67 | rgb.a = rgb2.g; 68 | return rgb; 69 | }else if(uv.x <= 0.75){ 70 | float4 rgb= InputA.Sample(def_sampler, uv); 71 | uv.x += 0.25; 72 | float4 rgb2= InputA.Sample(def_sampler, uv); 73 | rgb.a = rgb2.b; 74 | return rgb; 75 | }else{ 76 | return float4(0,0,0,0); 77 | } 78 | } 79 | 80 | technique Draw 81 | { 82 | pass 83 | { 84 | vertex_shader = VSDefault(vtx); 85 | pixel_shader = PSTemplate(vtx); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /merge alpha2.hlsl: -------------------------------------------------------------------------------- 1 | // The Star And Thank Author License (SATA) 2 | // Version 2.0, April 2021 3 | 4 | // Copyright © <2022> (shader.github@shugen.space) 5 | 6 | // Project Url: https://github.com/shugen002/shader/blob/master/merge%20alpha2.hlsl 7 | 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | 18 | // And wait, the most important, you should star/+1/like the project(s) in project url 19 | // section above first, and then thank the author(s) in Copyright section. 20 | 21 | // Here are some suggested ways: 22 | 23 | // - Email the authors a thank-you letter, and make friends with him/her/them. 24 | // - Report bugs or issues. 25 | // - Tell friends what a wonderful project this is. 26 | // - And, sure, you can just express thanks in your mind without telling the world. 27 | 28 | // Contributors of this project by forking have the option to add his/her name and 29 | // forked project url at copyright and project url sections, but shall not delete 30 | // or modify anything else in these two sections. 31 | 32 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 36 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 37 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 38 | // THE SOFTWARE. 39 | 40 | uniform float4x4 ViewProj< 41 | bool automatic = true; 42 | string name = "View Projection Matrix"; 43 | >; 44 | uniform texture2d InputA< 45 | bool automatic = true; 46 | >; 47 | 48 | sampler_state textureSampler { 49 | Filter = Linear; 50 | AddressU = Clamp; 51 | AddressV = Clamp; 52 | }; 53 | 54 | struct VertData { 55 | float4 pos : POSITION; 56 | float2 uv : TEXCOORD0; 57 | }; 58 | 59 | VertData VSDefault(VertData vtx) 60 | { 61 | vtx.pos = mul(float4(vtx.pos.xyz, 1.0), ViewProj); 62 | return vtx; 63 | } 64 | 65 | float4 PSAlphaFilter(VertData vtx) : TARGET 66 | { 67 | float2 uv = vtx.uv; 68 | float3 pixel = InputA.Sample(textureSampler, float2(vtx.uv.x, vtx.uv.y)).rgb; 69 | float alpha = InputA.Sample(textureSampler, float2(vtx.uv.x + 0.5, vtx.uv.y)).g; 70 | return float4(clamp(pixel.rgb / alpha, 0.0, 1.0), alpha); 71 | } 72 | 73 | technique Draw 74 | { 75 | pass 76 | { 77 | vertex_shader = VSDefault(vtx); 78 | pixel_shader = PSAlphaFilter(vtx); 79 | } 80 | } -------------------------------------------------------------------------------- /VHS Retro Video.hlsl: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // Defines 3 | //------------------------------------------------------------------------------ 4 | // Variations of PI/TAU 5 | #define PI 3.141592653 6 | #define TAU 6.283185307 7 | #define PIm2 6.283185307 8 | #define PIb2 1.570796326 9 | #define PIb4 0.785398163 10 | 11 | // Phi/Φ = Golden Ratio 12 | #define PHI 1.61803398874989484820459 13 | 14 | // e (Eulers Constant) 15 | #define EULERS_CONSTANT 2,7182818284590452353602874713527 16 | 17 | // Degrees <-> Radians Conversion 18 | #define TO_RAD(x) (x * 0.017453292) 19 | #define TO_DEG(x) (x * 57.295779513) 20 | 21 | //------------------------------------------------------------------------------ 22 | // Uniforms 23 | //------------------------------------------------------------------------------ 24 | uniform float4x4 ViewProj< 25 | bool automatic = true; 26 | >; 27 | 28 | uniform float4 Time< 29 | bool automatic = true; 30 | >; 31 | 32 | 33 | // Filter Support 34 | #ifdef IS_FILTER 35 | uniform texture2d InputA< 36 | bool automatic = true; 37 | >; 38 | #endif 39 | 40 | // Transition Support 41 | #ifdef IS_TRANSITION 42 | uniform texture2d InputA< 43 | bool automatic = true; 44 | >; 45 | 46 | uniform texture2d InputB< 47 | bool automatic = true; 48 | >; 49 | 50 | uniform float TransitionTime< 51 | bool automatic = true; 52 | >; 53 | #endif 54 | 55 | uniform int RandomSeed< 56 | bool automatic = true; 57 | >; 58 | 59 | uniform float4x4 Random< 60 | bool automatic = true; 61 | >; 62 | 63 | //------------------------------------------------------------------------------ 64 | // Structures 65 | //------------------------------------------------------------------------------ 66 | struct VertexInformation { 67 | float4 position : POSITION; 68 | float4 texcoord0 : TEXCOORD0; 69 | }; 70 | 71 | //------------------------------------------------------------------------------ 72 | // Samplers 73 | //------------------------------------------------------------------------------ 74 | sampler_state PointRepeatSampler { 75 | Filter = Point; 76 | AddressU = Repeat; 77 | AddressV = Repeat; 78 | }; 79 | sampler_state LinearRepeatSampler { 80 | Filter = Linear; 81 | AddressU = Repeat; 82 | AddressV = Repeat; 83 | }; 84 | 85 | sampler_state PointClampSampler { 86 | Filter = Point; 87 | AddressU = Clamp; 88 | AddressV = Clamp; 89 | }; 90 | sampler_state LinearClampSampler { 91 | Filter = Linear; 92 | AddressU = Clamp; 93 | AddressV = Clamp; 94 | }; 95 | 96 | //------------------------------------------------------------------------------ 97 | // Functions 98 | //------------------------------------------------------------------------------ 99 | VertexInformation DefaultVertexShader(VertexInformation vtx) { 100 | vtx.position = mul(float4(vtx.position.xyz, 1.0), ViewProj); 101 | return vtx; 102 | }; 103 | 104 | bool is_float_equal(float a, float b) { 105 | return (abs(a - b) <= .00001); 106 | } 107 | 108 | // Always provided by OBS 109 | uniform float4x4 ViewProj< 110 | bool automatic = true; 111 | >; 112 | 113 | // Provided by Stream Effects 114 | 115 | uniform float4 ViewSize< 116 | bool automatic = true; 117 | >; 118 | uniform texture2d InputA< 119 | bool automatic = true; 120 | >; 121 | 122 | 123 | // ---------- Shader Code 124 | 125 | 126 | struct VertFragData { 127 | float4 pos : POSITION; 128 | float2 uv : TEXCOORD0; 129 | }; 130 | 131 | sampler_state MeshTextureSampler 132 | { 133 | Filter = MIN_MAG_MIP_LINEAR; 134 | AddressU = Wrap; 135 | AddressV = Wrap; 136 | }; 137 | 138 | VertFragData VSDefault(VertFragData vtx) { 139 | vtx.pos = mul(float4(vtx.pos.xyz, 1.0), ViewProj); 140 | return vtx; 141 | } 142 | 143 | float4 PSDefault(VertFragData vtx) : TARGET { 144 | float xyratio = ViewSize.x / ViewSize.y; 145 | vtx.uv *= float2(ViewSize.x/2., ViewSize.y/2.); 146 | vtx.uv = floor(vtx.uv); 147 | vtx.uv /= float2(ViewSize.x/2., ViewSize.y/2.); 148 | vtx.uv.x -= (step(frac(Time.x * .4), vtx.uv.y) * .005); 149 | float4 colorR = InputA.Sample(MeshTextureSampler, vtx.uv); 150 | float4 colorG = InputA.Sample(MeshTextureSampler, vtx.uv + float2(0., 0.005)); 151 | float4 colorB = InputA.Sample(MeshTextureSampler, vtx.uv - float2(0.005/xyratio, 0.)); 152 | colorR.r = 1. - cos(.5 * PI * colorR.r); 153 | colorG.g = 1. - cos(.5 * PI * colorG.g); 154 | colorB.b = 1. - cos(.5 * PI * colorB.b); 155 | return float4(colorR.r, colorG.g, colorB.b, 1.); 156 | } 157 | 158 | technique Draw 159 | { 160 | pass 161 | { 162 | vertex_shader = VSDefault(vtx); 163 | pixel_shader = PSDefault(vtx); 164 | } 165 | } 166 | --------------------------------------------------------------------------------