xamarin / urho

Code to integrate with the Urho3D engine
Other
462 stars 122 forks source link

RenderPath post-processors not working on UWP (Viewport turns black) #239

Open fozzzgate opened 7 years ago

fozzzgate commented 7 years ago

Adding any post processor to the RenderPath in a UWP application causes the whole viewport to go black.

Steps to reproduce:

1) Download, compile, and run the UrhoSharp "FeatureSamples" project 2) Choose sample 9 (MultipleViewports) 3) Press the FXAA or Bloom buttons 4) On Android or WinForms or WPF, the effect is enabled, on UWP, the whole viewport turns black

This is also why sample 42 (PBRMaterials) fails and presumably why it is commented out in the UWP MainPage constructor and thus inaccessible in the UWP project.

However, post processors do work for the SamplyGame Windows Desktop project, so there is something different between the two projects.

fozzzgate commented 7 years ago

I created an UrhoSharp.Forms port of SamplyGame and it also has a completely black screen when a post processor is activated (everything is fine without a post processor activated). So something in Xamarin.Forms or UrhoSharp.Forms initialization seems to cause the problem.

On the other hand, FeatureSamples.UWP doesn't use Xamarin.Forms or UrhoSharp.Forms, and also has the problem, so it appears the problem can be triggered even on a regular UrhoSharp application (non-Xamarin.Forms / UrhoSharp.Forms).

SamplyGame has a Windows.Console application launcher, so something about that configuration avoids the problem. Also, the Windows.Console version of FeatureSamples works with post processors.

fozzzgate commented 7 years ago

The most similar projects with opposite outcomes are FeatureSamples.UWP (fails) and FeatureSamples.WPF (success). There is something different between:

var app = UrhoSurfaceCtrl.Run(value.Type, new ApplicationOptions("Data") {} ); [UWP - Fails]

and

var app = await UrhoSurfaceCtrl.Show(value.Type, new ApplicationOptions(assetsFolder: "Data")); [WPF - Success]

that appears to be causing the problems with post processors

utekai commented 5 years ago

When I change the renderpath and use FXAA2/3 on a UWP SharpReality platform, the screen goes black UNLESS I include a setting for HDR to true, then it seems to work.

I can get 'multiple viewports', 'basic rendering techniques' and 'pbr materials' to run on UWP and SharpReality platforms.

This setting is a required workaround, else the screen will go black as described.

((StereoApplication)Application).Renderer.HDRRendering = true;

If this is not set true, then the screen will be blank/black.

Here's an example which works:

((StereoApplication)Application).Renderer.HDRRendering = true;
var rp = ((StereoApplication)Application).Renderer.DefaultRenderPath.Clone();
rp.Append(Application.ResourceCache.GetXmlFile("PostProcess/FXAA2.xml"));
((StereoApplication)Application).Renderer.GetViewport(0).RenderPath = rp;
((StereoApplication)Application).Renderer.GetViewport(1).RenderPath = rp;