本文整理汇总了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(),
},
})