bx-1140-postprocessing #12
|
@ -1,7 +1,7 @@
|
|||
<script setup lang="ts">
|
||||
import { onMounted, watch } from 'vue';
|
||||
|
||||
import { EquirectangularReflectionMapping, ReinhardToneMapping } from 'three';
|
||||
import { ACESFilmicToneMapping, EquirectangularReflectionMapping, ReinhardToneMapping, SRGBColorSpace } from 'three';
|
||||
import { GainMapLoader } from '@monogrid/gainmap-js'
|
||||
import { useTresContext } from '@tresjs/core';
|
||||
|
||||
|
@ -26,7 +26,12 @@ const loadEnv = async () => {
|
|||
// scene.value.backgroundBlurriness = 0.15
|
||||
result.renderTarget.texture.dispose();
|
||||
}
|
||||
renderer.value.toneMapping = ReinhardToneMapping
|
||||
// renderer.value.toneMapping = ReinhardToneMapping
|
||||
renderer.value.outputColorSpace = SRGBColorSpace;
|
||||
renderer.value.toneMapping = ACESFilmicToneMapping;
|
||||
renderer.value.toneMappingExposure = 1;
|
||||
|
||||
renderer.value.setPixelRatio(1.5)
|
||||
onMounted(async () => {
|
||||
loadEnv()
|
||||
})
|
||||
|
|
|
@ -72,6 +72,10 @@ const loadModels = async () => {
|
|||
item.modelFile = loaded_scene
|
||||
item.name = element.name
|
||||
|
||||
if(!element.is_enabled) {
|
||||
item.modelFile.visible = false
|
||||
}
|
||||
|
||||
models.value.push(item)
|
||||
|
||||
const res = await fetch(`${SERVER_URL}/api/obj/clickable/?source=${element.id}`)
|
||||
|
|
|
@ -59,7 +59,7 @@ const clearColor = 'steelBlue'
|
|||
<template>
|
||||
<div>
|
||||
<div :class="[{ 'loading': models_loading }, 'canvas-wrapper']">
|
||||
<TresCanvas window-size :alpha="false" power-preference="high-performance" :clear-color="clearColor">
|
||||
<TresCanvas window-size :alpha="false" power-preference="high-performance" :clear-color="clearColor" :logarithmicDepthBuffer="true">
|
||||
<TresPerspectiveCamera :position="cameraPosition" ref="camera" />
|
||||
<OrbitControls v-bind="controlsState" @change="onChange" make-default />
|
||||
<Suspense>
|
||||
|
|
|
@ -9,6 +9,7 @@ import { OutputPass } from 'three/addons/postprocessing/OutputPass.js';
|
|||
import { useTresContext, useLoop } from '@tresjs/core';
|
||||
import { watch } from 'vue';
|
||||
import { Color, Fog, FogExp2 } from 'three';
|
||||
import { GammaCorrectionShader, TAARenderPass } from 'three/examples/jsm/Addons.js';
|
||||
|
||||
const { renderer, camera, scene } = useTresContext()
|
||||
|
||||
|
@ -20,37 +21,37 @@ const k = { start: 0.5, end: 3 }
|
|||
if (camera.value) {
|
||||
const renderPass = new RenderPass(scene.value, camera.value);
|
||||
|
||||
const bokehPass = new BokehPass(scene.value, camera.value, {
|
||||
focus: props.tiltShift.focus,
|
||||
aperture: (props.tiltShift.aperture) * 0.00001,
|
||||
maxblur: (props.tiltShift.maxblur) * 0.01
|
||||
});
|
||||
|
||||
// const bokehPass = new BokehPass(scene.value, camera.value, {
|
||||
// focus: props.tiltShift.focus,
|
||||
// aperture: (props.tiltShift.aperture) * 0.00001,
|
||||
// maxblur: (props.tiltShift.maxblur) * 0.01
|
||||
// });
|
||||
const outputPass = new OutputPass();
|
||||
composer.addPass(renderPass);
|
||||
composer.addPass(bokehPass);
|
||||
composer.addPass(outputPass);
|
||||
// composer.addPass(outputPass);
|
||||
|
||||
scene.value.fog = new Fog(props.clearColor, props.tiltShift.focus * k.start, props.tiltShift.focus * k.end)
|
||||
}
|
||||
const { onAfterRender } = useLoop()
|
||||
onAfterRender(() => {
|
||||
composer.render()
|
||||
// composer.render()
|
||||
})
|
||||
watch(props.tiltShift, () => {
|
||||
if (camera.value) {
|
||||
const args = {
|
||||
focus: props.tiltShift.focus,
|
||||
aperture: props.tiltShift.aperture * 0.00001,
|
||||
maxblur: props.tiltShift.maxblur * 0.01
|
||||
}
|
||||
const bokehPass = new BokehPass(scene.value, camera.value, args);
|
||||
composer.passes = []
|
||||
const renderPass = new RenderPass(scene.value, camera.value);
|
||||
const outputPass = new OutputPass();
|
||||
composer.addPass(renderPass);
|
||||
composer.addPass(bokehPass);
|
||||
composer.addPass(outputPass);
|
||||
|
||||
// const args = {
|
||||
// focus: props.tiltShift.focus,
|
||||
// aperture: props.tiltShift.aperture * 0.00001,
|
||||
// maxblur: props.tiltShift.maxblur * 0.01
|
||||
// }
|
||||
// const bokehPass = new BokehPass(scene.value, camera.value, args);
|
||||
// composer.passes = []
|
||||
// const renderPass = new RenderPass(scene.value, camera.value);
|
||||
// const outputPass = new OutputPass();
|
||||
// composer.addPass(renderPass);
|
||||
// composer.addPass(bokehPass);
|
||||
// composer.addPass(outputPass);
|
||||
const gammaCorrectionPass = new ShaderPass(GammaCorrectionShader);
|
||||
composer.addPass(gammaCorrectionPass);
|
||||
scene.value.fog = new Fog(props.clearColor, props.tiltShift.focus * k.start, props.tiltShift.focus * k.end)
|
||||
}
|
||||
}, { deep: true })
|
||||
|
|
Loading…
Reference in New Issue