Skip to content

Commit

Permalink
Color had to be normalized to [0.1] range. Also disabled lighting for…
Browse files Browse the repository at this point in the history
… uniform color over a cell. (equinor#978)
  • Loading branch information
nilscb authored May 11, 2022
1 parent 34f709a commit 84fbd84
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
11 changes: 7 additions & 4 deletions react/src/lib/components/DeckGLMap/layers/grid/fragment.glsl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ void main(void) {
return;
}
vec3 normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
// KEEP. Disable lighting for now. Better with uniform color pver a cell.
// vec3 normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
// Use normal lighting.
vec3 lightColor = lighting_getLightColor(vColor.rgb, cameraPosition, position_commonspace.xyz, normal);
fragColor = vec4(lightColor, 1.0);
// // Use normal lighting.
// vec3 lightColor = lighting_getLightColor(vColor.rgb, cameraPosition, position_commonspace.xyz, normal);
// fragColor = vec4(lightColor, 1.0);
fragColor = vec4(vColor, 1.0);
}
`;

Expand Down
12 changes: 5 additions & 7 deletions react/src/lib/components/DeckGLMap/layers/grid/gridLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function getColorMapColors(
for (let i = 0; i < 256; i++) {
const value = i / 255.0;
const rgb = rgbValues(value, colorMapName, colorTables);
let color: RGBColor = [155, 255, 255];
let color: RGBColor = [0, 0, 0];
if (rgb != undefined) {
if (Array.isArray(rgb)) {
color = [rgb[0], rgb[1], rgb[2]];
Expand Down Expand Up @@ -308,12 +308,10 @@ function makeVertexesAndColorArrays(

const propertyValue = cell.vs[ti];

const color = getColor(
propertyValue,
colors,
valueRange,
colorMapRange
);
let color = getColor(propertyValue, colors, valueRange, colorMapRange);

// Normalize color.
color = [color[0] / 255.0, color[1] / 255.0, color[2] / 255.0];

// Note. Equal color for all of a triangle vertxes gives constant color in
// a cell which is correct for this layer.
Expand Down

0 comments on commit 84fbd84

Please sign in to comment.