-
-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PBR shader support Iridescence (#2425)
* feat(shader): pbr shader support Iridescence
- Loading branch information
Showing
4 changed files
with
158 additions
and
6 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
39 changes: 39 additions & 0 deletions
39
packages/loader/src/gltf/extensions/KHR_materials_iridescence.ts
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,39 @@ | ||
import { PBRMaterial, Texture2D } from "@galacean/engine-core"; | ||
import { GLTFMaterialParser } from "../parser/GLTFMaterialParser"; | ||
import { registerGLTFExtension } from "../parser/GLTFParser"; | ||
import { GLTFParserContext, GLTFParserType } from "../parser/GLTFParserContext"; | ||
import { GLTFExtensionMode, GLTFExtensionParser } from "./GLTFExtensionParser"; | ||
import { IKHRMaterialsIridescence } from "./GLTFExtensionSchema"; | ||
|
||
@registerGLTFExtension("KHR_materials_iridescence", GLTFExtensionMode.AdditiveParse) | ||
class KHR_materials_iridescence extends GLTFExtensionParser { | ||
override additiveParse(context: GLTFParserContext, material: PBRMaterial, schema: IKHRMaterialsIridescence): void { | ||
const { | ||
iridescenceFactor = 0, | ||
iridescenceTexture, | ||
iridescenceIor = 1.3, | ||
iridescenceThicknessMinimum = 100, | ||
iridescenceThicknessMaximum = 400, | ||
iridescenceThicknessTexture | ||
} = schema; | ||
|
||
material.iridescence = iridescenceFactor; | ||
material.iridescenceIOR = iridescenceIor; | ||
material.iridescenceThicknessRange.set(iridescenceThicknessMinimum, iridescenceThicknessMaximum); | ||
|
||
if (iridescenceTexture) { | ||
GLTFMaterialParser._checkOtherTextureTransform(iridescenceTexture, "Iridescence texture"); | ||
|
||
context.get<Texture2D>(GLTFParserType.Texture, iridescenceTexture.index).then((texture) => { | ||
material.iridescenceTexture = texture; | ||
}); | ||
} | ||
if (iridescenceThicknessTexture) { | ||
GLTFMaterialParser._checkOtherTextureTransform(iridescenceThicknessTexture, "IridescenceThickness texture"); | ||
|
||
context.get<Texture2D>(GLTFParserType.Texture, iridescenceThicknessTexture.index).then((texture) => { | ||
material.iridescenceThicknessTexture = texture; | ||
}); | ||
} | ||
} | ||
} |
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