├── .gitignore
├── LICENSE
├── README.md
└── src
├── DepthEffect.Common
├── DepthEffect.Common.csproj
└── Shaders
│ ├── CompileShaders.cmd
│ ├── Depth.bin
│ └── Depth.hlsl
├── DepthEffect.UWP
├── App.xaml
├── App.xaml.cs
├── Assets
│ ├── Attribution.txt
│ ├── Depth1.jpg
│ ├── Image1.jpg
│ ├── LockScreenLogo.scale-200.png
│ ├── SplashScreen.scale-200.png
│ ├── Square150x150Logo.scale-200.png
│ ├── Square44x44Logo.scale-200.png
│ ├── Square44x44Logo.targetsize-24_altform-unplated.png
│ ├── StoreLogo.png
│ └── Wide310x150Logo.scale-200.png
├── DepthEffect.UWP.csproj
├── MainPage.xaml
├── MainPage.xaml.cs
├── Package.appxmanifest
└── Properties
│ ├── AssemblyInfo.cs
│ └── Default.rd.xml
├── DepthEffect.WinUI3
├── App.xaml
├── App.xaml.cs
├── Assets
│ ├── Attribution.txt
│ ├── Depth1.jpg
│ ├── Image1.jpg
│ ├── LockScreenLogo.scale-200.png
│ ├── SplashScreen.scale-200.png
│ ├── Square150x150Logo.scale-200.png
│ ├── Square44x44Logo.scale-200.png
│ ├── Square44x44Logo.targetsize-24_altform-unplated.png
│ ├── StoreLogo.png
│ └── Wide310x150Logo.scale-200.png
├── DepthEffect.WinUI3.csproj
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── Package.appxmanifest
├── Properties
│ └── launchSettings.json
├── Shaders
│ ├── DepthParallax.cs
│ └── Runners
│ │ └── DepthParallaxRunner.cs
└── app.manifest
└── DepthEffect.sln
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Ll]og/
33 | [Ll]ogs/
34 |
35 | # Visual Studio 2015/2017 cache/options directory
36 | .vs/
37 | # Uncomment if you have tasks that create the project's static files in wwwroot
38 | #wwwroot/
39 |
40 | # Visual Studio 2017 auto generated files
41 | Generated\ Files/
42 |
43 | # MSTest test Results
44 | [Tt]est[Rr]esult*/
45 | [Bb]uild[Ll]og.*
46 |
47 | # NUnit
48 | *.VisualState.xml
49 | TestResult.xml
50 | nunit-*.xml
51 |
52 | # Build Results of an ATL Project
53 | [Dd]ebugPS/
54 | [Rr]eleasePS/
55 | dlldata.c
56 |
57 | # Benchmark Results
58 | BenchmarkDotNet.Artifacts/
59 |
60 | # .NET Core
61 | project.lock.json
62 | project.fragment.lock.json
63 | artifacts/
64 |
65 | # ASP.NET Scaffolding
66 | ScaffoldingReadMe.txt
67 |
68 | # StyleCop
69 | StyleCopReport.xml
70 |
71 | # Files built by Visual Studio
72 | *_i.c
73 | *_p.c
74 | *_h.h
75 | *.ilk
76 | *.meta
77 | *.obj
78 | *.iobj
79 | *.pch
80 | *.pdb
81 | *.ipdb
82 | *.pgc
83 | *.pgd
84 | *.rsp
85 | *.sbr
86 | *.tlb
87 | *.tli
88 | *.tlh
89 | *.tmp
90 | *.tmp_proj
91 | *_wpftmp.csproj
92 | *.log
93 | *.tlog
94 | *.vspscc
95 | *.vssscc
96 | .builds
97 | *.pidb
98 | *.svclog
99 | *.scc
100 |
101 | # Chutzpah Test files
102 | _Chutzpah*
103 |
104 | # Visual C++ cache files
105 | ipch/
106 | *.aps
107 | *.ncb
108 | *.opendb
109 | *.opensdf
110 | *.sdf
111 | *.cachefile
112 | *.VC.db
113 | *.VC.VC.opendb
114 |
115 | # Visual Studio profiler
116 | *.psess
117 | *.vsp
118 | *.vspx
119 | *.sap
120 |
121 | # Visual Studio Trace Files
122 | *.e2e
123 |
124 | # TFS 2012 Local Workspace
125 | $tf/
126 |
127 | # Guidance Automation Toolkit
128 | *.gpState
129 |
130 | # ReSharper is a .NET coding add-in
131 | _ReSharper*/
132 | *.[Rr]e[Ss]harper
133 | *.DotSettings.user
134 |
135 | # TeamCity is a build add-in
136 | _TeamCity*
137 |
138 | # DotCover is a Code Coverage Tool
139 | *.dotCover
140 |
141 | # AxoCover is a Code Coverage Tool
142 | .axoCover/*
143 | !.axoCover/settings.json
144 |
145 | # Coverlet is a free, cross platform Code Coverage Tool
146 | coverage*.json
147 | coverage*.xml
148 | coverage*.info
149 |
150 | # Visual Studio code coverage results
151 | *.coverage
152 | *.coveragexml
153 |
154 | # NCrunch
155 | _NCrunch_*
156 | .*crunch*.local.xml
157 | nCrunchTemp_*
158 |
159 | # MightyMoose
160 | *.mm.*
161 | AutoTest.Net/
162 |
163 | # Web workbench (sass)
164 | .sass-cache/
165 |
166 | # Installshield output folder
167 | [Ee]xpress/
168 |
169 | # DocProject is a documentation generator add-in
170 | DocProject/buildhelp/
171 | DocProject/Help/*.HxT
172 | DocProject/Help/*.HxC
173 | DocProject/Help/*.hhc
174 | DocProject/Help/*.hhk
175 | DocProject/Help/*.hhp
176 | DocProject/Help/Html2
177 | DocProject/Help/html
178 |
179 | # Click-Once directory
180 | publish/
181 |
182 | # Publish Web Output
183 | *.[Pp]ublish.xml
184 | *.azurePubxml
185 | # Note: Comment the next line if you want to checkin your web deploy settings,
186 | # but database connection strings (with potential passwords) will be unencrypted
187 | *.pubxml
188 | *.publishproj
189 |
190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
191 | # checkin your Azure Web App publish settings, but sensitive information contained
192 | # in these scripts will be unencrypted
193 | PublishScripts/
194 |
195 | # NuGet Packages
196 | *.nupkg
197 | # NuGet Symbol Packages
198 | *.snupkg
199 | # The packages folder can be ignored because of Package Restore
200 | **/[Pp]ackages/*
201 | # except build/, which is used as an MSBuild target.
202 | !**/[Pp]ackages/build/
203 | # Uncomment if necessary however generally it will be regenerated when needed
204 | #!**/[Pp]ackages/repositories.config
205 | # NuGet v3's project.json files produces more ignorable files
206 | *.nuget.props
207 | *.nuget.targets
208 |
209 | # Microsoft Azure Build Output
210 | csx/
211 | *.build.csdef
212 |
213 | # Microsoft Azure Emulator
214 | ecf/
215 | rcf/
216 |
217 | # Windows Store app package directories and files
218 | AppPackages/
219 | BundleArtifacts/
220 | Package.StoreAssociation.xml
221 | _pkginfo.txt
222 | *.appx
223 | *.appxbundle
224 | *.appxupload
225 |
226 | # Visual Studio cache files
227 | # files ending in .cache can be ignored
228 | *.[Cc]ache
229 | # but keep track of directories ending in .cache
230 | !?*.[Cc]ache/
231 |
232 | # Others
233 | ClientBin/
234 | ~$*
235 | *~
236 | *.dbmdl
237 | *.dbproj.schemaview
238 | *.jfm
239 | *.pfx
240 | *.publishsettings
241 | orleans.codegen.cs
242 |
243 | # Including strong name files can present a security risk
244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
245 | #*.snk
246 |
247 | # Since there are multiple workflows, uncomment next line to ignore bower_components
248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
249 | #bower_components/
250 |
251 | # RIA/Silverlight projects
252 | Generated_Code/
253 |
254 | # Backup & report files from converting an old project file
255 | # to a newer Visual Studio version. Backup files are not needed,
256 | # because we have git ;-)
257 | _UpgradeReport_Files/
258 | Backup*/
259 | UpgradeLog*.XML
260 | UpgradeLog*.htm
261 | ServiceFabricBackup/
262 | *.rptproj.bak
263 |
264 | # SQL Server files
265 | *.mdf
266 | *.ldf
267 | *.ndf
268 |
269 | # Business Intelligence projects
270 | *.rdl.data
271 | *.bim.layout
272 | *.bim_*.settings
273 | *.rptproj.rsuser
274 | *- [Bb]ackup.rdl
275 | *- [Bb]ackup ([0-9]).rdl
276 | *- [Bb]ackup ([0-9][0-9]).rdl
277 |
278 | # Microsoft Fakes
279 | FakesAssemblies/
280 |
281 | # GhostDoc plugin setting file
282 | *.GhostDoc.xml
283 |
284 | # Node.js Tools for Visual Studio
285 | .ntvs_analysis.dat
286 | node_modules/
287 |
288 | # Visual Studio 6 build log
289 | *.plg
290 |
291 | # Visual Studio 6 workspace options file
292 | *.opt
293 |
294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
295 | *.vbw
296 |
297 | # Visual Studio 6 auto-generated project file (contains which files were open etc.)
298 | *.vbp
299 |
300 | # Visual Studio 6 workspace and project file (working project files containing files to include in project)
301 | *.dsw
302 | *.dsp
303 |
304 | # Visual Studio 6 technical files
305 | *.ncb
306 | *.aps
307 |
308 | # Visual Studio LightSwitch build output
309 | **/*.HTMLClient/GeneratedArtifacts
310 | **/*.DesktopClient/GeneratedArtifacts
311 | **/*.DesktopClient/ModelManifest.xml
312 | **/*.Server/GeneratedArtifacts
313 | **/*.Server/ModelManifest.xml
314 | _Pvt_Extensions
315 |
316 | # Paket dependency manager
317 | .paket/paket.exe
318 | paket-files/
319 |
320 | # FAKE - F# Make
321 | .fake/
322 |
323 | # CodeRush personal settings
324 | .cr/personal
325 |
326 | # Python Tools for Visual Studio (PTVS)
327 | __pycache__/
328 | *.pyc
329 |
330 | # Cake - Uncomment if you are using it
331 | # tools/**
332 | # !tools/packages.config
333 |
334 | # Tabs Studio
335 | *.tss
336 |
337 | # Telerik's JustMock configuration file
338 | *.jmconfig
339 |
340 | # BizTalk build output
341 | *.btp.cs
342 | *.btm.cs
343 | *.odx.cs
344 | *.xsd.cs
345 |
346 | # OpenCover UI analysis results
347 | OpenCover/
348 |
349 | # Azure Stream Analytics local run output
350 | ASALocalRun/
351 |
352 | # MSBuild Binary and Structured Log
353 | *.binlog
354 |
355 | # NVidia Nsight GPU debugger configuration file
356 | *.nvuser
357 |
358 | # MFractors (Xamarin productivity tool) working folder
359 | .mfractor/
360 |
361 | # Local History for Visual Studio
362 | .localhistory/
363 |
364 | # Visual Studio History (VSHistory) files
365 | .vshistory/
366 |
367 | # BeatPulse healthcheck temp database
368 | healthchecksdb
369 |
370 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
371 | MigrationBackup/
372 |
373 | # Ionide (cross platform F# VS Code tools) working folder
374 | .ionide/
375 |
376 | # Fody - auto-generated XML schema
377 | FodyWeavers.xsd
378 |
379 | # VS Code files for those working on multiple tools
380 | .vscode/*
381 | !.vscode/settings.json
382 | !.vscode/tasks.json
383 | !.vscode/launch.json
384 | !.vscode/extensions.json
385 | *.code-workspace
386 |
387 | # Local History for Visual Studio Code
388 | .history/
389 |
390 | # Windows Installer files from build outputs
391 | *.cab
392 | *.msi
393 | *.msix
394 | *.msm
395 | *.msp
396 |
397 | # JetBrains Rider
398 | *.sln.iml
399 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Dani John
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DeptEffectDemo
2 | Win2D parallax 3D effect using depth map sample project
3 |
4 | Discussion:
5 | https://github.com/CommunityToolkit/Labs-Windows/discussions/458
6 |
--------------------------------------------------------------------------------
/src/DepthEffect.Common/DepthEffect.Common.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | PreserveNewest
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/DepthEffect.Common/Shaders/CompileShaders.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 | setlocal
3 | pushd "%~dp0"
4 |
5 | where /q fxc >nul
6 | if %errorlevel% neq 0 (
7 | echo fxc not found.
8 | goto WRONG_COMMAND_PROMPT
9 | )
10 |
11 | if "%WindowsSdkDir%" == "" (
12 | goto WRONG_COMMAND_PROMPT
13 | )
14 |
15 | set INCLUDEPATH="%WindowsSdkDir%\Include\%WindowsSDKVersion%\um"
16 |
17 | if not exist %INCLUDEPATH%\d2d1effecthelpers.hlsli (
18 | echo d2d1effecthelpers.hlsli not found.
19 | goto WRONG_COMMAND_PROMPT
20 | )
21 |
22 | call :COMPILE Depth.hlsl || goto END
23 |
24 | goto END
25 |
26 | :COMPILE
27 | echo.
28 | echo Compiling %1
29 |
30 | fxc %1 /nologo /T lib_4_0_level_9_3_ps_only /D D2D_FUNCTION /D D2D_ENTRY=main /Fl %~n1.fxlib /I %INCLUDEPATH% || exit /b
31 | fxc %1 /nologo /T ps_4_0_level_9_3 /D D2D_FULL_SHADER /D D2D_ENTRY=main /E main /setprivate %~n1.fxlib /Fo:%~n1.bin /I %INCLUDEPATH% || exit /b
32 |
33 | del %~n1.fxlib
34 | exit /b
35 |
36 | :WRONG_COMMAND_PROMPT
37 | echo Please run from a Developer Command Prompt for VS2017.
38 |
39 | :END
40 | popd
41 | exit /b %errorlevel%
42 |
--------------------------------------------------------------------------------
/src/DepthEffect.Common/Shaders/Depth.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rocksdanister/DeptEffectDemo/201d0773dcd59d7ab6f48120d847f1e4672a8afe/src/DepthEffect.Common/Shaders/Depth.bin
--------------------------------------------------------------------------------
/src/DepthEffect.Common/Shaders/Depth.hlsl:
--------------------------------------------------------------------------------
1 | #define D2D_INPUT_COUNT 2
2 | #define D2D_INPUT0_COMPLEX
3 | #define D2D_INPUT1_SIMPLE
4 |
5 | #define D2D_REQUIRES_SCENE_POSITION
6 |
7 | #include "d2d1effecthelpers.hlsli"
8 |
9 | float2 mouse = {0, 0};
10 | float2 intensity = {1, 1};
11 |
12 | D2D_PS_ENTRY(main)
13 | {
14 | float2 uv = D2DGetScenePosition().xy;
15 |
16 | float depth = D2DGetInput(1).r;
17 | float2 parallax = mouse * depth * intensity;
18 |
19 | float4 color = D2DSampleInputAtPosition(0, uv + parallax);
20 | return color;
21 | }
--------------------------------------------------------------------------------
/src/DepthEffect.UWP/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/DepthEffect.UWP/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.InteropServices.WindowsRuntime;
6 | using Windows.ApplicationModel;
7 | using Windows.ApplicationModel.Activation;
8 | using Windows.Foundation;
9 | using Windows.Foundation.Collections;
10 | using Windows.UI.Xaml;
11 | using Windows.UI.Xaml.Controls;
12 | using Windows.UI.Xaml.Controls.Primitives;
13 | using Windows.UI.Xaml.Data;
14 | using Windows.UI.Xaml.Input;
15 | using Windows.UI.Xaml.Media;
16 | using Windows.UI.Xaml.Navigation;
17 |
18 | namespace DepthEffect.UWP
19 | {
20 | ///
21 | /// Provides application-specific behavior to supplement the default Application class.
22 | ///
23 | sealed partial class App : Application
24 | {
25 | ///
26 | /// Initializes the singleton application object. This is the first line of authored code
27 | /// executed, and as such is the logical equivalent of main() or WinMain().
28 | ///
29 | public App()
30 | {
31 | this.InitializeComponent();
32 | this.Suspending += OnSuspending;
33 | }
34 |
35 | ///
36 | /// Invoked when the application is launched normally by the end user. Other entry points
37 | /// will be used such as when the application is launched to open a specific file.
38 | ///
39 | /// Details about the launch request and process.
40 | protected override void OnLaunched(LaunchActivatedEventArgs e)
41 | {
42 | Frame rootFrame = Window.Current.Content as Frame;
43 |
44 | // Do not repeat app initialization when the Window already has content,
45 | // just ensure that the window is active
46 | if (rootFrame == null)
47 | {
48 | // Create a Frame to act as the navigation context and navigate to the first page
49 | rootFrame = new Frame();
50 |
51 | rootFrame.NavigationFailed += OnNavigationFailed;
52 |
53 | if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
54 | {
55 | //TODO: Load state from previously suspended application
56 | }
57 |
58 | // Place the frame in the current Window
59 | Window.Current.Content = rootFrame;
60 | }
61 |
62 | if (e.PrelaunchActivated == false)
63 | {
64 | if (rootFrame.Content == null)
65 | {
66 | // When the navigation stack isn't restored navigate to the first page,
67 | // configuring the new page by passing required information as a navigation
68 | // parameter
69 | rootFrame.Navigate(typeof(MainPage), e.Arguments);
70 | }
71 | // Ensure the current window is active
72 | Window.Current.Activate();
73 | }
74 | }
75 |
76 | ///
77 | /// Invoked when Navigation to a certain page fails
78 | ///
79 | /// The Frame which failed navigation
80 | /// Details about the navigation failure
81 | void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
82 | {
83 | throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
84 | }
85 |
86 | ///
87 | /// Invoked when application execution is being suspended. Application state is saved
88 | /// without knowing whether the application will be terminated or resumed with the contents
89 | /// of memory still intact.
90 | ///
91 | /// The source of the suspend request.
92 | /// Details about the suspend request.
93 | private void OnSuspending(object sender, SuspendingEventArgs e)
94 | {
95 | var deferral = e.SuspendingOperation.GetDeferral();
96 | //TODO: Save application state and stop any background activity
97 | deferral.Complete();
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/src/DepthEffect.UWP/Assets/Attribution.txt:
--------------------------------------------------------------------------------
1 | Images from https://www.pexels.com/
--------------------------------------------------------------------------------
/src/DepthEffect.UWP/Assets/Depth1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rocksdanister/DeptEffectDemo/201d0773dcd59d7ab6f48120d847f1e4672a8afe/src/DepthEffect.UWP/Assets/Depth1.jpg
--------------------------------------------------------------------------------
/src/DepthEffect.UWP/Assets/Image1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rocksdanister/DeptEffectDemo/201d0773dcd59d7ab6f48120d847f1e4672a8afe/src/DepthEffect.UWP/Assets/Image1.jpg
--------------------------------------------------------------------------------
/src/DepthEffect.UWP/Assets/LockScreenLogo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rocksdanister/DeptEffectDemo/201d0773dcd59d7ab6f48120d847f1e4672a8afe/src/DepthEffect.UWP/Assets/LockScreenLogo.scale-200.png
--------------------------------------------------------------------------------
/src/DepthEffect.UWP/Assets/SplashScreen.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rocksdanister/DeptEffectDemo/201d0773dcd59d7ab6f48120d847f1e4672a8afe/src/DepthEffect.UWP/Assets/SplashScreen.scale-200.png
--------------------------------------------------------------------------------
/src/DepthEffect.UWP/Assets/Square150x150Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rocksdanister/DeptEffectDemo/201d0773dcd59d7ab6f48120d847f1e4672a8afe/src/DepthEffect.UWP/Assets/Square150x150Logo.scale-200.png
--------------------------------------------------------------------------------
/src/DepthEffect.UWP/Assets/Square44x44Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rocksdanister/DeptEffectDemo/201d0773dcd59d7ab6f48120d847f1e4672a8afe/src/DepthEffect.UWP/Assets/Square44x44Logo.scale-200.png
--------------------------------------------------------------------------------
/src/DepthEffect.UWP/Assets/Square44x44Logo.targetsize-24_altform-unplated.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rocksdanister/DeptEffectDemo/201d0773dcd59d7ab6f48120d847f1e4672a8afe/src/DepthEffect.UWP/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
--------------------------------------------------------------------------------
/src/DepthEffect.UWP/Assets/StoreLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rocksdanister/DeptEffectDemo/201d0773dcd59d7ab6f48120d847f1e4672a8afe/src/DepthEffect.UWP/Assets/StoreLogo.png
--------------------------------------------------------------------------------
/src/DepthEffect.UWP/Assets/Wide310x150Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rocksdanister/DeptEffectDemo/201d0773dcd59d7ab6f48120d847f1e4672a8afe/src/DepthEffect.UWP/Assets/Wide310x150Logo.scale-200.png
--------------------------------------------------------------------------------
/src/DepthEffect.UWP/DepthEffect.UWP.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | x86
7 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}
8 | AppContainerExe
9 | Properties
10 | DepthEffect.UWP
11 | DepthEffect.UWP
12 | en-US
13 | UAP
14 | 10.0.22000.0
15 | 10.0.17763.0
16 | 14
17 | 512
18 | {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
19 | true
20 | false
21 |
22 |
23 | true
24 | bin\x86\Debug\
25 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
26 | ;2008
27 | full
28 | x86
29 | false
30 | prompt
31 | true
32 |
33 |
34 | bin\x86\Release\
35 | TRACE;NETFX_CORE;WINDOWS_UWP
36 | true
37 | ;2008
38 | pdbonly
39 | x86
40 | false
41 | prompt
42 | true
43 | true
44 |
45 |
46 | true
47 | bin\ARM\Debug\
48 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
49 | ;2008
50 | full
51 | ARM
52 | false
53 | prompt
54 | true
55 |
56 |
57 | bin\ARM\Release\
58 | TRACE;NETFX_CORE;WINDOWS_UWP
59 | true
60 | ;2008
61 | pdbonly
62 | ARM
63 | false
64 | prompt
65 | true
66 | true
67 |
68 |
69 | true
70 | bin\ARM64\Debug\
71 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
72 | ;2008
73 | full
74 | ARM64
75 | false
76 | prompt
77 | true
78 | true
79 |
80 |
81 | bin\ARM64\Release\
82 | TRACE;NETFX_CORE;WINDOWS_UWP
83 | true
84 | ;2008
85 | pdbonly
86 | ARM64
87 | false
88 | prompt
89 | true
90 | true
91 |
92 |
93 | true
94 | bin\x64\Debug\
95 | DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
96 | ;2008
97 | full
98 | x64
99 | false
100 | prompt
101 | true
102 |
103 |
104 | bin\x64\Release\
105 | TRACE;NETFX_CORE;WINDOWS_UWP
106 | true
107 | ;2008
108 | pdbonly
109 | x64
110 | false
111 | prompt
112 | true
113 | true
114 |
115 |
116 | PackageReference
117 |
118 |
119 |
120 | App.xaml
121 |
122 |
123 | MainPage.xaml
124 |
125 |
126 |
127 |
128 |
129 | Designer
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 | MSBuild:Compile
148 | Designer
149 |
150 |
151 | MSBuild:Compile
152 | Designer
153 |
154 |
155 |
156 |
157 | 6.2.14
158 |
159 |
160 | 1.26.0
161 |
162 |
163 |
164 |
165 | {0a78bfa2-7c9b-48b2-9df0-0c26457868a0}
166 | DepthEffect.Common
167 |
168 |
169 |
170 | 14.0
171 |
172 |
173 |
180 |
--------------------------------------------------------------------------------
/src/DepthEffect.UWP/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/DepthEffect.UWP/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Graphics.Canvas.Effects;
2 | using Microsoft.Graphics.Canvas.UI.Xaml;
3 | using Microsoft.Graphics.Canvas;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.IO;
7 | using System.Linq;
8 | using System.Numerics;
9 | using System.Runtime.InteropServices.WindowsRuntime;
10 | using System.Threading.Tasks;
11 | using Windows.Foundation;
12 | using Windows.Foundation.Collections;
13 | using Windows.Storage;
14 | using Windows.UI.Xaml;
15 | using Windows.UI.Xaml.Controls;
16 | using Windows.UI.Xaml.Controls.Primitives;
17 | using Windows.UI.Xaml.Data;
18 | using Windows.UI.Xaml.Input;
19 | using Windows.UI.Xaml.Media;
20 | using Windows.UI.Xaml.Navigation;
21 | using System.Diagnostics;
22 | using Microsoft.Graphics.Canvas.UI;
23 |
24 | namespace DepthEffect.UWP
25 | {
26 | public sealed partial class MainPage : Page
27 | {
28 | private CanvasBitmap image, depth;
29 | private PixelShaderEffect depthEffect;
30 | private Vector2 imageSize = new Vector2(1, 1);
31 | private Vector2 mousePos = new Vector2(0, 0);
32 | private Vector2 mouseOffset = new Vector2(0, 0);
33 |
34 | public MainPage()
35 | {
36 | this.InitializeComponent();
37 | }
38 |
39 | private void CanvasControl_CreateResources(CanvasAnimatedControl sender, CanvasCreateResourcesEventArgs args)
40 | {
41 | args.TrackAsyncAction(Canvas_CreateResourcesAsync(sender).AsAsyncAction());
42 | }
43 |
44 | private async Task Canvas_CreateResourcesAsync(CanvasAnimatedControl sender)
45 | {
46 | // Load shader
47 | var shaderFile = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync("Shaders\\Depth.bin");
48 | depthEffect = new PixelShaderEffect(await GetBytesFromFile(shaderFile));
49 |
50 | // Load images
51 | var imageFile = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync("Assets\\Image1.jpg");
52 | image = await CanvasBitmap.LoadAsync(sender, imageFile.Path);
53 | var depthFile = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync("Assets\\Depth1.jpg");
54 | depth = await CanvasBitmap.LoadAsync(sender, depthFile.Path);
55 | imageSize = image.Size.ToVector2();
56 |
57 | depthEffect.Source2 = depth;
58 | depthEffect.Source1 = image;
59 | //depthEffect.Source1Mapping = SamplerCoordinateMapping.Offset;
60 | //depthEffect.MaxSamplerOffset = 100;
61 | }
62 |
63 | private void CanvasControl_Update(ICanvasAnimatedControl sender, CanvasAnimatedUpdateEventArgs args)
64 | {
65 | // Is it better to calculate here?
66 | }
67 |
68 | void CanvasControl_Draw(ICanvasAnimatedControl sender, CanvasAnimatedDrawEventArgs args)
69 | {
70 | var size = sender.Size.ToVector2();
71 |
72 | mouseOffset.X += (-0.075f * mousePos.X - mouseOffset.X) * 0.08f;
73 | mouseOffset.Y += (-0.075f * mousePos.Y - mouseOffset.Y) * 0.08f;
74 | depthEffect.Properties["mouse"] = new Vector2(mouseOffset.X, mouseOffset.Y);
75 | depthEffect.Properties["intensity"] = new Vector2(0.75f, 1f);
76 |
77 | // Uniform, crop to hide edge distortions
78 | // Strech(size.Y / imageSize.Y + 0.25f, size.X / imageSize.X + 0.25f)
79 | float screenAspect = size.X / size.Y;
80 | float textureAspect = imageSize.X / imageSize.Y;
81 | var scale = textureAspect > screenAspect ? new Vector2(size.Y / imageSize.Y + 0.25f) : new Vector2(size.X / imageSize.X + 0.25f);
82 | args.DrawingSession.Transform = Matrix3x2.CreateScale(scale);
83 |
84 | // Center the output
85 | var offset = (size - imageSize * scale) / 2;
86 | args.DrawingSession.DrawImage(depthEffect, offset);
87 | }
88 |
89 | // This will not work if other controls ontop of canvas
90 | private void CanvasControl_PointerMoved(object sender, PointerRoutedEventArgs e)
91 | {
92 | var point = e.GetCurrentPoint(mainGrid);
93 | mousePos.X = (float)(point.Position.X);
94 | mousePos.Y = (float)(point.Position.Y);
95 | }
96 |
97 | private void CanvasControl_PointerExited(object sender, PointerRoutedEventArgs e)
98 | {
99 | // Reset to center
100 | mousePos.X = mousePos.Y = 0;
101 | }
102 |
103 | private void Page_Unloaded(object sender, RoutedEventArgs e)
104 | {
105 | this.canvasControl.RemoveFromVisualTree();
106 | this.canvasControl = null;
107 |
108 | //depthEffect?.Dispose();
109 | //image?.Dispose();
110 | //depth?.Dispose();
111 | }
112 |
113 | public async Task GetBytesFromFile(StorageFile file)
114 | {
115 | var stream = await file.OpenStreamForReadAsync();
116 | byte[] bytes = new byte[stream.Length];
117 | await stream.ReadAsync(bytes, 0, bytes.Length);
118 | stream.Seek(0, SeekOrigin.Begin);
119 | return bytes;
120 | }
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/src/DepthEffect.UWP/Package.appxmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
13 |
14 |
15 |
16 |
17 | DepthEffect.UWP
18 | rocks
19 | Assets\StoreLogo.png
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
34 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/src/DepthEffect.UWP/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("DepthEffect.UWP")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("DepthEffect.UWP")]
13 | [assembly: AssemblyCopyright("Copyright © 2023")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Version information for an assembly consists of the following four values:
18 | //
19 | // Major Version
20 | // Minor Version
21 | // Build Number
22 | // Revision
23 | //
24 | // You can specify all the values or you can default the Build and Revision Numbers
25 | // by using the '*' as shown below:
26 | // [assembly: AssemblyVersion("1.0.*")]
27 | [assembly: AssemblyVersion("1.0.0.0")]
28 | [assembly: AssemblyFileVersion("1.0.0.0")]
29 | [assembly: ComVisible(false)]
--------------------------------------------------------------------------------
/src/DepthEffect.UWP/Properties/Default.rd.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/DepthEffect.WinUI3/App.xaml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/DepthEffect.WinUI3/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.UI.Xaml;
2 | using Microsoft.UI.Xaml.Controls;
3 | using Microsoft.UI.Xaml.Controls.Primitives;
4 | using Microsoft.UI.Xaml.Data;
5 | using Microsoft.UI.Xaml.Input;
6 | using Microsoft.UI.Xaml.Media;
7 | using Microsoft.UI.Xaml.Navigation;
8 | using Microsoft.UI.Xaml.Shapes;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.IO;
12 | using System.Linq;
13 | using System.Runtime.InteropServices.WindowsRuntime;
14 | using Windows.ApplicationModel;
15 | using Windows.ApplicationModel.Activation;
16 | using Windows.Foundation;
17 | using Windows.Foundation.Collections;
18 |
19 | // To learn more about WinUI, the WinUI project structure,
20 | // and more about our project templates, see: http://aka.ms/winui-project-info.
21 |
22 | namespace DepthEffect.WinUI3
23 | {
24 | ///
25 | /// Provides application-specific behavior to supplement the default Application class.
26 | ///
27 | public partial class App : Application
28 | {
29 | ///
30 | /// Initializes the singleton application object. This is the first line of authored code
31 | /// executed, and as such is the logical equivalent of main() or WinMain().
32 | ///
33 | public App()
34 | {
35 | this.InitializeComponent();
36 | }
37 |
38 | ///
39 | /// Invoked when the application is launched.
40 | ///
41 | /// Details about the launch request and process.
42 | protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
43 | {
44 | m_window = new MainWindow();
45 | m_window.Activate();
46 | }
47 |
48 | private Window m_window;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/DepthEffect.WinUI3/Assets/Attribution.txt:
--------------------------------------------------------------------------------
1 | Images from https://www.pexels.com/
--------------------------------------------------------------------------------
/src/DepthEffect.WinUI3/Assets/Depth1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rocksdanister/DeptEffectDemo/201d0773dcd59d7ab6f48120d847f1e4672a8afe/src/DepthEffect.WinUI3/Assets/Depth1.jpg
--------------------------------------------------------------------------------
/src/DepthEffect.WinUI3/Assets/Image1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rocksdanister/DeptEffectDemo/201d0773dcd59d7ab6f48120d847f1e4672a8afe/src/DepthEffect.WinUI3/Assets/Image1.jpg
--------------------------------------------------------------------------------
/src/DepthEffect.WinUI3/Assets/LockScreenLogo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rocksdanister/DeptEffectDemo/201d0773dcd59d7ab6f48120d847f1e4672a8afe/src/DepthEffect.WinUI3/Assets/LockScreenLogo.scale-200.png
--------------------------------------------------------------------------------
/src/DepthEffect.WinUI3/Assets/SplashScreen.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rocksdanister/DeptEffectDemo/201d0773dcd59d7ab6f48120d847f1e4672a8afe/src/DepthEffect.WinUI3/Assets/SplashScreen.scale-200.png
--------------------------------------------------------------------------------
/src/DepthEffect.WinUI3/Assets/Square150x150Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rocksdanister/DeptEffectDemo/201d0773dcd59d7ab6f48120d847f1e4672a8afe/src/DepthEffect.WinUI3/Assets/Square150x150Logo.scale-200.png
--------------------------------------------------------------------------------
/src/DepthEffect.WinUI3/Assets/Square44x44Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rocksdanister/DeptEffectDemo/201d0773dcd59d7ab6f48120d847f1e4672a8afe/src/DepthEffect.WinUI3/Assets/Square44x44Logo.scale-200.png
--------------------------------------------------------------------------------
/src/DepthEffect.WinUI3/Assets/Square44x44Logo.targetsize-24_altform-unplated.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rocksdanister/DeptEffectDemo/201d0773dcd59d7ab6f48120d847f1e4672a8afe/src/DepthEffect.WinUI3/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
--------------------------------------------------------------------------------
/src/DepthEffect.WinUI3/Assets/StoreLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rocksdanister/DeptEffectDemo/201d0773dcd59d7ab6f48120d847f1e4672a8afe/src/DepthEffect.WinUI3/Assets/StoreLogo.png
--------------------------------------------------------------------------------
/src/DepthEffect.WinUI3/Assets/Wide310x150Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rocksdanister/DeptEffectDemo/201d0773dcd59d7ab6f48120d847f1e4672a8afe/src/DepthEffect.WinUI3/Assets/Wide310x150Logo.scale-200.png
--------------------------------------------------------------------------------
/src/DepthEffect.WinUI3/DepthEffect.WinUI3.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | WinExe
4 | net6.0-windows10.0.19041.0
5 | 10.0.17763.0
6 | DepthEffect.WinUI3
7 | app.manifest
8 | x86;x64;ARM64
9 | win10-x86;win10-x64;win10-arm64
10 | win10-$(Platform).pubxml
11 | true
12 | true
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | PreserveNewest
50 |
51 |
52 | PreserveNewest
53 |
54 |
55 |
56 |
61 |
62 | true
63 |
64 |
65 |
--------------------------------------------------------------------------------
/src/DepthEffect.WinUI3/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/DepthEffect.WinUI3/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.UI.Xaml;
2 | using Microsoft.UI.Xaml.Controls;
3 | using Microsoft.UI.Xaml.Controls.Primitives;
4 | using Microsoft.UI.Xaml.Data;
5 | using Microsoft.UI.Xaml.Input;
6 | using Microsoft.UI.Xaml.Media;
7 | using Microsoft.UI.Xaml.Navigation;
8 | using System.Collections.Generic;
9 | using System.Diagnostics;
10 | using System.Linq;
11 | using System.Runtime.InteropServices.WindowsRuntime;
12 | using Windows.Foundation;
13 | using Windows.Foundation.Collections;
14 | using TerraFX.Interop.Windows;
15 | using DepthEffect.WinUI3.Shaders.Runners;
16 |
17 | namespace DepthEffect.WinUI3
18 | {
19 | public sealed partial class MainWindow : Window
20 | {
21 | private float2 mousePos = new(0, 0);
22 |
23 | public MainWindow()
24 | {
25 | this.InitializeComponent();
26 | shaderPanel.ShaderRunner = new DepthParallaxRunner(() => mousePos);
27 | }
28 |
29 | private void ShaderPanel_PointerMoved(object sender, PointerRoutedEventArgs e)
30 | {
31 | var point = e.GetCurrentPoint(mainGrid);
32 | mousePos.X = (float)((float)point.Position.X / shaderPanel.ActualWidth);
33 | mousePos.Y = (float)((float)point.Position.Y / shaderPanel.ActualHeight);
34 | }
35 |
36 | private void ShaderPanel_PointerExited(object sender, PointerRoutedEventArgs e)
37 | {
38 | // Reset to center
39 | mousePos.X = mousePos.Y = 0;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/DepthEffect.WinUI3/Package.appxmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
14 |
15 |
16 |
17 |
18 | DepthEffect.WinUI3
19 | rocks
20 | Assets\StoreLogo.png
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
36 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/src/DepthEffect.WinUI3/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "DepthEffect.WinUI3 (Package)": {
4 | "commandName": "MsixPackage"
5 | },
6 | "DepthEffect.WinUI3 (Unpackaged)": {
7 | "commandName": "Project"
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/src/DepthEffect.WinUI3/Shaders/DepthParallax.cs:
--------------------------------------------------------------------------------
1 | using ComputeSharp;
2 |
3 | namespace DepthEffect.WinUI3.Shaders;
4 |
5 | [AutoConstructor]
6 | [EmbeddedBytecode(DispatchAxis.XY)]
7 | internal readonly partial struct DepthParallax : IPixelShader
8 | {
9 | public readonly IReadOnlyNormalizedTexture2D imageTexture;
10 |
11 | public readonly IReadOnlyNormalizedTexture2D depthTexture;
12 |
13 | public readonly float2 mouse = new(0, 0);
14 |
15 | public readonly float2 intensity = new(1, 1);
16 |
17 | ///
18 | public float4 Execute()
19 | {
20 | float2 fragCoord = new(ThreadIds.X, DispatchSize.Y - ThreadIds.Y);
21 | float2 uv = fragCoord / DispatchSize.XY;
22 | uv.Y = 1.0f - uv.Y;
23 |
24 | // Fill scale
25 | float screenAspect = (float)DispatchSize.X / DispatchSize.Y;
26 | float textureAspect = (float)imageTexture.Width / imageTexture.Height;
27 | float scaleX = 1f, scaleY = 1f;
28 | if (textureAspect > screenAspect)
29 | scaleX = screenAspect / textureAspect;
30 | else
31 | scaleY = textureAspect / screenAspect;
32 | uv = new Float2(scaleX, scaleY) * (uv - 0.5f) + 0.5f;
33 |
34 | float depth = depthTexture.Sample(uv).R;
35 | Float2 parallax = mouse * depth * intensity;
36 |
37 | float4 color = new(imageTexture.Sample(uv + parallax).RGB, 1);
38 | return color;
39 | }
40 | }
--------------------------------------------------------------------------------
/src/DepthEffect.WinUI3/Shaders/Runners/DepthParallaxRunner.cs:
--------------------------------------------------------------------------------
1 | using ComputeSharp.WinUI;
2 | using ComputeSharp;
3 | using System;
4 | using System.IO;
5 |
6 | namespace DepthEffect.WinUI3.Shaders.Runners;
7 |
8 | public sealed class DepthParallaxRunner : IShaderRunner
9 | {
10 | private readonly Func mouse;
11 | private readonly ReadOnlyTexture2D image, depth;
12 | private float2 mouseOffset = new(0, 0);
13 | private float2 intensity = new(0.75f, 1f);
14 |
15 | public DepthParallaxRunner(Func mouse)
16 | {
17 | var graphics = GraphicsDevice.GetDefault();
18 | image = graphics.LoadReadOnlyTexture2D(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Assets", "Image1.jpg"));
19 | depth = graphics.LoadReadOnlyTexture2D(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Assets", "Depth1.jpg"));
20 | this.mouse = mouse;
21 | }
22 |
23 | public bool TryExecute(IReadWriteNormalizedTexture2D texture, TimeSpan timespan, object? parameter)
24 | {
25 | mouseOffset.X += (-0.075f * mouse().X - mouseOffset.X) * 0.08f;
26 | mouseOffset.Y += (-0.075f * mouse().Y - mouseOffset.Y) * 0.08f;
27 | texture.GraphicsDevice.ForEach(texture, new DepthParallax(image, depth, mouseOffset, intensity));
28 |
29 | return true;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/DepthEffect.WinUI3/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | PerMonitorV2
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/DepthEffect.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.6.33815.320
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DepthEffect.UWP", "DepthEffect.UWP\DepthEffect.UWP.csproj", "{CC1D31C3-D601-44F1-A99E-1B127DF7C711}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DepthEffect.Common", "DepthEffect.Common\DepthEffect.Common.csproj", "{0A78BFA2-7C9B-48B2-9DF0-0C26457868A0}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DepthEffect.WinUI3", "DepthEffect.WinUI3\DepthEffect.WinUI3.csproj", "{EA17521E-C45A-49F8-A78C-86371760ADA9}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|Any CPU = Debug|Any CPU
15 | Debug|ARM = Debug|ARM
16 | Debug|ARM64 = Debug|ARM64
17 | Debug|x64 = Debug|x64
18 | Debug|x86 = Debug|x86
19 | Release|Any CPU = Release|Any CPU
20 | Release|ARM = Release|ARM
21 | Release|ARM64 = Release|ARM64
22 | Release|x64 = Release|x64
23 | Release|x86 = Release|x86
24 | EndGlobalSection
25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
26 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Debug|Any CPU.ActiveCfg = Debug|x64
27 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Debug|Any CPU.Build.0 = Debug|x64
28 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Debug|Any CPU.Deploy.0 = Debug|x64
29 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Debug|ARM.ActiveCfg = Debug|ARM
30 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Debug|ARM.Build.0 = Debug|ARM
31 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Debug|ARM.Deploy.0 = Debug|ARM
32 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Debug|ARM64.ActiveCfg = Debug|ARM64
33 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Debug|ARM64.Build.0 = Debug|ARM64
34 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Debug|ARM64.Deploy.0 = Debug|ARM64
35 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Debug|x64.ActiveCfg = Debug|x64
36 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Debug|x64.Build.0 = Debug|x64
37 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Debug|x64.Deploy.0 = Debug|x64
38 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Debug|x86.ActiveCfg = Debug|x86
39 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Debug|x86.Build.0 = Debug|x86
40 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Debug|x86.Deploy.0 = Debug|x86
41 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Release|Any CPU.ActiveCfg = Release|x64
42 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Release|Any CPU.Build.0 = Release|x64
43 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Release|Any CPU.Deploy.0 = Release|x64
44 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Release|ARM.ActiveCfg = Release|ARM
45 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Release|ARM.Build.0 = Release|ARM
46 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Release|ARM.Deploy.0 = Release|ARM
47 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Release|ARM64.ActiveCfg = Release|ARM64
48 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Release|ARM64.Build.0 = Release|ARM64
49 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Release|ARM64.Deploy.0 = Release|ARM64
50 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Release|x64.ActiveCfg = Release|x64
51 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Release|x64.Build.0 = Release|x64
52 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Release|x64.Deploy.0 = Release|x64
53 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Release|x86.ActiveCfg = Release|x86
54 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Release|x86.Build.0 = Release|x86
55 | {CC1D31C3-D601-44F1-A99E-1B127DF7C711}.Release|x86.Deploy.0 = Release|x86
56 | {0A78BFA2-7C9B-48B2-9DF0-0C26457868A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
57 | {0A78BFA2-7C9B-48B2-9DF0-0C26457868A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
58 | {0A78BFA2-7C9B-48B2-9DF0-0C26457868A0}.Debug|ARM.ActiveCfg = Debug|Any CPU
59 | {0A78BFA2-7C9B-48B2-9DF0-0C26457868A0}.Debug|ARM.Build.0 = Debug|Any CPU
60 | {0A78BFA2-7C9B-48B2-9DF0-0C26457868A0}.Debug|ARM64.ActiveCfg = Debug|Any CPU
61 | {0A78BFA2-7C9B-48B2-9DF0-0C26457868A0}.Debug|ARM64.Build.0 = Debug|Any CPU
62 | {0A78BFA2-7C9B-48B2-9DF0-0C26457868A0}.Debug|x64.ActiveCfg = Debug|Any CPU
63 | {0A78BFA2-7C9B-48B2-9DF0-0C26457868A0}.Debug|x64.Build.0 = Debug|Any CPU
64 | {0A78BFA2-7C9B-48B2-9DF0-0C26457868A0}.Debug|x86.ActiveCfg = Debug|Any CPU
65 | {0A78BFA2-7C9B-48B2-9DF0-0C26457868A0}.Debug|x86.Build.0 = Debug|Any CPU
66 | {0A78BFA2-7C9B-48B2-9DF0-0C26457868A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
67 | {0A78BFA2-7C9B-48B2-9DF0-0C26457868A0}.Release|Any CPU.Build.0 = Release|Any CPU
68 | {0A78BFA2-7C9B-48B2-9DF0-0C26457868A0}.Release|ARM.ActiveCfg = Release|Any CPU
69 | {0A78BFA2-7C9B-48B2-9DF0-0C26457868A0}.Release|ARM.Build.0 = Release|Any CPU
70 | {0A78BFA2-7C9B-48B2-9DF0-0C26457868A0}.Release|ARM64.ActiveCfg = Release|Any CPU
71 | {0A78BFA2-7C9B-48B2-9DF0-0C26457868A0}.Release|ARM64.Build.0 = Release|Any CPU
72 | {0A78BFA2-7C9B-48B2-9DF0-0C26457868A0}.Release|x64.ActiveCfg = Release|Any CPU
73 | {0A78BFA2-7C9B-48B2-9DF0-0C26457868A0}.Release|x64.Build.0 = Release|Any CPU
74 | {0A78BFA2-7C9B-48B2-9DF0-0C26457868A0}.Release|x86.ActiveCfg = Release|Any CPU
75 | {0A78BFA2-7C9B-48B2-9DF0-0C26457868A0}.Release|x86.Build.0 = Release|Any CPU
76 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Debug|Any CPU.ActiveCfg = Debug|x64
77 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Debug|Any CPU.Build.0 = Debug|x64
78 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Debug|Any CPU.Deploy.0 = Debug|x64
79 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Debug|ARM.ActiveCfg = Debug|x64
80 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Debug|ARM.Build.0 = Debug|x64
81 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Debug|ARM.Deploy.0 = Debug|x64
82 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Debug|ARM64.ActiveCfg = Debug|ARM64
83 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Debug|ARM64.Build.0 = Debug|ARM64
84 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Debug|ARM64.Deploy.0 = Debug|ARM64
85 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Debug|x64.ActiveCfg = Debug|x64
86 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Debug|x64.Build.0 = Debug|x64
87 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Debug|x64.Deploy.0 = Debug|x64
88 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Debug|x86.ActiveCfg = Debug|x86
89 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Debug|x86.Build.0 = Debug|x86
90 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Debug|x86.Deploy.0 = Debug|x86
91 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Release|Any CPU.ActiveCfg = Release|x64
92 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Release|Any CPU.Build.0 = Release|x64
93 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Release|Any CPU.Deploy.0 = Release|x64
94 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Release|ARM.ActiveCfg = Release|x64
95 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Release|ARM.Build.0 = Release|x64
96 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Release|ARM.Deploy.0 = Release|x64
97 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Release|ARM64.ActiveCfg = Release|ARM64
98 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Release|ARM64.Build.0 = Release|ARM64
99 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Release|ARM64.Deploy.0 = Release|ARM64
100 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Release|x64.ActiveCfg = Release|x64
101 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Release|x64.Build.0 = Release|x64
102 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Release|x64.Deploy.0 = Release|x64
103 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Release|x86.ActiveCfg = Release|x86
104 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Release|x86.Build.0 = Release|x86
105 | {EA17521E-C45A-49F8-A78C-86371760ADA9}.Release|x86.Deploy.0 = Release|x86
106 | EndGlobalSection
107 | GlobalSection(SolutionProperties) = preSolution
108 | HideSolutionNode = FALSE
109 | EndGlobalSection
110 | GlobalSection(ExtensibilityGlobals) = postSolution
111 | SolutionGuid = {638F244E-A45D-413D-8E4E-9E00FAC05EF6}
112 | EndGlobalSection
113 | EndGlobal
114 |
--------------------------------------------------------------------------------