solstice-solver

Solver library of the solstice app
git clone git://git.meso-star.com/solstice-solver.git
Log | Files | Refs | README | LICENSE

ssol_material_c.h (2689B)


      1 /* Copyright (C) 2018-2026 |Meso|Star> (contact@meso-star.com)
      2  * Copyright (C) 2016, 2018 CNRS
      3  *
      4  * This program is free software: you can redistribute it and/or modify
      5  * it under the terms of the GNU General Public License as published by
      6  * the Free Software Foundation, either version 3 of the License, or
      7  * (at your option) any later version.
      8  *
      9  * This program is distributed in the hope that it will be useful,
     10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     12  * GNU General Public License for more details.
     13  *
     14  * You should have received a copy of the GNU General Public License
     15  * along with this program. If not, see <http://www.gnu.org/licenses/>. */
     16 
     17 #ifndef SSOL_MATERIAL_C_H
     18 #define SSOL_MATERIAL_C_H
     19 
     20 #include <rsys/ref_count.h>
     21 
     22 struct s3d_hit;
     23 struct s3d_primitive;
     24 struct ssf_bsdf;
     25 struct ssol_device;
     26 
     27 struct dielectric {
     28   int dummy;
     29 };
     30 
     31 struct matte {
     32   ssol_shader_getter_T reflectivity;
     33 };
     34 
     35 struct mirror {
     36   ssol_shader_getter_T reflectivity;
     37   ssol_shader_getter_T roughness;
     38   enum ssol_microfacet_distribution distrib;
     39 };
     40 
     41 struct thin_dielectric {
     42   struct ssol_medium slab_medium;
     43   double thickness;
     44 };
     45 
     46 struct ssol_material {
     47   enum ssol_material_type type;
     48 
     49   ssol_shader_getter_T normal;
     50 
     51   union {
     52     struct dielectric dielectric;
     53     struct matte matte;
     54     struct mirror mirror;
     55     struct thin_dielectric thin_dielectric;
     56   } data;
     57 
     58   struct ssol_medium out_medium;
     59   struct ssol_medium in_medium;
     60 
     61   struct ssol_param_buffer* buf;
     62   struct ssol_device* dev;
     63   ref_T ref;
     64 };
     65 
     66 extern LOCAL_SYM void
     67 surface_fragment_setup
     68   (struct ssol_surface_fragment* fragment,
     69    const double pos[3],
     70    const double dir[3],
     71    const double normal[3],
     72    const struct s3d_primitive* primitive,
     73    const float uv[2]);
     74 
     75 extern LOCAL_SYM void
     76 material_shade_normal
     77   (const struct ssol_material* mtl,
     78    const struct ssol_surface_fragment* fragment,
     79    const double wavelength,
     80    double N[3]);
     81 
     82 extern LOCAL_SYM res_T
     83 material_create_bsdf
     84   (const struct ssol_material* mtl,
     85    const struct ssol_surface_fragment* fragment,
     86    const double wavelength, /* In nanometer */
     87    const struct ssol_medium* medium, /* Current medium */
     88    const int rendering, /* Is material used for rendering purposes */
     89    struct ssf_bsdf** bsdf); /* Bidirectional Scattering Distribution Function */
     90 
     91 extern LOCAL_SYM res_T
     92 material_get_next_medium
     93   (const struct ssol_material* mtl,
     94    const struct ssol_medium* medium, /* Current mediu */
     95    struct ssol_medium* next_medium);
     96 
     97 extern LOCAL_SYM int
     98 media_ceq(const struct ssol_medium* a, const struct ssol_medium* b);
     99 
    100 #endif /* SSOL_MATERIAL_C_H */
    101