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

render picking buffers at lower resolution, pixelRatio related fixes

parent e0a716c8
No related branches found
No related tags found
No related merge requests found
...@@ -110,9 +110,9 @@ namespace Canvas3D { ...@@ -110,9 +110,9 @@ namespace Canvas3D {
const controls = TrackballControls.create(input, camera, {}) const controls = TrackballControls.create(input, camera, {})
const renderer = Renderer.create(webgl, camera, { clearColor: p.backgroundColor }) const renderer = Renderer.create(webgl, camera, { clearColor: p.backgroundColor })
const pickScale = 1 let pickScale = 0.25 / webgl.pixelRatio
const pickWidth = Math.round(canvas.width * pickScale) let pickWidth = Math.round(canvas.width * pickScale)
const pickHeight = Math.round(canvas.height * pickScale) let pickHeight = Math.round(canvas.height * pickScale)
const objectPickTarget = createRenderTarget(webgl, pickWidth, pickHeight) const objectPickTarget = createRenderTarget(webgl, pickWidth, pickHeight)
const instancePickTarget = createRenderTarget(webgl, pickWidth, pickHeight) const instancePickTarget = createRenderTarget(webgl, pickWidth, pickHeight)
const groupPickTarget = createRenderTarget(webgl, pickWidth, pickHeight) const groupPickTarget = createRenderTarget(webgl, pickWidth, pickHeight)
...@@ -414,11 +414,14 @@ namespace Canvas3D { ...@@ -414,11 +414,14 @@ namespace Canvas3D {
Viewport.set(camera.viewport, 0, 0, canvas.width, canvas.height) Viewport.set(camera.viewport, 0, 0, canvas.width, canvas.height)
Viewport.set(controls.viewport, 0, 0, canvas.width, canvas.height) Viewport.set(controls.viewport, 0, 0, canvas.width, canvas.height)
const pickWidth = Math.round(canvas.width * pickScale) pickScale = 0.25 / webgl.pixelRatio
const pickHeight = Math.round(canvas.height * pickScale) pickWidth = Math.round(canvas.width * pickScale)
pickHeight = Math.round(canvas.height * pickScale)
objectPickTarget.setSize(pickWidth, pickHeight) objectPickTarget.setSize(pickWidth, pickHeight)
instancePickTarget.setSize(pickWidth, pickHeight) instancePickTarget.setSize(pickWidth, pickHeight)
groupPickTarget.setSize(pickWidth, pickHeight) groupPickTarget.setSize(pickWidth, pickHeight)
requestDraw(true)
} }
} }
} }
\ No newline at end of file
...@@ -256,7 +256,7 @@ export function createContext(gl: GLRenderingContext): WebGLContext { ...@@ -256,7 +256,7 @@ export function createContext(gl: GLRenderingContext): WebGLContext {
vertexArrayObject, vertexArrayObject,
fragDepth fragDepth
}, },
pixelRatio: getPixelRatio(), get pixelRatio () { return getPixelRatio() },
shaderCache, shaderCache,
programCache, programCache,
......
...@@ -20,6 +20,7 @@ export interface RenderTarget { ...@@ -20,6 +20,7 @@ export interface RenderTarget {
readonly image: TextureImage<any> readonly image: TextureImage<any>
readonly texture: Texture readonly texture: Texture
/** binds framebuffer and sets viewport to rendertarget's width and height */
bind: () => void bind: () => void
setSize: (width: number, height: number) => void setSize: (width: number, height: number) => void
readBuffer: (x: number, y: number, width: number, height: number, dst: Uint8Array) => void readBuffer: (x: number, y: number, width: number, height: number, dst: Uint8Array) => void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment