Skip to content

Commit

Permalink
Merge 6f971c2 into 3dd8698
Browse files Browse the repository at this point in the history
  • Loading branch information
tsherif committed Feb 7, 2020
2 parents 3dd8698 + 6f971c2 commit 21b325f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 105 deletions.
Expand Up @@ -21,7 +21,16 @@ void main(void) {
vec3 normal;
if (flatShading) {
// NOTE(Tarek): This is necessary because
// headless.gl reports the extension as
// available but does not support it in
// the shader.
#ifdef DERIVATIVES_AVAILABLE
normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
#else
normal = vec3(0.0, 0.0, 1.0);
#endif
} else {
normal = normals_commonspace;
}
Expand Down

This file was deleted.

This file was deleted.

26 changes: 17 additions & 9 deletions modules/mesh-layers/src/simple-mesh-layer/simple-mesh-layer.js
Expand Up @@ -25,14 +25,12 @@
import {Layer, project32, phongLighting, picking, COORDINATE_SYSTEM, log} from '@deck.gl/core';
import GL from '@luma.gl/constants';
import {Model, Geometry, Texture2D, isWebGL2} from '@luma.gl/core';
import {hasFeature, FEATURES} from '@luma.gl/webgl';

import {MATRIX_ATTRIBUTES, shouldComposeModelMatrix} from '../utils/matrix';

// NOTE(Tarek): Should eventually phase out the glsl1 versions.
import vs1 from './simple-mesh-layer-vertex.glsl1';
import fs1 from './simple-mesh-layer-fragment.glsl1';
import vs3 from './simple-mesh-layer-vertex.glsl';
import fs3 from './simple-mesh-layer-fragment.glsl';
import vs from './simple-mesh-layer-vertex.glsl';
import fs from './simple-mesh-layer-fragment.glsl';

/*
* Convert image data into texture
Expand Down Expand Up @@ -106,11 +104,21 @@ const defaultProps = {

export default class SimpleMeshLayer extends Layer {
getShaders() {
const gl2 = isWebGL2(this.context.gl);
const vs = gl2 ? vs3 : vs1;
const fs = gl2 ? fs3 : fs1;
const transpileToGLSL100 = !isWebGL2(this.context.gl);

return super.getShaders({vs, fs, modules: [project32, phongLighting, picking]});
const defines = {};

if (hasFeature(this.context.gl, FEATURES.GLSL_DERIVATIVES)) {
defines.DERIVATIVES_AVAILABLE = 1;
}

return super.getShaders({
vs,
fs,
modules: [project32, phongLighting, picking],
transpileToGLSL100,
defines
});
}

initializeState() {
Expand Down

0 comments on commit 21b325f

Please sign in to comment.