raysect / source

The main source repository for the Raysect project.
http://www.raysect.org
BSD 3-Clause "New" or "Revised" License
86 stars 23 forks source link

Help: How to modify the surface of a material #342

Closed PaoloZambon closed 4 years ago

PaoloZambon commented 4 years ago

Hi

I would like to model a bare, uncoated, N-BK7 slab, in the shape of a rectangular prism. One face of of the slab is treated with a coating which scatters incoming light as a Lambertian scatterer. I cannot find how to modify only one face of the slab without affecting all faces. Is there any trick to accomplish this?

Additionally, if the task described above is possible, I'd like to cut a circular hole in the coating, thus exposing the bare face of the slab.

I appreciate the help. Thanks, Paolo

CnlPepper commented 4 years ago

At present the material applies to the entire primitive. We don't yet have support for texturing, though you may be able to approximate a solution by modifying a material to have a separate calculation path if the hit coordinate lies within some bounds in the primitive's local coordinate space.

For example:

if hit_point.z > 0.3:
    # perform filtered surface interaction
else:
    # perform unfiltered surface interaction

Every surface point beyond 0.3 m along the z-axis will be filtered. Everything else, unfiltered. Expand in complexity as necessary.

UV mapping and other texturing will appear in raysect in the future, but we currently don't have the resources to make the changes required.

CnlPepper commented 4 years ago

If you need more complex geometry you could use a primitive (not attached to the world, you create a separate root object) to define a volume and just use the inside() method to discriminate if a point is inside or outside the volume. But you'd need to be very familiar with the scenegraph mechanics to pull this off.

mattngc commented 4 years ago

Assuming resolved due to time elapsed. Please reopen if you have further questions.