{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Polarizer optimization" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Overview\n", "\n", "An interesting feature of Mitsuba is its ability to account for the polarization state of light. This becomes even more powerful when combined with differentiable rendering. \n", "\n", "This tutorial demonstrates how those two concepts can be used together to perform a simple optimization. The setup is the following: we place two linear polarization filters in front of the camera. Initially, these are rotated in such a way that all the light passes through them. The optimization process will attempt to rotate one of the filter to minimize the overall brightness of the rendered image. Indeed, it is known that rotating this filter by 90 degrees will lead to complete cancelation of the polarization state, resulting in a darker image.\n", "\n", "More information about polarization can be found [here][1].\n", "\n", "
polarizer
][1] BSDF).\n",
"\n",
"[1]: https://mitsuba.readthedocs.io/en/latest/src/generated/plugins_bsdfs.html#linear-polarizer-material-polarizer"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2021-09-17T09:13:32.691239Z",
"start_time": "2021-09-17T09:13:32.226341Z"
}
},
"outputs": [],
"source": [
"import drjit as dr \n",
"import mitsuba as mi\n",
"\n",
"mi.set_variant('llvm_ad_rgb_polarized')\n",
"\n",
"scene = mi.load_file('../scenes/polarizers.xml')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can then perform the rendering of our initial scene. As expected, the two filters are aligned and let linearly polarized light through."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"ExecuteTime": {
"end_time": "2021-09-17T09:13:33.024683Z",
"start_time": "2021-09-17T09:13:32.803338Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"polarizer
plugin](https://mitsuba.readthedocs.io/en/latest/src/generated/plugins_bsdfs.html#linear-polarizer-material-polarizer)"
]
}
],
"metadata": {
"file_extension": ".py",
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
},
"metadata": {
"interpreter": {
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
}
},
"mimetype": "text/x-python",
"name": "python",
"npconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": 3
},
"nbformat": 4,
"nbformat_minor": 4
}