本文整理匯總了TypeScript中shared-utils/painterState.getEffect函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getEffect函數的具體用法?TypeScript getEffect怎麽用?TypeScript getEffect使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了getEffect函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getBlurByAlphaEffect
export function getBlurByAlphaEffect(
painter: Painter,
id: string,
{
strength,
size,
layerOpts,
startFrame: startLayer,
strengthOffset = 0,
blurRatioVertical = 1,
scaleFactor = 0.6,
}: BlurOpts,
) {
const passData: any[] = []
while (strength >= 1 / blurRatioVertical) {
passData.push({
strength,
direction: 0,
source: '0',
})
passData.push({
strength: strength * blurRatioVertical,
direction: 1,
source: '0',
})
strength *= scaleFactor
}
if (startLayer) {
passData[0].source = () => startLayer.image()
}
return getEffect(painter, id).update({
...layerOpts,
frag,
drawSettings: {
disable: [painter.gl.DEPTH_TEST],
},
uniforms: passData.map(data => ({
...data,
blurRatioVertical,
strengthOffset,
size: size || (() => [painter.gl.canvas.width, painter.gl.canvas.height]),
})),
})
}
示例2: makeClear
view: () => state.viewPort.camera.viewMat,
projection: () => state.viewPort.camera.projectionMat,
},
drawSettings: {
enable: [gl.DEPTH_TEST],
clearBits: makeClear(gl, 'color', 'depth'),
},
})
const bufferSpec: TextureData = { type: 'FLOAT' }
export const scene = getFrame(painter, 'scene').update({
layers: sceneLayer,
bufferStructure: [bufferSpec, bufferSpec, bufferSpec, bufferSpec],
})
const lightLayer = getEffect(painter, 'light').update({
frag: lightFrag,
uniforms: {
eyePosition: () => state.viewPort.camera.position,
lightMat: () => state.scene.lightTransforms[0],
view: () => state.viewPort.camera.viewMat,
tex: () => texture.image(),
positions: scene.image(0),
normals: scene.image(1),
uvs: scene.image(2),
colors: scene.image(3),
},
drawSettings: {
enable: [gl.BLEND],
clearBits: makeClear(gl, 'color'),
},
示例3: getFrame
getSketch,
} from 'shared-utils/painterState'
import { makeClear } from 'tvs-painter/dist/utils/context'
import { plane } from 'tvs-painter/dist/utils/geometry/plane'
import { events, gl, paint, painter } from './context'
import base from './glsl/base.frag'
import planeFrag from './glsl/plane-material.frag'
import planeVert from './glsl/plane-material.vert'
// ===== gof layers =====
const paintFrame = getFrame(painter, 'paint')
const bufferSize = 256
const effect = getEffect(painter, 'layer').update({
frag: base,
uniforms: {
size: bufferSize,
paint: () => paintFrame.image(),
previous: '0',
},
})
export const automaton = getFrame(painter, 'automaton').update({
layers: effect,
selfReferencing: true,
width: bufferSize,
height: bufferSize,
bufferStructure: [
{
示例4: getEffect
import { getEffect } from 'shared-utils/painterState'
import { painter } from './context'
// ===== layers =====
export const noise = getEffect(painter, 'noise')
export const toNormal = getEffect(painter, 'toNormal')
示例5: getLayer
})
// ===== layers =====
const points = getLayer(painter, 'points').update({
sketches: [pointsSketch],
uniforms: { size: () => [canvas.width, canvas.height] },
drawSettings: {
clearColor: [0, 0, 0, 1],
clearBits: gl.COLOR_BUFFER_BIT,
enable: [gl.BLEND],
blendFunc: [gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA],
},
})
const currentTriple = getEffect(painter, 'sides').update({
frag: sideFrag,
})
const current = getFrame(painter, 'current').update({
layers: [points, currentTriple],
})
const blend = getEffect(painter, 'blend').update({
frag: blendFrag,
uniforms: {
previous: '0',
current: () => current.image(),
},
})