Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lensflare: Better RTT support. #26886

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions examples/jsm/objects/Lensflare.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Mesh,
MeshBasicMaterial,
RawShaderMaterial,
UnsignedByteType,
Vector2,
Vector3,
Vector4
Expand Down Expand Up @@ -36,6 +37,8 @@ class Lensflare extends Mesh {
const tempMap = new FramebufferTexture( 16, 16 );
const occlusionMap = new FramebufferTexture( 16, 16 );

let currentType = UnsignedByteType;

// material

const geometry = Lensflare.Geometry;
Expand Down Expand Up @@ -162,6 +165,20 @@ class Lensflare extends Mesh {

renderer.getCurrentViewport( viewport );

const renderTarget = renderer.getRenderTarget();
const type = ( renderTarget !== null ) ? renderTarget.texture.type : UnsignedByteType;

if ( currentType !== type ) {

tempMap.dispose();
occlusionMap.dispose();

tempMap.type = occlusionMap.type = type;

currentType = type;

}

const invAspect = viewport.w / viewport.z;
const halfViewportWidth = viewport.z / 2.0;
const halfViewportHeight = viewport.w / 2.0;
Expand Down