MCPcopy Create free account
hub / github.com/pmndrs/postprocessing / updateScaleOffset

Method updateScaleOffset

src/effects/LUT3DEffect.js:177–221  ·  view source on GitHub ↗

* Updates the scale and offset for the LUT sampling coordinates. * * @private

()

Source from the content-addressed store, hash-verified

175 */
176
177 updateScaleOffset() {
178
179 const lut = this.lut;
180
181 if(lut !== null) {
182
183 const size = Math.min(lut.image.width, lut.image.height);
184 const scale = this.uniforms.get("scale").value;
185 const offset = this.uniforms.get("offset").value;
186
187 if(this.tetrahedralInterpolation && lut instanceof Data3DTexture) {
188
189 if(this.defines.has("CUSTOM_INPUT_DOMAIN")) {
190
191 const domainScale = lut.domainMax.clone().sub(lut.domainMin);
192 scale.setScalar(size - 1).divide(domainScale);
193 offset.copy(lut.domainMin).negate().multiply(scale);
194
195 } else {
196
197 scale.setScalar(size - 1);
198 offset.setScalar(0);
199
200 }
201
202 } else {
203
204 if(this.defines.has("CUSTOM_INPUT_DOMAIN")) {
205
206 const domainScale = lut.domainMax.clone().sub(lut.domainMin).multiplyScalar(size);
207 scale.setScalar(size - 1).divide(domainScale);
208 offset.copy(lut.domainMin).negate().multiply(scale).addScalar(1.0 / (2.0 * size));
209
210 } else {
211
212 scale.setScalar((size - 1) / size);
213 offset.setScalar(1.0 / (2.0 * size));
214
215 }
216
217 }
218
219 }
220
221 }
222
223 /**
224 * Configures parameters for tetrahedral interpolation.

Callers 1

Calls 1

copyMethod · 0.80

Tested by

no test coverage detected