-
Notifications
You must be signed in to change notification settings - Fork 236
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
base: master
Are you sure you want to change the base?
Feat lighting scatter mesh extra #343
Conversation
There was a problem hiding this 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.
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}') |
There was a problem hiding this comment.
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.
near=0.5 | ||
far=5000 |
There was a problem hiding this comment.
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.
// attribute float aux_next; | ||
// attribute float aux_previous; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vec4 view_pos = viewMatrix * vec4(model_pos, 1.0); | |
vec4 view_pos = modelViewMatrix * vec4(model_pos, 1.0); |
oops, my mistake.
|
||
lighting_model: any; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
e861e87
to
6dead3f
Compare
Reach feat_lighting functionality using new feat_lighting_scatter_mesh code