Feat lighting scatter mesh extra#343
Feat lighting scatter mesh extra#343rinftech-github wants to merge 10 commits intowidgetti:masterfrom
Conversation
maartenbreddels
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
| 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.
| 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.
| lighting_model: any; | |
| lighting_model: any; |
| this.material_rgb.needsUpdate = true; | ||
| this.line_material.needsUpdate = true; | ||
| this.line_material_rgb.needsUpdate = true; | ||
|
|
|
|
||
| @traitlets.default('material') | ||
| def _default_material(self): | ||
| return pythreejs.ShaderMaterial(side=pythreejs.enums.Side.DoubleSide) |
There was a problem hiding this comment.
| 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.default('material') | ||
| def _default_material(self): | ||
| return pythreejs.ShaderMaterial() |
There was a problem hiding this comment.
| 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.
| 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.
| 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