├── .editorconfig ├── .github ├── dependabot.yml └── workflows │ └── ci.yml ├── .gitignore ├── KaxamlPlugins ├── .editorconfig ├── Controls │ ├── AlphaChooser.cs │ ├── Coerce.cs │ ├── ColorChangedEventArgs.cs │ ├── ColorPicker.cs │ ├── ColorPickerUtil.cs │ ├── CursorAdorner.cs │ ├── DropDownColorPicker.cs │ ├── ElementCursorDecorator.cs │ ├── HueChooser.cs │ └── SaturationBrightnessChooser.cs ├── KaxamlPlugins.csproj ├── Properties │ └── AssemblyInfo.cs ├── RoundConverter.cs └── Themes │ └── generic.xaml ├── LICENSE ├── README.md ├── Settings.XamlStyler ├── Shazzam.sln ├── Shazzam.sln.DotSettings ├── Shazzam ├── .editorconfig ├── App.xaml ├── App.xaml.cs ├── CodeGen │ ├── CodeParser.cs │ ├── CompilerException.cs │ ├── Register.cs │ ├── ShaderClass.cs │ ├── ShaderCompiler.cs │ ├── ShaderModel.cs │ └── ShaderProfile.cs ├── Commands │ ├── AppCommands.cs │ ├── RelayCommand.cs │ └── RelayCommand`1.cs ├── Constants.cs ├── Controls │ ├── AdjustableColor.xaml │ ├── AdjustableColor.xaml.cs │ ├── AdjustableSlider.xaml │ ├── AdjustableSlider.xaml.cs │ ├── AdjustableSliderPair.xaml │ ├── AdjustableSliderPair.xaml.cs │ ├── AdjustableSliderQuadruplet.xaml │ ├── AdjustableSliderQuadruplet.xaml.cs │ ├── AdjustableSliderTriplet.xaml │ ├── AdjustableSliderTriplet.xaml.cs │ ├── HorizontalRevealMode.cs │ ├── Icons.xaml │ ├── Icons.xaml.cs │ ├── IndexOddEven.cs │ ├── IndexingStackPanel.cs │ ├── RangeControl.xaml │ ├── RangeControl.xaml.cs │ ├── Reveal.cs │ ├── SelectionLocation.cs │ ├── StackLocation.cs │ ├── TextureMapLocator.cs │ ├── TexturePicker.xaml │ ├── TexturePicker.xaml.cs │ └── VerticalRevealMode.cs ├── Converters │ ├── AnyToVisibilityConverter.cs │ ├── DoubleToStringConverter.cs │ ├── EqualityConverter.cs │ ├── InvertBooleanConverter.cs │ ├── RegisterTemplateSelector.cs │ ├── RegisterValueConverter.cs │ ├── StretchToIsCheckedConverter.cs │ ├── StringToVisibilityConverter.cs │ ├── UniversalTemplateSelector.cs │ └── VisiblityToVisibilityConverter.cs ├── D3DCompiler_40.dll ├── D3DX9_40.dll ├── D3DX9_40_64bit.dll ├── Fonts │ ├── Candara.ttf │ ├── Miramo.ttf │ └── Peric.ttf ├── Helpers │ ├── ColorExtensions.cs │ ├── Hsv.cs │ └── VersionHelper.cs ├── Images │ ├── ColorRange.png │ ├── Default │ │ ├── ColorRange.png │ │ ├── Geese.jpg │ │ └── crystal.jpg │ ├── Fire1.jpg │ ├── Light1.jpg │ ├── SpikeBalls.jpg │ ├── Star.png │ ├── SwirlLogo2.png │ ├── TextureMaps │ │ ├── bubbles.png │ │ ├── cactus.jpg │ │ ├── clouds.png │ │ ├── clover.png │ │ ├── color_range.png │ │ ├── curlique.png │ │ ├── curlique_small.png │ │ ├── flower.png │ │ ├── fractal_bands.png │ │ ├── fractal_butterfly.png │ │ ├── fractal_centerband.png │ │ ├── fractal_curls.png │ │ ├── fractal_edge.png │ │ ├── fractal_flame.png │ │ ├── glassblocks_big.png │ │ ├── glassblocks_medium.png │ │ ├── glassblocks_simple.png │ │ ├── koch_cubist.png │ │ ├── koch_snowflake.png │ │ ├── mawn.png │ │ ├── moire.png │ │ ├── noise.png │ │ ├── noise_bumpy.png │ │ ├── noise_weave.png │ │ ├── oil_slick.png │ │ ├── paise.png │ │ ├── paise2.png │ │ ├── peaks_horizontal.png │ │ ├── peaks_vertical.png │ │ ├── ring_center.png │ │ ├── ripple.png │ │ ├── rippled_glass.png │ │ ├── river.png │ │ ├── sand.png │ │ ├── streaks_aurora.png │ │ ├── streaks_grass.png │ │ ├── streaks_vertical.png │ │ ├── swirly.png │ │ ├── waves_horizontal.png │ │ ├── waves_vertical.png │ │ └── whirlpool.png │ ├── cactus.jpg │ ├── connect.png │ ├── disconnect.png │ ├── disk.png │ ├── gears.jpg │ ├── help.ico │ ├── lines.jpg │ ├── logo.ico │ ├── page_copy.png │ ├── plasma.wmv │ └── square.png ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── MainWindowViewModel.cs ├── Plugins │ ├── FileLoaderViewer.xaml │ ├── FileLoaderViewer.xaml.cs │ ├── SettingsPlugin.xaml │ └── SettingsPlugin.xaml.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ ├── Settings.cs │ └── Settings.settings ├── Resources │ ├── Brushes.xaml │ ├── Button.xaml │ ├── ComboBox.xaml │ ├── Geometry.xaml │ ├── HLSLSyntax.xshd │ ├── Menu.xaml │ ├── PluginTheme.xaml │ ├── ScrollBar.xaml │ ├── Slider.xaml │ └── TabControl.xaml ├── Samples │ ├── 1_SampleSyntax.fx │ ├── AngularGradient.fx │ ├── ApplyTextureMap.fx │ ├── BandedSwirl.fx │ ├── BandedSwirl_PS3.fx │ ├── Bands.fx │ ├── Bloom.fx │ ├── BrightExtract.fx │ ├── Circles.fx │ ├── Circles2.fx │ ├── ColorKeyAlpha.fx │ ├── ColorTone.fx │ ├── ContrastAdjust.fx │ ├── Desaturate.fx │ ├── DirectionalBlur.fx │ ├── Embossed.fx │ ├── Fade.fx │ ├── FrostyOutline.fx │ ├── Generative_Bands.fx │ ├── Generative_Mandlebrot1.fx │ ├── Generative_Star.fx │ ├── GlassTiles.fx │ ├── Gloom.fx │ ├── GrowablePoissonDisk.fx │ ├── HslWheel.fx │ ├── HsvWheel.fx │ ├── InvertColor.fx │ ├── LightStreak.fx │ ├── LinearGradient.fx │ ├── Magnify.fx │ ├── Mask.fx │ ├── Monochrome.fx │ ├── MultiInput_ColorChannels.fx │ ├── MultiInput_FourSources.fx │ ├── MultiInput_MergeImages.fx │ ├── MultiInput_Shift.fx │ ├── New.txt │ ├── OldMovie.fx │ ├── PaperFold.fx │ ├── PaperFoldModded.fx │ ├── ParametricEdgeDetection.fx │ ├── Pinch.fx │ ├── Pivot1.fx │ ├── Pixelate.fx │ ├── Ripple.fx │ ├── Sharpen.fx │ ├── SketchGranite.fx │ ├── SketchPencilStroke.fx │ ├── SmoothMagnify.fx │ ├── Splinter.fx │ ├── Swirl.fx │ ├── Tiler.fx │ ├── ToneMapping.fx │ ├── ToonShader.fx │ ├── Transition_BandedSwirl.fx │ ├── Transition_Blinds.fx │ ├── Transition_Blood.fx │ ├── Transition_CircleReveal.fx │ ├── Transition_CircleStretch.fx │ ├── Transition_CircularBlur.fx │ ├── Transition_CloudReveal.fx │ ├── Transition_Crumble.fx │ ├── Transition_Disolve.fx │ ├── Transition_Drop.fx │ ├── Transition_Fade.fx │ ├── Transition_LeastBright.fx │ ├── Transition_LineReveal.fx │ ├── Transition_MostBright.fx │ ├── Transition_Pixelate.fx │ ├── Transition_PixelateIn.fx │ ├── Transition_PixelateOut.fx │ ├── Transition_RadialBlur.fx │ ├── Transition_RadialWiggle.fx │ ├── Transition_RandomCircleReveal.fx │ ├── Transition_Ripple.fx │ ├── Transition_RotateCrumble.fx │ ├── Transition_Saturate.fx │ ├── Transition_Shrink.fx │ ├── Transition_SlideIn.fx │ ├── Transition_Smooth.fx │ ├── Transition_Swirl.fx │ ├── Transition_SwirlGrid.fx │ ├── Transition_SwirlGrid_PS3.fx │ ├── Transition_Water.fx │ ├── Transition_Wave.fx │ ├── TransparentAlternatingPixels.fx │ ├── TransparentAlternatingPixelsMultiplied.fx │ ├── TransparentAlternatingScanlines.fx │ ├── Warp.fx │ ├── WaveWarper.fx │ ├── ZoomBlur.fx │ └── shared.hlsli ├── Shazzam.csproj ├── Shazzam.csproj.DotSettings ├── ShazzamSwitchboard.cs ├── TargetFramework.cs ├── Tutorials │ ├── 01a_WhatIsAShader.fx │ ├── 01b_PartsOfAShader.fx │ ├── 02_ChangeColor.fx │ ├── 03a_Variables.fx │ ├── 03b_Swizzling.fx │ ├── 04a_AddColorParameters.fx │ ├── 04b_AddColorParameters.fx │ ├── 04c_TexturesVia_S_Registers.fx │ ├── 04d_InputVia_C_Registers.fx │ ├── 05_AddShazzamTags.fx │ ├── 06_SwapColors.fx │ ├── 07a_ChangePosition.fx │ ├── 07b_ChangePosition.fx │ ├── 07c_AddShazzamTags.fx │ ├── 08a_SwapPosition.fx │ ├── 08b_FlipPosition.fx │ ├── 09a_MorphNearbyPixels.fx │ ├── 13_UsingDXFunctions.fx │ └── 14_PS3.fx ├── Views │ ├── AboutView.xaml │ ├── AboutView.xaml.cs │ ├── CodeTabsView.xaml │ ├── CodeTabsView.xaml.cs │ ├── CodeViewModel.cs │ ├── Fav2.png │ ├── Plugin.cs │ ├── PluginView.xaml │ ├── PluginView.xaml.cs │ ├── check.png │ ├── greentarget.png │ └── info.png ├── app.config └── d3dx10_40.dll ├── ShazzamUnitTests ├── .editorconfig ├── CodeGen │ └── ShaderModelTests.cs ├── MainWindowVmUnitTest.cs ├── Sandbox │ ├── AngleTests.cs │ ├── Hlsl.cs │ ├── InterpolateTests.cs │ └── LerpRgbaTests.cs └── ShazzamUnitTests.csproj └── appveyor.yml /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: nuget 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | runs-on: windows-latest 8 | 9 | steps: 10 | - uses: actions/checkout@v3 11 | - name: setup 12 | uses: actions/setup-dotnet@v3 13 | with: 14 | dotnet-version: 7.0.x 15 | - name: restore 16 | run: dotnet restore 17 | - name: build 18 | run: dotnet build --configuration Release --no-restore 19 | - name: test 20 | run: dotnet test --configuration Release --no-build 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | Thumbs.db 3 | *.obj 4 | *.exe 5 | *.pdb 6 | *.user 7 | *.aps 8 | *.pch 9 | *.vspscc 10 | *_i.c 11 | *_p.c 12 | *.ncb 13 | *.suo 14 | *.sln.docstates 15 | *.tlb 16 | *.tlh 17 | *.bak 18 | *.cache 19 | *.ilk 20 | *.log 21 | [Bb]in 22 | [Dd]ebug*/ 23 | *.lib 24 | *.sbr 25 | obj/ 26 | [Rr]elease*/ 27 | _ReSharper*/ 28 | [Tt]est[Rr]esult* 29 | *.vssscc 30 | $tf*/ 31 | packages/* 32 | publish/* 33 | .vs/* 34 | Shazzam/packages/* 35 | -------------------------------------------------------------------------------- /KaxamlPlugins/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.cs] 2 | 3 | # Default severity for analyzer diagnostics with category 'StyleCop.CSharp.DocumentationRules' 4 | dotnet_analyzer_diagnostic.category-StyleCop.CSharp.DocumentationRules.severity = none 5 | # SA0001: XML comment analysis is disabled due to project configuration 6 | dotnet_diagnostic.SA0001.severity = none 7 | 8 | # WPF0060: Backing member for DependencyProperty should have standard documentation text. 9 | dotnet_diagnostic.WPF0060.severity = none 10 | # WPF0108: Backing member for RoutedEvent should have standard documentation text. 11 | dotnet_diagnostic.WPF0108.severity = none 12 | -------------------------------------------------------------------------------- /KaxamlPlugins/Controls/Coerce.cs: -------------------------------------------------------------------------------- 1 | namespace KaxamlPlugins.Controls 2 | { 3 | public static class Coerce 4 | { 5 | public static object? ClampDouble(object? value, double min, double max) 6 | { 7 | if (value is double d) 8 | { 9 | if (d < min) 10 | { 11 | return min; 12 | } 13 | 14 | if (d > max) 15 | { 16 | return max; 17 | } 18 | } 19 | 20 | return value; 21 | } 22 | 23 | public static object? ClampInt(object? value, int min, int max) 24 | { 25 | if (value is double d) 26 | { 27 | if (d < min) 28 | { 29 | return min; 30 | } 31 | 32 | if (d > max) 33 | { 34 | return max; 35 | } 36 | } 37 | 38 | return value; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /KaxamlPlugins/Controls/ColorChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | namespace KaxamlPlugins.Controls 2 | { 3 | using System.Windows; 4 | using System.Windows.Media; 5 | 6 | public class ColorChangedEventArgs : RoutedEventArgs 7 | { 8 | public ColorChangedEventArgs(RoutedEvent routedEvent, Color color) 9 | { 10 | this.RoutedEvent = routedEvent; 11 | this.Color = color; 12 | } 13 | 14 | public Color Color { get; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /KaxamlPlugins/Controls/CursorAdorner.cs: -------------------------------------------------------------------------------- 1 | namespace KaxamlPlugins.Controls 2 | { 3 | using System.Windows; 4 | using System.Windows.Documents; 5 | using System.Windows.Media; 6 | 7 | public sealed class CursorAdorner : Adorner 8 | { 9 | private readonly UIElement cursor; 10 | 11 | private Point offset; 12 | 13 | public CursorAdorner(ElementCursorDecorator owner, UIElement cursor) 14 | : base(owner) 15 | { 16 | this.cursor = cursor; 17 | this.AddVisualChild(cursor); 18 | } 19 | 20 | public Point Offset 21 | { 22 | get => this.offset; 23 | set 24 | { 25 | this.offset = value; 26 | this.InvalidateArrange(); 27 | } 28 | } 29 | 30 | protected override int VisualChildrenCount => 1; 31 | 32 | protected override Visual GetVisualChild(int index) 33 | { 34 | return this.cursor; 35 | } 36 | 37 | protected override Size ArrangeOverride(Size finalSize) 38 | { 39 | this.cursor.Arrange(new Rect(this.Offset, this.cursor.DesiredSize)); 40 | return finalSize; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /KaxamlPlugins/Controls/DropDownColorPicker.cs: -------------------------------------------------------------------------------- 1 | namespace KaxamlPlugins.Controls 2 | { 3 | using System.Windows; 4 | 5 | public class DropDownColorPicker : ColorPicker 6 | { 7 | static DropDownColorPicker() 8 | { 9 | DefaultStyleKeyProperty.OverrideMetadata(typeof(DropDownColorPicker), new FrameworkPropertyMetadata(typeof(DropDownColorPicker))); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /KaxamlPlugins/KaxamlPlugins.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net48 4 | library 5 | true 6 | latest 7 | Enable 8 | false 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /KaxamlPlugins/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | using System.Windows; 4 | 5 | [assembly: AssemblyTitle("KaxamlPlugins")] 6 | [assembly: AssemblyDescription("")] 7 | [assembly: AssemblyConfiguration("")] 8 | [assembly: AssemblyCompany("")] 9 | [assembly: AssemblyProduct("KaxamlPlugins")] 10 | [assembly: AssemblyCopyright("Copyright @ 2007")] 11 | [assembly: AssemblyTrademark("")] 12 | [assembly: AssemblyCulture("")] 13 | [assembly: ComVisible(false)] 14 | [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] 15 | [assembly: AssemblyVersion("1.0.0")] 16 | -------------------------------------------------------------------------------- /KaxamlPlugins/RoundConverter.cs: -------------------------------------------------------------------------------- 1 | namespace KaxamlPlugins 2 | { 3 | using System; 4 | using System.Globalization; 5 | using System.Windows.Data; 6 | 7 | [ValueConversion(typeof(string), typeof(double))] 8 | [ValueConversion(typeof(double), typeof(double))] 9 | public sealed class RoundConverter : IValueConverter 10 | { 11 | public static readonly RoundConverter Default = new(); 12 | 13 | object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture) 14 | { 15 | return value switch 16 | { 17 | string s 18 | when double.TryParse(s, out var d) 19 | => Math.Round(d, 2), 20 | double d => Math.Round(d, 2), 21 | _ => value, 22 | }; 23 | } 24 | 25 | object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 26 | { 27 | return value; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Shazzam 2 | A fork of https://shazzam.codeplex.com/ 3 | 4 | [![Build status](https://ci.appveyor.com/api/projects/status/ie0l6f2fjm4jhfap/branch/master?svg=true)](https://ci.appveyor.com/project/JohanLarsson/shazzam/branch/master) 5 | -------------------------------------------------------------------------------- /Settings.XamlStyler: -------------------------------------------------------------------------------- 1 | { 2 | "AttributesTolerance": 2, 3 | "KeepFirstAttributeOnSameLine": true, 4 | "MaxAttributeCharatersPerLine": 0, 5 | "MaxAttributesPerLine": 1, 6 | "NewlineExemptionElements": "RadialGradientBrush, GradientStop, LinearGradientBrush, ScaleTransfom, SkewTransform, RotateTransform, TranslateTransform, Trigger, Condition, Setter", 7 | "SeparateByGroups": false, 8 | "AttributeIndentation": 0, 9 | "AttributeIndentationStyle": 1, 10 | "RemoveDesignTimeReferences": false, 11 | "EnableAttributeReordering": true, 12 | "AttributeOrderingRuleGroups": [ 13 | "x:Class", 14 | "xmlns, xmlns:x", 15 | "xmlns:*", 16 | "x:Key, Key, x:Name, Name, x:Uid, Uid, Title", 17 | "Grid.Row, Grid.RowSpan, Grid.Column, Grid.ColumnSpan, Canvas.Left, Canvas.Top, Canvas.Right, Canvas.Bottom", 18 | "Width, Height, MinWidth, MinHeight, MaxWidth, MaxHeight", 19 | "Margin, Padding, HorizontalAlignment, VerticalAlignment, HorizontalContentAlignment, VerticalContentAlignment, Panel.ZIndex", 20 | "*:*, *", 21 | "PageSource, PageIndex, Offset, Color, TargetName, Property, Value, StartPoint, EndPoint", 22 | "mc:Ignorable, d:IsDataSource, d:LayoutOverrides, d:IsStaticText", 23 | "Storyboard.*, From, To, Duration" 24 | ], 25 | "FirstLineAttributes": "", 26 | "OrderAttributesByName": true, 27 | "PutEndingBracketOnNewLine": false, 28 | "RemoveEndingTagOfEmptyElement": true, 29 | "SpaceBeforeClosingSlash": true, 30 | "RootElementLineBreakRule": 0, 31 | "ReorderVSM": 2, 32 | "ReorderGridChildren": true, 33 | "ReorderCanvasChildren": false, 34 | "ReorderSetters": 0, 35 | "FormatMarkupExtension": true, 36 | "NoNewLineMarkupExtensions": "x:Bind, Binding", 37 | "ThicknessSeparator": 2, 38 | "ThicknessAttributes": "Margin, Padding, BorderThickness, ThumbnailClipMargin", 39 | "FormatOnSave": false, 40 | "CommentPadding": 2, 41 | } -------------------------------------------------------------------------------- /Shazzam.sln.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> 3 | True 4 | True 5 | True 6 | True 7 | True -------------------------------------------------------------------------------- /Shazzam/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.cs] 2 | 3 | # Default severity for analyzer diagnostics with category 'StyleCop.CSharp.DocumentationRules' 4 | dotnet_analyzer_diagnostic.category-StyleCop.CSharp.DocumentationRules.severity = none 5 | # SA0001: XML comment analysis is disabled due to project configuration 6 | dotnet_diagnostic.SA0001.severity = none 7 | 8 | # WPF0060: Backing member for DependencyProperty should have standard documentation text. 9 | dotnet_diagnostic.WPF0060.severity = none 10 | # WPF0061: Accessor method for attached property should have standard documentation text. 11 | dotnet_diagnostic.WPF0061.severity = none 12 | # WPF0108: Backing member for RoutedEvent should have standard documentation text. 13 | dotnet_diagnostic.WPF0108.severity = none 14 | 15 | 16 | -------------------------------------------------------------------------------- /Shazzam/CodeGen/CompilerException.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam.CodeGen 2 | { 3 | using System; 4 | 5 | [Serializable] 6 | public class CompilerException : Exception 7 | { 8 | public CompilerException() 9 | : base() 10 | { 11 | } 12 | 13 | public CompilerException(string message) 14 | : base(message) 15 | { 16 | } 17 | 18 | public CompilerException(string message, Exception inner) 19 | : base(message, inner) 20 | { 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Shazzam/CodeGen/ShaderProfile.cs: -------------------------------------------------------------------------------- 1 | // contributed by jeremiah.morrill@gmail.com 2 | 3 | // http://www.windows-tech.info/4/0311d2b4778d6ebe.php 4 | // Access is denied. 5 | // http://stackoverflow.com/questions/666799/embedding-unmanaged-dll-into-a-managed-c-dll 6 | namespace Shazzam.CodeGen 7 | { 8 | public enum ShaderProfile 9 | { 10 | PixelShader2, 11 | PixelShader3, 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Shazzam/Commands/AppCommands.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam.Commands 2 | { 3 | using System.Windows.Input; 4 | 5 | public static class AppCommands 6 | { 7 | public static readonly RoutedUICommand Exit = new( 8 | "Exit", 9 | "Exit", 10 | typeof(AppCommands)); 11 | 12 | public static readonly RoutedUICommand OpenImage = new( 13 | "Open Image", 14 | "OpenImage", 15 | typeof(AppCommands), 16 | new InputGestureCollection { new KeyGesture(Key.I, ModifierKeys.Control) }); 17 | 18 | public static readonly RoutedUICommand OpenMedia = new( 19 | "Open Media", 20 | "OpenMedia", 21 | typeof(AppCommands), 22 | new InputGestureCollection { new KeyGesture(Key.M, ModifierKeys.Control) }); 23 | 24 | public static readonly RoutedUICommand RemoveShader = new( 25 | "Remove Shader", 26 | "RemoveShader", 27 | typeof(AppCommands), 28 | new InputGestureCollection { new KeyGesture(Key.F6) }); 29 | 30 | public static readonly RoutedUICommand ApplyShader = new( 31 | "Apply Shader", 32 | "ApplyShader", 33 | typeof(AppCommands), 34 | new InputGestureCollection { new KeyGesture(Key.F5) }); 35 | 36 | public static readonly RoutedUICommand CompileShader = new( 37 | "Compile Shader", 38 | "CompileShader", 39 | typeof(AppCommands), 40 | new InputGestureCollection { new KeyGesture(Key.F7) }); 41 | 42 | public static void Initialize() 43 | { 44 | // Add a keyboard shortcut (Ctrl+Shift+S) to the "Save As" command. 45 | ApplicationCommands.SaveAs.InputGestures.Add(new KeyGesture(Key.S, ModifierKeys.Control | ModifierKeys.Shift)); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Shazzam/Commands/RelayCommand.cs: -------------------------------------------------------------------------------- 1 | // The following code is inspired by the work of Josh Smith 2 | // http://joshsmithonwpf.wordpress.com/ 3 | namespace Shazzam.Commands 4 | { 5 | using System; 6 | using System.Diagnostics; 7 | using System.Windows.Input; 8 | 9 | /// 10 | /// A command whose sole purpose is to 11 | /// relay its functionality to other 12 | /// objects by invoking delegates. The 13 | /// default return value for the CanExecute 14 | /// method is 'true'. 15 | /// 16 | public class RelayCommand : ICommand 17 | { 18 | private readonly Action execute; 19 | private readonly Func? canExecute; 20 | 21 | /// 22 | /// Creates a new command that can always execute. 23 | /// 24 | /// The execution logic. 25 | public RelayCommand(Action execute) 26 | : this(execute, null) 27 | { 28 | } 29 | 30 | /// 31 | /// Creates a new command. 32 | /// 33 | /// The execution logic. 34 | /// The execution status logic. 35 | public RelayCommand(Action execute, Func? canExecute) 36 | { 37 | this.execute = execute ?? throw new ArgumentNullException(nameof(execute)); 38 | this.canExecute = canExecute; 39 | } 40 | 41 | public event EventHandler CanExecuteChanged 42 | { 43 | add 44 | { 45 | if (this.canExecute != null) 46 | { 47 | CommandManager.RequerySuggested += value; 48 | } 49 | } 50 | 51 | remove 52 | { 53 | if (this.canExecute != null) 54 | { 55 | CommandManager.RequerySuggested -= value; 56 | } 57 | } 58 | } 59 | 60 | [DebuggerStepThrough] 61 | public bool CanExecute(object parameter) 62 | { 63 | return this.canExecute?.Invoke() ?? true; 64 | } 65 | 66 | public void Execute(object parameter) 67 | { 68 | this.execute(); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Shazzam/Commands/RelayCommand`1.cs: -------------------------------------------------------------------------------- 1 | // The following code is inspired by the work of Josh Smith 2 | // http://joshsmithonwpf.wordpress.com/ 3 | namespace Shazzam.Commands 4 | { 5 | using System; 6 | using System.Diagnostics; 7 | using System.Windows.Input; 8 | 9 | /// 10 | /// A command whose sole purpose is to 11 | /// relay its functionality to other 12 | /// objects by invoking delegates. The 13 | /// default return value for the CanExecute 14 | /// method is 'true'. 15 | /// 16 | public class RelayCommand : ICommand 17 | { 18 | private readonly Action execute; 19 | private readonly Predicate? canExecute; 20 | 21 | public RelayCommand(Action execute) 22 | : this(execute, null) 23 | { 24 | } 25 | 26 | /// 27 | /// Creates a new command. 28 | /// 29 | /// The execution logic. 30 | /// The execution status logic. 31 | public RelayCommand(Action execute, Predicate? canExecute) 32 | { 33 | this.execute = execute ?? throw new ArgumentNullException(nameof(execute)); 34 | this.canExecute = canExecute; 35 | } 36 | 37 | public event EventHandler CanExecuteChanged 38 | { 39 | add 40 | { 41 | if (this.canExecute != null) 42 | { 43 | CommandManager.RequerySuggested += value; 44 | } 45 | } 46 | 47 | remove 48 | { 49 | if (this.canExecute != null) 50 | { 51 | CommandManager.RequerySuggested -= value; 52 | } 53 | } 54 | } 55 | 56 | [DebuggerStepThrough] 57 | public bool CanExecute(object parameter) 58 | { 59 | return this.canExecute?.Invoke((T)parameter) ?? true; 60 | } 61 | 62 | public void Execute(object parameter) 63 | { 64 | this.execute((T)parameter); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Shazzam/Constants.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam 2 | { 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Windows.Media; 6 | 7 | public static class Constants 8 | { 9 | public static readonly IReadOnlyList Colors = CreateColors(360).ToArray(); 10 | 11 | private static IEnumerable CreateColors(int n) 12 | { 13 | var step = 360.0 / n; 14 | var hue = 0.0; 15 | while (hue < 360.0) 16 | { 17 | yield return Hsv.ColorFromHsv(hue, 1, 1); 18 | hue += step; 19 | } 20 | } 21 | 22 | public static class Paths 23 | { 24 | public static readonly string Application = "\\Shazzam\\"; 25 | public static readonly string GeneratedShaders = "\\Shazzam\\GeneratedShaders\\"; 26 | public static readonly string TextureMaps = "\\Images\\TextureMaps\\"; 27 | } 28 | 29 | public static class FileNames 30 | { 31 | public static readonly string TempShaderFx = "temp.fx"; 32 | public static readonly string TempShaderPs = "temp.ps"; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Shazzam/Controls/HorizontalRevealMode.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam.Controls 2 | { 3 | public enum HorizontalRevealMode 4 | { 5 | /// 6 | /// No horizontal reveal animation. 7 | /// 8 | None, 9 | 10 | /// 11 | /// Reveal from the left to the right. 12 | /// 13 | FromLeftToRight, 14 | 15 | /// 16 | /// Reveal from the right to the left. 17 | /// 18 | FromRightToLeft, 19 | 20 | /// 21 | /// Reveal from the center to the bounding edge. 22 | /// 23 | FromCenterToEdge, 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Shazzam/Controls/Icons.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam.Controls 2 | { 3 | using System.Windows; 4 | 5 | /// 6 | /// Interaction logic for Icons.xaml 7 | /// 8 | public partial class Icons : Window 9 | { 10 | public Icons() 11 | { 12 | this.InitializeComponent(); 13 | 14 | // Insert code required on object creation below this point. 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Shazzam/Controls/IndexOddEven.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam.Controls 2 | { 3 | public enum IndexOddEven 4 | { 5 | Odd, 6 | Even, 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Shazzam/Controls/RangeControl.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 | 17 | 22 | 23 | 28 | 29 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Shazzam/Controls/RangeControl.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam.Controls 2 | { 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | 6 | public partial class RangeControl : UserControl 7 | { 8 | public static readonly DependencyProperty MinProperty = DependencyProperty.Register( 9 | nameof(Min), 10 | typeof(double), 11 | typeof(RangeControl), 12 | new FrameworkPropertyMetadata( 13 | default(double), 14 | FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); 15 | 16 | public static readonly DependencyProperty MaxProperty = DependencyProperty.Register( 17 | nameof(Max), 18 | typeof(double), 19 | typeof(RangeControl), 20 | new FrameworkPropertyMetadata( 21 | default(double), 22 | FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); 23 | 24 | public static readonly DependencyProperty ValueProperty = DependencyProperty.Register( 25 | nameof(Value), 26 | typeof(double), 27 | typeof(RangeControl), 28 | new FrameworkPropertyMetadata( 29 | default(double), 30 | FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); 31 | 32 | public RangeControl() 33 | { 34 | this.InitializeComponent(); 35 | } 36 | 37 | public double Min 38 | { 39 | get => (double)this.GetValue(MinProperty); 40 | set => this.SetValue(MinProperty, value); 41 | } 42 | 43 | public double Max 44 | { 45 | get => (double)this.GetValue(MaxProperty); 46 | set => this.SetValue(MaxProperty, value); 47 | } 48 | 49 | public double Value 50 | { 51 | get => (double)this.GetValue(ValueProperty); 52 | set => this.SetValue(ValueProperty, value); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Shazzam/Controls/SelectionLocation.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam.Controls 2 | { 3 | public enum SelectionLocation 4 | { 5 | Before, 6 | Selected, 7 | After, 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Shazzam/Controls/StackLocation.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam.Controls 2 | { 3 | public enum StackLocation 4 | { 5 | First, 6 | Middle, 7 | Last, 8 | FirstAndLast, 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Shazzam/Controls/TextureMapLocator.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam.Controls 2 | { 3 | public struct TextureMapLocator 4 | { 5 | public string ShortFileName { get; set; } 6 | 7 | public string LongFileName { get; set; } 8 | 9 | public string TrimmedFileName { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Shazzam/Controls/VerticalRevealMode.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam.Controls 2 | { 3 | public enum VerticalRevealMode 4 | { 5 | /// 6 | /// No vertical reveal animation. 7 | /// 8 | None, 9 | 10 | /// 11 | /// Reveal from top to bottom. 12 | /// 13 | FromTopToBottom, 14 | 15 | /// 16 | /// Reveal from bottom to top. 17 | /// 18 | FromBottomToTop, 19 | 20 | /// 21 | /// Reveal from the center to the bounding edge. 22 | /// 23 | FromCenterToEdge, 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Shazzam/Converters/AnyToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam 2 | { 3 | using System; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | using System.Globalization; 7 | using System.Linq; 8 | using System.Windows; 9 | using System.Windows.Data; 10 | 11 | [ValueConversion(typeof(IEnumerable), typeof(Visibility))] 12 | public sealed class AnyToVisibilityConverter : IValueConverter 13 | { 14 | public static readonly AnyToVisibilityConverter VisibleWhenAny = new(Visibility.Visible, Visibility.Collapsed); 15 | public static readonly AnyToVisibilityConverter VisibleWhenEmpty = new(Visibility.Collapsed, Visibility.Visible); 16 | 17 | private readonly object whenAny; 18 | private readonly object whenEmpty; 19 | 20 | public AnyToVisibilityConverter(Visibility whenAny, Visibility whenEmpty) 21 | { 22 | this.whenAny = whenAny; 23 | this.whenEmpty = whenEmpty; 24 | } 25 | 26 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 27 | { 28 | if (value is IEnumerable enumerable) 29 | { 30 | return enumerable.Any() ? this.whenAny : this.whenEmpty; 31 | } 32 | 33 | return value; 34 | } 35 | 36 | object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 37 | { 38 | throw new NotSupportedException($"{nameof(AnyToVisibilityConverter)} can only be used in OneWay bindings"); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Shazzam/Converters/DoubleToStringConverter.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam 2 | { 3 | using System; 4 | using System.Globalization; 5 | using System.Windows.Data; 6 | 7 | [ValueConversion(typeof(double), typeof(string))] 8 | public sealed class DoubleToStringConverter : IValueConverter 9 | { 10 | public static readonly DoubleToStringConverter F1 = new("F1"); 11 | public static readonly DoubleToStringConverter F2 = new("F2"); 12 | 13 | private readonly string format; 14 | 15 | public DoubleToStringConverter(string format) 16 | { 17 | this.format = format; 18 | } 19 | 20 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 21 | { 22 | var number = (double)value; 23 | return number.ToString(this.format, CultureInfo.InvariantCulture); 24 | } 25 | 26 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 27 | { 28 | return System.Convert.ToDouble(value, CultureInfo.InvariantCulture); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Shazzam/Converters/EqualityConverter.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam 2 | { 3 | using System; 4 | using System.Globalization; 5 | using System.Windows.Data; 6 | 7 | [ValueConversion(typeof(object), typeof(bool))] 8 | public sealed class EqualityConverter : IValueConverter 9 | { 10 | public static readonly EqualityConverter Default = new(); 11 | 12 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 13 | { 14 | return value != null && value.ToString() == parameter.ToString(); 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 18 | { 19 | return (bool)value ? parameter : Binding.DoNothing; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Shazzam/Converters/InvertBooleanConverter.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam 2 | { 3 | using System; 4 | using System.Globalization; 5 | using System.Windows.Data; 6 | 7 | [ValueConversion(typeof(bool), typeof(bool))] 8 | public sealed class InvertBooleanConverter : IValueConverter 9 | { 10 | public static readonly InvertBooleanConverter Default = new(); 11 | 12 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 13 | { 14 | return !(bool)value; 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 18 | { 19 | return !(bool)value; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Shazzam/Converters/RegisterTemplateSelector.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam 2 | { 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | using System.Windows.Media; 6 | using System.Windows.Media.Media3D; 7 | 8 | public class RegisterTemplateSelector : DataTemplateSelector 9 | { 10 | public DataTemplate? SingleTemplate { get; set; } 11 | 12 | public DataTemplate? PairTemplate { get; set; } 13 | 14 | public DataTemplate? TripleTemplate { get; set; } 15 | 16 | public DataTemplate? QuadrupleTemplate { get; set; } 17 | 18 | public DataTemplate? ColorTemplate { get; set; } 19 | 20 | public override DataTemplate? SelectTemplate(object item, DependencyObject container) 21 | { 22 | return item switch 23 | { 24 | Register register 25 | when register.Type == typeof(double) || 26 | register.Type == typeof(float) || 27 | register.Type == typeof(int) 28 | => this.SingleTemplate, 29 | Register register 30 | when register.Type == typeof(Color) 31 | => this.ColorTemplate, 32 | Register register 33 | when register.Type == typeof(Point) || 34 | register.Type == typeof(Vector) || 35 | register.Type == typeof(Size) 36 | => this.PairTemplate, 37 | Register register 38 | when register.Type == typeof(Point3D) || 39 | register.Type == typeof(Vector3D) 40 | => this.TripleTemplate, 41 | Register register 42 | when register.Type == typeof(Point4D) 43 | => this.QuadrupleTemplate, 44 | _ => base.SelectTemplate(item, container), 45 | }; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Shazzam/Converters/RegisterValueConverter.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam 2 | { 3 | using System; 4 | using System.Globalization; 5 | using System.Windows; 6 | using System.Windows.Data; 7 | using System.Windows.Media.Media3D; 8 | 9 | public sealed class RegisterValueConverter : IValueConverter 10 | { 11 | public static readonly RegisterValueConverter Default = new(); 12 | 13 | public static object ConvertToUsualType(object value) 14 | { 15 | // Convert float to double, Vector to Point, Size to Point, and Vector3D to Point3D. 16 | // Leave anything else unchanged. 17 | if (value is float f) 18 | { 19 | return (double)f; 20 | } 21 | 22 | if (value is Vector v) 23 | { 24 | return (Point)v; 25 | } 26 | 27 | if (value is Size size) 28 | { 29 | return (Point)size; 30 | } 31 | 32 | if (value is Vector3D v3D) 33 | { 34 | return (Point3D)v3D; 35 | } 36 | 37 | return value; 38 | } 39 | 40 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 41 | { 42 | // Convert double to float, Point to Vector, Point to Size, and Point3D to Vector3D. 43 | // Leave anything else unchanged. 44 | if (targetType == typeof(float)) 45 | { 46 | return (float)(double)value; 47 | } 48 | 49 | if (targetType == typeof(Vector)) 50 | { 51 | return (Vector)(Point)value; 52 | } 53 | 54 | if (targetType == typeof(Size)) 55 | { 56 | var p = (Point)value; 57 | return new Size(Math.Max(0, p.X), Math.Max(0, p.Y)); 58 | } 59 | 60 | if (targetType == typeof(Vector3D)) 61 | { 62 | return (Vector3D)(Point3D)value; 63 | } 64 | 65 | return value; 66 | } 67 | 68 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 69 | { 70 | return ConvertToUsualType(value); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Shazzam/Converters/StretchToIsCheckedConverter.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam 2 | { 3 | using System; 4 | using System.Globalization; 5 | using System.Windows.Data; 6 | 7 | public sealed class StretchToIsCheckedConverter : IValueConverter 8 | { 9 | public static readonly StretchToIsCheckedConverter Default = new(); 10 | 11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | var mode = (System.Windows.Media.Stretch)value; 14 | if (mode.ToString().ToLower() == parameter.ToString().ToLower()) 15 | { 16 | return true; 17 | } 18 | 19 | return false; 20 | } 21 | 22 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 23 | { 24 | return !(bool)value; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Shazzam/Converters/StringToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam 2 | { 3 | using System; 4 | using System.Windows; 5 | using System.Windows.Data; 6 | 7 | [ValueConversion(typeof(string), typeof(Visibility))] 8 | public sealed class StringToVisibilityConverter : IValueConverter 9 | { 10 | public static readonly StringToVisibilityConverter CollapsedWhenNullOrEmpty = new(); 11 | 12 | public object Convert(object? value, Type targetType, object? parameter, System.Globalization.CultureInfo culture) 13 | { 14 | return value switch 15 | { 16 | null => Visibility.Collapsed, 17 | string { Length: 0 } => Visibility.Collapsed, 18 | _ => Visibility.Visible, 19 | }; 20 | } 21 | 22 | object IValueConverter.ConvertBack(object? value, Type targetType, object? parameter, System.Globalization.CultureInfo culture) 23 | { 24 | throw new NotSupportedException($"{nameof(StringToVisibilityConverter)} can only be used in OneWay bindings"); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Shazzam/Converters/UniversalTemplateSelector.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Markup; 8 | 9 | [ContentProperty(nameof(Templates))] 10 | public class UniversalTemplateSelector : DataTemplateSelector 11 | { 12 | #pragma warning disable CA1002 // Do not expose generic lists 13 | public List Templates { get; } = new(); 14 | #pragma warning restore CA1002 // Do not expose generic lists 15 | 16 | public override DataTemplate? SelectTemplate(object? item, DependencyObject container) 17 | { 18 | if (item is null) 19 | { 20 | return base.SelectTemplate(null, container); 21 | } 22 | 23 | foreach (var dataTemplate in this.Templates) 24 | { 25 | if (dataTemplate.DataType is Type dataType && 26 | dataType.IsInstanceOfType(item)) 27 | { 28 | return dataTemplate; 29 | } 30 | } 31 | 32 | return base.SelectTemplate(item, container); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Shazzam/Converters/VisiblityToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam 2 | { 3 | using System; 4 | using System.Windows; 5 | using System.Windows.Data; 6 | 7 | [ValueConversion(typeof(object), typeof(Visibility))] 8 | public sealed class VisibilityToVisibilityConverter : IValueConverter 9 | { 10 | public static readonly VisibilityToVisibilityConverter CollapsedWhenVisible = new(); 11 | 12 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 13 | { 14 | return value switch 15 | { 16 | Visibility.Visible => Visibility.Collapsed, 17 | _ => Visibility.Visible, 18 | }; 19 | } 20 | 21 | object IValueConverter.ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 22 | { 23 | throw new NotSupportedException($"{nameof(VisibilityToVisibilityConverter)} can only be used in OneWay bindings"); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Shazzam/D3DCompiler_40.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/D3DCompiler_40.dll -------------------------------------------------------------------------------- /Shazzam/D3DX9_40.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/D3DX9_40.dll -------------------------------------------------------------------------------- /Shazzam/D3DX9_40_64bit.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/D3DX9_40_64bit.dll -------------------------------------------------------------------------------- /Shazzam/Fonts/Candara.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Fonts/Candara.ttf -------------------------------------------------------------------------------- /Shazzam/Fonts/Miramo.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Fonts/Miramo.ttf -------------------------------------------------------------------------------- /Shazzam/Fonts/Peric.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Fonts/Peric.ttf -------------------------------------------------------------------------------- /Shazzam/Helpers/ColorExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam 2 | { 3 | using System; 4 | using System.Windows.Media; 5 | 6 | public static class ColorExtensions 7 | { 8 | // https://stackoverflow.com/a/26233318/1069200 9 | public static double Hue(this Color c) 10 | { 11 | var min = Math.Min(Math.Min(c.ScR, c.ScG), c.ScB); 12 | var max = Math.Max(Math.Max(c.ScR, c.ScG), c.ScB); 13 | 14 | if (min == max) 15 | { 16 | return 0; 17 | } 18 | 19 | var hue = 0f; 20 | if (max == c.ScR) 21 | { 22 | hue = (c.ScG - c.ScB) / (max - min); 23 | } 24 | else if (max == c.ScG) 25 | { 26 | hue = 2f + ((c.ScB - c.ScR) / (max - min)); 27 | } 28 | else 29 | { 30 | hue = 4f + ((c.ScR - c.ScG) / (max - min)); 31 | } 32 | 33 | hue *= 60; 34 | if (hue < 0) 35 | { 36 | hue += 360; 37 | } 38 | 39 | return Math.Round(hue); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Shazzam/Helpers/VersionHelper.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam 2 | { 3 | internal static class VersionHelper 4 | { 5 | internal static string GetVersionNumber() => System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); 6 | 7 | internal static string GetShortVersionNumber() 8 | { 9 | var assemblyInfo = System.Reflection.Assembly.GetExecutingAssembly(); 10 | return $"{assemblyInfo.GetName().Version.Major}.{assemblyInfo.GetName().Version.Minor}"; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Shazzam/Images/ColorRange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/ColorRange.png -------------------------------------------------------------------------------- /Shazzam/Images/Default/ColorRange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/Default/ColorRange.png -------------------------------------------------------------------------------- /Shazzam/Images/Default/Geese.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/Default/Geese.jpg -------------------------------------------------------------------------------- /Shazzam/Images/Default/crystal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/Default/crystal.jpg -------------------------------------------------------------------------------- /Shazzam/Images/Fire1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/Fire1.jpg -------------------------------------------------------------------------------- /Shazzam/Images/Light1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/Light1.jpg -------------------------------------------------------------------------------- /Shazzam/Images/SpikeBalls.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/SpikeBalls.jpg -------------------------------------------------------------------------------- /Shazzam/Images/Star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/Star.png -------------------------------------------------------------------------------- /Shazzam/Images/SwirlLogo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/SwirlLogo2.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/bubbles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/bubbles.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/cactus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/cactus.jpg -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/clouds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/clouds.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/clover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/clover.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/color_range.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/color_range.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/curlique.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/curlique.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/curlique_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/curlique_small.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/flower.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/flower.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/fractal_bands.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/fractal_bands.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/fractal_butterfly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/fractal_butterfly.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/fractal_centerband.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/fractal_centerband.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/fractal_curls.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/fractal_curls.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/fractal_edge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/fractal_edge.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/fractal_flame.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/fractal_flame.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/glassblocks_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/glassblocks_big.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/glassblocks_medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/glassblocks_medium.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/glassblocks_simple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/glassblocks_simple.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/koch_cubist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/koch_cubist.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/koch_snowflake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/koch_snowflake.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/mawn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/mawn.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/moire.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/moire.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/noise.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/noise.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/noise_bumpy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/noise_bumpy.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/noise_weave.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/noise_weave.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/oil_slick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/oil_slick.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/paise.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/paise.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/paise2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/paise2.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/peaks_horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/peaks_horizontal.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/peaks_vertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/peaks_vertical.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/ring_center.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/ring_center.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/ripple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/ripple.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/rippled_glass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/rippled_glass.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/river.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/river.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/sand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/sand.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/streaks_aurora.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/streaks_aurora.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/streaks_grass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/streaks_grass.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/streaks_vertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/streaks_vertical.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/swirly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/swirly.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/waves_horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/waves_horizontal.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/waves_vertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/waves_vertical.png -------------------------------------------------------------------------------- /Shazzam/Images/TextureMaps/whirlpool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/TextureMaps/whirlpool.png -------------------------------------------------------------------------------- /Shazzam/Images/cactus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/cactus.jpg -------------------------------------------------------------------------------- /Shazzam/Images/connect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/connect.png -------------------------------------------------------------------------------- /Shazzam/Images/disconnect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/disconnect.png -------------------------------------------------------------------------------- /Shazzam/Images/disk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/disk.png -------------------------------------------------------------------------------- /Shazzam/Images/gears.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/gears.jpg -------------------------------------------------------------------------------- /Shazzam/Images/help.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/help.ico -------------------------------------------------------------------------------- /Shazzam/Images/lines.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/lines.jpg -------------------------------------------------------------------------------- /Shazzam/Images/logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/logo.ico -------------------------------------------------------------------------------- /Shazzam/Images/page_copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/page_copy.png -------------------------------------------------------------------------------- /Shazzam/Images/plasma.wmv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/plasma.wmv -------------------------------------------------------------------------------- /Shazzam/Images/square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Images/square.png -------------------------------------------------------------------------------- /Shazzam/Plugins/FileLoaderViewer.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | 11 | 12 | 17 | Change location 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | Pre-installed samples 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | Learn more about HLSL 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /Shazzam/Plugins/SettingsPlugin.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam.Plugins 2 | { 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | using System.Windows.Media; 6 | 7 | public partial class SettingsPlugin : UserControl 8 | { 9 | public SettingsPlugin() 10 | { 11 | this.InitializeComponent(); 12 | this.Loaded += this.SettingsPluginLoaded; 13 | } 14 | 15 | private void SettingsPluginLoaded(object sender, RoutedEventArgs e) 16 | { 17 | if (RenderCapability.IsPixelShaderVersionSupported(3, 0)) 18 | { 19 | this.NotAvailable.SetCurrentValue(VisibilityProperty, Visibility.Collapsed); 20 | } 21 | else 22 | { 23 | this.NotAvailable.SetCurrentValue(VisibilityProperty, Visibility.Visible); 24 | this.NotAvailable.SetCurrentValue(ToolTipProperty, "PS_3 is not supported on your video card."); 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Shazzam/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | using System.Windows; 5 | 6 | [assembly: AssemblyTitle("Shazzam")] 7 | [assembly: AssemblyDescription("")] 8 | [assembly: AssemblyConfiguration("")] 9 | [assembly: AssemblyCompany("")] 10 | [assembly: AssemblyProduct("Shazzam")] 11 | [assembly: AssemblyCopyright("Copyright © 2008")] 12 | [assembly: AssemblyTrademark("")] 13 | [assembly: AssemblyCulture("")] 14 | 15 | [assembly: ComVisible(false)] 16 | [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] 17 | [assembly: AssemblyVersion("1.4.0.12")] 18 | [assembly: AssemblyFileVersion("1.4.0.0")] 19 | [assembly:InternalsVisibleTo("ShazzamUnitTests", AllInternalsVisible = true)] 20 | -------------------------------------------------------------------------------- /Shazzam/Properties/Settings.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam.Properties 2 | { 3 | // This class allows you to handle specific events on the settings class: 4 | // The SettingChanging event is raised before a setting's value is changed. 5 | // The PropertyChanged event is raised after a setting's value is changed. 6 | // The SettingsLoaded event is raised after the setting values are loaded. 7 | // The SettingsSaving event is raised before the setting values are saved. 8 | internal sealed partial class Settings 9 | { 10 | internal Settings() 11 | { 12 | this.PropertyChanged += (sender, e) => Default.Save(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Shazzam/Resources/Geometry.xaml: -------------------------------------------------------------------------------- 1 |  3 | M 1,5 L9,5 L 5,0 Z 4 | M 1,0 L9,0 L 5,5 Z 5 | M 5,5 L5,9 L 0,5 Z 6 | M 0,1 L0,9 L 5,5 Z 7 | -------------------------------------------------------------------------------- /Shazzam/Samples/1_SampleSyntax.fx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Samples/1_SampleSyntax.fx -------------------------------------------------------------------------------- /Shazzam/Samples/AngularGradient.fx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Samples/AngularGradient.fx -------------------------------------------------------------------------------- /Shazzam/Samples/ApplyTextureMap.fx: -------------------------------------------------------------------------------- 1 | /// ApplyTexture 2 | 3 | sampler2D Texture1 : register(s0); 4 | sampler2D TextureMap : register(s2); 5 | 6 | /// Apply texture from Texturmap image to original image 7 | /// Horizontal size of the map. 1= normal size 8 | /// 1 9 | /// 5 10 | /// 1 11 | float HorizontalSize : register(c0); 12 | 13 | /// Vertical size of the map. 1= normal size 14 | /// 1 15 | /// 5 16 | /// 1 17 | float VerticalSize : register(c3); 18 | 19 | float verticalOffset: register(C1); 20 | float horizontalOffset: register(C4); 21 | 22 | /// The Strength of the applied map size of the map. 0 = no map 23 | /// 0 24 | /// 5 25 | /// 1 26 | float strength :register(c5); 27 | 28 | 29 | 30 | struct VS_OUTPUT 31 | { 32 | float4 Position : POSITION; 33 | float4 Color : COlOR; 34 | float2 UV : TEXCOORD; 35 | }; 36 | 37 | 38 | 39 | //-------------------------------------------------------------------------------------- 40 | // Pixel Shader 41 | //-------------------------------------------------------------------------------------- 42 | float4 main(VS_OUTPUT input) : COlOR 43 | { 44 | float2 uvs = input.UV; 45 | float horzOffset =frac(uvs.x / HorizontalSize + min(1, horizontalOffset)); 46 | float vOffset = frac(uvs.y / VerticalSize + min(1, verticalOffset)); 47 | float2 offset = tex2D(TextureMap, float2(horzOffset, vOffset)).xy * strength - (strength/8); 48 | 49 | float4 c1 = tex2D(Texture1, frac(uvs + offset )); 50 | return c1; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /Shazzam/Samples/Bands.fx: -------------------------------------------------------------------------------- 1 | /// BandsEffect 2 | 3 | /// An effect that creates bands of bright regions. 4 | 5 | //----------------------------------------------------------------------------------------- 6 | // Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) 7 | //----------------------------------------------------------------------------------------- 8 | 9 | /// The number of verical bands to add to the output. The higher the value the more bands. 10 | /// 0 11 | /// 150 12 | /// 65 13 | float BandDensity : register(C0); 14 | 15 | /// Intensity of each band. 16 | /// 0 17 | /// .5 18 | /// 0.056 19 | float BandIntensity : register(C1); 20 | 21 | //-------------------------------------------------------------------------------------- 22 | // Sampler Inputs (Brushes, including Texture1) 23 | //-------------------------------------------------------------------------------------- 24 | 25 | sampler2D Texture1Sampler : register(S0); 26 | 27 | //-------------------------------------------------------------------------------------- 28 | // Pixel Shader 29 | //-------------------------------------------------------------------------------------- 30 | 31 | float4 main(float2 uv : TEXCOORD) : COLOR 32 | { 33 | float4 color; 34 | 35 | color = tex2D(Texture1Sampler, uv.xy); 36 | 37 | color.rgb+=tan(uv.x*BandDensity)*BandIntensity; 38 | return color; 39 | } 40 | -------------------------------------------------------------------------------- /Shazzam/Samples/BrightExtract.fx: -------------------------------------------------------------------------------- 1 | /// BrightExtractEffect 2 | 3 | /// An effect that dims all but the brightest pixels. 4 | 5 | //----------------------------------------------------------------------------------------- 6 | // Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) 7 | //----------------------------------------------------------------------------------------- 8 | 9 | /// Threshold below which values are discarded. 10 | /// 0 11 | /// 1 12 | /// 0.5 13 | float Threshold : register(C0); 14 | 15 | //-------------------------------------------------------------------------------------- 16 | // Sampler Inputs (Brushes, including Texture1) 17 | //-------------------------------------------------------------------------------------- 18 | 19 | sampler2D Texture1Sampler : register(S0); 20 | 21 | 22 | //-------------------------------------------------------------------------------------- 23 | // Pixel Shader 24 | //-------------------------------------------------------------------------------------- 25 | 26 | float4 main(float2 uv : TEXCOORD) : COLOR 27 | { 28 | // Look up the original image color. 29 | float4 originalColor = tex2D(Texture1Sampler, uv); 30 | 31 | // Undo pre-multiplied alpha. 32 | float3 rgb = originalColor.rgb / originalColor.a; 33 | 34 | // Adjust RGB to keep only values brighter than the specified threshold. 35 | rgb = saturate((rgb - Threshold) / (1 - Threshold)); 36 | 37 | // Re-apply alpha. 38 | return float4(rgb * originalColor.a, originalColor.a); 39 | } 40 | 41 | 42 | -------------------------------------------------------------------------------- /Shazzam/Samples/Circles.fx: -------------------------------------------------------------------------------- 1 | /// CirclesEffect 2 | 3 | /// An effect that generates concentric circles. 4 | 5 | //----------------------------------------------------------------------------------------- 6 | // Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) 7 | //----------------------------------------------------------------------------------------- 8 | 9 | /// The center of the swirl. (100,100) is lower right corner 10 | /// 0,0 11 | /// 100,100 12 | /// 50,50 13 | float2 Center : register(C0); 14 | 15 | 16 | 17 | /// The strength of the effect. 18 | /// 0 19 | /// 4 20 | /// 0.9 21 | float Size : register(C2); 22 | 23 | 24 | 25 | //-------------------------------------------------------------------------------------- 26 | // Sampler Inputs (Brushes, including Texture1) 27 | //-------------------------------------------------------------------------------------- 28 | 29 | sampler2D Texture1Sampler : register(S0); 30 | 31 | //-------------------------------------------------------------------------------------- 32 | // Pixel Shader 33 | //-------------------------------------------------------------------------------------- 34 | 35 | float4 main(float2 uv : TEXCOORD) : COLOR 36 | { 37 | // normalize 38 | // ================================ 39 | float2 centerNormalized ={ Center.x/100,Center.y/100}; 40 | 41 | // ================================ 42 | float2 dir = uv - centerNormalized; 43 | float dist = length(dir) * Size; 44 | float angle = atan2(dir.y, dir.x); 45 | 46 | 47 | float2 newDir; 48 | 49 | 50 | return tex2D(Texture1Sampler, centerNormalized + dist ); 51 | } 52 | -------------------------------------------------------------------------------- /Shazzam/Samples/ColorKeyAlpha.fx: -------------------------------------------------------------------------------- 1 | /// ColorKeyAlphaEffect 2 | 3 | /// An effect that makes pixels of a particular color transparent. 4 | 5 | //----------------------------------------------------------------------------------------- 6 | // Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) 7 | //----------------------------------------------------------------------------------------- 8 | 9 | /// The color that becomes transparent. 10 | /// Green 11 | float4 ColorKey : register(C0); 12 | 13 | /// The tolerance in color differences. 14 | /// 0 15 | /// 1 16 | /// 0.3 17 | float Tolerance : register(C1); 18 | 19 | //-------------------------------------------------------------------------------------- 20 | // Sampler Inputs (Brushes, including Texture1) 21 | //-------------------------------------------------------------------------------------- 22 | 23 | sampler2D Texture1Sampler : register(S0); 24 | 25 | //-------------------------------------------------------------------------------------- 26 | // Pixel Shader 27 | //-------------------------------------------------------------------------------------- 28 | 29 | float4 main(float2 uv : TEXCOORD) : COLOR 30 | { 31 | float4 color = tex2D( Texture1Sampler, uv ); 32 | 33 | if (all(abs(color.rgb - ColorKey.rgb) < Tolerance)) { 34 | color.rgba = 0; 35 | } 36 | 37 | return color; 38 | } 39 | -------------------------------------------------------------------------------- /Shazzam/Samples/ColorTone.fx: -------------------------------------------------------------------------------- 1 | /// ColorToneEffect 2 | 3 | /// An effect that blends between partial desaturation and a two-color ramp. 4 | 5 | //----------------------------------------------------------------------------------------- 6 | // Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) 7 | //----------------------------------------------------------------------------------------- 8 | 9 | /// The amount of desaturation to apply. 10 | /// 0 11 | /// 1 12 | /// 0.5 13 | float Desaturation : register(C0); 14 | 15 | /// The amount of color toning to apply. 16 | /// 0 17 | /// 1 18 | /// 0.5 19 | float Toned : register(C1); 20 | 21 | /// The first color to apply to input. This is usually a light tone. 22 | /// Yellow 23 | float4 LightColor : register(C2); 24 | 25 | /// The second color to apply to the input. This is usuall a dark tone. 26 | /// Navy 27 | float4 DarkColor : register(C3); 28 | 29 | //-------------------------------------------------------------------------------------- 30 | // Sampler Inputs (Brushes, including Texture1) 31 | //-------------------------------------------------------------------------------------- 32 | 33 | sampler2D Texture1Sampler : register(S0); 34 | 35 | //-------------------------------------------------------------------------------------- 36 | // Pixel Shader 37 | //-------------------------------------------------------------------------------------- 38 | 39 | float4 main(float2 uv : TEXCOORD) : COLOR 40 | { 41 | float4 color = tex2D(Texture1Sampler, uv); 42 | float3 scnColor = LightColor * (color.rgb / color.a); 43 | float gray = dot(float3(0.3, 0.59, 0.11), scnColor); 44 | 45 | float3 muted = lerp(scnColor, gray.xxx, Desaturation); 46 | float3 middle = lerp(DarkColor, LightColor, gray); 47 | 48 | scnColor = lerp(muted, middle, Toned); 49 | return float4(scnColor * color.a, color.a); 50 | } 51 | 52 | 53 | -------------------------------------------------------------------------------- /Shazzam/Samples/ContrastAdjust.fx: -------------------------------------------------------------------------------- 1 | /// ContrastAdjustEffect 2 | 3 | /// An effect that controls brightness and contrast. 4 | 5 | //----------------------------------------------------------------------------------------- 6 | // Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) 7 | //----------------------------------------------------------------------------------------- 8 | 9 | /// The brightness offset. 10 | /// -1 11 | /// 1 12 | /// 0 13 | float Brightness : register(C0); 14 | 15 | /// The contrast multiplier. 16 | /// 0 17 | /// 2 18 | /// 1.5 19 | float Contrast : register(C1); 20 | 21 | //-------------------------------------------------------------------------------------- 22 | // Sampler Inputs (Brushes, including Texture1) 23 | //-------------------------------------------------------------------------------------- 24 | 25 | sampler2D Texture1Sampler : register(S0); 26 | 27 | //-------------------------------------------------------------------------------------- 28 | // Pixel Shader 29 | //-------------------------------------------------------------------------------------- 30 | 31 | float4 main(float2 uv : TEXCOORD) : COLOR 32 | { 33 | float4 pixelColor = tex2D(Texture1Sampler, uv); 34 | pixelColor.rgb /= pixelColor.a; 35 | 36 | // Apply contrast. 37 | pixelColor.rgb = ((pixelColor.rgb - 0.5f) * max(Contrast, 0)) + 0.5f; 38 | 39 | // Apply brightness. 40 | pixelColor.rgb += Brightness; 41 | 42 | // Return final pixel color. 43 | pixelColor.rgb *= pixelColor.a; 44 | return pixelColor; 45 | } 46 | 47 | 48 | -------------------------------------------------------------------------------- /Shazzam/Samples/Desaturate.fx: -------------------------------------------------------------------------------- 1 | /// Desaturate 2 | /// An effect that turns the input into shades of a single color. 3 | 4 | sampler2D inputSampler : register(S0); 5 | 6 | //----------------------------------------------------------------------------------------- 7 | // Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) 8 | //----------------------------------------------------------------------------------------- 9 | 10 | /// Desaturates an image. the value can be betwen 0 and 1. 0 means the origianl image is returned. 1 means a monochrome image is produced. 11 | /// 0 12 | /// 1 13 | /// 1 14 | float Strength : register(C0); 15 | 16 | float4 main(float2 uv : TEXCOORD) : COLOR 17 | { 18 | float4 srcColor = tex2D(inputSampler, uv); 19 | float3 rgb = srcColor.rgb; 20 | float3 luminance = lerp(rgb, dot(rgb, float3(0.30, 0.59, 0.11)), Strength); 21 | return float4(luminance, srcColor.a); 22 | } -------------------------------------------------------------------------------- /Shazzam/Samples/DirectionalBlur.fx: -------------------------------------------------------------------------------- 1 | /// DirectionalBlurEffect 2 | 3 | /// An effect that blurs in a single direction. 4 | 5 | //----------------------------------------------------------------------------------------- 6 | // Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) 7 | //----------------------------------------------------------------------------------------- 8 | 9 | /// The direction of the blur (in degrees). 10 | /// 0 11 | /// 360 12 | /// 0 13 | float Angle : register(C0); 14 | 15 | /// The scale of the blur (as a fraction of the input size). 16 | /// 0 17 | /// 0.01 18 | /// 0.003 19 | float BlurAmount : register(C1); 20 | 21 | //-------------------------------------------------------------------------------------- 22 | // Sampler Inputs (Brushes, including Texture1) 23 | //-------------------------------------------------------------------------------------- 24 | 25 | sampler2D Texture1Sampler : register(S0); 26 | 27 | //-------------------------------------------------------------------------------------- 28 | // Pixel Shader 29 | //-------------------------------------------------------------------------------------- 30 | 31 | float4 main(float2 uv : TEXCOORD) : COLOR 32 | { 33 | float4 c = 0; 34 | float rad = Angle * 0.0174533f; 35 | float xOffset = cos(rad); 36 | float yOffset = sin(rad); 37 | 38 | for(int i=0; i<16; i++) 39 | { 40 | uv.x = uv.x - BlurAmount * xOffset; 41 | uv.y = uv.y - BlurAmount * yOffset; 42 | c += tex2D(Texture1Sampler, uv); 43 | } 44 | c /= 16; 45 | 46 | return c; 47 | } 48 | -------------------------------------------------------------------------------- /Shazzam/Samples/Embossed.fx: -------------------------------------------------------------------------------- 1 | /// EmbossedEffect 2 | 3 | /// An effect that embosses the input. 4 | 5 | //----------------------------------------------------------------------------------------- 6 | // Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) 7 | //----------------------------------------------------------------------------------------- 8 | 9 | /// The amplitude of the embossing. 10 | /// 0 11 | /// 1 12 | /// 0.5 13 | float Amount : register(C0); 14 | 15 | /// The separation between samples (as a fraction of input size). 16 | /// 0 17 | /// 0.01 18 | /// 0.003 19 | float Width : register(C1); 20 | 21 | //-------------------------------------------------------------------------------------- 22 | // Sampler Inputs (Brushes, including Texture1) 23 | //-------------------------------------------------------------------------------------- 24 | 25 | sampler2D Texture1Sampler : register(S0); 26 | 27 | 28 | //-------------------------------------------------------------------------------------- 29 | // Pixel Shader 30 | //-------------------------------------------------------------------------------------- 31 | 32 | float4 main(float2 uv : TEXCOORD) : COLOR 33 | { 34 | float4 outC = {0.5, 0.5, 0.5, 1.0}; 35 | 36 | outC -= tex2D(Texture1Sampler, uv - Width) * Amount; 37 | outC += tex2D(Texture1Sampler, uv + Width) * Amount; 38 | outC.rgb = (outC.r + outC.g + outC.b) / 3.0f; 39 | 40 | return outC; 41 | } 42 | 43 | 44 | -------------------------------------------------------------------------------- /Shazzam/Samples/Fade.fx: -------------------------------------------------------------------------------- 1 | #include 2 | /// Fade to a colour by animating the strength. 3 | sampler2D inputSampler : register(S0); 4 | 5 | /// The color used to tint the input. 6 | /// 0 7 | /// 1 8 | /// 0 9 | float Strength : register(C0); 10 | 11 | /// The colour to fade to. 12 | /// Black 13 | float4 To : register(C2); 14 | 15 | float4 main(float2 uv : TEXCOORD) : COLOR 16 | { 17 | float4 src = tex2D(inputSampler, uv); 18 | return lerp_rgba(src, To, Strength); 19 | } 20 | -------------------------------------------------------------------------------- /Shazzam/Samples/Generative_Bands.fx: -------------------------------------------------------------------------------- 1 | /// GenerateStar 2 | 3 | /// An effect that swirls the input in alternating clockwise and counterclockwise bands. 4 | 5 | //----------------------------------------------------------------------------------------- 6 | // Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) 7 | //----------------------------------------------------------------------------------------- 8 | 9 | /// The center of the star. 10 | /// 0,0 11 | /// 2,2 12 | /// .5,.5 13 | float2 Center : register(C0); 14 | 15 | 16 | /// The strength of the effect. 17 | /// -2 18 | /// 2 19 | /// 1.8 20 | float ColorStrength : register(C2); 21 | 22 | 23 | /// Green 24 | float4 mainColor : register(C4); 25 | 26 | /// Purple 27 | float4 secondaryColor : register(C5); 28 | 29 | /// -8 30 | /// 8 31 | /// 6 32 | float ringMultiplier : register(C6); 33 | 34 | //-------------------------------------------------------------------------------------- 35 | // Sampler Inputs (Brushes, including ImplicitInput) 36 | //-------------------------------------------------------------------------------------- 37 | 38 | sampler2D inputSource : register(S0); 39 | 40 | //-------------------------------------------------------------------------------------- 41 | // Pixel Shader 42 | //-------------------------------------------------------------------------------------- 43 | 44 | float4 main(float2 uv : TEXCOORD) : COLOR 45 | { 46 | float scaledDistance = tanh(dot(Center.y -uv.y, Center.x -uv.x)) * ringMultiplier; 47 | 48 | float blendFactor = tex2D (inputSource, scaledDistance) * ColorStrength; 49 | 50 | return lerp (secondaryColor, mainColor, blendFactor); 51 | } 52 | -------------------------------------------------------------------------------- /Shazzam/Samples/Generative_Star.fx: -------------------------------------------------------------------------------- 1 | /// GenerateStar 2 | 3 | /// An effect that swirls the input in alternating clockwise and counterclockwise bands. 4 | 5 | //----------------------------------------------------------------------------------------- 6 | // Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) 7 | //----------------------------------------------------------------------------------------- 8 | 9 | /// The center of the star. 10 | /// 0,0 11 | /// 2,2 12 | /// .5,.5 13 | float2 Center : register(C0); 14 | 15 | 16 | 17 | /// The strength of the effect. 18 | /// -2 19 | /// 2 20 | /// 1 21 | float ColorStrength : register(C2); 22 | 23 | 24 | /// Blue 25 | float4 mainColor : register(C4); 26 | 27 | /// Orange 28 | float4 secondaryColor : register(C5); 29 | 30 | /// 0.5 31 | /// 8 32 | /// 2 33 | float ringMultiplier : register(C6); 34 | 35 | //-------------------------------------------------------------------------------------- 36 | // Sampler Inputs (Brushes, including ImplicitInput) 37 | //-------------------------------------------------------------------------------------- 38 | 39 | sampler2D inputSource : register(S0); 40 | 41 | //-------------------------------------------------------------------------------------- 42 | // Pixel Shader 43 | //-------------------------------------------------------------------------------------- 44 | 45 | float4 main(float2 uv : TEXCOORD) : COLOR 46 | { 47 | float scaledDistance = sqrt(dot(Center.y -uv.y, Center.x -uv.x)) * ringMultiplier; 48 | 49 | float blendFactor = tex2D (inputSource, scaledDistance) * ColorStrength; 50 | 51 | return lerp (secondaryColor, mainColor, blendFactor); 52 | } 53 | -------------------------------------------------------------------------------- /Shazzam/Samples/GlassTiles.fx: -------------------------------------------------------------------------------- 1 | /// GlassTileEffect 2 | /// An effect mimics the look of glass tiles. 3 | // ------------------------------------------------------------------------------------ 4 | 5 | // contributed by Fakhruddin Faizal 6 | // http://hdprogramming.blogspot.com/ 7 | // modifications by Walt Ritscher 8 | // ----------------------------------------------------------------------------------------- 9 | // Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) 10 | // ----------------------------------------------------------------------------------------- 11 | 12 | 13 | /// The approximate number of tiles per row/column. 14 | /// 0 15 | /// 20 16 | ///5 17 | float Tiles : register(C0); 18 | 19 | /// The gap width between the tiles. 20 | /// 0/minValue> 21 | /// 10 22 | ///1 23 | float BevelWidth : register(C1); 24 | 25 | /// The offset for the upper left corner of the tiles. 26 | /// 0/minValue> 27 | /// 3 28 | ///1 29 | float Offset: register(C3); 30 | 31 | /// The color for the gap between the tiles. 32 | /// 0/minValue> 33 | /// 10 34 | ///1 35 | float4 GroutColor : register(C2); 36 | 37 | sampler2D input : register(s0); 38 | 39 | float4 main(float2 uv : TEXCOORD) : COLOR 40 | { 41 | float2 newUV1; 42 | newUV1.xy = uv.xy + tan((Tiles*2.5)*uv.xy + Offset)*(BevelWidth/100); 43 | 44 | float4 c1 = tex2D(input, newUV1); 45 | if(newUV1.x<0 || newUV1.x>1 || newUV1.y<0 || newUV1.y>1) 46 | { 47 | 48 | c1 = GroutColor; 49 | } 50 | c1.a=1; 51 | return c1; 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Shazzam/Samples/HslWheel.fx: -------------------------------------------------------------------------------- 1 | #include 2 | static float2 cp = float2(0.5, 0.5); 3 | 4 | /// The inner radius. 5 | /// 0 6 | /// 1 7 | /// 0 8 | float InnerRadius : register(C0); 9 | 10 | /// The inner saturation. 11 | /// 0 12 | /// 1 13 | /// 0 14 | float InnerSaturation : register(C1); 15 | 16 | /// The value in Hue, Saturation, Value. 17 | /// 0 18 | /// 1 19 | /// 0.5 20 | float Lightness : register(C2); 21 | 22 | /// The starting angle of the gradient, clockwise from X-axis 23 | /// -360 24 | /// 360 25 | /// 90 26 | float StartAngle : register(C3); 27 | 28 | /// The central angle of the gradient, positive value for clockwise. 29 | /// -360 30 | /// 360 31 | /// -360 32 | float CentralAngle : register(C4); 33 | 34 | float3 HUEtoRGB(in float H) 35 | { 36 | float R = abs(H * 6 - 3) - 1; 37 | float G = 2 - abs(H * 6 - 2); 38 | float B = 2 - abs(H * 6 - 4); 39 | return saturate(float3(R, G, B)); 40 | } 41 | 42 | // http://www.chilliant.com/rgb2hsv.html 43 | float3 HSLtoRGB(in float3 HSL) 44 | { 45 | float3 RGB = HUEtoRGB(HSL.x); 46 | float C = (1 - abs(2 * HSL.z - 1)) * HSL.y; 47 | return (RGB - 0.5) * C + HSL.z; 48 | } 49 | 50 | float4 main(float2 uv : TEXCOORD) : COLOR 51 | { 52 | float2 rv = uv - cp; 53 | float r = length(rv); 54 | float ir = InnerRadius / 2; 55 | if (r >= ir && r <= 0.5) 56 | { 57 | float sa = radians(StartAngle); 58 | float ca = radians(CentralAngle); 59 | float h = interpolate( 60 | 0, 61 | abs(ca), 62 | angle_from_start(uv, cp, sa, ca)); 63 | float s = lerp(InnerSaturation, 1, interpolate(ir, 0.5, r)); 64 | float l = Lightness; 65 | return float4(HSLtoRGB(float3(h, s, l)), 1); 66 | } 67 | 68 | return float4(0, 0, 0, 0); 69 | } -------------------------------------------------------------------------------- /Shazzam/Samples/HsvWheel.fx: -------------------------------------------------------------------------------- 1 | #include 2 | static float2 cp = float2(0.5, 0.5); 3 | 4 | /// The inner radius. 5 | /// 0 6 | /// 1 7 | /// 0 8 | float InnerRadius : register(C0); 9 | 10 | /// The inner saturation. 11 | /// 0 12 | /// 1 13 | /// 0 14 | float InnerSaturation : register(C1); 15 | 16 | /// The value. 17 | /// 0 18 | /// 1 19 | /// 1 20 | float Value : register(C2); 21 | 22 | /// The starting angle of the gradient, clockwise from X-axis 23 | /// -360 24 | /// 360 25 | /// 90 26 | float StartAngle : register(C3); 27 | 28 | /// The central angle of the gradient, positive value for clockwise. 29 | /// -360 30 | /// 360 31 | /// -360 32 | float CentralAngle : register(C4); 33 | 34 | float3 HUEtoRGB(in float H) 35 | { 36 | float R = abs(H * 6 - 3) - 1; 37 | float G = 2 - abs(H * 6 - 2); 38 | float B = 2 - abs(H * 6 - 4); 39 | return saturate(float3(R, G, B)); 40 | } 41 | 42 | // http://www.chilliant.com/rgb2hsv.html 43 | float3 HSVtoRGB(in float3 HSV) 44 | { 45 | float3 RGB = HUEtoRGB(HSV.x); 46 | return ((RGB - 1) * HSV.y + 1) * HSV.z; 47 | } 48 | 49 | float4 main(float2 uv : TEXCOORD) : COLOR 50 | { 51 | float2 rv = uv - cp; 52 | float r = length(rv); 53 | float ir = InnerRadius / 2; 54 | if (r >= ir && r <= 0.5) 55 | { 56 | float sa = radians(StartAngle); 57 | float ca = radians(CentralAngle); 58 | float h = interpolate( 59 | 0, 60 | abs(ca), 61 | angle_from_start(uv, cp, sa, ca)); 62 | float s = lerp(InnerSaturation, 1, interpolate(ir, 0.5, r)); 63 | float v = Value; 64 | return float4(HSVtoRGB(float3(h, s, v)), 1); 65 | } 66 | 67 | return float4(0, 0, 0, 0); 68 | } -------------------------------------------------------------------------------- /Shazzam/Samples/InvertColor.fx: -------------------------------------------------------------------------------- 1 | /// InvertColorEffect 2 | 3 | /// An effect that inverts all colors. 4 | 5 | //-------------------------------------------------------------------------------------- 6 | // Sampler Inputs (Brushes, including Texture1) 7 | //-------------------------------------------------------------------------------------- 8 | 9 | sampler2D Texture1Sampler : register(S0); 10 | 11 | //-------------------------------------------------------------------------------------- 12 | // Pixel Shader 13 | //-------------------------------------------------------------------------------------- 14 | 15 | float4 main(float2 uv : TEXCOORD) : COLOR 16 | { 17 | float4 color = tex2D( Texture1Sampler, uv ); 18 | float4 invertedColor = float4(color.a - color.rgb, color.a); 19 | return invertedColor; 20 | } 21 | -------------------------------------------------------------------------------- /Shazzam/Samples/LinearGradient.fx: -------------------------------------------------------------------------------- 1 | sampler2D inputSampler : register(S0); 2 | 3 | /// The primary color of the gradient. 4 | /// Blue 5 | float4 StartColor : register(C1); 6 | 7 | /// The secondary color of the gradient. 8 | /// Red 9 | float4 EndColor : register(C2); 10 | 11 | float4 lerp_rgba(float4 x, float4 y, float s) 12 | { 13 | float a = lerp(x.a, y.a, s); 14 | float3 rgb = lerp(x.rgb, y.rgb, s) * a; 15 | return float4(rgb.r, rgb.g, rgb.b, a); 16 | } 17 | 18 | float4 main(float2 uv : TEXCOORD) : COLOR 19 | { 20 | return lerp_rgba(StartColor, EndColor, uv.x); 21 | } -------------------------------------------------------------------------------- /Shazzam/Samples/Magnify.fx: -------------------------------------------------------------------------------- 1 | /// MagnifyEffect 2 | 3 | /// An effect that magnifies a circular region. 4 | 5 | //----------------------------------------------------------------------------------------- 6 | // Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) 7 | //----------------------------------------------------------------------------------------- 8 | 9 | /// The center point of the magnified region. 10 | /// 0,0 11 | /// 1,1 12 | /// 0.5,0.5 13 | float2 Center : register(C0); 14 | 15 | /// The radius of the magnified region. 16 | /// 0 17 | /// 1 18 | /// 0.25 19 | float Radius : register(C1); 20 | 21 | /// The magnification factor. 22 | /// 1 23 | /// 5 24 | /// 2 25 | float Magnification : register(C2); 26 | 27 | /// The aspect ratio (width / height) of the input. 28 | /// 0.5 29 | /// 2 30 | /// 1.5 31 | float AspectRatio : register(C4); 32 | 33 | //-------------------------------------------------------------------------------------- 34 | // Sampler Inputs (Brushes, including Texture1) 35 | //-------------------------------------------------------------------------------------- 36 | 37 | sampler2D Texture1Sampler : register(S0); 38 | 39 | //-------------------------------------------------------------------------------------- 40 | // Pixel Shader 41 | //-------------------------------------------------------------------------------------- 42 | 43 | float4 main(float2 uv : TEXCOORD) : COLOR 44 | { 45 | float2 centerToPixel = uv - Center; 46 | float dist = length(centerToPixel / float2(1, AspectRatio)); 47 | float2 samplePoint = uv; 48 | if (dist < Radius) { 49 | samplePoint = Center + centerToPixel / Magnification; 50 | } 51 | return tex2D(Texture1Sampler, samplePoint); 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Shazzam/Samples/Mask.fx: -------------------------------------------------------------------------------- 1 | /// MaskEffect 2 | /// An effect that makes black pixels transparent and all other pixels the provided color. 3 | 4 | //----------------------------------------------------------------------------------------- 5 | // Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) 6 | //----------------------------------------------------------------------------------------- 7 | 8 | /// The color to use for nonblack pixels. 9 | /// #66FF0000 10 | float4 Color : register(C0); 11 | 12 | /// The tolerance for what to treat as black. 13 | /// 0 14 | /// 1 15 | /// 0.1 16 | float Tolerance : register(C1); 17 | 18 | //-------------------------------------------------------------------------------------- 19 | // Sampler Inputs (Brushes, including Texture1) 20 | //-------------------------------------------------------------------------------------- 21 | sampler2D Texture1Sampler : register(S0); 22 | 23 | float4 main(float2 uv : TEXCOORD) : COLOR 24 | { 25 | float4 color = tex2D(Texture1Sampler, uv); 26 | if (all(color.rgb < Tolerance)) 27 | { 28 | return Color; 29 | } 30 | 31 | color.rgba = 0; 32 | return color; 33 | } -------------------------------------------------------------------------------- /Shazzam/Samples/Monochrome.fx: -------------------------------------------------------------------------------- 1 | /// MonochromeEffect 2 | 3 | /// An effect that turns the input into shades of a single color. 4 | 5 | //----------------------------------------------------------------------------------------- 6 | // Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) 7 | //----------------------------------------------------------------------------------------- 8 | 9 | /// The color used to tint the input. 10 | /// Yellow 11 | float4 FilterColor : register(C0); 12 | 13 | //-------------------------------------------------------------------------------------- 14 | // Sampler Inputs (Brushes, including Texture1) 15 | //-------------------------------------------------------------------------------------- 16 | 17 | sampler2D Texture1Sampler : register(S0); 18 | 19 | //-------------------------------------------------------------------------------------- 20 | // Pixel Shader 21 | //-------------------------------------------------------------------------------------- 22 | 23 | float4 main(float2 uv : TEXCOORD) : COLOR 24 | { 25 | float4 srcColor = tex2D(Texture1Sampler, uv); 26 | float3 rgb = srcColor.rgb; 27 | float3 luminance = dot(rgb, float3(0.30, 0.59, 0.11)); 28 | return float4(luminance * FilterColor.rgb, srcColor.a); 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /Shazzam/Samples/MultiInput_ColorChannels.fx: -------------------------------------------------------------------------------- 1 | sampler2D input : register(s0); 2 | 3 | 4 | /// The second input texture. 5 | /// c:\examplefolder\examplefile.jpg 6 | sampler2D Texture1 : register(s1); 7 | 8 | /// Change the ratio between the Red channel 9 | /// 0/minValue> 10 | /// 1 11 | /// 1 12 | float RedRatio : register(C0); 13 | 14 | /// Change the ratio between the Blue channel 15 | /// 0/minValue> 16 | /// 1 17 | /// 0.5 18 | float BlueRatio : register(C1); 19 | 20 | /// Change the ratio between the Green channel 21 | /// 0/minValue> 22 | /// 1 23 | /// 0.5 24 | float GreenRatio : register(C2); 25 | float4 main(float2 uv : TEXCOORD) : COLOR 26 | { 27 | 28 | float4 inputTex = tex2D(input, uv); 29 | float4 otherTex = tex2D(Texture1, uv); // texture 30 | inputTex.r = inputTex.r * (1-RedRatio ) + (otherTex.r * RedRatio); 31 | inputTex.b = inputTex.b * (1-BlueRatio ) + (otherTex.b * BlueRatio); 32 | inputTex.g = inputTex.g * (1-GreenRatio ) + (otherTex.g * GreenRatio); 33 | return inputTex; 34 | } 35 | -------------------------------------------------------------------------------- /Shazzam/Samples/MultiInput_FourSources.fx: -------------------------------------------------------------------------------- 1 | sampler2D Texture1 : register(s0); 2 | 3 | // use samples with dark edges 4 | // otherwise the combined colors will wash out result 5 | 6 | /// The second input texture. 7 | /// c:\examplefolder\examplefile.jpg 8 | sampler2D Texture2 : register(s1); 9 | /// The third input texture. 10 | /// c:\examplefolder\examplefile.jpg 11 | sampler2D Texture3 : register(s2); 12 | /// The fourth input texture. 13 | /// c:\examplefolder\examplefile.jpg 14 | sampler2D Texture4 : register(s3); 15 | 16 | /// The horizontal offset for this sample. 17 | /// 1/minValue> 18 | /// 5 19 | /// 1 20 | float Offset1 : register(C0); 21 | 22 | /// The horizontal offset for this sample. 23 | /// 1/minValue> 24 | /// 5 25 | /// 2 26 | float Offset2 : register(C1); 27 | 28 | 29 | /// The horizontal offset for this sample. 30 | /// 1/minValue> 31 | /// 5 32 | /// 3 33 | float Offset3 : register(C2); 34 | 35 | /// The horizontal offset for this sample. 36 | /// 1/minValue> 37 | /// 5 38 | /// 4 39 | float Offset4 : register(C3); 40 | float4 main(float2 uv : TEXCOORD) : COLOR 41 | { 42 | float columnCount = 4; 43 | float repeatInterval = 4; 44 | float2 uv1 = float2(( Offset1- uv.x * columnCount % repeatInterval) , (uv.y )) ; 45 | float2 uv2 = float2(( Offset2 -( uv.x * columnCount % repeatInterval) ) , (uv.y )) ; 46 | float2 uv3 = float2(( Offset3 -( uv.x * columnCount % repeatInterval) ) , (uv.y )) ; 47 | float2 uv4 = float2(( Offset4 -( uv.x * columnCount % repeatInterval) ) , (uv.y )) ; 48 | 49 | float4 texA = tex2D(Texture1, uv1); 50 | float4 texB = tex2D(Texture2, uv2); 51 | float4 texC= tex2D(Texture3, uv3); 52 | float4 texD = tex2D(Texture4, uv4); 53 | // return ((inputTex*Ratio)+(otherTex*(1 - Ratio))); // mix two images 54 | 55 | //float2 newUv = float2((uv.x * 2 % 1) , (uv.y * 2 % 1)) ; 56 | return texA*.6 + texB*.6 + texC *.6 +texD *.6; 57 | } 58 | -------------------------------------------------------------------------------- /Shazzam/Samples/MultiInput_MergeImages.fx: -------------------------------------------------------------------------------- 1 | sampler2D input : register(s0); 2 | 3 | 4 | /// The second input texture. 5 | /// c:\examplefolder\examplefile.jpg 6 | sampler2D Texture1 : register(s1); 7 | 8 | /// Change the ratio between the two Textures. 0 is 100% input source, 1 is 100 9 | /// 0/minValue> 10 | /// 1 11 | /// .5 12 | float Ratio : register(C0); 13 | float4 main(float2 uv : TEXCOORD) : COLOR 14 | { 15 | 16 | float4 inputTex = tex2D(input, uv); 17 | float4 otherTex = tex2D(Texture1, uv); // texture 18 | return ((inputTex*Ratio)+(otherTex*(1 - Ratio))); // mix two images 19 | } 20 | -------------------------------------------------------------------------------- /Shazzam/Samples/MultiInput_Shift.fx: -------------------------------------------------------------------------------- 1 | sampler2D input : register(s0); 2 | 3 | 4 | /// The second input texture. 5 | /// c:\examplefolder\examplefile.jpg 6 | sampler2D Texture1 : register(s1); 7 | 8 | /// Change the ratio between the two Textures. 0 is 100% input source, 1 is 100 9 | /// 0/minValue> 10 | /// 1 11 | /// .5 12 | float Ratio : register(C0); 13 | float4 main(float2 uv : TEXCOORD) : COLOR 14 | { 15 | float2 rev =uv; 16 | float temp = rev.x; 17 | rev.x = rev.y; 18 | rev.y = temp; 19 | float4 inputTex = tex2D(input, uv); 20 | float4 otherTex = tex2D(Texture1, rev); 21 | return ((inputTex*Ratio)+(otherTex*(1 - Ratio))); // mix two images 22 | } 23 | -------------------------------------------------------------------------------- /Shazzam/Samples/New.txt: -------------------------------------------------------------------------------- 1 | sampler2D input : register(s0); 2 | 3 | // new HLSL shader 4 | 5 | /// Explain the purpose of this variable. 6 | /// 5/minValue> 7 | /// 10 8 | /// 3.5 9 | float SampleI : register(C0); 10 | 11 | float4 main(float2 uv : TEXCOORD) : COLOR 12 | { 13 | float4 Color; 14 | Color= tex2D(input, uv.xy); 15 | 16 | return Color; 17 | } 18 | -------------------------------------------------------------------------------- /Shazzam/Samples/PaperFold.fx: -------------------------------------------------------------------------------- 1 |  // http://www.silverlightshow.net/items/Book-Folding-effect-using-Pixel-Shader.aspx 2 | 3 | sampler2D input : register(s0); 4 | 5 | /// The Left 6 | /// 0 7 | /// 1 8 | /// 0 9 | float left : register(c0); 10 | float4 transform(float2 uv : TEXCOORD) : COLOR 11 | { 12 | float right = 1 - left; 13 | // transforming the curent point (uv) according to the new boundaries. 14 | float2 tuv = float2((uv.x - left) / (right - left), uv.y); 15 | 16 | float tx = tuv.x; 17 | if (tx > 0.5) 18 | { 19 | tx = 1 - tx; 20 | } 21 | float top = left * tx; 22 | float bottom = 1 - top; 23 | if (uv.y >= top && uv.y <= bottom) 24 | { 25 | //linear interpolation between 0 and 1 considering the angle of folding. 26 | float ty = lerp(0, 1, (tuv.y - top) / (bottom - top)); 27 | // get the pixel from the transformed x and interpolated y. 28 | return tex2D(input, float2(tuv.x, ty)); 29 | } 30 | return 0; 31 | } 32 | 33 | float4 main(float2 uv : TEXCOORD) : COLOR 34 | { 35 | float right = 1 - left; 36 | if(uv.x > left && uv.x < right) 37 | { 38 | return transform(uv); 39 | } 40 | 41 | return 0; 42 | } -------------------------------------------------------------------------------- /Shazzam/Samples/PaperFoldModded.fx: -------------------------------------------------------------------------------- 1 |  2 | sampler2D input : register(s0); 3 | 4 | 5 | // The Left 6 | /// 0 7 | /// .5 8 | /// 0.2 9 | float left : register(c0); 10 | /// The Left 11 | /// 0 12 | /// 1 13 | /// 0.7 14 | float edge : register(c1); 15 | float4 transform(float2 uv : TEXCOORD) : COLOR 16 | { 17 | float right =.5 - left; 18 | // transforming the curent point (uv) according to the new boundaries. 19 | float2 transformedUv = float2((uv.x - left) / (right - left), uv.y); 20 | 21 | float tx = transformedUv.x; 22 | // if (tx > edge) 23 | // { 24 | /// tx = 1 - tx; 25 | //} 26 | float top = left * tx ; 27 | float bottom = 1 - top; 28 | if (uv.y >= top && uv.y <= bottom) 29 | { 30 | //linear interpolation between 0 and 1 considering the angle of folding. 31 | float ty = lerp(0, 1, (transformedUv.y - top ) / (bottom - top)+.1); 32 | // get the pixel from the transformed x and interpolated y. 33 | return tex2D(input, float2(transformedUv.x , ty)); 34 | } 35 | return 0; 36 | } 37 | 38 | float4 main(float2 uv : TEXCOORD) : COLOR 39 | { 40 | float right = 1 - left; 41 | if(uv.x > left && uv.x < right) 42 | { 43 | return transform(uv); 44 | } 45 | 46 | return 0; 47 | } -------------------------------------------------------------------------------- /Shazzam/Samples/Pinch.fx: -------------------------------------------------------------------------------- 1 | /// PinchEffect 2 | 3 | /// An effect that pinches a circular region. 4 | 5 | //----------------------------------------------------------------------------------------- 6 | // Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) 7 | //----------------------------------------------------------------------------------------- 8 | 9 | /// The center point of the pinched region. 10 | /// 0,0 11 | /// 1,1 12 | /// 0.5,0.5 13 | float2 Center : register(C0); 14 | 15 | /// The radius of the pinched region. 16 | /// 0 17 | /// 1 18 | /// 0.25 19 | float Radius : register(C1); 20 | 21 | /// The strength of the pinch effect. 22 | /// 0 23 | /// 2 24 | /// 1 25 | float Strength : register(C2); 26 | 27 | /// The aspect ratio (width / height) of the input. 28 | /// 0.5 29 | /// 2 30 | /// 1.5 31 | float AspectRatio : register(C3); 32 | 33 | //-------------------------------------------------------------------------------------- 34 | // Sampler Inputs (Brushes, including Texture1) 35 | //-------------------------------------------------------------------------------------- 36 | 37 | sampler2D Texture1Sampler : register(S0); 38 | 39 | 40 | //-------------------------------------------------------------------------------------- 41 | // Pixel Shader 42 | //-------------------------------------------------------------------------------------- 43 | 44 | float4 main(float2 uv : TEXCOORD) : COLOR 45 | { 46 | float2 dir = Center - uv; 47 | float2 scaledDir = dir; 48 | scaledDir.y /= AspectRatio; 49 | float dist = length(scaledDir); 50 | float range = saturate(1 - (dist / (abs(-sin(Radius * 8) * Radius) + 0.00000001F))); 51 | float2 samplePoint = uv + dir * range * Strength; 52 | return tex2D(Texture1Sampler, samplePoint); 53 | } 54 | 55 | 56 | -------------------------------------------------------------------------------- /Shazzam/Samples/Pivot1.fx: -------------------------------------------------------------------------------- 1 |  2 | sampler2D input : register(s0); 3 | 4 | 5 | // The Left 6 | /// 0 7 | /// .5 8 | /// 0 9 | float left : register(c0); 10 | /// The Left 11 | /// 0 12 | /// 1 13 | /// 0.5 14 | float edge : register(c1); 15 | float4 transform(float2 uv : TEXCOORD) : COLOR 16 | { 17 | float right = 1 - left; 18 | // transforming the curent point (uv) according to the new boundaries. 19 | float2 tuv = float2((uv.x - left) / (right - left), uv.y); 20 | 21 | float tx = tuv.x -edge; 22 | if (tx > edge) 23 | { 24 | tx = 1 - tx; 25 | } 26 | float top = left * tx; 27 | float bottom = 1 - top; 28 | if (uv.y >= top && uv.y <= bottom) 29 | { 30 | //linear interpolation between 0 and 1 considering the angle of folding. 31 | float ty = lerp(0, 1, (tuv.y - top ) / (bottom - top)); 32 | // get the pixel from the transformed x and interpolated y. 33 | return tex2D(input, float2(tuv.x , ty)); 34 | } 35 | return 0; 36 | } 37 | 38 | float4 main(float2 uv : TEXCOORD) : COLOR 39 | { 40 | float right = 1 - left; 41 | if(uv.x > left && uv.x < right) 42 | { 43 | return transform(uv); 44 | } 45 | 46 | return 0; 47 | } -------------------------------------------------------------------------------- /Shazzam/Samples/Pixelate.fx: -------------------------------------------------------------------------------- 1 | /// PixelateEffect 2 | 3 | /// An effect that turns the input into blocky pixels. 4 | 5 | //----------------------------------------------------------------------------------------- 6 | // Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) 7 | //----------------------------------------------------------------------------------------- 8 | 9 | /// The number of horizontal and vertical pixel blocks. 10 | /// Size 11 | /// 20,20 12 | /// 100,100 13 | /// 60,40 14 | float2 PixelCounts : register(C0); 15 | 16 | /// The amount to shift alternate rows (use 1 to get a brick wall look). 17 | /// 0 18 | /// 1 19 | /// 0 20 | float BrickOffset : register(C1); 21 | 22 | //-------------------------------------------------------------------------------------- 23 | // Sampler Inputs (Brushes, including Texture1) 24 | //-------------------------------------------------------------------------------------- 25 | 26 | sampler2D Texture1Sampler : register(S0); 27 | 28 | //-------------------------------------------------------------------------------------- 29 | // Pixel Shader 30 | //-------------------------------------------------------------------------------------- 31 | 32 | float4 main(float2 uv : TEXCOORD) : COLOR 33 | { 34 | float2 brickSize = 1.0 / PixelCounts; 35 | 36 | // Offset every other row of bricks 37 | float2 offsetuv = uv; 38 | bool oddRow = floor(offsetuv.y / brickSize.y) % 2.0 >= 1.0; 39 | if (oddRow) 40 | { 41 | offsetuv.x += BrickOffset * brickSize.x / 2.0; 42 | } 43 | 44 | float2 brickNum = floor(offsetuv / brickSize); 45 | float2 centerOfBrick = brickNum * brickSize + brickSize / 2; 46 | float4 color = tex2D(Texture1Sampler, centerOfBrick); 47 | 48 | return color; 49 | } 50 | 51 | 52 | -------------------------------------------------------------------------------- /Shazzam/Samples/Sharpen.fx: -------------------------------------------------------------------------------- 1 | /// SharpenEffect 2 | 3 | /// An effect that sharpens the input. 4 | 5 | //----------------------------------------------------------------------------------------- 6 | // Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) 7 | //----------------------------------------------------------------------------------------- 8 | 9 | /// The amount of sharpening. 10 | /// 0 11 | /// 2 12 | /// 1 13 | float Amount : register(C0); 14 | 15 | /// The size of the input (in pixels). 16 | /// Size 17 | /// 1,1 18 | /// 1000,1000 19 | /// 800,600 20 | float2 InputSize : register(C1); 21 | 22 | //-------------------------------------------------------------------------------------- 23 | // Sampler Inputs (Brushes, including Texture1) 24 | //-------------------------------------------------------------------------------------- 25 | 26 | sampler2D Texture1Sampler : register(S0); 27 | 28 | 29 | //-------------------------------------------------------------------------------------- 30 | // Pixel Shader 31 | //-------------------------------------------------------------------------------------- 32 | 33 | float4 main(float2 uv : TEXCOORD) : COLOR 34 | { 35 | float2 offset = 1 / InputSize; 36 | float4 color = tex2D(Texture1Sampler, uv); 37 | color.rgb += tex2D(Texture1Sampler, uv - offset) * Amount; 38 | color.rgb -= tex2D(Texture1Sampler, uv + offset) * Amount; 39 | return color; 40 | } 41 | 42 | 43 | -------------------------------------------------------------------------------- /Shazzam/Samples/SketchGranite.fx: -------------------------------------------------------------------------------- 1 | /// SketchGraniteEffect 2 | 3 | /// An paper sketch effect. 4 | 5 | // Created by Ali Daneshmandi 6 | // http://daneshmandi.spaces.live.com/ 7 | // http://vimeo.com/user2530151 8 | 9 | 10 | /// The brush size of the sketch effect. 11 | /// 0.0006 12 | /// 0.01 13 | /// 0.003 14 | float brushSize : register(C0); 15 | 16 | sampler Image : register(s0); 17 | float4 main(float2 texCoord: TEXCOORD,uniform float scale,uniform float pixelSize) : COLOR 18 | { 19 | float4 color = tex2D( Image, texCoord ); 20 | float2 samples[4] = {0, -1, -1, 0, 1, 0, 0, 1 }; 21 | float4 laplace = -4 * color; 22 | 23 | for (int i = 0; i < 4; i++) 24 | { 25 | laplace += tex2D(Image, texCoord + brushSize * samples[i]); 26 | laplace.r=laplace.rgb; 27 | laplace.g=laplace.rgb; 28 | laplace.b=laplace.rgb; 29 | } 30 | 31 | laplace =(1/ laplace); 32 | float4 complement; 33 | complement.rgb=1-laplace.rgb; 34 | complement.a = color.a; 35 | if(complement.r>1) 36 | { 37 | float gray = complement.r * 0.3 + complement.g * 0.59 + complement.b *0.11; 38 | complement.r = gray; 39 | complement.g = gray; 40 | complement.b = gray; 41 | return complement; 42 | } 43 | else 44 | { 45 | float gray = color.r * 0.3 + color.g * 0.59 + color.b *0.11; 46 | color.r = gray; 47 | color.g = gray; 48 | color.b = gray; 49 | return color; 50 | } 51 | } 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Shazzam/Samples/SketchPencilStroke.fx: -------------------------------------------------------------------------------- 1 |  /// SketchPencilStrokeEffect/class> 2 | 3 | /// A pencil stroke effect. 4 | 5 | // Created by Ali Daneshmandi 6 | // http://daneshmandi.spaces.live.com/ 7 | // http://vimeo.com/user2530151 8 | 9 | /// The brush size of the sketch effect. 10 | /// 0.001 11 | /// 0.019 12 | /// 0.005 13 | float brushSize : register(C0); 14 | 15 | sampler Image : register(s0); 16 | float4 main(float2 texCoord: TEXCOORD,uniform float scale,uniform float pixelSize) : COLOR 17 | { 18 | float4 color = tex2D( Image, texCoord ); 19 | float2 samples[4] = {0, -1, -1, 0, 1, 0, 0, 1 }; 20 | float4 complement = -4 * color; 21 | 22 | for (int i = 0; i < 4; i++) 23 | { 24 | complement += tex2D(Image, texCoord + (brushSize * samples[i])); 25 | complement.r=complement.rgb; 26 | complement.g=complement.rgb; 27 | complement.b=complement.rgb; 28 | complement.a=color.a; 29 | } 30 | 31 | complement.rgb=1-complement.rgb; 32 | return complement; 33 | 34 | } 35 | 36 | -------------------------------------------------------------------------------- /Shazzam/Samples/Splinter.fx: -------------------------------------------------------------------------------- 1 | /// Splinter 2 | /// Applies a triangular splinter pattern 3 | /// 4 | 5 | 6 | /// Change the horizontal offset of each tile. 7 | /// 0.01 8 | /// 1.5 9 | /// 1 10 | float SplinterIntensity : register(C3); 11 | 12 | 13 | /// Change the horizontal offset of each tile. 14 | /// 0.01 15 | /// 2/maxValue> 16 | /// 1 17 | float Multiplier : register(C2); 18 | 19 | 20 | /// Change the horizontal offset of each tile. 21 | /// 0.1 22 | /// 2 23 | /// .5 24 | float Push : register(C4); 25 | 26 | 27 | 28 | sampler2D Texture1Sampler : register(S0); 29 | 30 | float4 main(float2 uv : TEXCOORD) : COLOR 31 | { 32 | //float2 locator = float2(uv.x * uv.y % SplinterIntensity , uv.y / uv.x % Multiplier) ; 33 | 34 | float2 locator = float2(((uv.x *Push) + SplinterIntensity % uv.y) * sin (Multiplier) , sin( uv.y % uv.x) ); 35 | return tex2D( Texture1Sampler, locator ); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Shazzam/Samples/Swirl.fx: -------------------------------------------------------------------------------- 1 | /// SwirlEffect 2 | 3 | /// An effect that swirls the input in a spiral. 4 | 5 | //----------------------------------------------------------------------------------------- 6 | // Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) 7 | //----------------------------------------------------------------------------------------- 8 | 9 | /// The center point of the spiral. (1,1) is lower right corner 10 | /// 0,0 11 | /// 1,1 12 | /// 0.5,0.5 13 | float2 Center : register(C0); 14 | 15 | /// The amount of twist to the spiral. 16 | /// 0 17 | /// 20 18 | /// 10 19 | float SpiralStrength : register(C1); 20 | 21 | /// The aspect ratio (width / height) of the input. 22 | /// 0.5 23 | /// 2 24 | /// 1.5 25 | float AspectRatio : register(C2); 26 | 27 | //-------------------------------------------------------------------------------------- 28 | // Sampler Inputs (Brushes, including Texture1) 29 | //-------------------------------------------------------------------------------------- 30 | 31 | sampler2D Texture1Sampler : register(S0); 32 | 33 | //-------------------------------------------------------------------------------------- 34 | // Pixel Shader 35 | //-------------------------------------------------------------------------------------- 36 | 37 | float4 main(float2 uv : TEXCOORD) : COLOR 38 | { 39 | float2 dir = uv - Center; 40 | dir.y /= AspectRatio; 41 | float dist = length(dir); 42 | float angle = atan2(dir.y, dir.x); 43 | 44 | float newAngle = angle + SpiralStrength * dist; 45 | float2 newDir; 46 | sincos(newAngle, newDir.y, newDir.x); 47 | newDir.y *= AspectRatio; 48 | 49 | float2 samplePoint = Center + newDir * dist; 50 | bool isValid = all(samplePoint >= 0 && samplePoint <= 1); 51 | return isValid ? tex2D(Texture1Sampler, samplePoint) : float4(0, 0, 0, 0); 52 | } 53 | 54 | 55 | -------------------------------------------------------------------------------- /Shazzam/Samples/Tiler.fx: -------------------------------------------------------------------------------- 1 | /// Tiler 2 | /// Pixel shader tiles the image across multiple rows and columns 3 | /// 4 | 5 | // Created by A.Boschin: andrea@boschin.it 6 | // site: http://www.silverlightplayground.org 7 | // blog: http://blog.boschin.it 8 | 9 | 10 | /// The number of verical tiles to add to the output. The higher the value the more tiles. 11 | /// 0 12 | /// 20 13 | /// 4 14 | float VerticalTileCount : register(C1); 15 | 16 | /// The number of horizontal tiles to add to the output. The higher the value the more tiles. 17 | /// 0 18 | /// 20 19 | /// 3 20 | float HorizontalTileCount : register(C2); 21 | 22 | /// Change the horizontal offset of each tile. 23 | /// 0 24 | /// 1 25 | /// 0 26 | float HorizontalOffset : register(C3); 27 | 28 | /// Change the vertical offset of each tile. 29 | /// 0 30 | /// 1 31 | /// 0 32 | float VerticalOffset : register(C4); 33 | 34 | 35 | sampler2D Texture1Sampler : register(S0); 36 | 37 | float4 main(float2 uv : TEXCOORD) : COLOR 38 | { 39 | float2 newUv = float2((uv.x * HorizontalTileCount % 1) + HorizontalOffset , (uv.y * VerticalTileCount % 1)+VerticalOffset) ; 40 | return tex2D( Texture1Sampler, newUv ); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Shazzam/Samples/ToonShader.fx: -------------------------------------------------------------------------------- 1 | /// ToonShaderEffect 2 | 3 | /// An effect that applies cartoon-like shading (posterization). 4 | 5 | //----------------------------------------------------------------------------------------- 6 | // Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) 7 | //----------------------------------------------------------------------------------------- 8 | 9 | /// The number of color levels to use. 10 | /// 3 11 | /// 15 12 | /// 5 13 | float Levels : register(C0); 14 | 15 | //-------------------------------------------------------------------------------------- 16 | // Sampler Inputs (Brushes, including Texture1) 17 | //-------------------------------------------------------------------------------------- 18 | 19 | sampler2D Texture1Sampler : register(S0); 20 | 21 | //-------------------------------------------------------------------------------------- 22 | // Pixel Shader 23 | //-------------------------------------------------------------------------------------- 24 | 25 | float4 main(float2 uv : TEXCOORD) : COLOR 26 | { 27 | float4 color = tex2D( Texture1Sampler, uv ); 28 | color.rgb /= color.a; 29 | 30 | int levels = floor(Levels); 31 | color.rgb *= levels; 32 | color.rgb = floor(color.rgb); 33 | color.rgb /= levels; 34 | color.rgb *= color.a; 35 | return color; 36 | } 37 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_BandedSwirl.fx: -------------------------------------------------------------------------------- 1 | /// BandedSwirlTransitionEffect 2 | 3 | /// A transition effect 4 | 5 | /// The amount(%) of the transition from first texture to the second texture. 6 | /// 0 7 | /// 100 8 | /// 30 9 | float Progress : register(C0); 10 | 11 | /// The amount of twist for the Swirl. 12 | /// 0 13 | /// 10 14 | /// 1 15 | float twistAmount : register(C1); 16 | 17 | /// The amount of twist for the Swirl. 18 | /// 0 19 | /// 100 20 | /// 20 21 | float frequency : register(C2); 22 | 23 | /// The amount of twist for the Swirl. 24 | /// 0,0 25 | /// 1,1 26 | /// .5,.5 27 | float2 center : register(C3); 28 | sampler2D Texture1 : register(s0); 29 | sampler2D Texture2 : register(s1); 30 | 31 | float4 SampleWithBorder(float4 border, sampler2D tex, float2 uv) 32 | { 33 | if (any(saturate(uv) - uv)) 34 | { 35 | return border; 36 | } 37 | else 38 | { 39 | return tex2D(tex, uv); 40 | } 41 | } 42 | 43 | float4 BandedSwirl(float2 uv) 44 | { 45 | 46 | float2 toUV = uv - center; 47 | float distanceFromCenter = length(toUV); 48 | float2 normToUV = toUV / distanceFromCenter; 49 | float angle = atan2(normToUV.y, normToUV.x); 50 | 51 | angle += sin(distanceFromCenter * frequency) * (twistAmount /100) * Progress; 52 | float2 newUV; 53 | sincos(angle, newUV.y, newUV.x); 54 | newUV = newUV * distanceFromCenter + center; 55 | 56 | float4 c1 = tex2D(Texture2, frac(newUV)); 57 | float4 c2 = tex2D(Texture1, uv); 58 | 59 | return lerp(c1,c2, Progress/100); 60 | } 61 | 62 | //-------------------------------------------------------------------------------------- 63 | // Pixel Shader 64 | //-------------------------------------------------------------------------------------- 65 | float4 main(float2 uv : TEXCOORD) : COLOR 66 | { 67 | return BandedSwirl(uv); 68 | } 69 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_Blinds.fx: -------------------------------------------------------------------------------- 1 | /// BlindsTransitionEffect 2 | /// A transition effect 3 | /// 4 | 5 | /// The amount(%) of the transition from first texture to the second texture. 6 | /// 0 7 | /// 100 8 | /// 30 9 | float Progress : register(C0); 10 | 11 | /// The number of Blinds strips 12 | /// 2 13 | /// 15 14 | /// 5 15 | float NumberOfBlinds : register(C1); 16 | sampler2D Texture1 : register(s0); 17 | sampler2D Texture2 : register(s1); 18 | 19 | struct VS_OUTPUT 20 | 21 | { 22 | float4 Position : POSITION; 23 | float4 Color : COlOR; 24 | float2 UV : TEXCOORD; 25 | }; 26 | 27 | float4 Blinds(float2 uv) 28 | { 29 | if(frac(uv.y * NumberOfBlinds) < Progress/100) 30 | { 31 | return tex2D(Texture1, uv); 32 | } 33 | else 34 | { 35 | return tex2D(Texture2, uv); 36 | } 37 | } 38 | 39 | //-------------------------------------------------------------------------------------- 40 | // Pixel Shader 41 | //-------------------------------------------------------------------------------------- 42 | float4 main(VS_OUTPUT input) : COlOR 43 | { 44 | return Blinds(input.UV); 45 | } 46 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_Blood.fx: -------------------------------------------------------------------------------- 1 | /// BloodTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | 6 | /// 0 7 | /// 100 8 | /// 30 9 | float Progress : register(C0); 10 | 11 | /// The seed value that determines dripiness. 12 | /// 0 13 | /// 1/maxValue> 14 | /// .3 15 | float RandomSeed : register(C1); 16 | 17 | sampler2D Texture1 : register(s0); 18 | sampler2D Texture2 : register(s1); 19 | /// Another texture passed to the shader to determine drip pattern. 20 | sampler2D CloudInput : register(s2); 21 | 22 | struct VS_OUTPUT 23 | { 24 | float4 Position : POSITION; 25 | float4 Color : COlOR; 26 | float2 UV : TEXCOORD; 27 | }; 28 | 29 | float4 Blood(float2 uv,float progress) 30 | { 31 | float offset = min(progress + progress * tex2D(CloudInput, float2(uv.x, RandomSeed)).r, 1.0); 32 | uv.y -= offset; 33 | 34 | if(uv.y > 0.0) 35 | { 36 | return tex2D(Texture2, uv); 37 | } 38 | else 39 | { 40 | return tex2D(Texture1, frac(uv)); 41 | } 42 | } 43 | 44 | //-------------------------------------------------------------------------------------- 45 | // Pixel Shader 46 | //-------------------------------------------------------------------------------------- 47 | float4 main(VS_OUTPUT input) : COlOR 48 | { 49 | return Blood(input.UV, Progress/100); 50 | } 51 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_CircleReveal.fx: -------------------------------------------------------------------------------- 1 | /// CircleRevealTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | /// 0 6 | /// 100 7 | /// 30 8 | float Progress : register(C0); 9 | 10 | /// The fuzziness factor. 11 | /// 0 12 | /// 1 13 | /// .01 14 | float FuzzyAmount : register(C1); 15 | 16 | /// The size of the circle. 17 | /// 0 18 | /// 2 19 | /// .5 20 | float CircleSize : register(C2); 21 | 22 | /// The Center point of the effect 23 | /// 0,0 24 | /// 1,1 25 | /// .5,.5 26 | float2 CenterPoint: register(C3); 27 | 28 | sampler2D Texture1 : register(s0); 29 | sampler2D Texture2 : register(s1); 30 | 31 | struct VS_OUTPUT 32 | { 33 | float4 Position : POSITION; 34 | float4 Color : COlOR; 35 | float2 UV : TEXCOORD; 36 | }; 37 | 38 | float4 Circle(float2 uv,float progress) 39 | { 40 | float radius = -FuzzyAmount + progress * (CircleSize + 2.0 * FuzzyAmount); 41 | float fromCenter = length(uv - CenterPoint); 42 | float distFromCircle = fromCenter - radius; 43 | 44 | float4 c1 = tex2D(Texture2, uv); 45 | float4 c2 = tex2D(Texture1, uv); 46 | 47 | float p = saturate((distFromCircle + FuzzyAmount) / (2.0 * FuzzyAmount)); 48 | return lerp(c2, c1, p); 49 | } 50 | 51 | //-------------------------------------------------------------------------------------- 52 | // Pixel Shader 53 | //-------------------------------------------------------------------------------------- 54 | float4 main(VS_OUTPUT input) : COlOR 55 | { 56 | return Circle(input.UV, Progress/100); 57 | } 58 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_CircularBlur.fx: -------------------------------------------------------------------------------- 1 | /// CircularBlurTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | /// 0 6 | /// 100 7 | /// 30 8 | float Progress : register(C0); 9 | sampler2D Texture1 : register(s0); 10 | sampler2D Texture2 : register(s1); 11 | sampler2D trigInput : register(s2); 12 | 13 | struct VS_OUTPUT 14 | { 15 | float4 Position : POSITION; 16 | float4 Color : COlOR; 17 | float2 UV : TEXCOORD; 18 | }; 19 | 20 | float4 CircularBlur(float2 uv,float progress) 21 | { 22 | float2 center = float2(0.5,0.5); 23 | float2 toUV = uv - center; 24 | float distanceFromCenter = length(toUV); 25 | float2 normToUV = toUV / distanceFromCenter; 26 | float angle = tex2D(trigInput, (normToUV + 1) * 0.5).z; 27 | 28 | float4 c1 = float4(0,0,0,0); 29 | float s = progress * 0.005; 30 | int count = 7; 31 | 32 | for(int i=0; iCloudRevealTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | 6 | /// 0 7 | /// 100 8 | /// 30 9 | float Progress : register(C0); 10 | 11 | sampler2D Texture1 : register(s0); 12 | sampler2D Texture2 : register(s1); 13 | 14 | // default texturemap for this effect is Clouds 15 | sampler2D TextureMap : register(s2); 16 | 17 | struct VS_OUTPUT 18 | { 19 | float4 Position : POSITION; 20 | float4 Color : COlOR; 21 | float2 UV : TEXCOORD; 22 | }; 23 | 24 | float4 CloudReveal(float2 uv, float progress) 25 | { 26 | float cloud = tex2D(TextureMap, uv).r ; 27 | float4 c1 = tex2D(Texture2, uv); 28 | float4 c2 = tex2D(Texture1, uv); 29 | 30 | float a; 31 | float divide = .3; 32 | if (progress < divide) 33 | { 34 | a = lerp(0.0, cloud, progress / divide); 35 | } 36 | else 37 | { 38 | a = lerp(cloud, 1.0, (progress - divide) / divide); 39 | } 40 | 41 | return (a < 0.5) ? c1 : c2; 42 | } 43 | 44 | //-------------------------------------------------------------------------------------- 45 | // Pixel Shader 46 | //-------------------------------------------------------------------------------------- 47 | float4 main(VS_OUTPUT input) : COlOR 48 | { 49 | return CloudReveal(input.UV, Progress/100); 50 | } 51 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_Crumble.fx: -------------------------------------------------------------------------------- 1 | /// CrumbleTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | 6 | /// 0 7 | /// 100 8 | /// 30 9 | float Progress : register(C0); 10 | 11 | /// -1 12 | /// 1 13 | /// 0 14 | float randomSeed : register(C1); 15 | sampler2D Texture1 : register(s0); 16 | sampler2D Texture2 : register(s1); 17 | 18 | // default texturemap for this effect is Clouds 19 | sampler2D TextureMap : register(s2); 20 | 21 | struct VS_OUTPUT 22 | { 23 | float4 Position : POSITION; 24 | float4 Color : COlOR; 25 | float2 UV : TEXCOORD; 26 | }; 27 | 28 | float4 Crumple(float2 uv, float progress) 29 | { 30 | float2 offset = tex2D(TextureMap, float2(uv.x / 5, frac(uv.y / 5 + min(0.9, randomSeed)))).xy * 2.0 - 1.0; 31 | float p = progress * 2; 32 | if (p > 1.0) 33 | { 34 | p = 1.0 - (p - 1.0); 35 | } 36 | float4 c1 = tex2D(Texture2, frac(uv + offset * p)); 37 | float4 c2 = tex2D(Texture1, frac(uv + offset * p)); 38 | 39 | return lerp(c1, c2, progress); 40 | } 41 | 42 | //-------------------------------------------------------------------------------------- 43 | // Pixel Shader 44 | //-------------------------------------------------------------------------------------- 45 | float4 main(VS_OUTPUT input) : COlOR 46 | { 47 | return Crumple(input.UV, Progress/100); 48 | } 49 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_Disolve.fx: -------------------------------------------------------------------------------- 1 | /// DisolveTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | 6 | /// 0 7 | /// 100 8 | /// 30 9 | float Progress : register(C0); 10 | 11 | /// -1 12 | /// 1 13 | /// 0 14 | float randomSeed : register(C1); 15 | sampler2D Texture1 : register(s0); 16 | sampler2D Texture2 : register(s1); 17 | sampler2D noiseInput : register(s2); 18 | 19 | struct VS_OUTPUT 20 | { 21 | float4 Position : POSITION; 22 | float4 Color : COlOR; 23 | float2 UV : TEXCOORD; 24 | }; 25 | 26 | float4 Disolve(float2 uv, float progress) 27 | { 28 | float noise = tex2D(noiseInput, frac(uv + randomSeed)).x; 29 | if(noise > progress) 30 | { 31 | return tex2D(Texture2, uv); 32 | } 33 | else 34 | { 35 | return tex2D(Texture1, uv); 36 | } 37 | } 38 | 39 | //-------------------------------------------------------------------------------------- 40 | // Pixel Shader 41 | //-------------------------------------------------------------------------------------- 42 | float4 main(VS_OUTPUT input) : COlOR 43 | { 44 | return Disolve(input.UV, Progress/100); 45 | } 46 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_Drop.fx: -------------------------------------------------------------------------------- 1 | /// DropTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | 6 | /// 0 7 | /// 100 8 | /// 30 9 | float Progress : register(C0); 10 | 11 | /// -1 12 | /// 1 13 | /// 0 14 | float randomSeed : register(C1); 15 | sampler2D Texture1 : register(s0); 16 | sampler2D Texture2 : register(s1); 17 | sampler2D TextureMap : register(s2); 18 | 19 | struct VS_OUTPUT 20 | { 21 | float4 Position : POSITION; 22 | float4 Color : COlOR; 23 | float2 UV : TEXCOORD; 24 | }; 25 | 26 | float4 SampleWithBorder(float4 border, sampler2D tex, float2 uv) 27 | { 28 | if (any(saturate(uv) - uv)) 29 | { 30 | return border; 31 | } 32 | else 33 | { 34 | return tex2D(tex, uv); 35 | } 36 | } 37 | 38 | float4 DropFade(float2 uv, float progress) 39 | { 40 | float offset = -tex2D(TextureMap, float2(uv.x / 5, randomSeed)).x; 41 | float4 c1 = SampleWithBorder(float4(0,0,0,0), Texture2, float2(uv.x, uv.y + offset * progress)); 42 | float4 c2 = tex2D(Texture1, uv); 43 | 44 | if (c1.a <= 0.0) 45 | return c2; 46 | else 47 | return lerp(c1, c2, progress); 48 | } 49 | 50 | //-------------------------------------------------------------------------------------- 51 | // Pixel Shader 52 | //-------------------------------------------------------------------------------------- 53 | float4 main(VS_OUTPUT input) : COlOR 54 | { 55 | return DropFade(input.UV, Progress/100); 56 | } 57 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_Fade.fx: -------------------------------------------------------------------------------- 1 | /// FadeTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | /// 0 6 | /// 100 7 | /// 30 8 | float Progress : register(C0); 9 | 10 | sampler2D Texture1 : register(s0); 11 | sampler2D Texture2 : register(s1); 12 | 13 | struct VS_OUTPUT 14 | { 15 | float4 Position : POSITION; 16 | float4 Color : COlOR; 17 | float2 UV : TEXCOORD; 18 | }; 19 | 20 | float4 Fade(float2 uv, float progress) 21 | { 22 | float4 c1 = tex2D(Texture2, uv); 23 | float4 c2 = tex2D(Texture1, uv); 24 | 25 | return lerp(c1,c2, progress); 26 | } 27 | 28 | //-------------------------------------------------------------------------------------- 29 | // Pixel Shader 30 | //-------------------------------------------------------------------------------------- 31 | float4 main(VS_OUTPUT input) : COlOR 32 | { 33 | return Fade(input.UV, Progress/100); 34 | } 35 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_LeastBright.fx: -------------------------------------------------------------------------------- 1 | /// LeastBrightTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | /// 0 6 | /// 100 7 | /// 30 8 | float Progress : register(C0); 9 | 10 | sampler2D Texture1 : register(s0); 11 | sampler2D Texture2 : register(s1); 12 | 13 | float4 LeastBright(float2 uv,float progress) 14 | { 15 | int c = 4; 16 | int c2 = 3; 17 | float oc = (c -1) / 2; 18 | float oc2 = (c2 -1) / 2; 19 | float offset = 0.01 * progress; 20 | 21 | float leastBright = 1; 22 | float4 leastBrightColor; 23 | for(int y=0; yLineRevealTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | /// 0 6 | /// 100 7 | /// 30 8 | float Progress : register(C0); 9 | 10 | /// 0,0 11 | /// 1,1 12 | /// 1,0 13 | float2 lineOrigin : register(C1); 14 | 15 | /// 0,0 16 | /// 1,1 17 | /// 1,1 18 | float2 lineNormal : register(C2); 19 | 20 | /// 0,0 21 | /// 1,1 22 | /// 1,1 23 | float2 lineOffset : register(C3); 24 | 25 | /// 0 26 | /// .1 27 | /// .05 28 | float fuzzyAmount : register(C4); 29 | sampler2D Texture1 : register(s0); 30 | sampler2D Texture2 : register(s1); 31 | 32 | struct VS_OUTPUT 33 | { 34 | float4 Position : POSITION; 35 | float4 Color : COlOR; 36 | float2 UV : TEXCOORD; 37 | }; 38 | 39 | float4 LineReveal(float2 uv,float progress) 40 | { 41 | float2 currentLineOrigin = lerp(lineOrigin, lineOffset, progress); 42 | float2 normLineNormal = normalize(lineNormal); 43 | float4 c1 = tex2D(Texture2, uv); 44 | float4 c2 = tex2D(Texture1, uv); 45 | 46 | float distFromLine = dot(normLineNormal, uv-currentLineOrigin); 47 | float p = saturate((distFromLine + fuzzyAmount) / (2.0 * fuzzyAmount)); 48 | return lerp(c2, c1, p); 49 | } 50 | 51 | //-------------------------------------------------------------------------------------- 52 | // Pixel Shader 53 | //-------------------------------------------------------------------------------------- 54 | float4 main(VS_OUTPUT input) : COlOR 55 | { 56 | return LineReveal(input.UV, Progress/100); 57 | } 58 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_MostBright.fx: -------------------------------------------------------------------------------- 1 | /// MostBrightTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | /// 0 6 | /// 100 7 | /// 30 8 | float Progress : register(C0); 9 | 10 | sampler2D Texture1 : register(s0); 11 | sampler2D Texture2 : register(s1); 12 | 13 | float4 MostBright(float2 uv, float progress) 14 | { 15 | int c = 4; 16 | int c2 = 3; 17 | float oc = (c -1) / 2; 18 | float oc2 = (c2 -1) / 2; 19 | float offset = 0.01 * progress; 20 | 21 | float mostBright = 1; 22 | float4 mostBrightColor; 23 | for(int y=0; y mostBright) 31 | { 32 | mostBright = brightness; 33 | mostBrightColor = color; 34 | } 35 | } 36 | } 37 | 38 | float4 impl = tex2D(Texture1, uv); 39 | 40 | return lerp(mostBrightColor,impl, progress); 41 | } 42 | 43 | //-------------------------------------------------------------------------------------- 44 | // Pixel Shader 45 | //-------------------------------------------------------------------------------------- 46 | float4 main(float2 uv : TEXCOORD) : COlOR 47 | { 48 | return MostBright(uv , Progress/100); 49 | } 50 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_Pixelate.fx: -------------------------------------------------------------------------------- 1 | /// PixelateTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | /// 0 6 | /// 100 7 | /// 30 8 | float Progress : register(C0); 9 | 10 | sampler2D Texture1 : register(s0); 11 | sampler2D Texture2 : register(s1); 12 | 13 | float4 Pixelate(float2 uv ,float progress) 14 | { 15 | float pixels; 16 | float segment_progress; 17 | if (progress < 0.5) 18 | { 19 | segment_progress = 1 - progress * 2; 20 | } 21 | else 22 | { 23 | segment_progress = (progress - 0.5) * 2; 24 | 25 | } 26 | 27 | pixels = 5 + 1000 * segment_progress * segment_progress; 28 | float2 newUV = round(uv * pixels) / pixels; 29 | 30 | float4 c1 = tex2D(Texture2, newUV); 31 | float4 c2 = tex2D(Texture1, newUV); 32 | 33 | float lerp_progress = saturate((progress - 0.4) / 0.2); 34 | return lerp(c1,c2, lerp_progress); 35 | } 36 | 37 | //-------------------------------------------------------------------------------------- 38 | // Pixel Shader 39 | //-------------------------------------------------------------------------------------- 40 | float4 main(float2 uv : TEXCOORD) : COlOR 41 | { 42 | return Pixelate(uv, Progress/100); 43 | } 44 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_PixelateIn.fx: -------------------------------------------------------------------------------- 1 | /// PixelateInTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | /// 0 6 | /// 100 7 | /// 30 8 | float Progress : register(C0); 9 | 10 | sampler2D Texture1 : register(s0); 11 | sampler2D Texture2 : register(s1); 12 | 13 | float4 PixelateIn(float2 uv,float progress) 14 | { 15 | float pixels = 10 + 1000 * progress * progress; 16 | float2 newUV = round(uv * pixels) / pixels; 17 | float4 c2 = tex2D(Texture1, newUV); 18 | 19 | return c2; 20 | } 21 | 22 | //-------------------------------------------------------------------------------------- 23 | // Pixel Shader 24 | //-------------------------------------------------------------------------------------- 25 | float4 main(float2 uv : TEXCOORD) : COlOR 26 | { 27 | return PixelateIn(uv, Progress/100); 28 | } 29 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_PixelateOut.fx: -------------------------------------------------------------------------------- 1 | /// PixelateOutTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | /// 0 6 | /// 100 7 | /// 30 8 | float Progress : register(C0); 9 | 10 | sampler2D Texture1 : register(s0); 11 | sampler2D Texture2 : register(s1); 12 | 13 | 14 | float4 PixelateOut(float2 uv,float progress) 15 | { 16 | float pixels = max(4, 100 * (1.0 - progress)); 17 | float2 newUV = round(uv * pixels) / pixels; 18 | float4 c1 = tex2D(Texture2, newUV); 19 | float4 c2 = tex2D(Texture1, uv); 20 | 21 | if (progress > 0.8) 22 | { 23 | float new_progress = (progress - 0.8) * 5; 24 | return lerp(c1,c2, new_progress); 25 | } 26 | else 27 | { 28 | return c1; 29 | } 30 | } 31 | 32 | //-------------------------------------------------------------------------------------- 33 | // Pixel Shader 34 | //-------------------------------------------------------------------------------------- 35 | float4 main(float2 uv : TEXCOORD) : COlOR 36 | { 37 | return PixelateOut(uv, Progress/100); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_RadialBlur.fx: -------------------------------------------------------------------------------- 1 | /// RadialBlurTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | /// 0 6 | /// 100 7 | /// 30 8 | float Progress : register(C0); 9 | 10 | sampler2D Texture1 : register(s0); 11 | sampler2D Texture2 : register(s1); 12 | 13 | struct VS_OUTPUT 14 | { 15 | float4 Position : POSITION; 16 | float4 Color : COlOR; 17 | float2 UV : TEXCOORD; 18 | }; 19 | 20 | float4 RadialBlur(float2 uv,float progress) 21 | { 22 | float2 center = float2(0.5,0.5); 23 | float2 toUV = uv - center; 24 | float2 normToUV = toUV; 25 | 26 | 27 | float4 c1 = float4(0,0,0,0); 28 | int count = 24; 29 | float s = progress * 0.02; 30 | 31 | for(int i=0; iRadialWiggleTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | 6 | /// 0 7 | /// 100 8 | /// 30 9 | float Progress : register(C0); 10 | 11 | /// -1 12 | /// 1 13 | /// 0 14 | float randomSeed : register(C1); 15 | sampler2D Texture1 : register(s0); 16 | sampler2D Texture2 : register(s1); 17 | sampler2D TextureMap : register(s2); 18 | 19 | struct VS_OUTPUT 20 | { 21 | float4 Position : POSITION; 22 | float4 Color : COlOR; 23 | float2 UV : TEXCOORD; 24 | }; 25 | 26 | 27 | float4 RadialWiggle(float2 uv,float progress) 28 | { 29 | float2 center = float2(0.5,0.5); 30 | float2 toUV = uv - center; 31 | float distanceFromCenter = length(toUV); 32 | float2 normToUV = toUV / distanceFromCenter; 33 | float angle = (atan2(normToUV.y, normToUV.x) + 3.141592) / (2.0 * 3.141592); 34 | float offset1 = tex2D(TextureMap, float2(angle, frac(progress/3 + distanceFromCenter/5 + randomSeed))).x * 2.0 - 1.0; 35 | float offset2 = offset1 * 2.0 * min(0.3, (1-progress)) * distanceFromCenter; 36 | offset1 = offset1 * 2.0 * min(0.3, progress) * distanceFromCenter; 37 | 38 | float4 c1 = tex2D(Texture2, frac(center + normToUV * (distanceFromCenter + offset1))); 39 | float4 c2 = tex2D(Texture1, frac(center + normToUV * (distanceFromCenter + offset2))); 40 | 41 | return lerp(c1, c2, progress); 42 | } 43 | 44 | //-------------------------------------------------------------------------------------- 45 | // Pixel Shader 46 | //-------------------------------------------------------------------------------------- 47 | float4 main(VS_OUTPUT input) : COlOR 48 | { 49 | return RadialWiggle(input.UV,Progress/100); 50 | } 51 | 52 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_RandomCircleReveal.fx: -------------------------------------------------------------------------------- 1 | /// RandomCircleTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | 6 | /// 0 7 | /// 100 8 | /// 30 9 | float Progress : register(C0); 10 | 11 | /// -1 12 | /// 1 13 | /// 0 14 | float randomSeed : register(C1); 15 | sampler2D Texture1 : register(s0); 16 | sampler2D Texture2 : register(s1); 17 | sampler2D TextureMap : register(s2); 18 | 19 | struct VS_OUTPUT 20 | { 21 | float4 Position : POSITION; 22 | float4 Color : COlOR; 23 | float2 UV : TEXCOORD; 24 | }; 25 | 26 | float4 RandomCircle(float2 uv,float progress) 27 | { 28 | float radius = progress * 0.70710678; 29 | float2 fromCenter = uv - float2(0.5,0.5); 30 | float len = length(fromCenter); 31 | 32 | float2 toUV = normalize(fromCenter); 33 | float angle = (atan2(toUV.y, toUV.x) + 3.141592) / (2.0 * 3.141592); 34 | radius += progress * tex2D(TextureMap, float2(angle, frac(randomSeed + progress / 5.0))).r; 35 | 36 | if(len < radius) 37 | { 38 | return tex2D(Texture1, uv); 39 | } 40 | else 41 | { 42 | return tex2D(Texture2, uv); 43 | } 44 | } 45 | 46 | float4 main(VS_OUTPUT input) : COlOR 47 | { 48 | return RandomCircle(input.UV, Progress/100); 49 | } 50 | 51 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_Ripple.fx: -------------------------------------------------------------------------------- 1 | /// RippleTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | /// 0 6 | /// 100 7 | /// 30 8 | float Progress : register(C0); 9 | 10 | sampler2D Texture1 : register(s0); 11 | sampler2D Texture2 : register(s1); 12 | 13 | struct VS_OUTPUT 14 | { 15 | float4 Position : POSITION; 16 | float4 Color : COlOR; 17 | float2 UV : TEXCOORD; 18 | }; 19 | 20 | float4 Ripple(float2 uv,float progress) 21 | { 22 | float frequency = 20; 23 | float speed = 10; 24 | float amplitude = 0.05; 25 | float2 center = float2(0.5,0.5); 26 | float2 toUV = uv - center; 27 | float distanceFromCenter = length(toUV); 28 | float2 normToUV = toUV / distanceFromCenter; 29 | 30 | float wave = cos(frequency * distanceFromCenter - speed * progress); 31 | float offset1 = progress * wave * amplitude; 32 | float offset2 = (1.0 - progress) * wave * amplitude; 33 | 34 | float2 newUV1 = center + normToUV * (distanceFromCenter + offset1); 35 | float2 newUV2 = center + normToUV * (distanceFromCenter + offset2); 36 | 37 | float4 c1 = tex2D(Texture2, newUV1); 38 | float4 c2 = tex2D(Texture1, newUV2); 39 | 40 | return lerp(c1, c2, progress); 41 | } 42 | 43 | 44 | float4 main(VS_OUTPUT input) : COlOR 45 | { 46 | return Ripple(input.UV, Progress/100); 47 | } 48 | 49 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_RotateCrumble.fx: -------------------------------------------------------------------------------- 1 | /// RotateCrumbleTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | 6 | /// 0 7 | /// 100 8 | /// 30 9 | float Progress : register(C0); 10 | 11 | /// -1 12 | /// 1 13 | /// 0 14 | float randomSeed : register(C1); 15 | sampler2D Texture1 : register(s0); 16 | sampler2D Texture2 : register(s1); 17 | sampler2D TextureMap : register(s2); 18 | 19 | struct VS_OUTPUT 20 | { 21 | float4 Position : POSITION; 22 | float4 Color : COlOR; 23 | float2 UV : TEXCOORD; 24 | }; 25 | 26 | float4 RotateCrumple(float2 uv,float progress) 27 | { 28 | float2 offset = (tex2D(TextureMap, float2(uv.x / 10, frac(uv.y /10 + min(0.9, randomSeed)))).xy * 2.0 - 1.0); 29 | float2 center = uv + offset/10.0; 30 | float2 toUV = uv - center; 31 | float len = length(toUV); 32 | float2 normToUV = toUV / len; 33 | float angle = atan2(normToUV.y,normToUV.x); 34 | 35 | angle += 3.141592*2.0*progress; 36 | float2 newOffset; 37 | sincos(angle,newOffset.y, newOffset.x); 38 | newOffset *= len; 39 | 40 | float4 c1 = tex2D(Texture2, frac(center + newOffset)); 41 | float4 c2 = tex2D(Texture1, frac(center + newOffset)); 42 | 43 | return lerp(c1, c2, progress); 44 | } 45 | 46 | //-------------------------------------------------------------------------------------- 47 | // Pixel Shader 48 | //-------------------------------------------------------------------------------------- 49 | float4 main(VS_OUTPUT input) : COlOR 50 | { 51 | return RotateCrumple(input.UV, Progress/100); 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_Saturate.fx: -------------------------------------------------------------------------------- 1 | /// SaturateTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | /// 0 6 | /// 100 7 | /// 30 8 | float Progress : register(C0); 9 | 10 | sampler2D Texture1 : register(s0); 11 | sampler2D Texture2 : register(s1); 12 | 13 | 14 | 15 | float4 Saturate(float2 uv,float progress) 16 | { 17 | float4 c1 = tex2D(Texture2, uv); 18 | c1 = saturate(c1 * (2 * progress + 1)); 19 | float4 c2 = tex2D(Texture1, uv); 20 | 21 | if ( progress > 0.8) 22 | { 23 | float new_progress = (progress - 0.8) * 5.0; 24 | return lerp(c1,c2, new_progress); 25 | } 26 | else 27 | { 28 | return c1; 29 | } 30 | } 31 | 32 | 33 | //-------------------------------------------------------------------------------------- 34 | // Pixel Shader 35 | //-------------------------------------------------------------------------------------- 36 | float4 main(float2 uv : TEXCOORD) : COlOR 37 | { 38 | return Saturate(uv, Progress/100); 39 | } 40 | 41 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_Shrink.fx: -------------------------------------------------------------------------------- 1 | /// ShrinkTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | /// 0 6 | /// 100 7 | /// 30 8 | float Progress : register(C0); 9 | 10 | sampler2D Texture1 : register(s0); 11 | sampler2D Texture2 : register(s1); 12 | 13 | 14 | float4 SampleWithBorder(float4 border, sampler2D tex, float2 uv) 15 | { 16 | if (any(saturate(uv) - uv)) 17 | { 18 | return border; 19 | } 20 | else 21 | { 22 | return tex2D(tex, uv); 23 | } 24 | } 25 | 26 | float4 Shrink(float2 uv,float progress) 27 | { 28 | float speed = 200; 29 | float2 center = float2(0.5,0.5); 30 | float2 toUV = uv - center; 31 | float distanceFromCenter = length(toUV); 32 | float2 normToUV = toUV / distanceFromCenter; 33 | 34 | float2 newUV = center + normToUV * (distanceFromCenter * (progress * speed + 1)); 35 | 36 | float4 c1 = SampleWithBorder(float4(0,0,0,0), Texture2, newUV); 37 | 38 | if(c1.a <= 0) 39 | { 40 | return tex2D(Texture1, uv); 41 | } 42 | 43 | return c1; 44 | 45 | } 46 | 47 | //-------------------------------------------------------------------------------------- 48 | // Pixel Shader 49 | //-------------------------------------------------------------------------------------- 50 | float4 main(float2 uv : TEXCOORD) : COlOR 51 | { 52 | return Shrink(uv, Progress/100); 53 | } 54 | 55 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_SlideIn.fx: -------------------------------------------------------------------------------- 1 | /// SlideInTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | /// 6 | /// 0 7 | /// 100 8 | /// 30 9 | float Progress : register(C0); 10 | 11 | /// 0,0 12 | /// 1,1 13 | /// 1,0 14 | float2 slideAmount : register(C1); 15 | sampler2D Texture1 : register(s0); 16 | sampler2D Texture2 : register(s1); 17 | 18 | struct VS_OUTPUT 19 | { 20 | float4 Position : POSITION; 21 | float4 Color : COlOR; 22 | float2 UV : TEXCOORD; 23 | }; 24 | 25 | float4 SlideLeft(float2 uv,float progress) 26 | { 27 | uv += slideAmount * progress; 28 | if(any(saturate(uv)-uv)) 29 | { 30 | uv = frac(uv); 31 | return tex2D(Texture1, uv); 32 | } 33 | else 34 | { 35 | return tex2D(Texture2, uv); 36 | } 37 | } 38 | 39 | //-------------------------------------------------------------------------------------- 40 | // Pixel Shader 41 | //-------------------------------------------------------------------------------------- 42 | float4 main(VS_OUTPUT input) : COlOR 43 | { 44 | return SlideLeft(input.UV, Progress/100); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_Smooth.fx: -------------------------------------------------------------------------------- 1 | /// SmoothTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | 6 | /// 0 7 | /// 100 8 | /// 30 9 | float progress : register(C0); 10 | 11 | /// -1 12 | /// 1 13 | /// .4 14 | float twistAmount : register(C1); 15 | sampler2D Texture1 : register(s0); 16 | sampler2D Texture2 : register(s1); 17 | 18 | 19 | float4 main(float2 uv : TEXCOORD) : COlOR 20 | { 21 | float cellcount = 10; 22 | float cellsize = 1.0 / cellcount; 23 | 24 | float2 cell = floor(uv * cellcount); 25 | float2 oddeven = fmod(cell, 2.0); 26 | float cellTwistAmount = twistAmount; 27 | if (oddeven.x < 1.0) 28 | { 29 | cellTwistAmount *= -1; 30 | } 31 | if (oddeven.y < 1.0) 32 | { 33 | cellTwistAmount *= -1; 34 | } 35 | 36 | float2 newUV = frac(uv * cellcount); 37 | 38 | float2 center = float2(0.5,0.5); 39 | float2 toUV = newUV - center; 40 | float distanceFromCenter = length(toUV); 41 | float2 normToUV = toUV / distanceFromCenter; 42 | float angle = atan2(normToUV.y, normToUV.x); 43 | 44 | angle += max(0, 0.5-distanceFromCenter) * cellTwistAmount * progress; 45 | float2 newUV2; 46 | sincos(angle, newUV2.y, newUV2.x); 47 | newUV2 *= distanceFromCenter; 48 | newUV2 += center; 49 | 50 | newUV2 *= cellsize; 51 | newUV2 += cell * cellsize; 52 | 53 | float4 c1 = tex2D(Texture2, newUV2); 54 | float4 c2 = tex2D(Texture1, uv); 55 | 56 | return lerp(c1,c2, progress); 57 | } 58 | 59 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_Swirl.fx: -------------------------------------------------------------------------------- 1 | /// SwirlTransitionEffect 2 | 3 | /// A transition effect 4 | /// The amount(%) of the transition from first texture to the second texture. 5 | /// 0 6 | /// 100 7 | /// 30 8 | float Progress : register(C0); 9 | 10 | /// -70 11 | /// 70 12 | /// 30 13 | float twistAmount : register(C1); 14 | sampler2D Texture1 : register(s0); 15 | sampler2D Texture2 : register(s1); 16 | 17 | 18 | float4 SampleWithBorder(float4 border, sampler2D tex, float2 uv) 19 | { 20 | if (any(saturate(uv) - uv)) 21 | { 22 | return border; 23 | } 24 | else 25 | { 26 | return tex2D(tex, uv); 27 | } 28 | } 29 | 30 | float4 Swirl(float2 uv,float progress) 31 | { 32 | float2 center = float2(0.5,0.5); 33 | float2 toUV = uv - center; 34 | float distanceFromCenter = length(toUV); 35 | float2 normToUV = toUV / distanceFromCenter; 36 | float angle = atan2(normToUV.y, normToUV.x); 37 | 38 | angle += distanceFromCenter * distanceFromCenter * twistAmount * progress; 39 | float2 newUV; 40 | sincos(angle, newUV.y, newUV.x); 41 | newUV *= distanceFromCenter; 42 | newUV += center; 43 | 44 | float4 c1 = SampleWithBorder(float4(0,0,0,0), Texture2, newUV); 45 | float4 c2 = tex2D(Texture1, uv); 46 | 47 | return lerp(c1,c2, progress); 48 | } 49 | 50 | //-------------------------------------------------------------------------------------- 51 | // Pixel Shader 52 | //-------------------------------------------------------------------------------------- 53 | float4 main(float2 uv : TEXCOORD) : COlOR 54 | { 55 | return Swirl(uv, Progress/100); 56 | } 57 | 58 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_Water.fx: -------------------------------------------------------------------------------- 1 | /// WaterTransitionEffect 2 | 3 | /// A transition effect 4 | 5 | /// The amount(%) of the transition from first texture to the second texture. 6 | 7 | /// 0 8 | /// 100 9 | /// 30 10 | float Progress : register(C0); 11 | 12 | /// -1 13 | /// 1 14 | /// 0 15 | float randomSeed : register(C1); 16 | sampler2D Texture1 : register(s0); 17 | sampler2D Texture2 : register(s1); 18 | sampler2D TextureMap : register(s2); 19 | 20 | struct VS_OUTPUT 21 | { 22 | float4 Position : POSITION; 23 | float4 Color : COlOR; 24 | float2 UV : TEXCOORD; 25 | }; 26 | 27 | float4 Water(float2 uv,float progress) 28 | { 29 | float2 offset = tex2D(TextureMap, float2(uv.x / 10, frac(uv.y /10 + min(0.9, randomSeed)))).xy * 2.0 - 1.0; 30 | float4 c1 = tex2D(Texture2, frac(uv + offset * progress)); 31 | float4 c2 = tex2D(Texture1, uv); 32 | 33 | if (c1.a <= 0.0) 34 | return c2; 35 | else 36 | return lerp(c1, c2, progress); 37 | } 38 | 39 | //-------------------------------------------------------------------------------------- 40 | // Pixel Shader 41 | //-------------------------------------------------------------------------------------- 42 | float4 main(VS_OUTPUT input) : COlOR 43 | { 44 | return Water(input.UV, Progress/100); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Shazzam/Samples/Transition_Wave.fx: -------------------------------------------------------------------------------- 1 | /// WaveTransitionEffect 2 | 3 | /// A transition effect 4 | 5 | /// The amount(%) of the transition from first texture to the second texture. 6 | /// 0 7 | /// 100 8 | /// 30 9 | float Progress : register(C0); 10 | sampler2D Texture1 : register(s0); 11 | sampler2D Texture2 : register(s1); 12 | 13 | float4 SampleWithBorder(float4 border, sampler2D tex, float2 uv) 14 | { 15 | if (any(saturate(uv) - uv)) 16 | { 17 | return border; 18 | } 19 | else 20 | { 21 | return tex2D(tex, uv); 22 | } 23 | } 24 | 25 | float4 Wave(float2 uv, float progress) 26 | { 27 | float mag = 0.1; 28 | float phase = 14; 29 | float freq = 20; 30 | 31 | float2 newUV = uv + float2(mag * progress * sin(freq * uv.y + phase * progress), 0); 32 | 33 | float4 c1 = SampleWithBorder(0, Texture2, newUV); 34 | float4 c2 = tex2D(Texture1, uv); 35 | 36 | return lerp(c1,c2, progress); 37 | } 38 | 39 | float4 StandingWave(float2 uv,float progress) 40 | { 41 | float pi = 3.141592; 42 | float mag = 0.01; 43 | float freq = 8 * pi; 44 | float freq2 = 6 * pi; 45 | 46 | float2 newUV = uv + mag * sin(progress*freq2) * float2(cos(freq * uv.x), sin(freq * uv.y)); 47 | 48 | float4 c1 = tex2D(Texture2, frac(newUV)); 49 | float4 c2 = tex2D(Texture1, uv); 50 | 51 | return lerp(c1,c2, progress); 52 | } 53 | 54 | float4 MotionBlur(float2 uv,float progress) 55 | { 56 | float4 c1 = 0; 57 | int count = 26; 58 | float2 direction = float2(0.05, 0.05); 59 | float2 offset = progress * direction; 60 | float2 startUV = uv - offset * 0.5; 61 | float2 delta = offset / (count-1); 62 | 63 | for(int i=0; iTransparentAlternatingPixels 6 | 7 | /// Pixel shader that samples the color from an image and draws every odd pixel transparent. 8 | /// 9 | 10 | // Parameters 11 | 12 | /// The Size of the texture. 13 | /// 0,0 14 | /// 2048,2048 15 | /// 512,512 16 | float2 TextureSize : register(C0); 17 | 18 | // Sampler 19 | sampler2D TexSampler : register(S0); 20 | 21 | // Shader 22 | float4 main(float2 texCoord : TEXCOORD) : COLOR 23 | { 24 | // Default color is fully transparent 25 | float4 color = 0; 26 | 27 | // Scale to int texture size, add x and y 28 | float2 vpos = texCoord * TextureSize * 0.5f; 29 | float vposSum = vpos.x + vpos.y; 30 | 31 | // Calc diff between rounded half and half to get 0 or 0.5 32 | float diff = round(vposSum) - vposSum; 33 | float diffSq = diff * diff; 34 | 35 | // Even or odd? Only even pixels are sampled 36 | if(diffSq < 0.1) 37 | { 38 | color = tex2D(TexSampler, texCoord); 39 | } 40 | return color; 41 | } 42 | -------------------------------------------------------------------------------- /Shazzam/Samples/TransparentAlternatingPixelsMultiplied.fx: -------------------------------------------------------------------------------- 1 | // Contributed by Rene Schulte 2 | // Copyright (c) 2009 Rene Schulte 3 | // http://kodierer.blogspot.com/2009/10/read-between-pixels-hlsl-kill-pixel.html 4 | 5 | /// TransparentAlternatingPixelsMultiplied 6 | /// Pixel shader that samples the color from an image and draws every odd pixel transparent. 7 | /// 8 | 9 | // Parameters 10 | 11 | /// The Size of the texture. 12 | /// 0,0 13 | /// 2048,2048 14 | /// 512,512 15 | float2 TextureSize : register(C0); 16 | 17 | // Sampler 18 | sampler2D TexSampler : register(S0); 19 | 20 | // Shader 21 | float4 main(float2 texCoord : TEXCOORD) : COLOR 22 | { 23 | // Default color is fully transparent 24 | float4 color = 0; 25 | 26 | // Scale to int texture size, add x and y 27 | float2 vpos = texCoord * TextureSize * 0.5f; 28 | float vposSum = vpos.x * vpos.y; 29 | 30 | // Calc diff between rounded half and half to get 0 or 0.5 31 | float diff = round(vposSum) - vposSum; 32 | float diffSq = diff * diff; 33 | 34 | // Even or odd? Only even pixels are sampled 35 | if(diffSq < 0.1) 36 | { 37 | color = tex2D(TexSampler, texCoord); 38 | } 39 | return color; 40 | } 41 | -------------------------------------------------------------------------------- /Shazzam/Samples/TransparentAlternatingScanlines.fx: -------------------------------------------------------------------------------- 1 | // Contributed by Rene Schulte 2 | // Copyright (c) 2009 Rene Schulte 3 | // http://kodierer.blogspot.com/2009/10/read-between-pixels-hlsl-kill-pixel.html 4 | 5 | /// TransparentAlternatingScanlines 6 | /// Pixel shader that samples the color from an image and draws every odd row transparent. 7 | /// 8 | 9 | 10 | /// The Size of the texture. 11 | /// 0,0 12 | /// 2048,2048 13 | /// 512,512 14 | float2 TextureSize : register(C0); 15 | 16 | // Sampler 17 | sampler2D TexSampler : register(S0); 18 | 19 | // Shader 20 | float4 main(float2 texCoord : TEXCOORD) : COLOR 21 | { 22 | // Default color is fully transparent 23 | float4 color = 0; 24 | 25 | // Scale to int texture size 26 | float row = texCoord.y * TextureSize.y * 0.5f; 27 | 28 | // Calc diff between rounded half and half to get 0 or 0.5 29 | float diff = round(row) - row; 30 | float diffSq = diff * diff; 31 | 32 | // Even or odd? Only even lines are sampled 33 | if(diffSq < 0.1) 34 | { 35 | color = tex2D(TexSampler, texCoord); 36 | } 37 | return color; 38 | } 39 | -------------------------------------------------------------------------------- /Shazzam/Samples/WaveWarper.fx: -------------------------------------------------------------------------------- 1 | /// WaveWarperEffect 2 | 3 | /// An effect that applies a wave pattern to the input. 4 | 5 | // Copyright (C) 2009 Timmy Kokke 6 | // blog: http://blog.timmykokke.com 7 | // email: info@timmykokke.com 8 | // twitter: @sorskoot 9 | 10 | sampler2D input : register(s0); 11 | 12 | /// The moment in time. Animate this value over a long period of time. The speed depends on the 13 | /// size. The larger the size, the larger the increase in time on every frame, thus from 0 to 2048 in a smaller amount of time. 14 | /// 15 | /// 0/minValue> 16 | /// 2048 17 | /// 0 18 | float Time : register(C0); 19 | 20 | /// The distance between waves. (the higher the value the closer the waves are to their neighbor). 21 | /// 32 22 | /// 256 23 | /// 64 24 | float WaveSize: register(C1); 25 | 26 | float dist(float a, float b, float c, float d){ 27 | return sqrt((a - c) * (a - c) + (b - d) * (b - d)); 28 | } 29 | 30 | float4 main(float2 uv : TEXCOORD) : COLOR 31 | { 32 | float4 Color = 0; 33 | float f = sin(dist(uv.x + Time, uv.y, 0.128, 0.128)*WaveSize) 34 | + sin(dist(uv.x, uv.y, 0.64, 0.64)*WaveSize) 35 | + sin(dist(uv.x, uv.y + Time / 7, 0.192, 0.64)*WaveSize); 36 | uv.xy = uv.xy+((f/WaveSize)); 37 | Color= tex2D( input , uv.xy); 38 | return Color; 39 | } 40 | -------------------------------------------------------------------------------- /Shazzam/Samples/ZoomBlur.fx: -------------------------------------------------------------------------------- 1 | /// ZoomBlurEffect 2 | 3 | /// An effect that applies a radial blur to the input. 4 | 5 | //----------------------------------------------------------------------------------------- 6 | // Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) 7 | //----------------------------------------------------------------------------------------- 8 | 9 | /// The center of the blur. 10 | /// 0 11 | /// 0.2 12 | /// 0.9,0.6 13 | float2 Center : register(C0); 14 | 15 | /// The amount of blur. 16 | /// 0 17 | /// 0.2 18 | /// 0.1 19 | float BlurAmount : register(C1); 20 | 21 | //-------------------------------------------------------------------------------------- 22 | // Sampler Inputs (Brushes, including ImplicitInput) 23 | //-------------------------------------------------------------------------------------- 24 | 25 | sampler2D inputSource : register(S0); 26 | 27 | //-------------------------------------------------------------------------------------- 28 | // Pixel Shader 29 | //-------------------------------------------------------------------------------------- 30 | 31 | float4 main(float2 uv : TEXCOORD) : COLOR 32 | { 33 | float4 c = 0; 34 | uv -= Center; 35 | 36 | for (int i = 0; i < 15; i++) 37 | { 38 | float scale = 1.0 + BlurAmount * (i / 14.0); 39 | c += tex2D(inputSource, uv * scale + Center); 40 | } 41 | 42 | c /= 15; 43 | return c; 44 | } 45 | -------------------------------------------------------------------------------- /Shazzam/Samples/shared.hlsli: -------------------------------------------------------------------------------- 1 | static float PI = 3.14159274f; 2 | static float PI2 = 6.28318548f; 3 | 4 | float4 lerp_rgba(float4 x, float4 y, float s) 5 | { 6 | float a = lerp(x.a, y.a, s); 7 | float3 rgb = lerp(x.rgb, y.rgb, s) * a; 8 | return float4(rgb.r, rgb.g, rgb.b, a); 9 | } 10 | 11 | float interpolate(float min, float max, float value) 12 | { 13 | if (min == max) 14 | { 15 | return 0.5; 16 | } 17 | 18 | if (min < max) 19 | { 20 | return clamp((value - min) / (max - min), 0, 1); 21 | } 22 | 23 | return clamp((value - max) / (min - max), 0, 1); 24 | } 25 | 26 | 27 | float clamp_angle_positive(float a) 28 | { 29 | if (a < 0) 30 | { 31 | return a + PI2; 32 | } 33 | 34 | return a; 35 | } 36 | 37 | float clamp_angle_negative(float a) 38 | { 39 | if (a > 0) 40 | { 41 | return a - PI2; 42 | } 43 | 44 | return a; 45 | } 46 | 47 | float angle_from_start(float2 uv, float2 center_point, float start_angle, float central_angle) 48 | { 49 | float2 v = uv - center_point; 50 | return central_angle > 0 51 | ? clamp_angle_positive(clamp_angle_positive(atan2(v.x, -v.y)) - clamp_angle_positive(start_angle)) 52 | : abs(clamp_angle_negative(clamp_angle_negative(atan2(v.x, -v.y)) - clamp_angle_negative(start_angle))); 53 | } 54 | -------------------------------------------------------------------------------- /Shazzam/Shazzam.csproj.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | True 3 | True 4 | True 5 | True 6 | True -------------------------------------------------------------------------------- /Shazzam/ShazzamSwitchboard.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam 2 | { 3 | using System.Windows; 4 | using Shazzam.Views; 5 | using FileLoaderPlugin = Shazzam.Plugins.FileLoaderPlugin; 6 | 7 | public static class ShazzamSwitchboard 8 | { 9 | public static Window MainWindow { get; set; } 10 | 11 | public static CodeTabView CodeTabView { get; set; } 12 | 13 | public static FileLoaderPlugin FileLoaderPlugin { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Shazzam/TargetFramework.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam 2 | { 3 | public enum TargetFramework 4 | { 5 | WPF, 6 | Silverlight, 7 | WPF_PS3, 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Shazzam/Tutorials/01a_WhatIsAShader.fx: -------------------------------------------------------------------------------- 1 | // Tutorial Title: What is a Shader 2 | // Lesson Plan : Explain what a shader is. 3 | sampler2D ourImage : register(s0); 4 | 5 | float4 main(float2 locationInSource : TEXCOORD) : COLOR 6 | { 7 | 8 | // a shader is an algorithm that is compiled 9 | // and loaded into the Graphics Processor Unit (GPU) 10 | // this algorithm is run once, for every pixel in the input image 11 | // GPUs are efficient parallel processors and will run 12 | // your algorithm on thousands of pixels at a time 13 | return tex2D( ourImage , locationInSource.xy); 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Shazzam/Tutorials/01b_PartsOfAShader.fx: -------------------------------------------------------------------------------- 1 | // Tutorial Title: The part of the Shader in HLSL 2 | // Lesson Plan : Learn the core shader syntax for a simple shader 3 | sampler2D ourImage : register(s0); 4 | 5 | 6 | // main is the entry point for the shader 7 | // for Shazzam you need to name this function 'main' 8 | 9 | // the inbound parameter type is float2 10 | // it represents the individual pixel from the original source 11 | // which is call a TEXTURE in HLSL 12 | 13 | // the return type is float4 14 | // float4 contains four float values which we 15 | // can think of as the color of a pixel 16 | // (alpha, red, green, blue) 17 | 18 | float4 main(float2 locationInSource : TEXCOORD) : COLOR 19 | { 20 | 21 | // tex2D is a HLSL function 22 | // 1st arg is a bitmap (called a texture in HLSL) 23 | // ourImage: the incoming image, passed in from the GPU register (s0) 24 | // 25 | // 2nd arg is a locator for the pixel, this is normalized to range 0..1 26 | 27 | // what is this doing? 28 | // tex2D takes our sample input, gets a pixel at the current x,y location 29 | // and returns the color of the existing pixel, which means that the color is not altered 30 | return tex2D( ourImage , locationInSource.xy); 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Shazzam/Tutorials/02_ChangeColor.fx: -------------------------------------------------------------------------------- 1 |  2 | sampler2D ourImage : register(s0); 3 | 4 | float4 main(float2 locationInSource : TEXCOORD) : COLOR 5 | { 6 | // create a variable to hold our color 7 | float4 color; 8 | // get the color of the current pixel 9 | color = tex2D( ourImage , locationInSource.xy); 10 | 11 | // color has four value that we can change 12 | // color.r, color.g, color.b, color.a 13 | 14 | // values are normalized, so 0 is no color, 1 is full color 15 | color.r= 1; // set the red portion to 100% 16 | 17 | // What to try in this tutorial 18 | // 01: change color.r = 1 to color.b = 1; 19 | // 02: change color.r = 1 to color.r = .4 (changes red value to 40%) 20 | // 03: change color.r= 1 to color.a= .5 (changes the alpha value to 50%) 21 | 22 | 23 | return color; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Shazzam/Tutorials/03a_Variables.fx: -------------------------------------------------------------------------------- 1 |  2 | sampler2D ourImage : register(s0); 3 | 4 | float4 main(float2 locationInSource : TEXCOORD) : COLOR 5 | { 6 | 7 | // The simplest variable declaration includes a type and a variable name, 8 | // example: a floating-point declaration 9 | float x; 10 | 11 | // init the variable on declaration. 12 | float y = 5.6f; 13 | 14 | 15 | // declaring an array 16 | bool myBools[6]; 17 | 18 | // init the array on declaration. 19 | bool moreBools[4] = {true, true, false, false}; 20 | 21 | 22 | 23 | float4 color ={5,5,5,5}; 24 | return color; 25 | 26 | } -------------------------------------------------------------------------------- /Shazzam/Tutorials/03b_Swizzling.fx: -------------------------------------------------------------------------------- 1 | // Tutorial Title: Swizzling 2 | // Lesson Plan : Learn about Vector types and the Swizzling syntax 3 | sampler2D ourImage : register(s0); 4 | 5 | void ShowVectorSyntax() 6 | { 7 | // vectors in HLSL are groups of the same variable type 8 | // a contains one float 9 | float a; 10 | 11 | // use the array syntax 12 | float ar [2]; 13 | 14 | // use the vector syntax 15 | // b contains two floats 16 | // data is stored in GPU in special packed array format 17 | float2 b = 5.6f; 18 | 19 | // what about these? 20 | int3 c; 21 | int4 d; 22 | 23 | // this would be handy for holding a 3D point 24 | float3 pointDemo; 25 | 26 | // this could hold a color or any other 4 floats 27 | float4 color; 28 | 29 | // less common syntax 30 | vector anotherColor; 31 | 32 | // access the value stored in the vector 33 | float redVal = color[0]; 34 | float greenVal = color[1]; 35 | 36 | // special component namespace syntax allowed 37 | // get value using one of the component namespaces 38 | redVal = color.r; // can also use color.b, color.g and color.a 39 | // the other component namespace 40 | redVal = color.x; // can also use color.y, color.z, color.w 41 | 42 | // this also works for different size vectors 43 | float2 currentPoint; 44 | float result = currentPoint.y; 45 | result = currentPoint.g; // looks odd, but works 46 | 47 | } 48 | 49 | void SwizzlingDemo() 50 | { 51 | // what is Swizzling? 52 | // you can combine access to the individual vector values in a single line 53 | // this can result in faster code on the GPU 54 | float4 color={.8,.8,.8,.8}; 55 | float2 blueAndGreen = {color[1],color[2]}; // not swizzling 56 | float2 redAndBlue= color.rb; // this is swizzling 57 | 58 | float2 allColors = color.rb ; // note, assignes the values of g and a =1 59 | // beware, you cannot combine component namespaces 60 | // float2 yuck = color.rw ; // won't compile 61 | } 62 | 63 | float4 main(float2 locationInSource : TEXCOORD) : COLOR 64 | { 65 | 66 | float4 color ={0,0,0,0}; 67 | return color; 68 | 69 | } -------------------------------------------------------------------------------- /Shazzam/Tutorials/04a_AddColorParameters.fx: -------------------------------------------------------------------------------- 1 | // Tutorial Title: Add Color Parameters (1) 2 | // Lesson Plan : Replace the colors in an existing input texture 3 | sampler2D ourImage : register(s0); 4 | 5 | // add top-level variables to the shader 6 | // top-level vars are placed in the (Cx) registers 7 | 8 | // the float type contains a 32-bit floating point value 9 | float RedInput : register(C0); 10 | float GreenInput : register(C1); 11 | float BlueInput : register(C2); 12 | 13 | float NotInRegister = 5 ; 14 | float4 main(float2 locationInSource : TEXCOORD) : COLOR 15 | { 16 | // create a variable to hold our color 17 | float4 color; 18 | // get the color of the current pixel 19 | color = tex2D( ourImage , locationInSource.xy); 20 | 21 | color.r= RedInput; // assign the Red variable to the red portion 22 | color.g= GreenInput; 23 | color.b= BlueInput; 24 | 25 | float getValue = NotInRegister; // access the value 26 | // it will not show up in the parameters list however 27 | 28 | // the following line will fail however, because you cannot modify a globel var 29 | // NotInRegister = 9 ; 30 | 31 | // modify these variable at runtime in Shazzam with the controls in the 'Tryout shader (adjust settings)' tab. 32 | 33 | return color; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Shazzam/Tutorials/04b_AddColorParameters.fx: -------------------------------------------------------------------------------- 1 | // Tutorial Title: Add Color Parameters (1) 2 | // Lesson Plan : Replace the colors in an existing input texture 3 | sampler2D ourImage : register(s0); 4 | 5 | // add top-level variables to the shader 6 | // top-level vars are placed in the (Cx) registers 7 | 8 | // the float type contains a 32-bit floating point value 9 | float RedInput : register(C0); 10 | float GreenInput : register(C1); 11 | float BlueInput : register(C2); 12 | 13 | float NotInRegister = 5 ; 14 | float4 main(float2 locationInSource : TEXCOORD) : COLOR 15 | { 16 | // create a variable to hold our color 17 | float4 color; 18 | // get the color of the current pixel 19 | color = tex2D( ourImage , locationInSource.xy); 20 | 21 | color.r= RedInput; // assign the Red variable to the red portion 22 | color.g= GreenInput; 23 | color.b= BlueInput; 24 | 25 | float getValue = NotInRegister; // access the value 26 | // it will not show up in the parameters list however 27 | 28 | // the following line will fail however, because you cannot modify a globel var 29 | // NotInRegister = 9 ; 30 | 31 | // modify these variable at runtime in Shazzam with the controls in the 'Tryout shader (adjust settings)' tab. 32 | 33 | return color; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Shazzam/Tutorials/04c_TexturesVia_S_Registers.fx: -------------------------------------------------------------------------------- 1 | // Tutorial Title: Show All the Input passed via the register 2 | // Lesson Plan : Learn about the S registers 3 | 4 | // all shaders have at least one texture passed into the main function 5 | sampler2D ourImage : register(s0); 6 | // you can have three more textures 7 | // note that each one is passed in via a different S register 8 | sampler2D alternate1 : register(s1); 9 | sampler2D alternate2 : register(s2); 10 | sampler2D alternate3 : register(s3); 11 | 12 | 13 | float4 main(float2 locationInSource : TEXCOORD) : COLOR 14 | { 15 | // create a variable to hold our color 16 | float4 color; 17 | // get the color of the current pixel 18 | color = tex2D( ourImage , locationInSource.xy); 19 | 20 | 21 | return color; 22 | // TODO: look at these input parameter at runtime in Shazzam with 23 | // the controls in the 'Tryout shader (adjust settings)' tab. 24 | } 25 | -------------------------------------------------------------------------------- /Shazzam/Tutorials/04d_InputVia_C_Registers.fx: -------------------------------------------------------------------------------- 1 | // Tutorial Title: Show All the Input passed via the register 2 | // Lesson Plan : Learn about the C registers and how each is represnted in the Settings window 3 | 4 | //-------------------------------------------------------------------------------------- 5 | // float 6 | //-------------------------------------------------------------------------------------- 7 | 8 | float SampleFloat : register(c0); 9 | 10 | //-------------------------------------------------------------------------------------- 11 | // float2 12 | //-------------------------------------------------------------------------------------- 13 | 14 | // float2 could be used for Point, Size or Vector. 15 | 16 | float2 SamplePoint: register(C1); 17 | float2 SampleVector : register(C2); 18 | 19 | //-------------------------------------------------------------------------------------- 20 | // float3 21 | //-------------------------------------------------------------------------------------- 22 | 23 | // float3 maps to Point3D. 24 | // Not available in Silverlight. 25 | 26 | 27 | float3 SamplePoint3D : register(C3); 28 | 29 | //-------------------------------------------------------------------------------------- 30 | // float4 31 | //-------------------------------------------------------------------------------------- 32 | 33 | // float4 could represent a Color or Point4D 34 | 35 | 36 | float4 SampleColor: register(C4); 37 | 38 | sampler2D inputTexture : register(S0); 39 | 40 | 41 | float4 main(float2 uv : TEXCOORD) : COLOR 42 | { 43 | float4 color; 44 | return float4(0,2,3,4);; 45 | } 46 | -------------------------------------------------------------------------------- /Shazzam/Tutorials/05_AddShazzamTags.fx: -------------------------------------------------------------------------------- 1 | /// XML tags with the triple-slash are Shazzam specific tags, 2 | /// they are not part of the HLSL specification and are parsed 3 | /// by Shazzam and used to provide semantic or compiler information 4 | ///------------------------------------------------------------- 5 | // Provide a description for this Shader. 6 | // Shazzam will generate comments from this description. 7 | /// Provide 8 | /// 9 | /// Specify a default Class name for generated file. Otherwise it will use the file name 10 | /// SuggestedClassName 11 | /// ============================================================================= 12 | 13 | sampler2D ourImage : register(s0); 14 | 15 | // Shazzam contains a number of XML tags 16 | // that provide extra information for each top-level variable 17 | // The also permit storing min, max and defaults for the variable 18 | // Everytime the HLSL code is compile the these values are assigned to the WPF 19 | // defaults for the WPF dependency property 20 | 21 | /// Modifies the Red value. // appears in the Shazzam tooltips 22 | /// 0 23 | /// 1 24 | /// 1 25 | float RedValue : register(C0); 26 | 27 | /// Modifies the Green value. 28 | /// 0 29 | /// 1 30 | /// .5 31 | float GreenValue : register(C1); 32 | /// Modifies the Blue value. 33 | /// 0 34 | /// 1 35 | /// .5 36 | float BlueValue : register(C2); 37 | float4 main(float2 locationInSource : TEXCOORD) : COLOR 38 | { 39 | // create a variable to hold our color 40 | float4 color; 41 | // get the color of the current pixel 42 | color = tex2D( ourImage , locationInSource.xy); 43 | 44 | 45 | // assign the variables 46 | color.r *= RedValue; 47 | color.g *= GreenValue; 48 | color.b *= BlueValue; 49 | 50 | 51 | // modify these variable at runtime in Shazzam with the controls in the 'Tryout shader (adjust settings)' tab. 52 | 53 | 54 | 55 | return color; 56 | 57 | } 58 | -------------------------------------------------------------------------------- /Shazzam/Tutorials/06_SwapColors.fx: -------------------------------------------------------------------------------- 1 |  2 | sampler2D ourImage : register(s0); 3 | 4 | float4 main(float2 locationInSource : TEXCOORD) : COLOR 5 | { 6 | // create a variable to hold our color 7 | float4 color; 8 | // get the color of the current pixel 9 | 10 | color = tex2D( ourImage , locationInSource.xy); 11 | 12 | 13 | float temp; 14 | 15 | temp = color.b; 16 | color.r= color.b; // (assigns the value in the blue channel to the red channel) 17 | 18 | 19 | // What to try in this tutorial 20 | 21 | // 01: swap colors 22 | // float blue = color.b; 23 | // float red = color.r; 24 | // float green = color.g; 25 | // color.b= green; // (assigns the value in the blue channel to the red channel) 26 | // color.r =blue; 27 | // color.g = red; 28 | 29 | 30 | return color; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Shazzam/Tutorials/07a_ChangePosition.fx: -------------------------------------------------------------------------------- 1 |  2 | sampler2D ourImage : register(s0); 3 | 4 | float4 main(float2 locationInSource : TEXCOORD) : COLOR 5 | { 6 | // create a variable to hold our color 7 | float4 color; 8 | // get the color of the current pixel 9 | 10 | // float2 has two coordinate values that we can change 11 | // locationInSource.x, locationInSource.y, 12 | 13 | color = tex2D( ourImage , locationInSource.xy *2); // swizzle the x and y 14 | // makes the image smaller 15 | 16 | // What to try in this tutorial 17 | // 01: locationInSource.xy *.5 18 | 19 | return color ; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Shazzam/Tutorials/07b_ChangePosition.fx: -------------------------------------------------------------------------------- 1 |  2 | sampler2D ourImage : register(s0); 3 | 4 | float4 main(float2 locationInSource : TEXCOORD) : COLOR 5 | { 6 | // create a variable to hold our color 7 | float4 color; 8 | // get the color of the current pixel 9 | 10 | // float2 has two coordinate values that we can change 11 | // locationInSource.x, locationInSource.y, 12 | locationInSource.x = locationInSource.x * 1.5 ; 13 | locationInSource.y = locationInSource.y *.9; 14 | 15 | color = tex2D( ourImage ,( locationInSource.xy)); 16 | 17 | // What to try in this tutorial 18 | // 01: color = tex2D( ourImage , sin(locationInSource.xy)); 19 | // 02: color = tex2D( ourImage , cos(locationInSource.xy)); 20 | 21 | return color ; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Shazzam/Tutorials/07c_AddShazzamTags.fx: -------------------------------------------------------------------------------- 1 |  2 | sampler2D ourImage : register(s0); 3 | 4 | // add our input values here 5 | 6 | /// The x Value to change. 7 | /// -5 8 | /// 5 9 | /// 1.2 10 | float xValue : register(C0); 11 | 12 | /// The y Value to change. 13 | /// -5 14 | /// 5 15 | /// .8 16 | float yValue : register(C1); 17 | 18 | float4 main(float2 locationInSource : TEXCOORD) : COLOR 19 | { 20 | // create a variable to hold our color 21 | float4 color; 22 | // get the color of the current pixel 23 | 24 | // HLSL permits other inputs to shader 25 | // must declare fields to do this 26 | // it would be simpler to test these values 27 | // if we could add some test controls in Shazzam 28 | 29 | // use the Shazzam attributes to provide initial values 30 | // and default ranges 31 | locationInSource.x = locationInSource.x * xValue; 32 | locationInSource.y =locationInSource.y * yValue; 33 | 34 | color = tex2D( ourImage , locationInSource.xy); 35 | 36 | return color ; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /Shazzam/Tutorials/08a_SwapPosition.fx: -------------------------------------------------------------------------------- 1 |  2 | sampler2D input : register(s0); 3 | 4 | 5 | float SampleI : register(C0); 6 | 7 | float4 main(float2 uv : TEXCOORD) : COLOR 8 | { 9 | 10 | float temp = uv.x; 11 | uv.x= uv.y; 12 | uv.y= temp; 13 | float4 Color = tex2D( input , uv.xy); 14 | 15 | 16 | return Color; 17 | } 18 | -------------------------------------------------------------------------------- /Shazzam/Tutorials/08b_FlipPosition.fx: -------------------------------------------------------------------------------- 1 |  2 | sampler2D input : register(s0); 3 | 4 | /// The x Value to change. 5 | /// 0 6 | /// 1 7 | /// 1 8 | float xValue : register(C0); 9 | 10 | float SampleI : register(C0); 11 | 12 | float4 main(float2 uv : TEXCOORD) : COLOR 13 | { 14 | 15 | float temp = uv.x = 1-uv.x; // flip on vertical axis 16 | // float temp = uv.y = 1-uv.y; // flip on horizontal axis 17 | 18 | float4 Color = tex2D( input , uv.xy); 19 | 20 | return Color; 21 | } 22 | -------------------------------------------------------------------------------- /Shazzam/Tutorials/09a_MorphNearbyPixels.fx: -------------------------------------------------------------------------------- 1 |  2 | sampler2D input : register(s0); 3 | /// CenterX. 4 | /// 2/minValue> 5 | /// 12 6 | /// 1 7 | float CenterX : register(C0); 8 | 9 | 10 | /// -10/minValue> 11 | /// 10 12 | /// .128 13 | float CenterY : register(C1); 14 | 15 | /// The distance between bands. (the higher the value the closer the bands are to their neighbor). 16 | /// 0 17 | /// 250 18 | /// 48 19 | float BandSize: register(C2); 20 | 21 | 22 | 23 | float distort(float x, float y, float c, float d){ 24 | return sqrt((x - c) * (x - c) + (y - d) * (y - d)); 25 | } 26 | 27 | float4 main(float2 uv : TEXCOORD) : COLOR 28 | { 29 | float4 Color = 0; 30 | 31 | float wobble = sin (distort(uv.x ,uv.y ,CenterX ,CenterY) * BandSize); 32 | uv.xy = uv.xy+(( wobble/BandSize )); 33 | Color= tex2D( input , uv.xy); 34 | return Color; 35 | } 36 | -------------------------------------------------------------------------------- /Shazzam/Tutorials/13_UsingDXFunctions.fx: -------------------------------------------------------------------------------- 1 |  2 | sampler2D ourImage : register(s0); 3 | 4 | float4 main(float2 locationInSource : TEXCOORD) : COLOR 5 | { 6 | // create a variable to hold our color 7 | float4 color; 8 | // get the color of the current pixel 9 | 10 | // use the DirectX sqrt function (square root) 11 | locationInSource.x = sqrt(sqrt(locationInSource.x)) ; 12 | locationInSource.y = sqrt(locationInSource.y) ; 13 | 14 | // then apply a sine value 15 | 16 | color = tex2D( ourImage , locationInSource.xy); 17 | 18 | return color ; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Shazzam/Tutorials/14_PS3.fx: -------------------------------------------------------------------------------- 1 | // The following restrictions apply when using a PS 3.0 shader. 2 | 3 | // When a PS 3.0 shader is assigned, the number of samplers increases to 8. Assign the PS 3.0 shader before other shaders to enable registering 8 samplers. 4 | 5 | // The full shader constant register limit of 224 for floats is used. For more information, see ps_3_0. 6 | 7 | // The following data types are supported in PS 3.0 shaders only. An exception is thrown if these are used in lower shader versions. 8 | 9 | // int and types convertible to int: uint, byte, sbyte, long, ulong, short, ushort, char 10 | 11 | //bool 12 | 13 | // if a valid PS 3.0 shader is loaded on a computer that does not have hardware support for PS 3.0, the shader is ignored. If the shader is invalid, no exception is thrown. 14 | 15 | // If a computer has more than one video card, the behavior is defined by the least capable video card. For example, if the computer has two video cards, one of which supports PS 3.0 and one of which does not, the behavior is the same as if the computer does not support PS 3.0. 16 | 17 | //If a computer supports rendering PS 3.0 in hardware, but an invalid PS 3.0 shader is assigned, the InvalidPixelShaderEncountered event is raised. An example of an invalid PS 3.0 shader is one compiled with the ps_3_sw flag. The ShaderEffect class accepts only PS 3.0 shaders that are compiled with the ps_3_0 flag passed to fxc.exe. For more information, see Effect-Compiler Tool. 18 | -------------------------------------------------------------------------------- /Shazzam/Views/AboutView.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam.Views 2 | { 3 | using System.Diagnostics; 4 | using System.Windows; 5 | using System.Windows.Controls; 6 | using System.Windows.Documents; 7 | 8 | public partial class AboutView : UserControl 9 | { 10 | public AboutView() 11 | { 12 | this.InitializeComponent(); 13 | this.AddHandler(Hyperlink.RequestNavigateEvent, new RoutedEventHandler(OnRequestNavigate), handledEventsToo: false); 14 | this.versionText.Text = VersionHelper.GetVersionNumber(); 15 | this.versionRun.Text = $"v{VersionHelper.GetShortVersionNumber()}"; 16 | 17 | static void OnRequestNavigate(object sender, RoutedEventArgs e) 18 | { 19 | if (e.OriginalSource is Hyperlink hl) 20 | { 21 | var navigateUri = hl.NavigateUri.ToString(); 22 | Process.Start(new ProcessStartInfo(navigateUri)); 23 | e.Handled = true; 24 | } 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Shazzam/Views/CodeViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace Shazzam.Views 2 | { 3 | using System.ComponentModel; 4 | using System.Runtime.CompilerServices; 5 | 6 | public sealed class CodeViewModel : INotifyPropertyChanged 7 | { 8 | public static readonly CodeViewModel Instance = new(); 9 | private ShaderModel? shaderModel; 10 | 11 | private CodeViewModel() 12 | { 13 | } 14 | 15 | public event PropertyChangedEventHandler? PropertyChanged; 16 | 17 | public bool AreGeneratedCodeTabsEnabled => Properties.Settings.Default.AreGeneratedCodeTabsEnabled; 18 | 19 | public ShaderModel? ShaderModel 20 | { 21 | get => this.shaderModel; 22 | set 23 | { 24 | if (ReferenceEquals(value, this.shaderModel)) 25 | { 26 | return; 27 | } 28 | 29 | this.shaderModel = value; 30 | this.OnPropertyChanged(); 31 | } 32 | } 33 | 34 | private void OnPropertyChanged([CallerMemberName] string? propertyName = null) 35 | { 36 | this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Shazzam/Views/Fav2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Views/Fav2.png -------------------------------------------------------------------------------- /Shazzam/Views/check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Views/check.png -------------------------------------------------------------------------------- /Shazzam/Views/greentarget.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Views/greentarget.png -------------------------------------------------------------------------------- /Shazzam/Views/info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/Views/info.png -------------------------------------------------------------------------------- /Shazzam/d3dx10_40.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JohanLarsson/Shazzam/9d70246be6f0db8f3021d5e88f0c8270dbdd61b8/Shazzam/d3dx10_40.dll -------------------------------------------------------------------------------- /ShazzamUnitTests/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.cs] 2 | 3 | # Default severity for analyzer diagnostics with category 'StyleCop.CSharp.DocumentationRules' 4 | dotnet_analyzer_diagnostic.category-StyleCop.CSharp.DocumentationRules.severity = none 5 | # SA0001: XML comment analysis is disabled due to project configuration 6 | dotnet_diagnostic.SA0001.severity = none 7 | -------------------------------------------------------------------------------- /ShazzamUnitTests/MainWindowVmUnitTest.cs: -------------------------------------------------------------------------------- 1 | namespace ShazzamUnitTests 2 | { 3 | using System.Windows; 4 | using System.Windows.Media; 5 | using NUnit.Framework; 6 | 7 | using Shazzam; 8 | 9 | public class MainWindowVmUnitTest 10 | { 11 | [Test] 12 | public void CodeAndImageRows_CheckDefault_AreBothSameHeight() 13 | { 14 | var vm = MainWindowViewModel.Instance; 15 | var rowHeight = new GridLength(5, GridUnitType.Star); 16 | Assert.AreEqual(vm.CodeRowHeight, rowHeight); 17 | Assert.AreEqual(vm.ImageRowHeight, rowHeight); 18 | } 19 | 20 | [Test] 21 | public void FullScreenCodeCommand_RunCommand_ImageRowSetToZero() 22 | { 23 | var vm = MainWindowViewModel.Instance; 24 | vm.FullScreenCodeCommand.Execute(this); 25 | Assert.AreEqual(vm.ImageRowHeight, new GridLength(0)); 26 | } 27 | 28 | [Test] 29 | public void FullScreenImageCommand_RunCommand_CodeRowSetToZero() 30 | { 31 | var vm = MainWindowViewModel.Instance; 32 | vm.FullScreenImageCommand.Execute(this); 33 | Assert.AreEqual(vm.CodeRowHeight, new GridLength(0)); 34 | } 35 | 36 | [Test] 37 | public void ImageStretchCommand_CheckDefault_IsUniform() 38 | { 39 | var vm = MainWindowViewModel.Instance; 40 | Assert.AreEqual(vm.ImageStretch, Stretch.Uniform); 41 | } 42 | 43 | [Test] 44 | public void ImageStretchCommand_RunCommand_StretchValueCorrect() 45 | { 46 | var vm = MainWindowViewModel.Instance; 47 | vm.ImageStretchCommand.Execute("none"); 48 | Assert.AreEqual(vm.ImageStretch, Stretch.None); 49 | vm.ImageStretchCommand.Execute("fill"); 50 | Assert.AreEqual(vm.ImageStretch, Stretch.Fill); 51 | vm.ImageStretchCommand.Execute("uniform"); 52 | Assert.AreEqual(vm.ImageStretch, Stretch.Uniform); 53 | 54 | vm.ImageStretchCommand.Execute("uniformtofill"); 55 | Assert.AreEqual(vm.ImageStretch, Stretch.UniformToFill); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /ShazzamUnitTests/Sandbox/AngleTests.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | #pragma warning disable SA1101, SA1300, SA1400 3 | #pragma warning disable IDE0007, IDE0009, IDE0040, IDE1006 4 | namespace ShazzamUnitTests.Sandbox 5 | { 6 | using NUnit.Framework; 7 | using static Hlsl.Types; 8 | 9 | public class AngleTests : Hlsl 10 | { 11 | private const float PI2 = 6.28318548f; 12 | 13 | [TestCase("1 0.5", "0.5 0.5", 0, 360, 90)] 14 | [TestCase("1 0.5", "0.5 0.5", 0, -360, 270)] 15 | [TestCase("0.5 1", "0.5 0.5", 0, 360, 180)] 16 | [TestCase("0.5 1", "0.5 0.5", 0, -360, 180)] 17 | [TestCase("0.5 1", "0.5 0.5", 90, 360, 90)] 18 | [TestCase("0.5 1", "0.5 0.5", 90, -360, 270)] 19 | [TestCase("0.5 -1", "0.5 0.5", -90, 360, 90)] 20 | [TestCase("0.5 -1", "0.5 0.5", -90, -360, 270)] 21 | public void AngleFromStart(string uvs, string cps, float start, float centralAngle, float expected) 22 | { 23 | var uv = Parse(uvs); 24 | var cp = Parse(cps); 25 | var angleFromStart = angle_from_start(uv, cp, radians(start), radians(centralAngle)); 26 | Assert.AreEqual(expected, degrees(angleFromStart), 0.001); 27 | } 28 | 29 | private static float2 Parse(string text) => Types.float2.Parse(text); 30 | 31 | float clamp_angle_positive(float a) 32 | { 33 | if (a < 0) 34 | { 35 | return a + PI2; 36 | } 37 | 38 | return a; 39 | } 40 | 41 | float clamp_angle_negative(float a) 42 | { 43 | if (a > 0) 44 | { 45 | return a - PI2; 46 | } 47 | 48 | return a; 49 | } 50 | 51 | float angle_from_start(float2 uv, float2 center_point, float start_angle, float central_angle) 52 | { 53 | float2 v = uv - center_point; 54 | return central_angle > 0 55 | ? clamp_angle_positive(clamp_angle_positive(atan2(v.x, -v.y)) - clamp_angle_positive(start_angle)) 56 | : abs(clamp_angle_negative(clamp_angle_negative(atan2(v.x, -v.y)) - clamp_angle_negative(start_angle))); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /ShazzamUnitTests/Sandbox/InterpolateTests.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | #pragma warning disable SA1101, SA1300, SA1400 3 | #pragma warning disable IDE0007, IDE0009, IDE0040, IDE1006 4 | namespace ShazzamUnitTests.Sandbox 5 | { 6 | using NUnit.Framework; 7 | 8 | public class InterpolateTests : Hlsl 9 | { 10 | [TestCase(0, 1, -1, 0)] 11 | [TestCase(0, 1, 0, 0)] 12 | [TestCase(0, 1, 0.5f, 0.5f)] 13 | [TestCase(0, 1, 1, 1f)] 14 | [TestCase(0, 1, 2, 1f)] 15 | [TestCase(1, 0, -1, 0)] 16 | [TestCase(1, 0, 0, 0)] 17 | [TestCase(1, 0, 0.5f, 0.5f)] 18 | [TestCase(1, 0, 1, 1f)] 19 | [TestCase(1, 0, 2, 1f)] 20 | public void Test(float min, float max, float value, float expected) 21 | { 22 | Assert.AreEqual(expected, interpolate(min, max, value), 1E-3); 23 | } 24 | 25 | float interpolate(float min, float max, float value) 26 | { 27 | if (abs(min - max) < 0.001) 28 | { 29 | return 0.5f; 30 | } 31 | 32 | if (min < max) 33 | { 34 | return clamp((value - min) / (max - min), 0, 1); 35 | } 36 | 37 | return clamp((value - max) / (min - max), 0, 1); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ShazzamUnitTests/Sandbox/LerpRgbaTests.cs: -------------------------------------------------------------------------------- 1 | // ReSharper disable All 2 | #pragma warning disable SA1101, SA1300, SA1400 3 | #pragma warning disable IDE0007, IDE0009, IDE0040, IDE1006 4 | namespace ShazzamUnitTests.Sandbox 5 | { 6 | using NUnit.Framework; 7 | using static Hlsl.Types; 8 | 9 | public class LerpRgbaTests : Hlsl 10 | { 11 | [TestCase("#FFFF0000", "#00FFFFFF", 0, "#FFFF0000")] 12 | [TestCase("#FFFF0000", "#00FFFFFF", 0.5f, "#7F7F3F3F")] 13 | [TestCase("#FFFF0000", "#00FF0000", 0.5f, "#7F7F0000")] 14 | [TestCase("#FFFF0000", "#00FFFFFF", 1, "#00000000")] 15 | [TestCase("#FFFF0000", "#FFFFFFFF", 0, "#FFFF0000")] 16 | [TestCase("#FFFF0000", "#FFFFFFFF", 1, "#FFFFFFFF")] 17 | public void LerpRgba(string x, string y, float s, string expected) 18 | { 19 | Assert.AreEqual(expected, lerp_rgba(Parse(x), Parse(y), s)); 20 | } 21 | 22 | private static float4 Parse(string text) => Types.float4.Parse(text); 23 | 24 | float4 lerp_rgba(float4 x, float4 y, float s) 25 | { 26 | float a = lerp(x.a, y.a, s); 27 | float3 rgb = lerp(x.rgb, y.rgb, s) * a; 28 | return float4(rgb.r, rgb.g, rgb.b, a); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ShazzamUnitTests/ShazzamUnitTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net48 4 | true 5 | latest 6 | Enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | image: Visual Studio 2019 2 | 3 | before_build: 4 | - ps: dotnet restore 5 | 6 | configuration: Release 7 | 8 | build: 9 | verbosity: minimal --------------------------------------------------------------------------------