Created
July 15, 2021 18:09
-
-
Save ThomasGorisse/2c7ce11f1bda18afe86820ed31eeca7f to your computer and use it in GitHub Desktop.
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
IndirectLight buildIndirectLight() { | |
Preconditions.checkNotNull(irradianceData, "\"irradianceData\" was null."); | |
Preconditions.checkState( | |
irradianceData.length >= FLOATS_PER_VECTOR, | |
"\"irradianceData\" does not have enough components to store a vector"); | |
if (reflectCubemap == null) { | |
throw new IllegalStateException("reflectCubemap is null."); | |
} | |
// Modulates ambient color with modulation factor. irradianceData must have at least one vector | |
// of three floats. | |
irradianceData[0] = ambientColor.r * colorCorrection.r; | |
irradianceData[1] = ambientColor.g * colorCorrection.g; | |
irradianceData[2] = ambientColor.b * colorCorrection.b; | |
IndirectLight indirectLight = | |
new IndirectLight.Builder() | |
.reflections(reflectCubemap) | |
.irradiance(SH_ORDER, irradianceData) | |
.intensity(intensity * lightEstimate) | |
.build(EngineInstance.getEngine().getFilamentEngine()); | |
// There is a bug in filament where setting the rotation doesn't work if it is done using | |
// the builder. It must be done on the actual indirect light object. | |
if (rotation != null) { | |
indirectLight.setRotation(quaternionToRotationMatrix(rotation)); | |
} | |
if (indirectLight == null) { | |
throw new IllegalStateException("Light Probe is invalid."); | |
} | |
return indirectLight; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment