Skip to content

Commit

Permalink
Merge pull request #457 from KhronosGroup/KHR_materials_anisotropy
Browse files Browse the repository at this point in the history
KHR_materials_anisotropy
  • Loading branch information
UX3D-kanzler authored May 30, 2023
2 parents 3a69482 + 0c7e9ca commit 47a1919
Show file tree
Hide file tree
Showing 14 changed files with 353 additions and 80 deletions.
188 changes: 117 additions & 71 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,77 +100,106 @@ GltfState containing a state for visualization in GltfView

**Kind**: global class

* [GltfState](#GltfState)
* [new GltfState(view)](#new_GltfState_new)
* _instance_
* [.gltf](#GltfState+gltf)
* [.environment](#GltfState+environment)
* [.userCamera](#GltfState+userCamera)
* [.sceneIndex](#GltfState+sceneIndex)
* [.cameraIndex](#GltfState+cameraIndex)
* [.animationIndices](#GltfState+animationIndices)
* [.animationTimer](#GltfState+animationTimer)
* [.variant](#GltfState+variant)
* [.renderingParameters](#GltfState+renderingParameters)
* [.morphing](#GltfState+renderingParameters.morphing)
* [.skinning](#GltfState+renderingParameters.skinning)
* [.clearColor](#GltfState+renderingParameters.clearColor)
* [.exposure](#GltfState+renderingParameters.exposure)
* [.usePunctual](#GltfState+renderingParameters.usePunctual)
* [.useIBL](#GltfState+renderingParameters.useIBL)
* [.iblIntensity](#GltfState+renderingParameters.iblIntensity)
* [.renderEnvironmentMap](#GltfState+renderingParameters.renderEnvironmentMap)
* [.blurEnvironmentMap](#GltfState+renderingParameters.blurEnvironmentMap)
* [.toneMap](#GltfState+renderingParameters.toneMap)
* [.debugOutput](#GltfState+renderingParameters.debugOutput)
* [.environmentRotation](#GltfState+renderingParameters.environmentRotation)
* [.useDirectionalLightsWithDisabledIBL](#GltfState+renderingParameters.useDirectionalLightsWithDisabledIBL)
* [.internalMSAA](#GltfState+renderingParameters.internalMSAA)
* _static_
* [.ToneMaps](#GltfState.ToneMaps)
* [.NONE](#GltfState.ToneMaps.NONE)
* [.ACES_HILL_EXPOSURE_BOOST](#GltfState.ToneMaps.ACES_HILL_EXPOSURE_BOOST)
* [.ACES_NARKOWICZ](#GltfState.ToneMaps.ACES_NARKOWICZ)
* [.ACES_HILL](#GltfState.ToneMaps.ACES_HILL)
* [.DebugOutput](#GltfState.DebugOutput)
* [.NONE](#GltfState.DebugOutput.NONE)
* [.generic](#GltfState.DebugOutput.generic)
* [.UV_COORDS_0](#GltfState.DebugOutput.generic.UV_COORDS_0)
* [.UV_COORDS_1](#GltfState.DebugOutput.generic.UV_COORDS_1)
* [.NORMAL](#GltfState.DebugOutput.generic.NORMAL)
* [.GEOMETRYNORMAL](#GltfState.DebugOutput.generic.GEOMETRYNORMAL)
* [.TANGENT](#GltfState.DebugOutput.generic.TANGENT)
* [.BITANGENT](#GltfState.DebugOutput.generic.BITANGENT)
* [.WORLDSPACENORMAL](#GltfState.DebugOutput.generic.WORLDSPACENORMAL)
* [.ALPHA](#GltfState.DebugOutput.generic.ALPHA)
* [.OCCLUSION](#GltfState.DebugOutput.generic.OCCLUSION)
* [.EMISSIVE](#GltfState.DebugOutput.generic.EMISSIVE)
* [.mr](#GltfState.DebugOutput.mr)
* [.METALLIC_ROUGHNESS](#GltfState.DebugOutput.mr.METALLIC_ROUGHNESS)
* [.BASECOLOR](#GltfState.DebugOutput.mr.BASECOLOR)
* [.METALLIC](#GltfState.DebugOutput.mr.METALLIC)
* [.ROUGHNESS](#GltfState.DebugOutput.mr.ROUGHNESS)
* [.clearcoat](#GltfState.DebugOutput.clearcoat)
* [.CLEARCOAT](#GltfState.DebugOutput.clearcoat.CLEARCOAT)
* [.CLEARCOAT_FACTOR](#GltfState.DebugOutput.clearcoat.CLEARCOAT_FACTOR)
* [.CLEARCOAT_ROUGHNESS](#GltfState.DebugOutput.clearcoat.CLEARCOAT_ROUGHNESS)
* [.CLEARCOAT_NORMAL](#GltfState.DebugOutput.clearcoat.CLEARCOAT_NORMAL)
* [.sheen](#GltfState.DebugOutput.sheen)
* [.SHEEN](#GltfState.DebugOutput.sheen.SHEEN)
* [.SHEEN_COLOR](#GltfState.DebugOutput.sheen.SHEEN_COLOR)
* [.SHEEN_ROUGHNESS](#GltfState.DebugOutput.sheen.SHEEN_ROUGHNESS)
* [.specular](#GltfState.DebugOutput.specular)
* [.SPECULAR](#GltfState.DebugOutput.specular.SPECULAR)
* [.SPECULAR_FACTOR](#GltfState.DebugOutput.specular.SPECULAR_FACTOR)
* [.SPECULAR_COLOR](#GltfState.DebugOutput.specular.SPECULAR_COLOR)
* [.transmission](#GltfState.DebugOutput.transmission)
* [.TRANSMISSION_VOLUME](#GltfState.DebugOutput.transmission.TRANSMISSION_VOLUME)
* [.TRANSMISSION_FACTOR](#GltfState.DebugOutput.transmission.TRANSMISSION_FACTOR)
* [.VOLUME_THICKNESS](#GltfState.DebugOutput.transmission.VOLUME_THICKNESS)
* [.iridescence](#GltfState.DebugOutput.iridescence)
* [.IRIDESCENCE](#GltfState.DebugOutput.iridescence.IRIDESCENCE)
* [.IRIDESCENCE_FACTOR](#GltfState.DebugOutput.iridescence.IRIDESCENCE_FACTOR)
* [.IRIDESCENCE_THICKNESS](#GltfState.DebugOutput.iridescence.IRIDESCENCE_THICKNESS)
- [Classes](#classes)
- [GltfView](#gltfview)
- [new GltfView(context)](#new-gltfviewcontext)
- [gltfView.createState() ⇒ GltfState](#gltfviewcreatestate--gltfstate)
- [gltfView.createResourceLoader(\[externalDracoLib\], \[externalKtxLib\]) ⇒ ResourceLoader](#gltfviewcreateresourceloaderexternaldracolib-externalktxlib--resourceloader)
- [gltfView.renderFrame(state, width, height)](#gltfviewrenderframestate-width-height)
- [gltfView.gatherStatistics(state) ⇒ Object](#gltfviewgatherstatisticsstate--object)
- [GltfState](#gltfstate)
- [new GltfState(view)](#new-gltfstateview)
- [gltfState.gltf](#gltfstategltf)
- [gltfState.environment](#gltfstateenvironment)
- [gltfState.userCamera](#gltfstateusercamera)
- [gltfState.sceneIndex](#gltfstatesceneindex)
- [gltfState.cameraIndex](#gltfstatecameraindex)
- [gltfState.animationIndices](#gltfstateanimationindices)
- [gltfState.animationTimer](#gltfstateanimationtimer)
- [gltfState.variant](#gltfstatevariant)
- [gltfState.renderingParameters](#gltfstaterenderingparameters)
- [renderingParameters.morphing](#renderingparametersmorphing)
- [renderingParameters.skinning](#renderingparametersskinning)
- [renderingParameters.clearColor](#renderingparametersclearcolor)
- [renderingParameters.exposure](#renderingparametersexposure)
- [renderingParameters.usePunctual](#renderingparametersusepunctual)
- [renderingParameters.useIBL](#renderingparametersuseibl)
- [renderingParameters.iblIntensity](#renderingparametersiblintensity)
- [renderingParameters.renderEnvironmentMap](#renderingparametersrenderenvironmentmap)
- [renderingParameters.blurEnvironmentMap](#renderingparametersblurenvironmentmap)
- [renderingParameters.toneMap](#renderingparameterstonemap)
- [renderingParameters.debugOutput](#renderingparametersdebugoutput)
- [renderingParameters.environmentRotation](#renderingparametersenvironmentrotation)
- [renderingParameters.useDirectionalLightsWithDisabledIBL](#renderingparametersusedirectionallightswithdisabledibl)
- [renderingParameters.internalMSAA](#renderingparametersinternalmsaa)
- [GltfState.ToneMaps](#gltfstatetonemaps)
- [ToneMaps.NONE](#tonemapsnone)
- [ToneMaps.ACES\_HILL\_EXPOSURE\_BOOST](#tonemapsaces_hill_exposure_boost)
- [ToneMaps.ACES\_NARKOWICZ](#tonemapsaces_narkowicz)
- [ToneMaps.ACES\_HILL](#tonemapsaces_hill)
- [GltfState.DebugOutput](#gltfstatedebugoutput)
- [DebugOutput.NONE](#debugoutputnone)
- [DebugOutput.generic](#debugoutputgeneric)
- [generic.UV\_COORDS\_0](#genericuv_coords_0)
- [generic.UV\_COORDS\_1](#genericuv_coords_1)
- [generic.NORMAL](#genericnormal)
- [generic.GEOMETRYNORMAL](#genericgeometrynormal)
- [generic.TANGENT](#generictangent)
- [generic.BITANGENT](#genericbitangent)
- [generic.WORLDSPACENORMAL](#genericworldspacenormal)
- [generic.ALPHA](#genericalpha)
- [generic.OCCLUSION](#genericocclusion)
- [generic.EMISSIVE](#genericemissive)
- [DebugOutput.mr](#debugoutputmr)
- [mr.METALLIC\_ROUGHNESS](#mrmetallic_roughness)
- [mr.BASECOLOR](#mrbasecolor)
- [mr.METALLIC](#mrmetallic)
- [mr.ROUGHNESS](#mrroughness)
- [DebugOutput.clearcoat](#debugoutputclearcoat)
- [clearcoat.CLEARCOAT](#clearcoatclearcoat)
- [clearcoat.CLEARCOAT\_FACTOR](#clearcoatclearcoat_factor)
- [clearcoat.CLEARCOAT\_ROUGHNESS](#clearcoatclearcoat_roughness)
- [clearcoat.CLEARCOAT\_NORMAL](#clearcoatclearcoat_normal)
- [DebugOutput.sheen](#debugoutputsheen)
- [sheen.SHEEN](#sheensheen)
- [sheen.SHEEN\_COLOR](#sheensheen_color)
- [sheen.SHEEN\_ROUGHNESS](#sheensheen_roughness)
- [DebugOutput.specular](#debugoutputspecular)
- [specular.SPECULAR](#specularspecular)
- [specular.SPECULAR\_FACTOR](#specularspecular_factor)
- [specular.SPECULAR\_COLOR](#specularspecular_color)
- [DebugOutput.transmission](#debugoutputtransmission)
- [transmission.TRANSMISSION\_VOLUME](#transmissiontransmission_volume)
- [transmission.TRANSMISSION\_FACTOR](#transmissiontransmission_factor)
- [transmission.VOLUME\_THICKNESS](#transmissionvolume_thickness)
- [DebugOutput.iridescence](#debugoutputiridescence)
- [iridescence.IRIDESCENCE](#iridescenceiridescence)
- [iridescence.IRIDESCENCE\_FACTOR](#iridescenceiridescence_factor)
- [iridescence.IRIDESCENCE\_THICKNESS](#iridescenceiridescence_thickness)
- [anisotropy.ANISOTROPIC\_STRENGTH](#anisotropyanisotropic_strength)
- [anisotropy.ANISOTROPIC\_DIRECTION](#anisotropyanisotropic_direction)
- [ResourceLoader](#resourceloader)
- [new ResourceLoader(view)](#new-resourceloaderview)
- [resourceLoader.loadGltf(gltfFile, \[externalFiles\]) ⇒ Promise](#resourceloaderloadgltfgltffile-externalfiles--promise)
- [resourceLoader.loadEnvironment(environmentFile, \[lutFiles\]) ⇒ Promise](#resourceloaderloadenvironmentenvironmentfile-lutfiles--promise)
- [resourceLoader.initKtxLib(\[externalKtxLib\])](#resourceloaderinitktxlibexternalktxlib)
- [resourceLoader.initDracoLib(\[externalDracoLib\])](#resourceloaderinitdracolibexternaldracolib)
- [UserCamera](#usercamera)
- [new UserCamera()](#new-usercamera)
- [userCamera.setVerticalFoV(yfov)](#usercamerasetverticalfovyfov)
- [userCamera.getPosition()](#usercameragetposition)
- [userCamera.getRotation()](#usercameragetrotation)
- [userCamera.getLookDirection()](#usercameragetlookdirection)
- [userCamera.getTarget()](#usercameragettarget)
- [userCamera.lookAt(from, to)](#usercameralookatfrom-to)
- [userCamera.setPosition(position)](#usercamerasetpositionposition)
- [userCamera.setTarget(target)](#usercamerasettargettarget)
- [userCamera.setRotation(yaw, pitch)](#usercamerasetrotationyaw-pitch)
- [userCamera.setDistanceFromTarget(distance, target)](#usercamerasetdistancefromtargetdistance-target)
- [userCamera.zoomBy(value)](#usercamerazoombyvalue)
- [userCamera.orbit(x, y)](#usercameraorbitx-y)
- [userCamera.pan(x, y)](#usercamerapanx-y)
- [userCamera.fitViewToScene(gltf, sceneIndex)](#usercamerafitviewtoscenegltf-sceneindex)

<a name="new_GltfState_new"></a>

Expand Down Expand Up @@ -429,6 +458,9 @@ such as "NORMAL"
* [.IRIDESCENCE](#GltfState.DebugOutput.iridescence.IRIDESCENCE)
* [.IRIDESCENCE_FACTOR](#GltfState.DebugOutput.iridescence.IRIDESCENCE_FACTOR)
* [.IRIDESCENCE_THICKNESS](#GltfState.DebugOutput.iridescence.IRIDESCENCE_THICKNESS)
* [.anisotropy](#GltfState.DebugOutput.anisotropy)
* [.ANISOTROPIC_STRENGTH](#GltfState.DebugOutput.anisotropy.ANISOTROPIC_STRENGTH)
* [.ANISOTROPIC_DIRECTION](#GltfState.DebugOutput.anisotropy.ANISOTROPIC_DIRECTION)

<a name="GltfState.DebugOutput.NONE"></a>

Expand Down Expand Up @@ -711,6 +743,20 @@ output the iridescence thickness
**Kind**: static property of [<code>iridescence</code>](#GltfState.DebugOutput.iridescence)
<a name="ResourceLoader"></a>

<a name="GltfState.DebugOutput.anisotropy.IRIDESCENCE"></a>

##### anisotropy.ANISOTROPIC\_STRENGTH
output the anisotropy strength

**Kind**: static property of [<code>anisotropy</code>](#GltfState.DebugOutput.anisotropy)
<a name="GltfState.DebugOutput.anisotropy.ANISOTROPIC_STRENGTH"></a>

##### anisotropy.ANISOTROPIC\_DIRECTION
output the final anisotropic direction as defined by the anisotropicTexture and anisotropic rotation

**Kind**: static property of [<code>anisotropy</code>](#GltfState.DebugOutput.anisotropy)
<a name="ResourceLoader"></a>

## ResourceLoader
ResourceLoader can be used to load resources for the GltfState
that are then used to display the loaded data with GltfView
Expand Down
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ This is the official [Khronos glTF 2.0](https://www.khronos.org/gltf/) Sample Vi
Table of Contents
-----------------

- [Version](#version)
- [Credits](#credits)
- [Features](#features)
- [Setup](#setup)
- [API](#api)
- [Web App](#web-app)
- [Physically-Based Materials in glTF 2.0](#physically-based-materials-in-gltf-20)
- [Khronos glTF 2.0 Sample Viewer](#khronos-gltf-20-sample-viewer)
- [Table of Contents](#table-of-contents)
- [Version](#version)
- [Credits](#credits)
- [Features](#features)
- [Setup](#setup)
- [API](#api)
- [GltfView](#gltfview)
- [GltfState](#gltfstate)
- [ResourceLoader](#resourceloader)
- [Web App](#web-app)
- [Render Fidelity Tools](#render-fidelity-tools)
- [Physically-Based Materials in glTF 2.0](#physically-based-materials-in-gltf-20)

Version
-------
Expand Down Expand Up @@ -46,6 +52,7 @@ Features
- [x] [KHR_materials_variants](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_variants)
- [x] [KHR_materials_volume](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_volume)
- [x] [KHR_materials_iridescence](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_iridescence)
- [x] [KHR_materials_anisotropy](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_anisotropy)
- [x] [KHR_mesh_quantization](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_mesh_quantization)
- [x] [KHR_texture_basisu](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_basisu)
- [x] [KHR_texture_transform](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_transform)
Expand Down
1 change: 1 addition & 0 deletions app_web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ <h2 class="title is-spaced">Advanced Controls</h2>
<b-switch class="smallerLabel" v-model="specularEnabled">KHR_materials_specular</b-switch>
<b-switch class="smallerLabel" v-model="emissiveStrengthEnabled">KHR_materials_emissive_strength</b-switch>
<b-switch class="smallerLabel" v-model="iridescenceEnabled">KHR_materials_iridescence</b-switch>
<b-switch class="smallerLabel" v-model="anisotropyEnabled">KHR_materials_anisotropy</b-switch>
</b-field>
<b-field label="Statistics" class="subtitle">
<json-to-ui-template v-bind:data="statistics" v-bind:isinner="false">
Expand Down
2 changes: 2 additions & 0 deletions app_web/src/logic/uimodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ class UIModel
map( ({ newValue, oldValue }) => newValue));
this.iridescenceEnabled = app.$watchAsObservable('iridescenceEnabled').pipe(
map( ({ newValue, oldValue }) => newValue));
this.anisotropyEnabled = app.$watchAsObservable('anisotropyEnabled').pipe(
map( ({ newValue, oldValue }) => newValue));
this.specularEnabled = app.$watchAsObservable('specularEnabled').pipe(
map( ({ newValue, oldValue }) => newValue));
this.emissiveStrengthEnabled = app.$watchAsObservable('emissiveStrengthEnabled').pipe(
Expand Down
4 changes: 4 additions & 0 deletions app_web/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ async function main()
uiModel.iridescenceEnabled.subscribe( iridescenceEnabled => {
state.renderingParameters.enabledExtensions.KHR_materials_iridescence = iridescenceEnabled;
});
uiModel.anisotropyEnabled.subscribe( anisotropyEnabled => {
state.renderingParameters.enabledExtensions.KHR_materials_anisotropy = anisotropyEnabled;
});
uiModel.specularEnabled.subscribe( specularEnabled => {
state.renderingParameters.enabledExtensions.KHR_materials_specular = specularEnabled;
});
Expand All @@ -228,6 +231,7 @@ async function main()
listenForRedraw(uiModel.iorEnabled);
listenForRedraw(uiModel.specularEnabled);
listenForRedraw(uiModel.iridescenceEnabled);
listenForRedraw(uiModel.anisotropyEnabled);
listenForRedraw(uiModel.emissiveStrengthEnabled);

uiModel.iblEnabled.subscribe( iblEnabled => {
Expand Down
1 change: 1 addition & 0 deletions app_web/src/ui/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const app = new Vue({
volumeEnabled: true,
iorEnabled: true,
iridescenceEnabled: true,
anisotropyEnabled: true,
specularEnabled: true,
emissiveStrengthEnabled: true,

Expand Down
12 changes: 11 additions & 1 deletion source/GltfState/gltf_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class GltfState
KHR_materials_specular: true,
/** KHR_materials_iridescence adds a thin-film iridescence effect */
KHR_materials_iridescence: true,
/** KHR_materials_anisotropy defines microfacet grooves in the surface, stretching the specular reflection on the surface */
KHR_materials_anisotropy: true,
KHR_materials_emissive_strength: true,
},
/** clear color expressed as list of ints in the range [0, 255] */
Expand Down Expand Up @@ -196,7 +198,7 @@ GltfState.DebugOutput = {
VOLUME_THICKNESS: "Volume Thickness",
},

/** output tranmission lighting */
/** output iridescence */
iridescence: {
/** output the combined iridescence */
IRIDESCENCE: "Iridescence",
Expand All @@ -205,6 +207,14 @@ GltfState.DebugOutput = {
/** output the iridescence thickness*/
IRIDESCENCE_THICKNESS: "Iridescence Thickness",
},

/** output anisotropy */
anisotropy: {
/** output the anisotropic strength*/
ANISOTROPIC_STRENGTH: "Anisotropic Strength",
/** output final direction as defined by the anisotropyTexture and rotation*/
ANISOTROPIC_DIRECTION: "Anisotropic Direction",
},
};

export { GltfState };
3 changes: 3 additions & 0 deletions source/Renderer/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,9 @@ class gltfRenderer
{debugOutput: GltfState.DebugOutput.iridescence.IRIDESCENCE, shaderDefine: "DEBUG_IRIDESCENCE"},
{debugOutput: GltfState.DebugOutput.iridescence.IRIDESCENCE_FACTOR, shaderDefine: "DEBUG_IRIDESCENCE_FACTOR"},
{debugOutput: GltfState.DebugOutput.iridescence.IRIDESCENCE_THICKNESS, shaderDefine: "DEBUG_IRIDESCENCE_THICKNESS"},

{debugOutput: GltfState.DebugOutput.anisotropy.ANISOTROPIC_STRENGTH, shaderDefine: "DEBUG_ANISOTROPIC_STRENGTH"},
{debugOutput: GltfState.DebugOutput.anisotropy.ANISOTROPIC_DIRECTION, shaderDefine: "DEBUG_ANISOTROPIC_DIRECTION"},
];

let mappingCount = 0;
Expand Down
Loading

0 comments on commit 47a1919

Please sign in to comment.