Compare commits

...

1 Commits

Author SHA1 Message Date
Benjamin Doherty
b236bd4f50 Fix cancelled vertices on iOS OpenGL ES simulator 2022-11-15 20:24:21 -08:00
5 changed files with 27 additions and 7 deletions

View File

@@ -442,9 +442,15 @@ Program FMaterial::getProgramBuilderWithVariants(
}
}
int platformId = 0;
#if defined(IOS)
platformId = 1;
#endif
program.specializationConstants({
{ 0, (int)mEngine.getSupportedFeatureLevel() },
{ 1, (int)CONFIG_MAX_INSTANCES }
{ 1, (int)CONFIG_MAX_INSTANCES },
{ 2, platformId }
});
return program;

View File

@@ -123,6 +123,7 @@ utils::io::sstream& CodeGenerator::generateProlog(utils::io::sstream& out, Shade
out << '\n';
generateSpecificationConstant(out, "BACKEND_FEATURE_LEVEL", 0, 1);
generateSpecificationConstant(out, "CONFIG_MAX_INSTANCES", 1, (int)CONFIG_MAX_INSTANCES);
generateSpecificationConstant(out, "TARGET_PLATFORM", 2, 0);
out << '\n';
out << SHADERS_COMMON_DEFINES_GLSL_DATA;

View File

@@ -22,3 +22,11 @@
#define float3x3 mat3
#define float4x4 mat4
#define TARGET_PLATFORM_UNKNOWN 0
#define TARGET_PLATFORM_IOS 1
#if defined(TARGET_GLES_ENVIRONMENT)
const bool openGlesIos = TARGET_PLATFORM == TARGET_PLATFORM_IOS;
#else
const bool openGlesIos = false;
#endif

View File

@@ -128,7 +128,7 @@ highp vec4 getCascadeLightSpacePosition(uint cascade) {
// For the first cascade, return the interpolated light space position.
// This branch will be coherent (mostly) for neighboring fragments, and it's worth avoiding
// the matrix multiply inside computeLightSpacePosition.
if (cascade == 0u) {
if (cascade == 0u && !openGlesIos) {
// Note: this branch may cause issues with derivatives
return vertex_lightSpacePosition;
}

View File

@@ -141,11 +141,16 @@ void main() {
#endif
#if defined(VARIANT_HAS_SHADOWING) && defined(VARIANT_HAS_DIRECTIONAL_LIGHTING)
vertex_lightSpacePosition = computeLightSpacePosition(
vertex_worldPosition.xyz, vertex_worldNormal,
frameUniforms.lightDirection,
shadowUniforms.shadows[0].normalBias,
shadowUniforms.shadows[0].lightFromWorldMatrix);
if (openGlesIos) {
// Hack for OpenGL ES on iOS.
vertex_lightSpacePosition = vec4(1.0);
} else {
vertex_lightSpacePosition = computeLightSpacePosition(
vertex_worldPosition.xyz, vertex_worldNormal,
frameUniforms.lightDirection,
shadowUniforms.shadows[0].normalBias,
shadowUniforms.shadows[0].lightFromWorldMatrix);
}
#endif
#endif // !defined(USE_OPTIMIZED_DEPTH_VERTEX_SHADER)