YafaRay Core  v3.2.0-ALPHA-10-g60452c5
surface.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * surface.h: Surface sampling representation and api
4  * This is part of the yafray package
5  * Copyright (C) 2002 Alejandro Conty Estevez
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  */
22 #ifndef Y_SURFACE_H
23 #define Y_SURFACE_H
24 #include "vector3d.h"
25 #include "color.h"
26 
27 #include<yafray_config.h>
28 
30 class material_t;
31 class light_t;
32 class object3d_t;
33 class diffRay_t;
34 class vector3d_t;
35 
37 {
38  public:
40  {
41  // Empty
42  }
43  float b0 = 0.f;
44  float b1 = 0.f;
45  float b2 = 0.f;
46  float t = 0.f;
47  const vector3d_t * edge1 = nullptr;
48  const vector3d_t * edge2 = nullptr;
49 };
50 
57 {
58  public:
59  float getDistToNearestEdge() const;
60 
61  //int object; //!< the object owner of the point.
63  const light_t *light;
64  const object3d_t *object;
65  // point2d_t screenpos; // only used with 'win' texture coord. mode
66  void *origin;
68 
69  // Geometry related
75  // color_t vertex_col;
76  bool hasUV;
77  bool hasOrco;
78  bool available;
79  int primNum;
80 
81  float U;
82  float V;
91  //float dudNU;
92  //float dudNV;
93  //float dvdNU;
94  //float dvdNV;
95 
96  // Differential ray for mipmaps calculations
97  const diffRay_t * ray = nullptr;
98 };
99 
101 {
102  if(data.edge1 && data.edge2)
103  {
104  float edge1len = data.edge1->length();
105  float edge2len = data.edge2->length();
106  float edge12len = (*(data.edge1) + *(data.edge2)).length() * 0.5f;
107 
108  float edge1dist = data.b1 * edge1len;
109  float edge2dist = data.b2 * edge2len;
110  float edge12dist = data.b0 * edge12len;
111 
112  float edgeMinDist = std::min(edge12dist, std::min(edge1dist, edge2dist));
113 
114  return edgeMinDist;
115  }
116  else return std::numeric_limits<float>::infinity();
117 }
118 
119 
120 YAFRAYCORE_EXPORT surfacePoint_t blend_surface_points(surfacePoint_t const& sp_0, surfacePoint_t const& sp_1, float const alpha);
121 
125 {
126  public:
127  spDifferentials_t(const surfacePoint_t &spoint, const diffRay_t &ray);
129  void reflectedRay(const diffRay_t &in, diffRay_t &out) const;
131  void refractedRay(const diffRay_t &in, diffRay_t &out, float IOR) const;
132  float projectedPixelArea();
133  void getUVdifferentials(float &dUdx, float &dVdx, float &dUdy, float &dVdy) const;
137  protected:
138  void dU_dV_from_dP_dPdU_dPdV(float &dU, float &dV, const point3d_t &dP, const vector3d_t &dPdU, const vector3d_t &dPdV) const;
139 };
140 
142 
143 #endif
vector3d_t dPdV
v-axis in world space (normalized)
Definition: surface.h:86
bool available
Definition: surface.h:78
intersectData_t data
Definition: surface.h:67
vector3d_t dPdV_abs
v-axis in world space (before normalization)
Definition: surface.h:90
vector3d_t dPdx
Definition: surface.h:134
YAFRAYCORE_EXPORT surfacePoint_t blend_surface_points(surfacePoint_t const &sp_0, surfacePoint_t const &sp_1, float const alpha)
Definition: surface.cc:119
float getDistToNearestEdge() const
Definition: surface.h:100
bool hasOrco
Definition: surface.h:77
vector3d_t dPdy
Definition: surface.h:135
bool hasUV
Definition: surface.h:76
float V
the v texture coord.
Definition: surface.h:82
vector3d_t dSdU
u-axis in shading space (NU, NV, N)
Definition: surface.h:87
#define __BEGIN_YAFRAY
vector3d_t dPdU
u-axis in world space (normalized)
Definition: surface.h:85
vector3d_t NV
third vector building orthogonal shading space with N
Definition: surface.h:84
vector3d_t Ng
the geometric normal.
Definition: surface.h:71
Definition: light.h:29
vector3d_t NU
second vector building orthogonal shading space with N
Definition: surface.h:83
float U
the u texture coord.
Definition: surface.h:81
vector3d_t N
the shading normal.
Definition: surface.h:70
const vector3d_t * edge2
Definition: surface.h:48
const object3d_t * object
object the prim belongs to
Definition: surface.h:64
const material_t * material
the surface material
Definition: surface.h:62
const light_t * light
light source if surface point is on a light
Definition: surface.h:63
const vector3d_t * edge1
Definition: surface.h:47
vector3d_t dSdV
v-axis in shading space (NU, NV, N)
Definition: surface.h:88
#define YAFRAYCORE_EXPORT
point3d_t P
the (world) position.
Definition: surface.h:73
void * origin
Definition: surface.h:66
vector3d_t orcoNg
the untransformed geometric normal.
Definition: surface.h:72
Definition: ray.h:24
point3d_t orcoP
Definition: surface.h:74
vector3d_t dPdU_abs
u-axis in world space (before normalization)
Definition: surface.h:89
const surfacePoint_t & sp
Definition: surface.h:136
#define __END_YAFRAY
float min(float a, float b)
Definition: GridVolume.cc:116