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

Alex/g pipeline update #3258

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
fd86c98
Edge drawing render pass using both depth and normal data
AlexandruPopovici Aug 20, 2024
e5f3410
Merge branch 'main' into alex/WEB-1354
AlexandruPopovici Aug 22, 2024
6d40fa6
Edges are now mixed with the rest of the passes in the final pass
AlexandruPopovici Aug 23, 2024
da87e8a
Set MSAA for SS edges framebuffers to maximum number of samples
AlexandruPopovici Aug 23, 2024
cacbe66
New depth gradient extraction approach. Several improvements over the…
AlexandruPopovici Sep 2, 2024
1789a8d
Some changes to the normal gradient extraction. Using Robert's Cross …
AlexandruPopovici Sep 4, 2024
6dabdd8
Combined static AO with edges
AlexandruPopovici Sep 9, 2024
2237219
Implemented SMAA and static TAA. Both toggeable in realtime for bette…
AlexandruPopovici Sep 10, 2024
9376058
Added the normal pass and fixed some issues
AlexandruPopovici Sep 25, 2024
801c281
The pipeline is now capable of jitter individual passes if requested
AlexandruPopovici Sep 25, 2024
7869833
Added TAA pass. Technically it can be used to antialias anything. Rig…
AlexandruPopovici Sep 25, 2024
ef7c100
Added a TAA pipeline on the final image. Added DPR into pipeline resi…
AlexandruPopovici Oct 1, 2024
143568f
Edges pipeline
AlexandruPopovici Oct 1, 2024
1fe769b
Edges + TAA + AO + COLOR pipeline
AlexandruPopovici Oct 1, 2024
d3ba413
ShadedView mode
AlexandruPopovici Oct 3, 2024
084d4b0
Visibility is now properly reset when coming from a visibility condit…
AlexandruPopovici Oct 7, 2024
2fc5ccb
Added another version for 'shaded' view, inspired by blender's viewpo…
AlexandruPopovici Oct 7, 2024
c575c90
Added pen view together with a sample paper like texture for vissual …
AlexandruPopovici Oct 8, 2024
901fe7d
A form of techincal view
AlexandruPopovici Oct 9, 2024
cbf3f39
Arctic view. Separate viewport pass from matcap pass
AlexandruPopovici Oct 9, 2024
554e45c
Cleaned up the ao shader a bit. Formalized progressive ao pass options
AlexandruPopovici Oct 9, 2024
710d9d3
WIP on BasitMode
AlexandruPopovici Oct 10, 2024
b15add3
Added pipeline switching to the sandbox. Edge pass now has an optiona…
AlexandruPopovici Oct 10, 2024
fe45a5e
Implemented BasicMode using material overrides
AlexandruPopovici Oct 10, 2024
490008d
Merged with latest main
AlexandruPopovici Oct 14, 2024
b422fc3
Moar merging
AlexandruPopovici Oct 14, 2024
ab71daa
Fix merge issues
AlexandruPopovici Oct 14, 2024
cf8bae2
More merge misses
AlexandruPopovici Oct 14, 2024
08a93bf
Stating stream
AlexandruPopovici Oct 14, 2024
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
30 changes: 14 additions & 16 deletions packages/frontend-2/lib/viewer/extensions/PassReader.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { type SpecklePass } from '@speckle/viewer'
import { Extension } from '@speckle/viewer'
import type SpeckleRenderer from '@speckle/viewer/dist/modules/SpeckleRenderer'
import type { WebGLRenderTarget } from 'three'
import { Vector3, Vector4 } from 'three'

Expand All @@ -12,23 +10,23 @@ export class PassReader extends Extension {

public async read(): Promise<string> {
return new Promise<string>((resolve, reject) => {
const renderer: SpeckleRenderer = this.viewer.getRenderer()
// const renderer: SpeckleRenderer = this.viewer.getRenderer()

const dephPass: SpecklePass = renderer.pipeline.composer
.passes[0] as unknown as SpecklePass
// o_0
// const dephPass: SpecklePass = renderer.pipeline.composer
// .passes[0] as unknown as SpecklePass
// // o_0

this.renderTarget = dephPass.outputRenderTarget
if (!this.renderTarget) {
reject('Issue with depth pass render target')
return
}
// this.renderTarget = dephPass.outputRenderTarget
// if (!this.renderTarget) {
reject('Issue with depth pass render target')
// return
// }

const bufferSize = this.renderTarget.width * this.renderTarget.height * 4
if (this.outputBuffer.length !== bufferSize)
this.outputBuffer = new Uint8Array(bufferSize)
this.needsRead = true
this.readbackExecutor = resolve
// const bufferSize = this.renderTarget.width * this.renderTarget.height * 4
// if (this.outputBuffer.length !== bufferSize)
// this.outputBuffer = new Uint8Array(bufferSize)
// this.needsRead = true
// this.readbackExecutor = resolve
})
}

Expand Down
197 changes: 182 additions & 15 deletions packages/viewer-sandbox/src/Sandbox.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
import { SectionTool, SpeckleStandardMaterial, TreeNode } from '@speckle/viewer'
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import {
ArcticViewPipeline,
EdgesPipeline,
PenViewPipeline,
SectionTool,
ShadedViewPipeline,
SpeckleStandardMaterial,
TreeNode
} from '@speckle/viewer'
import {
CanonicalView,
Viewer,
Expand Down Expand Up @@ -142,7 +154,6 @@ export default class Sandbox {
// Mad HTML/CSS skills
container.appendChild(this.pane['containerElem_'])

// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
this.pane['containerElem_'].style = 'pointer-events:auto;'

this.tabs = this.pane.addTab({
Expand All @@ -162,7 +173,7 @@ export default class Sandbox {
this.addStreamControls(url)
this.addViewControls()
this.addBatches()
this.properties = await this.viewer.getObjectProperties()
// this.properties = await this.viewer.getObjectProperties()
this.batchesParams.totalBvhSize = this.getBVHSize()
this.refresh()
})
Expand Down Expand Up @@ -274,7 +285,6 @@ export default class Sandbox {
this.objectControls.dispose()
}
this.objectControls = this.tabs.pages[0].addFolder({
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
title: `Object: ${node.model.id}`
})

Expand Down Expand Up @@ -377,7 +387,6 @@ export default class Sandbox {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore

// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const file = e.target?.files[0] as Blob & { name: string }

const reader = new FileReader()
Expand Down Expand Up @@ -412,7 +421,7 @@ export default class Sandbox {
})
toggleSectionBox.on('click', () => {
let box = this.viewer.getRenderer().boxFromObjects(
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
this.selectionList.map((val) => val.hits[0].node.model.raw.id) as string[]
)
if (!box) {
Expand Down Expand Up @@ -443,7 +452,7 @@ export default class Sandbox {
})
zoomExtents.on('click', () => {
this.viewer.getExtension(CameraController).setCameraView(
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
this.selectionList.map((val) => val.hits[0].node.model.id) as string[],
true
)
Expand Down Expand Up @@ -499,27 +508,68 @@ export default class Sandbox {
await waitForAnimation(1000)
}
})
this.tabs.pages[0].addSeparator()

const pipeline = { output: 0 }
this.tabs.pages[0]
.addInput(pipeline, 'output', {
label: 'Pipeline',
options: {
DEFAULT: 0,
SHADED: 1,
PEN: 2,
ARCTIC: 3
}
})
.on('change', (value) => {
switch (value.value) {
case 0:
this.viewer.getRenderer().pipeline = new EdgesPipeline(
this.viewer.getRenderer()
)
break
case 1:
this.viewer.getRenderer().pipeline = new ShadedViewPipeline(
this.viewer.getRenderer()
)
break
case 2:
this.viewer.getRenderer().pipeline = new PenViewPipeline(
this.viewer.getRenderer()
)
break
case 3:
this.viewer.getRenderer().pipeline = new ArcticViewPipeline(
this.viewer.getRenderer()
)
break

default:
break
}
this.viewer.resize()
this.viewer.requestRender(UpdateFlags.RENDER_RESET)
})

this.tabs.pages[0].addSeparator()
const colors = this.tabs.pages[0].addButton({
title: `PM's Colors`
})
colors.on('click', async () => {
const colorNodes = this.viewer.getWorldTree().findAll(
(node: TreeNode) =>
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
node.model.renderView &&
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
node.model.renderView.renderData.colorMaterial &&
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
node.model.renderView.geometryType === GeometryType.MESH
)
const colorMap: { [color: number]: Array<string> } = {}
for (let k = 0; k < colorNodes.length; k++) {
const node = colorNodes[k]
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access

const color: number = node.model.renderView.renderData.colorMaterial.color
if (!colorMap[color]) colorMap[color] = []
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access

colorMap[color].push(node.model.id)
}
const colorGroups = []
Expand Down Expand Up @@ -547,6 +597,8 @@ export default class Sandbox {
}
})

this.tabs.pages[0].addSeparator()

const canonicalViewsFolder = this.tabs.pages[0].addFolder({
title: 'Canonical Views',
expanded: false
Expand All @@ -563,6 +615,122 @@ export default class Sandbox {
.setCameraView(sides[k] as CanonicalView, true)
})
}
// const edgesParams = {
// depthMultiplier: 1,
// depthBias: 0.001,
// normalMultiplier: 1,
// normalBias: 1,
// outlineDensity: 0.5,
// outlineThickness: 1,
// smaa: false,
// taa: true
// }
// const edgesFolder = this.tabs.pages[0].addFolder({
// title: 'Edges',
// expanded: true
// })
// edgesFolder
// .addInput(edgesParams, 'depthMultiplier', {
// label: 'depthMultiplier',
// min: 0,
// max: 1,
// step: 0.01
// })
// .on('change', (value) => {
// this.viewer.getRenderer().pipeline.edgesPass.edgesMaterial.uniforms[
// 'uDepthMultiplier'
// ].value = value.value
// this.viewer.getRenderer().pipeline.edgesPass.edgesMaterial.needsUpdate = true
// this.viewer.requestRender()
// })
// edgesFolder
// .addInput(edgesParams, 'depthBias', {
// label: 'depthBias',
// min: 0,
// max: 1,
// step: 0.0001
// })
// .on('change', (value) => {
// this.viewer.getRenderer().pipeline.edgesPass.edgesMaterial.uniforms[
// 'uDepthBias'
// ].value = value.value
// this.viewer.getRenderer().pipeline.edgesPass.edgesMaterial.needsUpdate = true
// this.viewer.requestRender()
// })
// edgesFolder
// .addInput(edgesParams, 'normalMultiplier', {
// label: 'normalMultiplier',
// min: 0,
// max: 1,
// step: 0.01
// })
// .on('change', (value) => {
// this.viewer.getRenderer().pipeline.edgesPass.edgesMaterial.uniforms[
// 'uNormalMultiplier'
// ].value = value.value
// this.viewer.getRenderer().pipeline.edgesPass.edgesMaterial.needsUpdate = true
// this.viewer.requestRender()
// })
// edgesFolder
// .addInput(edgesParams, 'normalBias', {
// label: 'normalBias',
// min: 0,
// max: 50,
// step: 0.1
// })
// .on('change', (value) => {
// this.viewer.getRenderer().pipeline.edgesPass.edgesMaterial.uniforms[
// 'uNormalBias'
// ].value = value.value
// this.viewer.getRenderer().pipeline.edgesPass.edgesMaterial.needsUpdate = true
// this.viewer.requestRender()
// })
// edgesFolder
// .addInput(edgesParams, 'outlineDensity', {
// label: 'outlineDensity',
// min: 0,
// max: 1,
// step: 0.01
// })
// .on('change', (value) => {
// this.viewer.getRenderer().pipeline.edgesPass.edgesMaterial.uniforms[
// 'uOutlineDensity'
// ].value = value.value
// this.viewer.getRenderer().pipeline.edgesPass.edgesMaterial.needsUpdate = true
// this.viewer.requestRender()
// })
// edgesFolder
// .addInput(edgesParams, 'outlineThickness', {
// label: 'outlineThickness',
// min: 0,
// max: 10,
// step: 0.1
// })
// .on('change', (value) => {
// this.viewer.getRenderer().pipeline.edgesPass.edgesMaterial.uniforms[
// 'uOutlineThickness'
// ].value = value.value
// this.viewer.getRenderer().pipeline.edgesPass.edgesMaterial.needsUpdate = true
// this.viewer.requestRender()
// })
// edgesFolder
// .addInput(edgesParams, 'smaa', {
// label: 'SMAA'
// })
// .on('change', (value) => {
// this.viewer.getRenderer().pipeline.smaaPass.enabled = edgesParams.smaa
// this.viewer.getRenderer().pipeline.pipelineOutput = 8
// this.viewer.requestRender()
// })
// edgesFolder
// .addInput(edgesParams, 'taa', {
// label: 'TAA'
// })
// .on('change', (value) => {
// this.viewer.getRenderer().pipeline.taaPass.enabled = edgesParams.taa
// this.viewer.getRenderer().pipeline.pipelineOutput = 8
// this.viewer.requestRender()
// })
}

makeSceneUI() {
Expand Down Expand Up @@ -702,7 +870,8 @@ export default class Sandbox {
DYNAMIC_AO: 5,
DYNAMIC_AO_BLURED: 6,
PROGRESSIVE_AO: 7,
FINAL: 8
FINAL: 8,
EDGES: 9
}
})
.on('change', () => {
Expand Down Expand Up @@ -1341,9 +1510,7 @@ export default class Sandbox {
const objects = this.viewer.getRenderer().allObjects
// eslint-disable-next-line @typescript-eslint/no-explicit-any
objects.traverse((obj: any) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
if (obj.hasOwnProperty('boundsTreeSizeInBytes')) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
size += obj['boundsTreeSizeInBytes']
// console.log(obj['boundsTreeSizeInBytes'] / 1024 / 1024)
}
Expand Down
18 changes: 15 additions & 3 deletions packages/viewer-sandbox/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const getStream = () => {
// prettier-ignore
// 'https://speckle.xyz/streams/da9e320dad/commits/5388ef24b8?c=%5B-7.66134,10.82932,6.41935,-0.07739,-13.88552,1.8697,0,1%5D'
// Revit sample house (good for bim-like stuff with many display meshes)
// 'https://speckle.xyz/streams/da9e320dad/commits/5388ef24b8'
'https://speckle.xyz/streams/da9e320dad/commits/5388ef24b8'
// 'https://latest.speckle.dev/streams/c1faab5c62/commits/ab1a1ab2b6'
// 'https://speckle.xyz/streams/da9e320dad/commits/5388ef24b8'
// 'https://latest.speckle.dev/streams/58b5648c4d/commits/60371ecb2d'
Expand Down Expand Up @@ -211,7 +211,7 @@ const getStream = () => {
// 'https://latest.speckle.dev/streams/92b620fb17/commits/b4366a7086?filter=%7B%7D&c=%5B-31.02357,37.60008,96.58899,11.01564,7.40652,66.0411,0,1%5D)'
// double
// 'https://latest.speckle.dev/streams/92b620fb17/commits/b4366a7086?overlay=c009dbe144&filter=%7B%7D&c=%5B-104.70053,-98.80617,67.44669,6.53096,1.8739,38.584,0,1%5D'
// 'https://latest.speckle.dev/streams/c43ac05d04/commits/ec724cfbeb',
// 'https://latest.speckle.dev/streams/c43ac05d04/commits/ec724cfbeb'
// 'https://latest.speckle.dev/streams/efd2c6a31d/commits/4b495e1901'
// 'https://latest.speckle.dev/streams/efd2c6a31d/commits/4b495e1901'
// tekla 2
Expand Down Expand Up @@ -406,25 +406,37 @@ const getStream = () => {
// 'https://latest.speckle.systems/projects/126cd4b7bb/models/6221c985c0'

// DUI3 Color Proxies
// 'https://app.speckle.systems/projects/93200a735d/models/d1fbf678f1'
// ' https://app.speckle.systems/projects/93200a735d/models/d1fbf678f1'
// 'https://app.speckle.systems/projects/b53a53697a/models/93fa215ba9'
// 'https://latest.speckle.systems/projects/126cd4b7bb/models/5ec85fc2a2'
// 'https://latest.speckle.systems/projects/2af60ce1b6/models/09dbceb25f@5af6d6a3f4'
// 'https://latest.speckle.systems/projects/2af60ce1b6/models/09dbceb25f@ebb895355d'

// Backfaces
// 'https://app.speckle.systems/projects/69bf87aa61/models/c8f443a03e'

// 'https://app.speckle.systems/projects/cdaeb201d9/models/1ad10b0a5b'
// 'https://app.speckle.systems/projects/93200a735d/models/d1fbf678f1@088537140b'
// 'https://app.speckle.systems/projects/93200a735d/models/e3c3849167'
// 'https://app.speckle.systems/projects/93200a735d/models/d1fbf678f1@088537140b'
// 'https://app.speckle.systems/projects/93200a735d/models/e3c3849167'

// Text with no material
// 'https://latest.speckle.systems/projects/731c6e2fd1/models/bcd3a4a706'
// 'https://latest.speckle.systems/projects/126cd4b7bb/models/44a3cddb93'
// 'https://latest.speckle.systems/projects/126cd4b7bb/models/afec5fcb04@0c2ad0b86b'
// 'https://latest.speckle.systems/projects/126cd4b7bb/models/44a3cddb93'
// 'https://latest.speckle.systems/projects/126cd4b7bb/models/44a3cddb93@31654f1e2c'
// Homepage
// 'https://app.speckle.systems/projects/0c1ea0ca62/models/729a6f557d@9bff3c6f1f'

// BREPs as display values
// 'https://latest.speckle.systems/projects/126cd4b7bb/models/b613d77690@046b56bf12'

// 'https://app.speckle.systems/projects/00a5c443d6/models/de56edf901'

'https://app.speckle.systems/projects/6cf358a40e/models/e01ffbc891@f1ddc19011'
// 'https://app.speckle.systems/projects/6cf358a40e/models/e01ffbc891@f1ddc19011'
)
}

Expand Down
Binary file added packages/viewer/src/assets/matcap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/viewer/src/assets/paper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/viewer/src/assets/white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading