Skip to content
Snippets Groups Projects
Commit c5f08ace authored by Alexander Rose's avatar Alexander Rose
Browse files

coloring improvements

parent 4f7d6bdc
No related branches found
No related tags found
No related merge requests found
......@@ -70,7 +70,7 @@ export async function StructureView(app: App, viewer: Viewer, models: ReadonlyAr
const active: { [k: string]: boolean } = {
cartoon: true,
point: false,
surface: true,
surface: false,
ballAndStick: false,
carbohydrate: false,
spacefill: false,
......
......@@ -48,6 +48,20 @@ uniform sampler2D tMarker;
#pragma glslify: texture3dFrom2dNearest = require(./utils/texture3d-from-2d-nearest.glsl)
#pragma glslify: texture3dFrom2dLinear = require(./utils/texture3d-from-2d-linear.glsl)
// uniform vec3 uLightPosition;
uniform vec3 uLightColor;
uniform vec3 uLightAmbient;
uniform mat4 uView;
#pragma glslify: attenuation = require(./utils/attenuation.glsl)
#pragma glslify: calculateSpecular = require(./utils/phong-specular.glsl)
#pragma glslify: calculateDiffuse = require(./utils/oren-nayar-diffuse.glsl)
const float specularScale = 0.15;
const float shininess = 200.0;
const float roughness = 100.0;
const float albedo = 0.95;
#if defined(dGridTexType_2d)
vec4 textureVal(vec3 pos) {
return texture3dFrom2dLinear(tGridTex, pos, uGridDim, uGridTexDim);
......@@ -135,7 +149,19 @@ vec4 raymarch(vec3 startLoc, vec3 step, vec3 viewDir) {
color = readFromTexture(tColor, instance * float(uGroupCount) + group, uColorTexDim).rgb;
#endif
src.rgb = color * abs(dot(gradient, viewDir));
vec3 L = normalize(viewDir); // light direction
vec3 V = normalize(viewDir); // eye direction
vec3 N = normalize(gradient); // surface normal
// compute our diffuse & specular terms
float specular = calculateSpecular(L, V, N, shininess) * specularScale;
vec3 diffuse = uLightColor * calculateDiffuse(L, V, N, roughness, albedo);
vec3 ambient = uLightAmbient;
// add the lighting
vec3 finalColor = color.rgb * (diffuse + ambient) + specular;
src.rgb = finalColor;
src.a = uAlpha;
float marker = readFromTexture(tMarker, instance * float(uGroupCount) + group, uMarkerTexDim).a * 256.0;
......
......@@ -15,7 +15,7 @@ uniform vec3 uLightColor;
uniform vec3 uLightAmbient;
uniform mat4 uView;
#ifndef dFlatShaded
#if !defined(dFlatShaded) || !defined(enabledStandardDerivatives)
varying vec3 vNormal;
#endif
......@@ -23,9 +23,9 @@ uniform mat4 uView;
#pragma glslify: calculateSpecular = require(./utils/phong-specular.glsl)
#pragma glslify: calculateDiffuse = require(./utils/oren-nayar-diffuse.glsl)
const float specularScale = 0.65;
const float shininess = 100.0;
const float roughness = 5.0;
const float specularScale = 0.15;
const float shininess = 200.0;
const float roughness = 100.0;
const float albedo = 0.95;
void main() {
......@@ -45,7 +45,7 @@ void main() {
vec3 V = normalize(vViewPosition); // eye direction
// surface normal
#ifdef dFlatShaded
#if defined(dFlatShaded) && defined(enabledStandardDerivatives)
vec3 fdx = dFdx(vViewPosition);
vec3 fdy = dFdy(vViewPosition);
vec3 N = -normalize(cross(fdx, fdy));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment