Skip to content
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
2 changes: 1 addition & 1 deletion examples/experimental/tfjs/src/layers/tensor-2d-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class Tensor2DLayer extends BitmapLayer<{
'fs:DECKGL_FILTER_COLOR': `
float normalizedValue = (color.a - colorDomain.x) / (colorDomain.y - colorDomain.x);
vec2 coord = vec2(normalizedValue, 0.5);
color = texture2D(colorScale, coord);
color = texture(colorScale, coord);
`
}
};
Expand Down
8 changes: 5 additions & 3 deletions modules/aggregation-layers/src/heatmap-layer/max-fs.glsl.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export default `\
varying vec4 outTexture;
#version 300 es
in vec4 outTexture;
out vec4 fragColor;
void main() {
gl_FragColor = outTexture;
gl_FragColor.g = outTexture.r / max(1.0, outTexture.a);
fragColor = outTexture;
fragColor.g = outTexture.r / max(1.0, outTexture.a);
}
`;
5 changes: 3 additions & 2 deletions modules/aggregation-layers/src/heatmap-layer/max-vs.glsl.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export default `\
attribute vec4 inTexture;
varying vec4 outTexture;
#version 300 es
in vec4 inTexture;
out vec4 outTexture;

void main()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// THE SOFTWARE.

export default `\
#version 300 es
#define SHADER_NAME triangle-layer-fragment-shader

precision highp float;
Expand All @@ -28,19 +29,21 @@ uniform sampler2D texture;
uniform sampler2D colorTexture;
uniform float aggregationMode;

varying vec2 vTexCoords;
varying float vIntensityMin;
varying float vIntensityMax;
in vec2 vTexCoords;
in float vIntensityMin;
in float vIntensityMax;

out vec4 fragColor;

vec4 getLinearColor(float value) {
float factor = clamp(value * vIntensityMax, 0., 1.);
vec4 color = texture2D(colorTexture, vec2(factor, 0.5));
vec4 color = texture(colorTexture, vec2(factor, 0.5));
color.a *= min(value * vIntensityMin, 1.0);
return color;
}

void main(void) {
vec4 weights = texture2D(texture, vTexCoords);
vec4 weights = texture(texture, vTexCoords);
float weight = weights.r;

if (aggregationMode > 0.5) {
Expand All @@ -54,6 +57,6 @@ void main(void) {

vec4 linearColor = getLinearColor(weight);
linearColor.a *= opacity;
gl_FragColor =linearColor;
fragColor = linearColor;
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// Inspired by screen-grid-layer vertex shader in deck.gl

export default `\
#version 300 es
#define SHADER_NAME heatp-map-layer-vertex-shader

uniform sampler2D maxTexture;
Expand All @@ -29,17 +30,17 @@ uniform vec2 colorDomain;
uniform float threshold;
uniform float aggregationMode;

attribute vec3 positions;
attribute vec2 texCoords;
in vec3 positions;
in vec2 texCoords;

varying vec2 vTexCoords;
varying float vIntensityMin;
varying float vIntensityMax;
out vec2 vTexCoords;
out float vIntensityMin;
out float vIntensityMax;

void main(void) {
gl_Position = project_position_to_clipspace(positions, vec3(0.0), vec3(0.0));
vTexCoords = texCoords;
vec4 maxTexture = texture2D(maxTexture, vec2(0.5));
vec4 maxTexture = texture(maxTexture, vec2(0.5));
float maxValue = aggregationMode < 0.5 ? maxTexture.r : maxTexture.g;
float minValue = maxValue * threshold;
if (colorDomain[1] > 0.) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export default `\
varying vec4 weightsTexture;
#version 300 es
in vec4 weightsTexture;
out vec4 fragColor;
// Epanechnikov function, keeping for reference
// float epanechnikovKDE(float u) {
// return 0.75 * (1.0 - u * u);
Expand All @@ -13,7 +15,7 @@ void main()
if (dist > 0.5) {
discard;
}
gl_FragColor = weightsTexture * gaussianKDE(2. * dist);
DECKGL_FILTER_COLOR(gl_FragColor, geometry);
fragColor = weightsTexture * gaussianKDE(2. * dist);
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export default `\
attribute vec3 positions;
attribute vec3 positions64Low;
attribute float weights;
varying vec4 weightsTexture;
#version 300 es
in vec3 positions;
in vec3 positions64Low;
in float weights;
out vec4 weightsTexture;
uniform float radiusPixels;
uniform float textureWidth;
uniform vec4 commonBounds;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,22 @@

/* fragment shader for the grid-layer */
export default `\
#version 300 es
#define SHADER_NAME screen-grid-layer-fragment-shader

precision highp float;

varying vec4 vColor;
varying float vSampleCount;
in vec4 vColor;
in float vSampleCount;

out vec4 fragColor;

void main(void) {
if (vSampleCount <= 0.0) {
discard;
}
gl_FragColor = vColor;
fragColor = vColor;

DECKGL_FILTER_COLOR(gl_FragColor, geometry);
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
// THE SOFTWARE.

export default `\
#version 300 es
#define SHADER_NAME screen-grid-layer-vertex-shader
#define RANGE_COUNT 6

attribute vec3 positions;
attribute vec3 instancePositions;
attribute vec4 instanceCounts;
attribute vec3 instancePickingColors;
in vec3 positions;
in vec3 instancePositions;
in vec4 instanceCounts;
in vec3 instancePickingColors;

uniform float opacity;
uniform vec3 cellScale;
Expand All @@ -36,8 +37,8 @@ uniform vec2 colorDomain;
uniform bool shouldUseMinMax;
uniform sampler2D maxTexture;

varying vec4 vColor;
varying float vSampleCount;
out vec4 vColor;
out float vSampleCount;

vec4 quantizeScale(vec2 domain, vec4 range[RANGE_COUNT], float value) {
vec4 outColor = vec4(0., 0., 0., 0.);
Expand All @@ -62,7 +63,7 @@ void main(void) {
vSampleCount = instanceCounts.a;

float weight = instanceCounts.r;
float maxWeight = texture2D(maxTexture, vec2(0.5)).r;
float maxWeight = texture(maxTexture, vec2(0.5)).r;

float step = weight / maxWeight;
vec4 minMaxColor = mix(minColor, maxColor, step) / 255.;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@
// THE SOFTWARE.

export default `\
#version 300 es
#define SHADER_NAME gpu-aggregation-to-grid-fs

precision highp float;

varying vec3 vWeights;
in vec3 vWeights;

out vec4 fragColor;

void main(void) {
gl_FragColor = vec4(vWeights, 1.0);
DECKGL_FILTER_COLOR(gl_FragColor, geometry);
fragColor = vec4(vWeights, 1.0);
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@
// THE SOFTWARE.

export default `\
#version 300 es
#define SHADER_NAME gpu-aggregation-to-grid-vs

attribute vec3 positions;
attribute vec3 positions64Low;
attribute vec3 weights;
in vec3 positions;
in vec3 positions64Low;
in vec3 weights;
uniform vec2 cellSize;
uniform vec2 gridSize;
uniform bool projectPoints;
uniform vec2 translation;
uniform vec3 scaling;

varying vec3 vWeights;
out vec3 vWeights;

vec2 project_to_pixel(vec4 pos) {
vec4 result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
// THE SOFTWARE.

export default `\
#version 300 es
#define SHADER_NAME gpu-aggregation-transform-mean-vs
attribute vec4 aggregationValues;
varying vec4 meanValues;
in vec4 aggregationValues;
out vec4 meanValues;

void main()
{
Expand Down
35 changes: 19 additions & 16 deletions modules/arcgis/src/commons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,26 @@ export function initializeResources(device: Device) {
this.buffer = device.createBuffer(new Int8Array([-1, -1, 1, -1, -1, 1, 1, 1]));

this.model = new Model(device, {
vs: `
attribute vec2 a_pos;
varying vec2 v_texcoord;
void main(void) {
gl_Position = vec4(a_pos, 0.0, 1.0);
v_texcoord = (a_pos + 1.0) / 2.0;
}
vs: `\
#version 300 es
in vec2 a_pos;
out vec2 v_texcoord;
void main(void) {
gl_Position = vec4(a_pos, 0.0, 1.0);
v_texcoord = (a_pos + 1.0) / 2.0;
}
`,
fs: `
precision mediump float;
uniform sampler2D u_texture;
varying vec2 v_texcoord;
void main(void) {
vec4 rgba = texture2D(u_texture, v_texcoord);
rgba.rgb *= rgba.a;
gl_FragColor = rgba;
}
fs: `\
#version 300 es
precision mediump float;
uniform sampler2D u_texture;
in vec2 v_texcoord;
out vec4 fragColor;
void main(void) {
vec4 rgba = texture(u_texture, v_texcoord);
rgba.rgb *= rgba.a;
fragColor = rgba;
}
`,
attributes: {
// eslint-disable-next-line camelcase
Expand Down
24 changes: 15 additions & 9 deletions modules/core/src/effects/post-process-effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,33 +84,39 @@ function createPasses(device: Device, module: ShaderModule, id: string): ScreenP
}

const FILTER_FS_TEMPLATE = func => `\
#version 300 es
uniform sampler2D texture;
uniform vec2 texSize;

varying vec2 position;
varying vec2 coordinate;
varying vec2 uv;
in vec2 position;
in vec2 coordinate;
in vec2 uv;

out vec4 fragColor;

void main() {
vec2 texCoord = coordinate;

gl_FragColor = texture2D(texture, texCoord);
gl_FragColor = ${func}(gl_FragColor, texSize, texCoord);
fragColor = texture(texture, texCoord);
fragColor = ${func}(fragColor, texSize, texCoord);
}
`;

const SAMPLER_FS_TEMPLATE = func => `\
#version 300 es
uniform sampler2D texture;
uniform vec2 texSize;

varying vec2 position;
varying vec2 coordinate;
varying vec2 uv;
in vec2 position;
in vec2 coordinate;
in vec2 uv;

out vec4 fragColor;

void main() {
vec2 texCoord = coordinate;

gl_FragColor = ${func}(texture, texSize, texCoord);
fragColor = ${func}(texture, texSize, texCoord);
}
`;

Expand Down
6 changes: 3 additions & 3 deletions modules/core/src/shaderlib/shadow/shadow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ uniform bool shadow_uUseShadowMap;
uniform int shadow_uLightId;
uniform float shadow_uLightCount;

varying vec3 shadow_vPosition[max_lights];
out vec3 shadow_vPosition[max_lights];

vec4 shadow_setVertexPosition(vec4 position_commonspace) {
if (shadow_uDrawShadowMap) {
Expand All @@ -64,14 +64,14 @@ uniform sampler2D shadow_uShadowMap1;
uniform vec4 shadow_uColor;
uniform float shadow_uLightCount;

varying vec3 shadow_vPosition[max_lights];
in vec3 shadow_vPosition[max_lights];

const vec4 bitPackShift = vec4(1.0, 255.0, 65025.0, 16581375.0);
const vec4 bitUnpackShift = 1.0 / bitPackShift;
const vec4 bitMask = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);

float shadow_getShadowWeight(vec3 position, sampler2D shadowMap) {
vec4 rgbaDepth = texture2D(shadowMap, position.xy);
vec4 rgbaDepth = texture(shadowMap, position.xy);

float z = dot(rgbaDepth, bitUnpackShift);
return smoothstep(0.001, 0.01, position.z - z);
Expand Down
Loading