VR-Vantage 3.0.3 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ssBrdf.h
Go to the documentation of this file.
1 
2 // Copyright JRM Enterprises, Inc. 2011 - 2012
3 // All rights reserved.
4 //
5 // This code is the intellectual property of JRM Enterprises, Inc.
6 // It may not be used or released as source or compiled binary form
7 // without the prior written consent of JRM Enterprises, Inc.
8 //
9 // Original Author: Tom Rix Date: July 2011
11 
12 #ifndef _ssBrdf_
13 #define _ssBrdf_
14 
15 
16 #include "ssdllexport.h"
17 
18 
20 // class: ssBrdf
21 //
22 // description: class to generate brdf specific LUT's
23 //
25 {
26 private:
27  static double g(double a, double b);
28  static double G(double b) ;
29  static double h_Sr(double a, double e);
30  static double H_Sr(double a, double e);
31  static double H_PhongEven(double a, double n);
32  static double H_PhongOdd(double a, double n);
33  static double H_PhongAverage(double a, double h);
34  static double H_PhongEvenNoN(double a);
35  static double H_PhongOddNoN(double a);
36  static double H_PhongAverageNoN(double a);
37 public:
38 
39  /*
40  * The SrTable is packed
41  * g,G,h,H
42  * And assumed to be standard C row major
43  *
44  * g, x -> b [0-1], y -> cos (a) [1-0] as a [0 - pi/2]
45  * InvG, x -> b [0-1], y -> duplicates
46  * h, x -> e [0-1], y -> cos (a) [1-0] as a [0 - pi/2]
47  * H, x -> e [0-1], y -> cos (a) [1-0] as a [0 - pi/2]
48  *
49  * h and H are very dependent on e, so the width should be between least 512 - 4096
50  * cos (a) does not vary much, so the height should be between 64 - 256
51  * both width and height must be greater than 1
52  *
53  * half_float_overflow_check
54  * If the returned table is to be used as half floats this value should be true
55  * Else this value should be false.
56  * half floats overflow at 65536.0, when the expontent is too large to store.
57  *
58  * returns false if input data is bad.
59  */
60 
61  static bool SrTable (float *t, unsigned int width, unsigned int height, bool half_float_overflow_check = false);
62 
63  /*
64  * Converts the total dhr into a diffuse reflectance
65  */
66  static double pd_Sr(double dhr, double percent_specular, double angle_dhr, double grazing_angle_reflectivity);
67 
68  /*
69  * Converts the total dhr into a specular reflectance
70  */
71  static double ps_Sr(double dhr, double percent_specular, double angle_dhr, double grazing_angle_reflectivity);
72 
73  /*
74  * Helper function to return the emissive part of the total dhr.
75  * Assumes the material is opaque
76  */
77  static double pe_Sr(double dhr, double percent_specular, double angle_dhr, double grazing_angle_reflectivity);
78 
79  /*
80  * Converts angle independent k into angle dependent
81  */
82  static double K_PhongH (double k, double angle, double grazing_angle_reflection) ;
83 
84  /*
85  * Recovers the old phong values
86  */
87  static void RecoverOldPhong (double dhr, double angleDhr, double percentSpecular, double lobe, double *Shine, double* Kamb, double* Kdif, double *Kspec);
88 
89  /*
90  * The PhongHTable is packed
91  * g,G,1,H
92  * And assumed to be standard C row major
93  *
94  * g, x -> b [0-1], y -> cos (a) [1-0] as a [0 - pi/2]
95  * InvG, x -> b [0-1], y -> duplicates
96  * 1.0
97  * H without 1/(n+1), x -> y -> cos(a) [0-1] as a [0 - pi/2]
98  *
99  * half_float_overflow_check
100  * If the returned table is to be used as half floats this value should be true
101  * Else this value should be false.
102  * half floats overflow at 65536.0, when the expontent is too large to store.
103  *
104  */
105  static bool PhongHTable (float *t, unsigned int width, unsigned int height, bool half_float_overflow_check = false);
106 
107  /*
108  * A complement to the SR and PhongH table
109  * Fills a similarly allocaded table with random numbers [0 - 1]
110  * That will be used in the SR calculations
111  */
112  static bool RoughnessTable (float *t, unsigned int width, unsigned int height);
113 
114 };
115 
116 #endif // _ssBrdf_
117 


Copyright © 2005-2023 MAK Technologies. All Rights Reserved (www.mak.com)