-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Remove now-redundant feature level 0 materials"
This reverts most of commit 9a6b8bf. The hello triangle sample remains unreverted. The original commit inadvertently broke screen space reflections, and perhaps other features when the default material was used. The source of the issue is that MaterialBuilder.cpp (correctly) filters out variants that aren't supported in feature level 0 materials, including screen space reflections. Unfortunately, while the "feature level 0 compatibility" feature itself was intended to make creating duplicate materials like this redundant in client code, unfortunately, it seems the best solution for resolving this issue is to simply keep these redundant materials in the core. To elaborate: clients should expect that feature level 0 materials that they create work on /all/ feature levels /exactly/ or /close to exactly/ identically. This includes restricting more advanced features that theoretically could be available on a higher feature level, like SSR. It's already true that if a user would like to optionally opt-in to a more advanced material which takes advantage of more advanced features, they would have to maintain two separate versions of that material: one for feature level 3 and one for feature level 1. It should be no different in this case. However, the materials built into the engine core are an exception to this expectation. Given that feature level 0 was tacked on after the fact with fewer features, there must /by necessity/ have been a new material introduced for both the default material and the default skybox specifically for feature level 0 with fewer features than extant client apps expected to be included by default. I imagine if filament were to be rebuilt from the ground up, this exception wouldn't exist. However, the end result is this somewhat messy redundancy.
- Loading branch information
1 parent
21ea99a
commit 976f304
Showing
7 changed files
with
116 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
material { | ||
name : "Filament Default Material", | ||
shadingModel : unlit, | ||
featureLevel: 0 | ||
} | ||
|
||
fragment { | ||
void material(inout MaterialInputs material) { | ||
prepareMaterial(material); | ||
material.baseColor.rgb = vec3(0.8); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
material { | ||
name : Skybox, | ||
parameters : [ | ||
{ | ||
type : int, | ||
name : showSun | ||
}, | ||
{ | ||
type : int, | ||
name : constantColor | ||
}, | ||
{ | ||
type : samplerCubemap, | ||
name : skybox | ||
}, | ||
{ | ||
type : float4, | ||
name : color | ||
} | ||
], | ||
variables : [ | ||
eyeDirection | ||
], | ||
vertexDomain : device, | ||
depthWrite : false, | ||
shadingModel : unlit, | ||
variantFilter : [ skinning, shadowReceiver, vsm ], | ||
culling: none, | ||
featureLevel: 0 | ||
} | ||
|
||
fragment { | ||
void material(inout MaterialInputs material) { | ||
prepareMaterial(material); | ||
vec4 sky; | ||
if (materialParams.constantColor != 0) { | ||
sky = materialParams.color; | ||
} else { | ||
sky = vec4(textureCube(materialParams_skybox, variable_eyeDirection.xyz).rgb, 1.0); | ||
sky.rgb *= frameUniforms.iblLuminance; | ||
} | ||
if (materialParams.showSun != 0 && frameUniforms.sun.w >= 0.0) { | ||
vec3 direction = normalize(variable_eyeDirection.xyz); | ||
// Assume the sun is a sphere | ||
vec3 sun = frameUniforms.lightColorIntensity.rgb * | ||
(frameUniforms.lightColorIntensity.a * (4.0 * PI)); | ||
float cosAngle = dot(direction, frameUniforms.lightDirection); | ||
float x = (cosAngle - frameUniforms.sun.x) * frameUniforms.sun.z; | ||
float gradient = pow(1.0 - saturate(x), frameUniforms.sun.w); | ||
sky.rgb = sky.rgb + gradient * sun; | ||
} | ||
material.baseColor = sky; | ||
} | ||
} | ||
|
||
vertex { | ||
void materialVertex(inout MaterialVertexInputs material) { | ||
material.eyeDirection.xyz = material.worldPosition.xyz; | ||
} | ||
} |