MCPcopy Create free account
hub / github.com/beutton/browser-flight-simulator / createRenderTarget

Function createRenderTarget

packages/clouds/src/CloudsPass.ts:37–73  ·  view source on GitHub ↗
(
  name: string,
  { depthVelocity, shadowLength }: RenderTargetOptions
)

Source from the content-addressed store, hash-verified

35}
36
37function createRenderTarget(
38 name: string,
39 { depthVelocity, shadowLength }: RenderTargetOptions
40): RenderTarget {
41 const renderTarget: WebGLRenderTarget & {
42 depthVelocity?: Texture
43 shadowLength?: Texture
44 } = new WebGLRenderTarget(1, 1, {
45 depthBuffer: false,
46 stencilBuffer: false,
47 type: HalfFloatType
48 })
49 renderTarget.texture.minFilter = LinearFilter
50 renderTarget.texture.magFilter = LinearFilter
51 renderTarget.texture.name = name
52
53 let depthVelocityBuffer
54 if (depthVelocity) {
55 depthVelocityBuffer = renderTarget.texture.clone()
56 depthVelocityBuffer.isRenderTargetTexture = true
57 renderTarget.depthVelocity = depthVelocityBuffer
58 renderTarget.textures.push(depthVelocityBuffer)
59 }
60 let shadowLengthBuffer
61 if (shadowLength) {
62 shadowLengthBuffer = renderTarget.texture.clone()
63 shadowLengthBuffer.isRenderTargetTexture = true
64 shadowLengthBuffer.format = RedFormat
65 renderTarget.shadowLength = shadowLengthBuffer
66 renderTarget.textures.push(shadowLengthBuffer)
67 }
68
69 return Object.assign(renderTarget, {
70 depthVelocity: depthVelocityBuffer ?? null,
71 shadowLength: shadowLengthBuffer ?? null
72 })
73}
74
75export interface CloudsPassOptions extends PassBaseOptions {
76 parameterUniforms: CloudParameterUniforms

Callers 1

initRenderTargetsMethod · 0.70

Calls 1

cloneMethod · 0.45

Tested by

no test coverage detected