TheRaytracers / freecad-povray-render

FreeCAD workbench to render images of your model easily.
GNU Lesser General Public License v2.1
6 stars 1 forks source link

Rendering extra details #1

Open leoheck opened 3 years ago

leoheck commented 3 years ago

First of all, pretty nice repo. I started to use the raytracing workbench with pov-ray last week. Then every time I had to tweak and change everything by hand after exporting the design. With this workbench I don't need this much of a tweak, this is awesome.

Alright, straight to the point. I am trying to simulate the behavior of a light pipe. This is a small acrylic plastic that is used inside devices to move the light from one LED to another point, for instance, in the interface of a case.

I am pretty new to what I am doing and what I want to achieve. But maybe this plugin could have or has a way to define internal reflection and parameters like that.

In short, this is what I want to achieve http://www.imagico.de/pov/metamaterials.php

This is the code I am using to create this.

#include "glass.inc"

#declare M_light_pipe = material {
    texture {
        pigment {
            color rgbf <1.0, 0.73333, 0.0, 0.8>
        }
        finish { F_Glass2 } // Behaves as an acrylic plastic
    }
    interior { 
        I_Glass 
        caustics 1.0 
        ior 1.4
        dispersion 10.0
        dispersion_samples 10
        fade_distance 0.1
        fade_power 0.2
        fade_color <1.0, 0.73333, 0.0>
    }
};

object {
    Display
    material { 
        M_light_pipe 
    }
    texture {
        pigment {
            color rgb <1, 1, 1> transmit 0.9
        }
        finish { StdFinish }
  }
}

My question is, does this plugin have a way to change these settings especially this internal and the ior?

If not, It would be nice to have a way to insert code manually before rendering, so it could be a txt object inside of the Freecad, with extra code to add, then it adds automatically before rendering something.

What do you think?

TheRaytracers commented 3 years ago

First of all, pretty nice repo. I started to use the raytracing workbench with pov-ray last week. Then every time I had to tweak and change everything by hand after exporting the design. With this workbench I don't need this much of a tweak, this is awesome.

Thanks, you're welcome :)

My question is, does this plugin have a way to change these settings especially this internal and the ior?

If not, It would be nice to have a way to insert code manually before rendering, so it could be a txt object inside of the Freecad, with extra code to add, then it adds automatically before rendering something.

You can use the name_user.inc file, where you can insert your code and / or apply own materials. On this wiki page the concept is explained: Power User

Considering the POV-Ray code: I'm not an expert for visible laser beams and refraction so I can't help you in this area. Unfortunately the official POV-Ray-sites are offline due to a hardware failure (visit their website povray.org for details), so also the very good Wiki of them is offline. But maybe this could be a good starting point: Tutorial: visible (laser) light beams with povray
When their forum is online again, I also can recommend it very much!

leoheck commented 3 years ago

Yeah, it is pretty hard to find material now. I am using cached versions of the pages on Google. Thanks for the explanations and the references.

I found this, with really good examples https://melusine.eu.org/syracuse/pstricks/pst-caustic/

I was also able to make and share an initial syntax highlight for povray for Sublime Text if anyone is interested. https://packagecontrol.io/packages/PovRay

TheRaytracers commented 3 years ago

Fortunately the POV-Ray server are online again!

Although I don't speak French, the page you linked is extremely helpful! I created a minimal example including a lens and a laser beam with FreeCAD, the workbench and POV-Ray: LaserTest.zip
This example is pretty computionally intense, due to the medium to see the beam. For testing purposes you should use a plane instead of a medium to see the light beams.

As far as I understand, light pipes are based on the principle of total reflection. I didn't test it, but I think POV-Ray should support this feature because it is inharent to refraction.

The files of the minimal example should be attached.

TheRaytracers commented 3 years ago

Yes, total reflection works, see this picture: scene (50)

Unfortunately, I do not know how to make it so that the laser beam is also displayed inside the lens.

Considering directly your original question: Probably you have to create a spline of many spheres as a light pipe and put a cylindrical light at the beginning of it.
I created a small macro a few months ago to simplify the creation of splines for POV-Ray. If you want, I can look it up again.

leoheck commented 3 years ago

This is pretty cool. I am creating this small LED light already, thanks for the tip. I am not particularly interested in seeing inside the object but in the interface where it leaves it, so I could check of the light pipe is going to work as expected or not.

image

This image shows a simple example of something that I would like to see working. If I could replicate this, I would be confident to try more complex shapes, and then it could help me to decide if this is a good candidate for a try in a real-life by manufacturing it 3d printing it using for instance SLS.

leoheck commented 3 years ago

By the way, thanks for sharing your Freecad model too.

TheRaytracers commented 3 years ago

It seems to work, see the attachment: All files are in the ZIP file. This time, I commented out the medium to increase the speed of the renderings drastically (now you only see the result on the visor). LightPipe.zip LightPipe_arc (1) LightPipe_straight (1)

leoheck commented 3 years ago

Pretty amazing @TheRaytracers thank you so much for these examples.

TheRaytracers commented 3 years ago

Pretty amazing @TheRaytracers thank you so much for these examples.

You're welcome :)

leoheck commented 3 years ago

I was playing with your 3d models and POV files @TheRaytracers. I removed the plane since it is not very important for me. It is interesting to see how similar these results are from the previews image which I believe are from real objects (I got them on Google).

portfolio_view portfolio_view

Quick question @TheRaytracers is it possible to tweak the roughness of the input and output planes of the given objects? For instance, it seems to me that if we have a rough face/area it will be easier for light to pass through. More light will pass because less light will be reflected back. This is just my thought, but I would like to test this too. Do you know if it is possible to have such a configuration?

TheRaytracers commented 3 years ago

Sorry for the late reply.

Do you mean this faces with "input" and "output plane"?
image

In general, you can use normals to create surfaces, where the light gets refracted in another way. There is already a predefined texture for it, called "Milky Glass". Here are a few renderings with different scales of the texture: LightPipe_straight (12) LightPipe_straight (13) LightPipe_straight (14)

leoheck commented 3 years ago

Yes, you are correct. This is what I was trying to do. image

TheRaytracers commented 3 years ago

If you only want the highlighted surfaces are rough, you can apply the "Milky Glass" texture to boxes that are subtracted from the beginning and end of the pipe: image

Then the rough surface of the boxes is applied to the input and output plane.

leoheck commented 3 years ago

That is a good idea. I have to test this. I will get back here if I can make something good to share.

leoheck commented 3 years ago

So just thinking deeper. I can make the plane you are using, small, and place it right in front of the output of the light pipe. With the milky glass texture you described, and then it may be enough to have something close to what I will see in real life, right?

TheRaytracers commented 3 years ago

So just thinking deeper. I can make the plane you are using, small, and place it right in front of the output of the light pipe. With the milky glass texture you described, and then it may be enough to have something close to what I will see in real life, right?

I'm not deep into the real surface texture of glass fibers or plastic (which is what light pipes are mostly made of), so I can't say exactly where the difference between model and reality lies (even though your results are pretty close to reality). But you can definitely try to assign the Milky Glass texture to the highlighted blocks from my last post and subtract them from the light pipe.