Skip to content

Commit 08cc803

Browse files
committed
Sorted out gamma correction issues
1 parent f0ef113 commit 08cc803

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

polykit/renderers/backends.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ def interactive(self, intensity=0.4, standalone=True):
3535
Set to True if called within standalone script
3636
"""
3737

38-
self.scene.lights.append(fl.light.Light(direction=[0,0,1], color=[intensity]*3, theta=np.pi))
38+
self.scene.lights.append(fl.light.Light(direction=[0,0,1],
39+
color=[intensity]*3,
40+
theta=np.pi))
3941

4042
view = interact.SceneView(self.scene)
4143

@@ -104,7 +106,7 @@ def _fresnel(self,
104106
List of 3D positions of the monomers to be displayed
105107
bonds : Mx2 int array
106108
List of pairwise inter-monomer bonds to be displayed
107-
colors : Nx3 float array
109+
colors : Nx3 or Nx4 float array
108110
List of RGB colors to be assigned to each monomer
109111
radii : Mx1 float array
110112
List of bond/particle radii
@@ -125,12 +127,14 @@ def _fresnel(self,
125127
"""
126128

127129
scene = fl.Scene()
128-
129-
geometry = fl.geometry.Cylinder(scene, N=bonds.shape[0], outline_width=outline)
130130

131+
geometry = fl.geometry.Cylinder(scene, N=bonds.shape[0], outline_width=outline)
132+
131133
geometry.points[:] = positions[bonds]
132134
geometry.radius[:] = radii[bonds].min(axis=1)
133-
geometry.color[:] = fl.color.linear(colors[bonds].reshape(-1, 3)).reshape((-1, 2, 3))
135+
136+
corrected_colors = fl.color.linear(colors)
137+
geometry.color[:] = corrected_colors[bonds]
134138

135139
geometry.material = fl.material.Material(color=fl.color.linear([.25,.25,.25]),
136140
roughness=roughness,
@@ -157,7 +161,8 @@ def _fresnel(self,
157161

158162
geometry2.radius[:] = radii[polymer_mask]
159163
geometry2.position[:] = positions[polymer_mask]
160-
geometry2.color[:] = fl.color.linear(colors[polymer_mask])
164+
165+
geometry2.color[:] = corrected_colors[polymer_mask]
161166

162167
geometry2.material = geometry.material
163168
geometry2.outline_material = geometry.material.outline_material

0 commit comments

Comments
 (0)