Hacker News new | past | comments | ask | show | jobs | submit login
Inkscape Ray Tracing – an extension for Inkscape to draw optical diagrams (github.com/damienbloch)
276 points by app4soft on Feb 6, 2021 | hide | past | favorite | 36 comments



As an academic, this is exactly the kind of tool that is perfect for teaching and making exam questions with the minimum of fuss. Thank you for doing it, and thank HN for bringing it to my attention!


JFTR, Also take a look on Astree[0] & Foucault2[1].

[0] https://github.com/edeforas/Astree

[1] https://github.com/edeforas/Foucault2


Happy to know it can be useful! Just keep in mind that it's still fairly bugged for an extensive usage. Because the issue is maybe with the way Inkscape handles python extensions, it might take a bit before it'll be stable.


I’m very excited about this. But I’m I’m also interested to hear why you chose to build this instead of using Zemax’s sequential mode. I’ve written two bespoke ray tracers in my career and to this day I wonder if I should have written them as zemax extensions. Is it just cost?


Zemax would definitely be a more professional option, but I never got the opportunity to dive into it. Also this is more for quick plots than for complex optics


> Zemax would definitely be a more professional option

Astree — a FLOSS alternative to Zemax.[0]

[0] https://github.com/edeforas/Astree


It’s almost definitely cost! Zemax is what, a 5-digit price for the full pack? Prohibitively expensive for anyone but those deep inside the industry who really get their bang for the buck.


When it is, are there any plans to put it on https://inkscape.org/gallery/=extension/?


If people can find a use for it, this might be a good idea. But haven't discussed this yet


Could you use this to rough out a Koehler illumination? I'm playing with UC2 (https://github.com/bionanoimaging/UC2-GIT) and one of the projects is to build a KI scope (https://github.com/bionanoimaging/UC2-GIT/tree/master/TheBOX...) leading up to abbe experiment.

I mainly want to be able to plug in different objective lens strengths and experiment with the overall system geometry.


> Could you use this to rough out a Koehler illumination?

Please, ask extension dev via issues tracker.[0]

UPD: Dev is here now![1]

[0] https://github.com/damienBloch/inkscape-raytracing/issues

[1] https://news.ycombinator.com/user?id=damienbloch


I'd like to to add simple tools someday (like ABCD matrices along a beam). But at some point it's probably better to switch to more evolved softwares, like the ones mentioned in the thread


JFTR, A simple ray tracing showing the concept of Koehler illumination.[0]

[0] https://www.researchgate.net/figure/A-simple-ray-tracing-sho...


So, I do not personally have a use for this, but I have always wanted to see how to make an Inkscape plugin and this is an excellent example.

Thank you!


This is so cool and I would have loved to have had this while I was still an academic for diagrams and interactively playing around with setups. For real design, of course the maths gets harder and the software get more expensive. The closest alternatives that I found before were optgeo[1] and OpticalRayTracer[2] but an inkscape plugin like this is much more useful for making diagrams for article, posters and presentation.

[1] http://jeanmarie.biansan.free.fr/optgeo.html [2] https://arachnoid.com/OpticalRayTracer/


> The closest alternatives that I found

As said here few times, try Astree[0] & Foucault2[1] (FLOSS alternatives to Zemax software).

[0] https://github.com/edeforas/Astree

[1] https://github.com/edeforas/Foucault2


Wow this is very cool.

I am sorry to hijack this thread to ask a related question. Does anyone know if libraries or programs exist that can model light rays in 3D for objects without circular base, for instance for modelling head lamps on cars and such?


> Does anyone know if libraries or programs exist that can model light rays in 3D for objects without circular base, for instance for modelling head lamps on cars and such?

I guess there are already such addons for Blender app, but I'm not sure what exactly you need, so it would be better to ask such question in Blender Community places[0].

Take a look on those two.[1,2]

[0] https://www.blender.org/community/

[1] https://github.com/CodeFHD/OptiCore

[2] https://github.com/TobiasNils/Ray-Optics-Analyzer


I vaguely remember reading about a job that required Open Cascade, to do this (designing optics for automotive applications), if that's what you're seeking. Company was called DBM Reflex in Laval, QC I'm sure other tools (ie. game engines) will also allow you to model all types of optical effects.


Game engines generally aren't able to model optical phenomena very well, but some rendering engines that use unbiased path tracing, especially if using spectral colours, can do so very well, to the point where they can be used in physics research. Some are guaranteed to tend towards the physically correct solution as long as the material functions are correct.


The absolute best tool for this is LuxRender, which comes with a Blender extension. It is quite accurate.

Otherwise, Mitsuba also works, and the new version even provides differentiable rendering.


Not adding anything to this conversation, but...

Such a delightful find, thank you for sharing!


Inkscape traces images and converts them to SVG, right? Can this be scripted from the command line? I want to convert a line drawing into an SVG.


Inkscape's tracing functionality uses the `potrace` command line program.



Could this be used as a simple lens designer? Or are there better programs for than?


> Or are there better programs for than?

There's the rayopt[1] Python library. You can find a repo of notebooks modelling a bunch of lenses from the original patents here[2]. I've played around a bit with that myself, modelling a Voigtländer Color-Skopar.

[1] https://github.com/quartiq/rayopt [2] https://github.com/quartiq/rayopt-notebooks


Very cool, thank you!


> Could this be used as a simple lens designer? Or are there better programs for than?

Take a look on Etienne de Foras'[0] Astree[1] (an amateur telescope making FLOSS app to help with optical design and optimisation) and on Foucault2[2] (an amateur telescope making FLOSS app to help with mirror design and polishing).

Astree in most cases is enough alternative to proprietary Zemax (+ Astree already support ZMX file format).[3]

[0] http://edeforas.free.fr/?cat=6

[1] https://github.com/edeforas/Astree

[2] https://github.com/edeforas/Foucault2

[3] https://github.com/edeforas/Astree/issues/28


These both look really interesting too, thanks!


Speaking about it, has anyone experience using a laser cutter to create fresnel lens, out of transparent plastic?

At some point I want to do this, and this plugin might seem helpful.


Seems like it, rays seem to be accurately refracted between object boundaries, depending on the optical index you set for that object. Pretty cool!


That's not actually Ray Tracing as that supports only a single ray sample that's not used to produce a rasterized realistic Image but is instead for creating a diagram of a Ray Path on a 2D simulated Optical experiment Table.

It's only tracing a Path in 2D and for visualizing the ray path and not really using that for actual AO, Shadow, Ambient Occlusion, etc on a 3D Image for realistic image production.

It's a nice tool for the Optical Experimenters out there to Produce SVG based Graphical representations for Publishing their works in Optics/Related fields but that's not Ray Tracing in the way that's used in say Blender 3D's Cycles Rendering(On CPU core or GPU Shader Cores) where photo realistic Images are Produced Using Simulated Rays in a simulated 3D environment/Scene.


I do optics design, and use "ray tracing" to analyze optical systems -- lenses, mirrors, etc. So imagine my surprise when I see a link for "ray tracing," and it's some graphical rendering that I can't fathom or use.

It is actually the same thing, but applied to different areas of interest. In both cases it uses equations from physics to form a simulation of light propagation that is accurate enough under certain conditions.

Optical ray tracing predates the computer age, so people learned analysis techniques that required tracing a bare minimum number of rays. In fact you can learn a lot about a simple system by tracing just two rays. For this reason, ray diagrams shown in optics designs tend to show relatively few rays.

But every optics designer wishes we could have the same cool tools as the graphics people, but with the analysis features that we need.


That's exactly ray tracing in original and all-purpose meaning and sense what this is about.


Perhaps it is the 3D artists that are using the term incorrectly. Or maybe the term can have more than one meaning.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: