Skip to content

Commit

Permalink
Revert "EdgesRenderer to WebGPU"
Browse files Browse the repository at this point in the history
This reverts commit f90c74e.
  • Loading branch information
deltakosh committed Aug 16, 2024
1 parent f90c74e commit 5ea66dc
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 115 deletions.
4 changes: 2 additions & 2 deletions packages/dev/core/src/Rendering/boundingBoxRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ export class BoundingBoxRenderer implements ISceneComponent {
*/
public enabled = true;

/** Shader language used by the renderer */
/** Shader language used by the material */
protected _shaderLanguage = ShaderLanguage.GLSL;

/**
* Gets the shader language used in this renderer.
* Gets the shader language used in this material.
*/
public get shaderLanguage(): ShaderLanguage {
return this._shaderLanguage;
Expand Down
31 changes: 6 additions & 25 deletions packages/dev/core/src/Rendering/edgesRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import { Camera } from "../Cameras/camera";
import { Constants } from "../Engines/constants";
import type { Node } from "../node";

import "../Shaders/line.fragment";
import "../Shaders/line.vertex";
import type { DataBuffer } from "../Buffers/dataBuffer";
import { SmartArray } from "../Misc/smartArray";
import { DrawWrapper } from "../Materials/drawWrapper";
import { ShaderLanguage } from "core/Materials/shaderLanguage";

declare module "../scene" {
export interface Scene {
Expand Down Expand Up @@ -244,7 +245,7 @@ export class EdgesRenderer implements IEdgesRenderer {
*/
public customInstances = new SmartArray<Matrix>(32);

private static _GetShader(scene: Scene, shaderLanguage: ShaderLanguage): ShaderMaterial {
private static _GetShader(scene: Scene): ShaderMaterial {
if (!scene._edgeRenderLineShader) {
const shader = new ShaderMaterial(
"lineShader",
Expand All @@ -254,14 +255,6 @@ export class EdgesRenderer implements IEdgesRenderer {
attributes: ["position", "normal"],
uniforms: ["world", "viewProjection", "color", "width", "aspectRatio"],
uniformBuffers: ["Scene", "Mesh"],
shaderLanguage: shaderLanguage,
extraInitializationsAsync: async () => {
if (shaderLanguage === ShaderLanguage.WGSL) {
await Promise.all([import("../ShadersWGSL/line.vertex"), import("../ShadersWGSL/line.fragment")]);
} else {
await Promise.all([import("../Shaders/line.vertex"), import("../Shaders/line.fragment")]);
}
},
},
false
);
Expand All @@ -276,16 +269,6 @@ export class EdgesRenderer implements IEdgesRenderer {
return scene._edgeRenderLineShader;
}

/** Shader language used*/
protected _shaderLanguage = ShaderLanguage.GLSL;

/**
* Gets the shader language used.
*/
public get shaderLanguage(): ShaderLanguage {
return this._shaderLanguage;
}

/**
* Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
* Beware when you use this class with complex objects as the adjacencies computation can be really long
Expand All @@ -301,10 +284,8 @@ export class EdgesRenderer implements IEdgesRenderer {
this._options = options ?? null;

this._epsilon = epsilon;
const engine = this._source.getScene().getEngine();
if (engine.isWebGPU) {
this._drawWrapper = new DrawWrapper(engine);
this._shaderLanguage = ShaderLanguage.WGSL;
if (this._source.getScene().getEngine().isWebGPU) {
this._drawWrapper = new DrawWrapper(source.getEngine());
}

this._prepareRessources();
Expand All @@ -330,7 +311,7 @@ export class EdgesRenderer implements IEdgesRenderer {
return;
}

this._lineShader = EdgesRenderer._GetShader(this._source.getScene(), this._shaderLanguage);
this._lineShader = EdgesRenderer._GetShader(this._source.getScene());
}

/** @internal */
Expand Down
14 changes: 4 additions & 10 deletions packages/dev/core/src/Rendering/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,7 @@ export * from "../ShadersWGSL/geometry.fragment";
export * from "../ShadersWGSL/geometry.vertex";

// Bounding Box Renderer
export * from "../Shaders/boundingBoxRenderer.fragment";
export * from "../Shaders/boundingBoxRenderer.vertex";
export * from "../ShadersWGSL/boundingBoxRenderer.fragment";
export * from "../ShadersWGSL/boundingBoxRenderer.vertex";

// Edges Renderer
export * from "../Shaders/line.fragment";
export * from "../Shaders/line.vertex";
export * from "../ShadersWGSL/line.fragment";
export * from "../ShadersWGSL/line.vertex";
import "../Shaders/boundingBoxRenderer.fragment";
import "../Shaders/boundingBoxRenderer.vertex";
import "../ShadersWGSL/boundingBoxRenderer.fragment";
import "../ShadersWGSL/boundingBoxRenderer.vertex";
20 changes: 0 additions & 20 deletions packages/dev/core/src/ShadersWGSL/line.fragment.fx

This file was deleted.

58 changes: 0 additions & 58 deletions packages/dev/core/src/ShadersWGSL/line.vertex.fx

This file was deleted.

0 comments on commit 5ea66dc

Please sign in to comment.