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

WebGPURenderer: Improve PointsNodeMaterial #1505

Merged
merged 5 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 12 additions & 19 deletions examples-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -14060,31 +14060,24 @@ index aa8149e3..f9fd7f00 100644
position.y = matrix.elements[13];
position.z = matrix.elements[14];
diff --git a/examples-testing/examples/webgpu_instance_points.ts b/examples-testing/examples/webgpu_instance_points.ts
index fdc3d614..9a660e06 100644
index 4b29d389..c793ca87 100644
--- a/examples-testing/examples/webgpu_instance_points.ts
+++ b/examples-testing/examples/webgpu_instance_points.ts
@@ -1,5 +1,18 @@
@@ -1,4 +1,4 @@
-import * as THREE from 'three';
-import { color, storage, Fn, instanceIndex, sin, time, float, uniform, attribute, mix, vec3 } from 'three/tsl';
+import * as THREE from 'three/webgpu';
+import {
+ color,
+ storage,
+ Fn,
+ instanceIndex,
+ sin,
+ time,
+ float,
+ uniform,
+ attribute,
+ mix,
+ vec3,
import {
color,
storage,
@@ -12,6 +12,7 @@ import {
shapeCircle,
mix,
vec3,
+ ShaderNodeObject,
+} from 'three/tsl';
} from 'three/tsl';

import Stats from 'three/addons/libs/stats.module.js';

@@ -11,18 +24,28 @@ import InstancedPointsGeometry from 'three/addons/geometries/InstancedPointsGeom
@@ -21,18 +22,28 @@ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';

import * as GeometryUtils from 'three/addons/utils/GeometryUtils.js';

Expand All @@ -14099,7 +14092,7 @@ index fdc3d614..9a660e06 100644
+ camera2: THREE.PerspectiveCamera,
+ controls: OrbitControls,
+ backgroundNode: ShaderNodeObject<THREE.Node>;
+let material: THREE.InstancedPointsNodeMaterial;
+let material: THREE.PointsNodeMaterial;
+let stats: Stats;
+let gui: GUI;
+let effectController: {
Expand Down
13 changes: 0 additions & 13 deletions types/three/examples/jsm/geometries/InstancedPointsGeometry.d.ts

This file was deleted.

10 changes: 0 additions & 10 deletions types/three/examples/jsm/objects/InstancedPoints.d.ts

This file was deleted.

3 changes: 2 additions & 1 deletion types/three/src/Three.TSL.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export const materialLineWidth: typeof TSL.materialLineWidth;
export const materialMetalness: typeof TSL.materialMetalness;
export const materialNormal: typeof TSL.materialNormal;
export const materialOpacity: typeof TSL.materialOpacity;
export const materialPointWidth: typeof TSL.materialPointWidth;
export const materialPointSize: typeof TSL.materialPointSize;
export const materialReference: typeof TSL.materialReference;
export const materialReflectivity: typeof TSL.materialReflectivity;
export const materialRefractionRatio: typeof TSL.materialRefractionRatio;
Expand Down Expand Up @@ -415,6 +415,7 @@ export const shaderStages: typeof TSL.shaderStages;
export const shadow: typeof TSL.shadow;
export const shadowPositionWorld: typeof TSL.shadowPositionWorld;
export const sharedUniformGroup: typeof TSL.sharedUniformGroup;
export const shapeCircle: typeof TSL.shapeCircle;
export const sheen: typeof TSL.sheen;
export const sheenRoughness: typeof TSL.sheenRoughness;
export const shiftLeft: typeof TSL.shiftLeft;
Expand Down
33 changes: 0 additions & 33 deletions types/three/src/materials/nodes/InstancedPointsNodeMaterial.d.ts

This file was deleted.

4 changes: 0 additions & 4 deletions types/three/src/materials/nodes/NodeMaterials.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export {
default as InstancedPointsNodeMaterial,
InstancedPointsNodeMaterialParameters,
} from "./InstancedPointsNodeMaterial.js";
export { default as Line2NodeMaterial, Line2NodeMaterialParameters } from "./Line2NodeMaterial.js";
export { default as LineBasicNodeMaterial, LineBasicNodeMaterialParameters } from "./LineBasicNodeMaterial.js";
export { default as LineDashedNodeMaterial, LineDashedNodeMaterialParameters } from "./LineDashedNodeMaterial.js";
Expand Down
21 changes: 7 additions & 14 deletions types/three/src/materials/nodes/PointsNodeMaterial.d.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
import { Color } from "../../math/Color.js";
import { Texture } from "../../textures/Texture.js";
import { PointsMaterialParameters } from "../PointsMaterial.js";
import NodeMaterial, { NodeMaterialParameters } from "./NodeMaterial.js";
import Node from "../../nodes/core/Node.js";
import SpriteNodeMaterial, { SpriteNodeMaterialParameters } from "./SpriteNodeMaterial.js";

export interface PointsNodeMaterialParameters extends NodeMaterialParameters, PointsMaterialParameters {
export interface PointsNodeMaterialParameters extends SpriteNodeMaterialParameters {
sizeNode?: Node | null | undefined;
}

export default class PointsNodeMaterial extends NodeMaterial {
readonly isPointsNodeMaterial: true;
export default class PointsNodeMaterial extends SpriteNodeMaterial {
sizeNode: Node | null;

// Properties from PointsMaterial
readonly isPointsMaterial: true;
color: Color;
map: Texture | null;
alphaMap: Texture | null;
size: number;
sizeAttenuation: boolean;
readonly isPointsNodeMaterial: true;

constructor(parameters?: PointsNodeMaterialParameters);
}
3 changes: 3 additions & 0 deletions types/three/src/nodes/TSL.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ export * from "./pmrem/PMREMUtils.js";
// procedural
export * from "./procedural/Checker.js";

// shapes
export * from "./shapes/Shapes.js";

// materialX
export * from "./materialx/MaterialXNodes.js";

Expand Down
6 changes: 3 additions & 3 deletions types/three/src/nodes/accessors/MaterialNode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export type MaterialNodeScope =
| typeof MaterialNode.LINE_GAP_SIZE
| typeof MaterialNode.LINE_WIDTH
| typeof MaterialNode.LINE_DASH_OFFSET
| typeof MaterialNode.POINT_WIDTH
| typeof MaterialNode.POINT_SIZE
| typeof MaterialNode.DISPERSION
| typeof MaterialNode.LIGHT_MAP
| typeof MaterialNode.AO
Expand Down Expand Up @@ -77,7 +77,7 @@ export default class MaterialNode extends Node {
static LINE_GAP_SIZE: "gapSize";
static LINE_WIDTH: "linewidth";
static LINE_DASH_OFFSET: "dashOffset";
static POINT_WIDTH: "pointWidth";
static POINT_SIZE: "size";
static DISPERSION: "dispersion";
static LIGHT_MAP: "light";
static AO: "ao";
Expand Down Expand Up @@ -122,7 +122,7 @@ export const materialLineDashSize: ShaderNodeObject<MaterialNode>;
export const materialLineGapSize: ShaderNodeObject<MaterialNode>;
export const materialLineWidth: ShaderNodeObject<MaterialNode>;
export const materialLineDashOffset: ShaderNodeObject<MaterialNode>;
export const materialPointWidth: ShaderNodeObject<MaterialNode>;
export const materialPointSize: ShaderNodeObject<MaterialNode>;
export const materialDispersion: ShaderNodeObject<MaterialNode>;
export const materialLightMap: ShaderNodeObject<MaterialNode>;
export const materialAO: ShaderNodeObject<MaterialNode>;
Expand Down
4 changes: 4 additions & 0 deletions types/three/src/nodes/shapes/Shapes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Node from "../core/Node.js";
import { NodeRepresentation, ShaderNodeObject } from "../tsl/TSLCore.js";

export const shapeCircle: (coord?: NodeRepresentation) => ShaderNodeObject<Node>;
Loading