Skip to content
Snippets Groups Projects
Commit 34c82b11 authored by Alexander Rose's avatar Alexander Rose
Browse files

fixed gpu gaussian density grid shift

parent 633fbe46
No related branches found
No related tags found
No related merge requests found
...@@ -80,6 +80,7 @@ export interface HistogramPyramid { ...@@ -80,6 +80,7 @@ export interface HistogramPyramid {
export function createHistogramPyramid(ctx: WebGLContext, inputTexture: Texture): HistogramPyramid { export function createHistogramPyramid(ctx: WebGLContext, inputTexture: Texture): HistogramPyramid {
const { gl, framebufferCache } = ctx const { gl, framebufferCache } = ctx
// printTexture(ctx, inputTexture, 2)
const inputTextureMaxDim = Math.max(inputTexture.width, inputTexture.height) const inputTextureMaxDim = Math.max(inputTexture.width, inputTexture.height)
// This part set the levels // This part set the levels
...@@ -139,7 +140,7 @@ export function createHistogramPyramid(ctx: WebGLContext, inputTexture: Texture) ...@@ -139,7 +140,7 @@ export function createHistogramPyramid(ctx: WebGLContext, inputTexture: Texture)
offset += size; offset += size;
} }
// printTexture(ctx, pyramidTexture, 3) // printTexture(ctx, pyramidTexture, 2)
// //
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
import { RuntimeContext } from 'mol-task' import { RuntimeContext } from 'mol-task'
import { PositionData, DensityData, DensityTextureData } from '../common' import { PositionData, DensityData, DensityTextureData } from '../common'
import { Box3D } from '../../geometry' import { Box3D } from '../../geometry'
import { GaussianDensityGPUProps, getDelta } from '../gaussian-density' import { GaussianDensityGPUProps } from '../gaussian-density'
import { OrderedSet } from 'mol-data/int' import { OrderedSet } from 'mol-data/int'
import { Vec3, Tensor, Mat4 } from '../../linear-algebra' import { Vec3, Tensor, Mat4 } from '../../linear-algebra'
import { ValueCell } from 'mol-util' import { ValueCell } from 'mol-util'
...@@ -229,12 +229,15 @@ async function prepareGaussianDensityData(ctx: RuntimeContext, position: Positio ...@@ -229,12 +229,15 @@ async function prepareGaussianDensityData(ctx: RuntimeContext, position: Positio
} }
const pad = maxRadius * 2 + resolution const pad = maxRadius * 2 + resolution
const expandedBox = Box3D.expand(Box3D.empty(), box, Vec3.create(pad, pad, pad)); const expandedBox = Box3D.expand(Box3D(), box, Vec3.create(pad, pad, pad));
const extent = Vec3.sub(Vec3.zero(), expandedBox.max, expandedBox.min) const expandedDim = Box3D.size(Vec3(), expandedBox)
const delta = getDelta(expandedBox, resolution) const scaledBox = Box3D.scale(Box3D(), expandedBox, 1 / resolution)
const dim = Vec3.zero() const dim = Box3D.size(Vec3(), scaledBox)
Vec3.ceil(dim, Vec3.mul(dim, extent, delta)) Vec3.ceil(dim, dim)
const delta = Vec3.div(Vec3(), dim, expandedDim)
// console.log({ maxRadius, resolution, pad, box, expandedBox, delta })
// console.log('grid dim gpu', dim) // console.log('grid dim gpu', dim)
return { drawCount: n, positions, radii, groups, delta, expandedBox, dim } return { drawCount: n, positions, radii, groups, delta, expandedBox, dim }
......
...@@ -45,15 +45,8 @@ async function init() { ...@@ -45,15 +45,8 @@ async function init() {
z: [0, 2], z: [0, 2],
indices: OrderedSet.ofSortedArray([0, 1]), indices: OrderedSet.ofSortedArray([0, 1]),
} }
const box = Box3D.create(Vec3.create(-1, -1, -1), Vec3.create(3, 3, 3)) const box = Box3D.create(Vec3.create(0, 0, 0), Vec3.create(2, 2, 2))
// const position: PositionData = { const radius = () => 1.8
// x: [0],
// y: [0],
// z: [0],
// indices: OrderedSet.ofSortedArray([0]),
// }
// const box = Box3D.create(Vec3.create(-1, -1, -1), Vec3.create(1, 1, 1))
const radius = () => 1.4
const props = { const props = {
resolution: 0.1, resolution: 0.1,
radiusOffset: 0, radiusOffset: 0,
...@@ -61,7 +54,7 @@ async function init() { ...@@ -61,7 +54,7 @@ async function init() {
} }
const isoValue = Math.exp(-props.smoothness) const isoValue = Math.exp(-props.smoothness)
if (true) { if (false) {
console.time('gpu gaussian2') console.time('gpu gaussian2')
const densityTextureData2 = await computeGaussianDensityTexture2d(position, box, radius, props, webgl).run() const densityTextureData2 = await computeGaussianDensityTexture2d(position, box, radius, props, webgl).run()
webgl.waitForGpuCommandsCompleteSync() webgl.waitForGpuCommandsCompleteSync()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment