UNPKG

molstar

Version:

A comprehensive macromolecular library.

19 lines (18 loc) 807 B
"use strict"; /** * Copyright (c) 2017-2018 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Michael Krone <michael.krone@uni-tuebingen.de> */ Object.defineProperty(exports, "__esModule", { value: true }); exports.texture3d_from_2d_nearest = void 0; exports.texture3d_from_2d_nearest = ` vec4 texture3dFrom2dNearest(sampler2D tex, vec3 pos, vec3 gridDim, vec2 texDim) { float zSlice = floor(pos.z * gridDim.z + 0.5); // round to nearest z-slice float column = intMod(zSlice * gridDim.x, texDim.x) / gridDim.x; float row = floor(intDiv(zSlice * gridDim.x, texDim.x)); vec2 coord = (vec2(column * gridDim.x, row * gridDim.y) + (pos.xy * gridDim.xy)) / texDim; return texture2D(tex, coord); } `;