Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.
Talk:Creating a Lens application that uses HLSL effects for filters
Hamishwillee - Added some categories
I know this is in draft, but I've added some categories so I don't forget to do it later. I'm wondering if we need another one to show this is C++ rather than Silverlight or XNA - ie C++, DirectX, "Unmanaged" code. Any particular thoughts on that?
07:17, 20 November 2012 (EET)
Thank you for adding the categories to the article, although I usually put them just before publishing the final version of the article. I was thinking of adding the DirectX category, since there isn't any C++ nor unmanaged code in the final project, as everything is done under the hood by the internal bindings of SharpDX.
On another note, since this is Windows Phone 8 exclusive, shouldn't the category Windows Phone be excluded?Cheers.
14:06, 20 November 2012 (EET)
Hamishwillee - Your call
In my own articles I handle categories the same way (add at the end) and this is desirable. Unfortunately this is the thing most people forget so when reviewing other's articles I tend to add the categories if I think they are going to finish the article in a reasonable time. If I have some doubt on that I'll often add Template:UnderConstruction.
Would DirectX be used as a catch-all for all articles related to the new "games libraries"? ie the equivalent to XNA and Silverlight categories on this wiki? If so, yes, happy for that to be added.
>On another note, since this is Windows Phone 8 exclusive, shouldn't the category Windows Phone be excluded?
No. Every article gets Windows Phone, and articles that are specific to WP8 get that tag too. The tag means "introduced in WP8".
This wasn't quite my preference - I actually wanted Windows Phone for every article and WP version tags for all versions. I'm not completely happy with what we're using, but we'll see how it goes.
05:58, 21 November 2012 (EET)
Likebobby - DraftWill you finish this article? I'm really exited about it :)
18:59, 6 December 2012 (EET)
Yes, I'm planning on finishing this article and the other about IAP and Wallet usage in time for the current contest. I'm just having some problems with unexpected bugs in SharpDX (its creator doesn't have a Windows Phone to test the reported bugs, and I don't like doing article-specific workarounds) and getting a test device to try the samples in something that isn't the emulator.Cheers.
22:32, 6 December 2012 (EET)
Sebaw - draft and api
Can I expect this example to be finished soon? Second thing is, is api ICameraCaptureDeviceNative and family available in public sdk? I cannot find this...
13:55, 10 December 2012 (EET)
Hello sebaw,I'm planning on finishing it tomorrow or the day after so it qualifies for the current competition. I think ICameraCaptureDeviceNative is an interface for use in native code, in managed code you should use PhotoCaptureDevice and AudioVideoCaptureDevice.
03:18, 11 December 2012 (EET)
Hamishwillee -No "this is an entry in the competition header"?
05:33, 14 December 2012 (EET)
R2d2rigo -Whoops, my bad. It's added now.
11:56, 14 December 2012 (EET)
Pixsta - SharpDX problems on WP8
Thanks for the great article. Just one important comment: the SharpDX framework generally works on WP8 but it has some serious problems. For instance if you leave (=send to background) your sample app by pressing the "Windows" button and then bringing it back to foreground using the "Back" button the app does not restart properly. I already tried to track down the problem by debugging the SharpDX source code but without success.The exception is raised in "SharpDX.Toolkit.Graphics.EffectData", method "MergeFrom", line "var shader = source.Shaders[shaderLink.Index];" (line 171 in the current source) if anyone want to try to track the problem as well.
18:30, 17 December 2012 (EET)
R2d2rigo -@Pixsta: yes, SharpDX (especially the Toolkit part) is somewhat buggy in WP8, due to the fact that its maintainer doesn't have a physical device to test it. What happens here is that both the content and the graphics device are being disposed when the app goes to background, and there isn't any graphics device available when the execution resumes. I'll try to fix it or at least add it to the official bug tracker.
01:17, 18 December 2012 (EET)
Hamishwillee - Nice job
Just had full read through this. Very impressive job.If you add a bug, add a note linking to it in the body of the article please.
06:34, 18 December 2012 (EET)
what if I want just a island of DirectX instead of full screen?DrawingSurfaceBackgroundGrid must be the root elements of a page.
10:08, 24 December 2012 (EET)
You can use the DrawingSurface control for XAML-heavy applications that only need a defined area drawn using DirectX: http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj662943(v=vs.105).aspxCheers.
15:30, 24 December 2012 (EET)
Tamas305 - Problem compiling
A first chance exception of type 'SharpDX.Toolkit.Content.AssetNotFoundException' occurred in SharpDX.Toolkit.DLL An exception of type 'SharpDX.Toolkit.Content.AssetNotFoundException' occurred in SharpDX.Toolkit.DLL but was not handled in user code
I get this error when trying to build. It breaks on the following line:
inversionEffect = Content.Load<Effect>("Inverted.tkfxo");
What could be causing this? I'm using the latest libraries from SharpDX's website compiled today.
Also, do you have any idea how to get started with using the Native Camera APIs? I don't know how I should start. I would prefer not to use SharpDX if possible and use C++ but I have no idea how I should display the camera feed.Thank you
20:13, 7 April 2013 (EEST)
Emiswelt - Lag / Flicker (Threading Issue)?
When I run the code on a Lumia 620, occasional lagging occours. It looks like previous frames are being drawn for the fracture of a second. What could that be? A threading issue maybe?
With best regards,Emi
talk) 13:50, 11 September 2013 (EEST)(
Can Poyrazoğlu - Lag/Flicker issueI am also having the same issue with emiswelt on my Lumia 920 too. Maybe the frames aren't copied to GPU in correct order as they are received from the camera preview buffer. The effect is not apparent if I'm not moving the phone but if I move the phone fast, it really creates a bad user experience. It's like, frames that need to be drawn a few iterations before are getting drawn where they should have already been drawn in past (I mean, a few hundred milliseconds ago), or dropped. But they definitely shouldn't be drawn there. If I preview at a higher resolution than 640x480, the effect is even more apparent, making the app almost non-usable.
talk) 00:38, 14 September 2013 (EEST)(
Pieter.voloshyn - How to apply SharpDX.Toolkit.Graphics.Effect directly?
I'm creating an image editor for Windows Phone 8 / Windows 8 using SharpDX api and trying to apply a custom effect (SharpDX.Toolkit.Graphics.Effect) to a WriteableBitmap.
The effect itself is applied, but the result looks strange. Seems to me that the texture was reduced and inverted.
The code follows below:
/**********/ GraphicsDevice graphicsDevice = GraphicsDevice.New();
RenderTarget2D renderTarget = RenderTarget2D.New( graphicsDevice, _originalBitmap.PixelWidth, _originalBitmap.PixelHeight, PixelFormat.B8G8R8A8.UNorm );
Texture2D texture = Texture2D.New( graphicsDevice, _originalBitmap.PixelWidth, _originalBitmap.PixelHeight, PixelFormat.B8G8R8A8.UNorm ); texture.SetData<int>( _originalBitmap.Pixels );
Effect effect = new Effect( graphicsDevice, SimpleEffectTest.Effects.Invert.EffectBytecode );
graphicsDevice.SetRenderTargets( renderTarget );
SpriteBatch spriteBatch = new SpriteBatch( graphicsDevice ); spriteBatch.Begin( SpriteSortMode.Deferred, effect ); spriteBatch.Draw( texture, Vector2.Zero, Color.White ); spriteBatch.End();
renderTarget.GetData<int>( _resultBitmap.Pixels ); /**********/
Do you know what I'm doing wrong here?
You can download my project here: https://skydrive.live.com/redir?resid=3B9524A154570D71!853
Best regards,Pieter Voloshyn
talk) 02:55, 20 September 2013 (EEST)(
Pieter.voloshyn - Update: How to apply SharpDX.Toolkit.Graphics.Effect directly?
I finally found what I did wrong. I changed the parameters for the main pixel shader function under HLSL file with the same parameters found in this article.Thanks!
talk) 05:54, 20 September 2013 (EEST)(
Emiswelt - Lag/Flicker Issue [Solution]
The lag/flicker issue is caused by a SharpDX bug on some devices. (See: https://github.com/sharpdx/SharpDX/issues/160)
The solution is to set Game.IsFixedTimeStep to false.(To whom it may concern, the thread-unsafe operations also may lead to crashes on some devices. More on a thread safe approach can be found here: http://stackoverflow.com/questions/18740980/displaying-camera-preview-using-directx-texture2d-causes-oscillation-on-windows)
talk) 09:24, 20 September 2013 (EEST)(
Emiswelt - Emiswelt - Lag/Flicker IssueFYI: Solution to the Lag/Flicker issue is now also added to the above article itself.
talk) 09:35, 20 September 2013 (EEST)(
Woah, thank you Emiswelt! This article was made with one of the first SharpDX for Windows Phone versions available (I even had to submit some patches for bugs that I found while writing the article!) and the API has changed too much since I wrote the code; it's quite strange that these kind of bugs didn't appear sooner.It would be nice to update this article to SharpDX 2.5.0, but I don't have too much time right now and I think a lot of problems would arise due to API changes :(
talk) 15:38, 23 September 2013 (EEST)(
Emiswelt - Lag/Flicker Issue on Lumia 920
Another one: Calling GetPreviewBufferArgb from the Thread which rises the PreviewFrameAvailable event is not safe. This is apparently an issue in the Windows Phone API, and results in freezing/lag on the Lumia 920 and 925. Possible Workaround: Set a boolean to true if a new frame is available, then, check the boolean before draw and, if the boolean is set to true, update the texture (since the thread calling draw should be the same thread which calls initialize).@R2d2rigo, by the way, I think this example is great.
talk) 18:15, 26 September 2013 (EEST)(
Hamishwillee - Emiswelt - thanks!
Thanks very much for keeping this updated - much appreciated. Did you also update the zip file attached?
As an aside, your profile is pretty much empty - this is what other's see: https://developer.nokia.com/Profile/?u=emiswelt . If you have time it would be great if you could put some more information about yourself and make the profile public (there is a link to "security/ privacy" in the profile section)
talk) 03:20, 30 September 2013 (EEST)(
Hamishwillee - R2d2rigo - what version?
What version of SharpDX did you use? Can you add it to the "dependencies" field in the ArticleMetaData? Also a Template:Note about this in the "Adding SharpDX references" section would help users?
talk) 03:22, 30 September 2013 (EEST)(
Can Poyrazoğlu - Game.IsFixedTimeStep = false didn't solve the flickering issueSetting IsFixedTimeStep to false didn't change anything, but the stackoverflow link did it. Just lock on any object and put the getpreviewbufferargb and setdata<int> methods inside it. In stackoverflow, they told that the performance drops a lot with this solution, but I haven't seen any performance drop..
talk) 00:16, 6 October 2013 (EEST)(
Can Poyrazoğlu - How do we correct aspect ratio distortion of the viewfinder (drawing surface background grid)?My app is working fine but when I rotate my phone, drawing surface still tries to draw the same image into the same surface, which changes aspect ratio of the drawn image and distorts the image. What is the solution to that? How can we draw obeying the aspect ratio?
talk) 02:13, 6 October 2013 (EEST)(