Skip to content

Commit

Permalink
add lightning macros in box and sphere programs, missing in 53c770e
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Deubler <[email protected]>
  • Loading branch information
TerminalTim committed Sep 4, 2024
1 parent 53c770e commit 67b0cfb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/display/src/displays/webgl/program/Box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import fragmentShader from '../glsl/box_fragment.glsl';

import Program from './Program';
import {GLStates} from './GLStates';
import {GeometryBuffer} from '../buffer/GeometryBuffer';


class BoxProgram extends Program {
Expand All @@ -35,9 +36,22 @@ class BoxProgram extends Program {
depth: true
});

static getProgramId(buffer: GeometryBuffer, macros?: { [name: string]: string | number | boolean }) {
const specular = <number>macros?.SPECULAR;
return specular ? buffer.type + specular : buffer.type;
}

static getMacros(buffer: GeometryBuffer) {
const {uniforms} = buffer;
let macros;
if (uniforms.specular) {
macros = {SPECULAR: 2};
}
return macros;
}

constructor(gl: WebGLRenderingContext, devicePixelRation: number, macros?: { [name: string]: string | number | boolean }) {
super(gl, devicePixelRation, macros);

this.mode = gl.TRIANGLES;
this.vertexShaderSrc = vertexShader;
this.fragmentShaderSrc = fragmentShader;
Expand Down
15 changes: 15 additions & 0 deletions packages/display/src/displays/webgl/program/Sphere.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,26 @@
*/

import BoxProgram from './Box';
import {GeometryBuffer} from '../buffer/GeometryBuffer';


class SphereProgram extends BoxProgram {
name = 'Sphere';

static getProgramId(buffer: GeometryBuffer, macros?: { [name: string]: string | number | boolean }) {
const specular = <number>macros?.SPECULAR;
return specular ? buffer.type + specular : buffer.type;
}

static getMacros(buffer: GeometryBuffer) {
const {uniforms} = buffer;
let macros;
if (uniforms.specular) {
macros = {SPECULAR: 2};
}
return macros;
}

constructor(gl: WebGLRenderingContext, devicePixelRation: number) {
super(gl, devicePixelRation, {SPHERE: true});
}
Expand Down

0 comments on commit 67b0cfb

Please sign in to comment.