From 0e18eda54ec9eb330fc683e4f70ecf595fff327e Mon Sep 17 00:00:00 2001
From: Alexander Rose <alex.rose@rcsb.org>
Date: Wed, 18 Apr 2018 10:20:58 -0700
Subject: [PATCH] wip, color & lighting tweaks

---
 src/mol-geo/representation/structure/spacefill.ts |  2 +-
 src/mol-gl/renderable/mesh.ts                     | 10 +++++-----
 src/mol-gl/shader/mesh.frag                       |  7 ++++---
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/mol-geo/representation/structure/spacefill.ts b/src/mol-geo/representation/structure/spacefill.ts
index 2890a64b1..3e243611a 100644
--- a/src/mol-geo/representation/structure/spacefill.ts
+++ b/src/mol-geo/representation/structure/spacefill.ts
@@ -70,7 +70,7 @@ export default function Spacefill(): UnitsRepresentation<SpacefillProps> {
             const spheres = createRenderObject('mesh', {
                 position: mesh.vertexBuffer,
                 normal: mesh.normalBuffer,
-                color: { '@type': 'attribute', value: (mesh as any).colorBuffer },
+                color: { type: 'attribute', value: (mesh as any).colorBuffer },
                 transform: ValueCell.create(transformArray),
                 elements: mesh.indexBuffer,
 
diff --git a/src/mol-gl/renderable/mesh.ts b/src/mol-gl/renderable/mesh.ts
index ffc996b9f..37c81bbef 100644
--- a/src/mol-gl/renderable/mesh.ts
+++ b/src/mol-gl/renderable/mesh.ts
@@ -17,9 +17,9 @@ type Mesh = 'mesh'
 
 type Uniforms = { [k: string]: REGL.Uniform | REGL.Texture }
 
-type AttributeColor = { '@type': 'attribute', value: ValueCell<Float32Array> }
-type InstanceColor = { '@type': 'instance', value: ValueCell<ColorTexture> }
-type ElementColor = { '@type': 'element', value: ValueCell<ColorTexture> }
+type AttributeColor = { type: 'attribute', value: ValueCell<Float32Array> }
+type InstanceColor = { type: 'instance', value: ValueCell<ColorTexture> }
+type ElementColor = { type: 'element', value: ValueCell<ColorTexture> }
 type Color = AttributeColor | InstanceColor | ElementColor
 
 namespace Mesh {
@@ -42,7 +42,7 @@ namespace Mesh {
             instanceCount: data.instanceCount,
             ..._uniforms
         }
-        if (data.color['@type'] === 'instance' || data.color['@type'] === 'element') {
+        if (data.color.type === 'instance' || data.color.type === 'element') {
             Object.assign(uniforms, createColorUniforms(regl, data.color.value as ValueCell<ColorTexture>))
         }
         const attributes = getBuffers({
@@ -51,7 +51,7 @@ namespace Mesh {
             normal: Attribute.create(regl, data.normal, data.positionCount, { size: 3 }),
             ...createTransformAttributes(regl, data.transform, data.instanceCount)
         })
-        if (data.color['@type'] === 'attribute') {
+        if (data.color.type === 'attribute') {
             attributes.color = Attribute.create(regl, data.color.value as ValueCell<Float32Array>, data.positionCount, { size: 3 }).buffer
         }
         const command = regl({
diff --git a/src/mol-gl/shader/mesh.frag b/src/mol-gl/shader/mesh.frag
index 2f679b9e9..caa69f0c8 100644
--- a/src/mol-gl/shader/mesh.frag
+++ b/src/mol-gl/shader/mesh.frag
@@ -45,17 +45,18 @@ float orenNayarDiffuse(vec3 lightDirection, vec3 viewDirection, vec3 surfaceNorm
 #pragma glslify: attenuation = require(./attenuation.glsl)
 
 const float specularScale = 0.65;
-const float shininess = 10.0;
+const float shininess = 30.0;
 const float roughness = 5.0;
 const float albedo = 0.95;
 
 void main() {
     // determine surface to light direction
-    vec4 lightPosition = view * vec4(light.position, 1.0);
+    // vec4 lightPosition = view * vec4(light.position, 1.0);
+    vec4 lightPosition = vec4(vec3(0.0, 0.0, -10000.0), 1.0);
     vec3 lightVector = lightPosition.xyz - vViewPosition;
 
     // calculate attenuation
-    float lightDistance = length(lightVector);
+    // float lightDistance = length(lightVector);
     float falloff = 1.0; // attenuation(light.radius, light.falloff, lightDistance);
 
     vec3 L = normalize(lightVector); // light direction
-- 
GitLab