xamarin / urho

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

Shadows not working on UrhoSharp, UrhoSharp.Reality ... or any D3D11 platform. #374

Open utekai opened 5 years ago

utekai commented 5 years ago

I suspect the shader but don't know the source of the problem well enough.

Have spent hours going through settings and such with no success.

If shadows do work, please show a single simple example with them working ... in a stereoapplication.

utekai commented 5 years ago

It's more than hololens. Shadows don't work on UWP.

It would appear the issue lies with the shader.

The winForms and WPF urhosharp samples, for instance Physics Stress Test, have the shadows.

The UWP samples don't. Also the hololens which also runs D3D11, doesn't have shadows.

There's more than just shadows not working, water, in the water feature sample paints black, and outline don't work either. Though in the basic techniques feature sample, water does seems to work fine and doesn't paint black.

The basic techniques sample using NoTextureMultiply also doesn't work, the multiply blend state always fails.

utekai commented 5 years ago

This points back to the Urho3D implementation of D3D11 support, rather than urhosharp specifically.

Opened a case on the urho3d discourse forum, and one of the resident experts states:

I’m unable to reproduce Your issuses on ‘normal’ (c++) version of the engine (running on dx11, win10), so I’ve downloaded urhosharp samples and I can see them when running on UWP, so the problem is on the urhosharp’s side.
utekai commented 5 years ago

Over at the urho3d board this bug was found regarding this issue. The initial commit found the bug, and rather than fixing it, they backed out the original commit. This is the original commit:

https://github.com/urho3d/Urho3D/commit/46793bbb7235568c11e73c596add6be315133df1

What I've found is this isn't the determining factor. It might be part of the issue, but in my testing with uwp and urhosharp, the multiSample showed it always remains at 1, never more.

utekai commented 5 years ago

The conversation around that commit, shown here, discussed a fix proposed by the original author of urho3d engine.

What I did was start exploring the files involved, View.cpp, Graphics.cpp, D3D11Graphics.cpp. Both in relation to shadows and water painting black.

It's important to keep this in mind. I'm a beginner with urho3d, an graphics and 3d in general, and what I do can't be trusted, or relied upon, even by me.

In View.cpp, I backed out those changes, and it had ZERO effect on what was happening with shadows or water. I've not tracked back to anything that exposes a problem with shadows. However, with water painting black, I got it to paint mostly clear, but had to turn off the reflection plane and clipping plane, and on the surface, a 2dtexture, instead of Diffuse, used Environment, and got the water to paint clear.

utekai commented 5 years ago

To highlight what is happening on D3D11 UWP platforms, modify the water feature sample thusly:

1.Change the waterMat as such waterMat.SetTexture(TextureUnit.Environment, renderTexture); and comment out the use of reflection and clipplane on the reflectionCamera. Then run the sample

Here the water is clear on UWP with buffers/textures oriented differently.

If you leave in the changes and run WPF or winForms samples, which work correctly without any changes, you'll note the environment texture change causes the water material to act like a mirror. BUT NOT ON UWP, where these changes cause the water to be clear. There is also noticed a mismatch in what appears to be the backBuffer.

This test is done using the urhosharp from nuget.

When urhosharp nuget is removed, and the underlying urho3d modified to handle bug #2232 over at the urho3d github, there is no change for UWP.

utekai commented 5 years ago

So I'm not sure how to fix this or troubleshoot further. Leaving it unless someone offers how to troubleshoot this more ... just pointing out how broken it is for UWP and SharpReality.

  1. No shadows
  2. Improper clipplane, reflection plane and surface texture rendering.
MustacheEmperor commented 5 years ago

Utekai, I'm sorry I didn't see this issue earlier to tell you my own experience and save you the trouble. I also encountered this several months ago in a very similar context, asked the same question on the Urho3D board, and didn't even make it as far as you have. As it is, I can verify that this issue is trivial to reproduce on UWP and no combination of shadow map settings etc alter the result.

VGFP commented 5 years ago

I have the same issue with UWP and can not find the workaround. From what I know UWP supports only DirectX so the solution may be using the ANGLE Project to translate openGL to DirectX or similar method (openGL is used in UrhoSharp.iOS and Android and these projects don't have problem with shadows).

utekai commented 4 years ago

I don't think there is a workaround for shadows, I think it's a broken feature or unimplemented feature from the original implementation of UWP platform in urhosharp. ANGLE implementation seems like a bigger project than an original implementation of shadow maps for UWP.