Skip to content

Instantly share code, notes, and snippets.

@andyshora
Created July 30, 2019 10:24
Show Gist options
  • Save andyshora/42c97afd82ad87cad98dbd3747433d85 to your computer and use it in GitHub Desktop.
Save andyshora/42c97afd82ad87cad98dbd3747433d85 to your computer and use it in GitHub Desktop.
BufferGeometry with alpha custom blending
particlesGeometry.current = new THREE.BufferGeometry()
particlesGeometry.current.addAttribute('position', new THREE.Float32BufferAttribute(positions.current, 3).setDynamic( true ))
particlesGeometry.current.addAttribute('color', new THREE.Float32BufferAttribute(colorBuffer, 3).setDynamic( true ))
const loader = new THREE.TextureLoader()
const texture = loader.load(lensflare)
texture.premultiplyAlpha = false
texture.needsUpdate = true
const blendSrc = { name: 'SrcAlpha', constant: THREE.SrcAlphaFactor }
const blendDst = { name: 'DstAlpha', constant: THREE.DstAlphaFactor }
const material = new THREE.PointsMaterial({
map: texture,
size: 2,
vertexColors: THREE.VertexColors,
sizeAttenuation: true,
blending: THREE.CustomBlending,
blendSrc: blendSrc.constant,
blendDst: blendDst.constant,
blendEquation: THREE.AddEquation,
transparent: true,
depthTest: false
})
const mesh = new THREE.Points( particlesGeometry.current, material )
@andyshora
Copy link
Author

lensflare0_alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment