Browse Source

Shadow support on Emscripten. For now same capability as on mobiles; no cascaded shadow map.

Lasse Öörni 10 years ago
parent
commit
84b5a2de5f

+ 2 - 3
Source/Urho3D/Graphics/GraphicsDefs.h

@@ -30,9 +30,8 @@ namespace Urho3D
 
 class Vector3;
 
-/// Graphics capability support level. Emscripten also uses OpenGL ES but will have higher capability than actual mobiles,
-/// so it is not included
-#if defined(ANDROID) || defined(IOS) || defined(RPI)
+/// Graphics capability support level. WebGL will at least for now also behave similarly as mobiles
+#if defined(ANDROID) || defined(IOS) || defined(RPI) || defined(EMSCRIPTEN)
 #define MOBILE_GRAPHICS
 #else
 #define DESKTOP_GRAPHICS

+ 1 - 1
Source/Urho3D/Graphics/Light.h

@@ -44,7 +44,7 @@ enum LightType
 static const float SHADOW_MIN_QUANTIZE = 0.1f;
 static const float SHADOW_MIN_VIEW = 1.0f;
 static const int MAX_LIGHT_SPLITS = 6;
-#if !defined(ANDROID) && !defined(IOS) && !defined(RPI)
+#ifdef DESKTOP_GRAPHICS
 static const int MAX_CASCADE_SPLITS = 4;
 #else
 static const int MAX_CASCADE_SPLITS = 1;

+ 8 - 0
Source/Urho3D/Graphics/OpenGL/OGLGraphics.cpp

@@ -2695,7 +2695,11 @@ void Graphics::CheckFeatureSupport(String& extensions)
         glesDepthStencilFormat = GL_DEPTH_COMPONENT24_OES;
     if (CheckExtension(extensions, "GL_OES_packed_depth_stencil"))
         glesDepthStencilFormat = GL_DEPTH24_STENCIL8_OES;
+    #ifdef EMSCRIPTEN
+    if (!CheckExtension(extensions, "WEBGL_depth_texture"))
+    #else
     if (!CheckExtension(extensions, "GL_OES_depth_texture"))
+    #endif
     {
         shadowMapFormat_ = 0;
         hiresShadowMapFormat_ = 0;
@@ -2710,6 +2714,10 @@ void Graphics::CheckFeatureSupport(String& extensions)
         #endif
         shadowMapFormat_ = GL_DEPTH_COMPONENT;
         hiresShadowMapFormat_ = 0;
+        // WebGL shadow map rendering seems to be extremely slow without an attached dummy color texture
+        #ifdef EMSCRIPTEN
+        dummyColorFormat_ = GetRGBAFormat();
+        #endif
     }
     #endif
 }