Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat lighting scatter mesh extra #343

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

rinftech-github
Copy link

Reach feat_lighting functionality using new feat_lighting_scatter_mesh code

Copy link
Collaborator

@maartenbreddels maartenbreddels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gave myself a review, but a second pair of eyes would be great, also gave some idea what to do.

Comment on lines +609 to +621
kwargs = kwargs.copy()
if lighting_model == 'DEFAULT':
pass # ok, we rely on Scatter widget's default
elif lighting_model == 'PHYSICAL':
material = pythreejs.MeshPhysicalMaterial(
opacity=opacity,
emissiveIntensity=emissive_intensity,
roughness=roughness,
metalness=metalness)
kwargs['material'] = material
else:
# TODO: PHONG/LAMBERT
raise ValueError(f'Unknown lighting_model={lighting_model}')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is quite similar to scatter, and something we want at a lot of places, maybe put it in a private function _create_material(....) to reuse it.

Comment on lines +1729 to +1730
near=0.5
far=5000
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.1, 100 seems like good default for the others.

Comment on lines +46 to +47
// attribute float aux_next;
// attribute float aux_previous;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to disable aux, because we are using too many attributes (16 is the max), that is because if we set USE_COLOR, color is also an attribute. I'll think about how to solve this.

@@ -112,25 +309,106 @@ void main(void) {
vec4 position_transformed = geo_matrix * vec4(position, 1.0);
position_transformed.xyz = position_transformed.xyz / position_transformed.w;
model_pos += move_to_vector * (position_transformed.xyz*size_vector);
vec4 view_pos = modelViewMatrix * vec4(model_pos, 1.0);
vec4 view_pos = viewMatrix * vec4(model_pos, 1.0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
vec4 view_pos = viewMatrix * vec4(model_pos, 1.0);
vec4 view_pos = modelViewMatrix * vec4(model_pos, 1.0);

oops, my mistake.

Comment on lines +35 to +37

lighting_model: any;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
lighting_model: any;
lighting_model: any;

@@ -458,6 +470,8 @@ class ScatterView extends widgets.WidgetView {
this.material_rgb.needsUpdate = true;
this.line_material.needsUpdate = true;
this.line_material_rgb.needsUpdate = true;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

traitlets.Instance(pythreejs.MeshPhysicalMaterial),
traitlets.Instance(pythreejs.MeshPhongMaterial),
traitlets.Instance(pythreejs.MeshLambertMaterial),
], help='A :any:`pythreejs.Material` that is used for the mesh').tag(sync=True, **widgets.widget_serialization)

@traitlets.default('material')
def _default_material(self):
return pythreejs.ShaderMaterial(side=pythreejs.enums.Side.DoubleSide)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return pythreejs.ShaderMaterial(side=pythreejs.enums.Side.DoubleSide)
return pythreejs.ShaderMaterial(side=pythreejs.enums.Side.DoubleSide, lights=True)

we could this, and remove the this.lights = true in the js code (mesh.ts), which makes it slightly more flexible.

traitlets.Instance(pythreejs.MeshPhysicalMaterial),
traitlets.Instance(pythreejs.MeshPhongMaterial),
traitlets.Instance(pythreejs.MeshLambertMaterial),
], help='A :any:`pythreejs.Material` that is used for the mesh').tag(sync=True, **widgets.widget_serialization)

@traitlets.default('material')
def _default_material(self):
return pythreejs.ShaderMaterial()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return pythreejs.ShaderMaterial()
return pythreejs.ShaderMaterial(lights=True)

Same here, we could remove the this.material.lights = true in scatter.ts

patchShader(shader);
};
material.needsUpdate = true;
material.lights = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
material.lights = true;

No need for this if we set it in the ShaderMaterial constructor from the Python side (Phong, Physical etc don't seem to need this)

material.needsUpdate = true;
patchMaterial(material);
material.lights = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
material.lights = true;

No need for this if we set it in the ShaderMaterial constructor from the Python side (Phong, Physical etc don't seem to need this)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants