當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript painterState.getEffect函數代碼示例

本文整理匯總了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]),
		})),
	})
}
開發者ID:trivial-space,項目名稱:playground,代碼行數:47,代碼來源:blur.ts

示例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'),
	},
開發者ID:trivial-space,項目名稱:playground,代碼行數:31,代碼來源:renderer.ts

示例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: [
		{
開發者ID:trivial-space,項目名稱:playground,代碼行數:31,代碼來源:renderer.ts

示例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')
開發者ID:trivial-space,項目名稱:playground,代碼行數:8,代碼來源:index.ts

示例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(),
	},
})
開發者ID:trivial-space,項目名稱:playground,代碼行數:30,代碼來源:index.ts


注:本文中的shared-utils/painterState.getEffect函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。