Skip to content
Closed
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
15 changes: 14 additions & 1 deletion modules/layers/src/bitmap-layer/bitmap-layer-fragment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ uniform sampler2D bitmapTexture;

in vec2 vTexCoord;
in vec2 vTexPos;
in vec3 cameraPosition;
in vec4 position_commonspace;

out vec4 fragColor;

Expand Down Expand Up @@ -110,11 +112,22 @@ void main(void) {
}
vec4 bitmapColor = texture(bitmapTexture, uv);

fragColor = apply_opacity(color_tint(color_desaturate(bitmapColor.rgb)), bitmapColor.a * layer.opacity);
vec3 bitmapColorRgb = color_tint(color_desaturate(bitmapColor.rgb));
fragColor = apply_opacity(bitmapColorRgb, bitmapColor.a * layer.opacity);

geometry.uv = uv;
DECKGL_FILTER_COLOR(fragColor, geometry);

if (!bool(picking.isActive)) {
vec3 normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
fragColor.rgb = lighting_getLightColor(
fragColor.rgb,
cameraPosition,
position_commonspace.xyz,
normal
);
}

if (bool(picking.isActive) && !bool(picking.isAttribute)) {
// Since instance information is not used, we can use picking color for pixel index
fragColor.rgb = packUVsIntoRGB(uv);
Expand Down
4 changes: 4 additions & 0 deletions modules/layers/src/bitmap-layer/bitmap-layer-vertex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ in vec3 positions64Low;

out vec2 vTexCoord;
out vec2 vTexPos;
out vec3 cameraPosition;
out vec4 position_commonspace;

const vec3 pickingColor = vec3(1.0, 0.0, 0.0);

Expand All @@ -21,6 +23,8 @@ void main(void) {
geometry.pickingColor = pickingColor;

gl_Position = project_position_to_clipspace(positions, positions64Low, vec3(0.0), geometry.position);
position_commonspace = geometry.position;
cameraPosition = project.cameraPosition;
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);

vTexCoord = texCoords;
Expand Down
16 changes: 14 additions & 2 deletions modules/layers/src/bitmap-layer/bitmap-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import {
Color,
TextureSource,
Position,
DefaultProps
DefaultProps,
Material,
phongMaterial
} from '@deck.gl/core';
import {Model} from '@luma.gl/engine';
import type {SamplerProps, Texture} from '@luma.gl/core';
Expand All @@ -38,6 +40,8 @@ const defaultProps: DefaultProps<BitmapLayerProps> = {
transparentColor: {type: 'color', value: [0, 0, 0, 0]},
tintColor: {type: 'color', value: [255, 255, 255]},

material: true,

textureParameters: {type: 'object', ignore: true, value: null}
};

Expand Down Expand Up @@ -92,6 +96,14 @@ type _BitmapLayerProps = {
*/
tintColor?: Color;

/**
* Material settings for lighting effect.
*
* @default true
* @see https://deck.gl/docs/developer-guide/using-lighting
*/
material?: Material;

/** Customize the [texture parameters](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texParameter). */
textureParameters?: SamplerProps | null;
};
Expand Down Expand Up @@ -129,7 +141,7 @@ export default class BitmapLayer<ExtraPropsT extends {} = {}> extends Layer<
};

getShaders() {
return super.getShaders({vs, fs, modules: [project32, picking, bitmapUniforms]});
return super.getShaders({vs, fs, modules: [project32, phongMaterial, picking, bitmapUniforms]});
}

initializeState() {
Expand Down
9 changes: 8 additions & 1 deletion test/modules/layers/bitmap-layer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ test('BitmapLayer#constructor', () => {
testCases: [
{
title: 'Empty layer',
props: {id: 'empty'}
props: {id: 'empty'},
onAfterUpdate({layer}) {
const modules = layer
.getModels()[0]
.shaderInputs.getModules()
.map(module => module.name);
expect(modules, 'uses lighting material shader module').toContain('phongMaterial');
}
},
{
title: 'Null layer',
Expand Down
Binary file modified test/render/golden-images/bitmap-imagecoordinates.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/render/golden-images/bitmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading