Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add config option for uniform lighting #561

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cortex/defaults.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ filter = url(#dropshadow)
voxlines = false
voxline_color = #FFFFFF
voxline_width = 0.01
# Overwrites emissive, specular, and diffuse to have uniform lighting
uniform_illumination = false
specularity = 1.0
overlayscale = 1
anim_speed = 2
Expand Down
23 changes: 23 additions & 0 deletions cortex/webgl/resources/js/mriview_surface.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ var mriview = (function(module) {
}
]);

// Update uniform values based on the uniform illumination option
if (viewopts.uniform_illumination == 'true') {
this.uniforms.diffuse.value.set(0, 0, 0); // Set diffuse to 0
this.uniforms.specular.value.set(0, 0, 0); // Set specular to 0
this.uniforms.emissive.value.set(1, 1, 1); // Set emissive to 1
}

this.ui = (new jsplot.Menu()).add({
unfold: {action:[this, "setMix", 0., 1.]},
pivot: {action:[this, "setPivot", -180, 180]},
Expand All @@ -101,6 +108,7 @@ var mriview = (function(module) {
toggleMultipleLayers: {action: this.toggleMultipleLayers.bind(this), key: 'm', hidden: true, help: "Toggle multiple layers"},
dither: {action:[this, "setDither"]},
sampler: {action:[this, "setSampler", ["nearest", "trilinear"]]},
uniform_illumination: {action:[this, "setUniformIllumination"]},
});


Expand Down Expand Up @@ -846,5 +854,20 @@ var mriview = (function(module) {
this.object.add(this.mesh);
}

module.Surface.prototype.setUniformIllumination = function(val) {
if (val === undefined)
return this.uniforms.emissive.value.x == 1; // Check current state

if (val) {
this.uniforms.diffuse.value.set(0, 0, 0);
this.uniforms.specular.value.set(0, 0, 0);
this.uniforms.emissive.value.set(1, 1, 1);
} else {
this.uniforms.diffuse.value.set(.8, .8, .8);
this.uniforms.specular.value.set(.005, .005, .005);
this.uniforms.emissive.value.set(.2, .2, .2);
}
};

return module;
}(mriview || {}));
Loading