Skip to content

Commit 85c08a5

Browse files
authored
Merge pull request #392 from KhronosGroup/feature/emissiveStrength
Feature/emissive strength
2 parents 315d20e + 9ddf17a commit 85c08a5

File tree

11 files changed

+42
-10
lines changed

11 files changed

+42
-10
lines changed

app_web/index.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,9 @@ <h2 class="title is-spaced">Advanced Controls</h2>
386386
v-bind:disabled="transmissionEnabled === false ? true : false"
387387
v-model="volumeEnabled">KHR_materials_volume</b-switch>
388388
<b-switch class="smallerLabel" v-model="iorEnabled">KHR_materials_ior</b-switch>
389-
<b-switch class="smallerLabel" v-model="specularEnabled">KHR_materials_specular
390-
</b-switch>
391-
<b-switch class="smallerLabel" v-model="iridescenceEnabled">
392-
KHR_materials_iridescence</b-switch>
389+
<b-switch class="smallerLabel" v-model="specularEnabled">KHR_materials_specular</b-switch>
390+
<b-switch class="smallerLabel" v-model="emissiveStrengthEnabled">KHR_materials_emissive_strength</b-switch>
391+
<b-switch class="smallerLabel" v-model="iridescenceEnabled">KHR_materials_iridescence</b-switch>
393392
</b-field>
394393
<b-field label="Statistics" class="subtitle">
395394
<json-to-ui-template v-bind:data="statistics" v-bind:isinner="false">
@@ -406,4 +405,4 @@ <h2 class="title is-spaced">Advanced Controls</h2>
406405

407406
<script src="GltfSVApp.umd.js"></script>
408407

409-
</html>
408+
</html>

app_web/src/logic/uimodel.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ class UIModel
9797
map( ({ newValue, oldValue }) => newValue));
9898
this.specularEnabled = app.$watchAsObservable('specularEnabled').pipe(
9999
map( ({ newValue, oldValue }) => newValue));
100+
this.emissiveStrengthEnabled = app.$watchAsObservable('emissiveStrengthEnabled').pipe(
101+
map( ({ newValue, oldValue }) => newValue));
100102
this.iblEnabled = app.iblChanged$.pipe(pluck("event", "msg"));
101103
this.punctualLightsEnabled = app.punctualLightsChanged$.pipe(pluck("event", "msg"));
102104
this.renderEnvEnabled = app.$watchAsObservable('renderEnv').pipe(

app_web/src/main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,17 @@ async function main()
218218
uiModel.specularEnabled.subscribe( specularEnabled => {
219219
state.renderingParameters.enabledExtensions.KHR_materials_specular = specularEnabled;
220220
});
221+
uiModel.emissiveStrengthEnabled.subscribe( enabled => {
222+
state.renderingParameters.enabledExtensions.KHR_materials_emissive_strength = enabled;
223+
});
221224
listenForRedraw(uiModel.clearcoatEnabled);
222225
listenForRedraw(uiModel.sheenEnabled);
223226
listenForRedraw(uiModel.transmissionEnabled);
224227
listenForRedraw(uiModel.volumeEnabled);
225228
listenForRedraw(uiModel.iorEnabled);
226229
listenForRedraw(uiModel.specularEnabled);
227230
listenForRedraw(uiModel.iridescenceEnabled);
231+
listenForRedraw(uiModel.emissiveStrengthEnabled);
228232

229233
uiModel.iblEnabled.subscribe( iblEnabled => {
230234
state.renderingParameters.useIBL = iblEnabled;

app_web/src/ui/ui.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ const app = new Vue({
9393
iorEnabled: true,
9494
iridescenceEnabled: true,
9595
specularEnabled: true,
96+
emissiveStrengthEnabled: true,
9697

9798
activeTab: 0,
9899
tabsHidden: false,

assets/models

Submodule models updated 167 files

source/GltfState/gltf_state.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class GltfState
5555
KHR_materials_specular: true,
5656
/** KHR_materials_iridescence adds a thin-film iridescence effect */
5757
KHR_materials_iridescence: true,
58+
KHR_materials_emissive_strength: true,
5859
},
5960
/** clear color expressed as list of ints in the range [0, 255] */
6061
clearColor: [58, 64, 74, 255],

source/Renderer/shaders/animation.glsl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ mat4 getSkinningMatrix()
6363
a_weights_1.z * getMatrixFromTexture(u_jointsSampler, int(a_joints_1.z) * 2) +
6464
a_weights_1.w * getMatrixFromTexture(u_jointsSampler, int(a_joints_1.w) * 2);
6565
#endif
66-
66+
if (skin == mat4(0)) {
67+
return mat4(1);
68+
}
6769
return skin;
6870
}
6971

@@ -87,7 +89,9 @@ mat4 getSkinningNormalMatrix()
8789
a_weights_1.z * getMatrixFromTexture(u_jointsSampler, int(a_joints_1.z) * 2 + 1) +
8890
a_weights_1.w * getMatrixFromTexture(u_jointsSampler, int(a_joints_1.w) * 2 + 1);
8991
#endif
90-
92+
if (skin == mat4(0)) {
93+
return mat4(1);
94+
}
9195
return skin;
9296
}
9397

source/Renderer/shaders/material_info.glsl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ uniform float u_IridescenceIOR;
3434
uniform float u_IridescenceThicknessMinimum;
3535
uniform float u_IridescenceThicknessMaximum;
3636

37-
//PBR Next IOR
37+
// Emissive Strength
38+
uniform float u_EmissiveStrength;
39+
40+
// PBR Next IOR
3841
uniform float u_Ior;
3942

4043
// Alpha mode

source/Renderer/shaders/pbr.frag

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ void main()
245245
#endif
246246

247247
f_emissive = u_EmissiveFactor;
248+
#ifdef MATERIAL_EMISSIVE_STRENGTH
249+
f_emissive *= u_EmissiveStrength;
250+
#endif
248251
#ifdef HAS_EMISSIVE_MAP
249252
f_emissive *= texture(u_EmissiveSampler, getEmissiveUV()).rgb;
250253
#endif

0 commit comments

Comments
 (0)