Skip to content

Instantly share code, notes, and snippets.

@tdbe
Created July 31, 2017 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdbe/b3c34c3f487669a0f6d532dadb384596 to your computer and use it in GitHub Desktop.
Save tdbe/b3c34c3f487669a0f6d532dadb384596 to your computer and use it in GitHub Desktop.
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2016 Tudor Berechet
* Copyright (c) 2015 Fredrik Lindh
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
/******************************************************************************
* This is a Signed Distance Field Raytracer Shader experiment for Unreal Engine 4
* Use it as a cheat sheet, I commented it and included all sources & resources.
******************************************************************************/
#include "Common.usf"
/*
//Uniform Buffers
//This buffer should contain variables that never, or very seldomly change
BEGIN_UNIFORM_BUFFER_STRUCT(FPixelShaderConstantParameters, )
DECLARE_UNIFORM_BUFFER_STRUCT_MEMBER(FVector4, StartColor)
END_UNIFORM_BUFFER_STRUCT(FPixelShaderConstantParameters)
//This buffer is for variables that change very often (each fram for example)
BEGIN_UNIFORM_BUFFER_STRUCT(FPixelShaderDynamicParameters, )
DECLARE_UNIFORM_BUFFER_STRUCT_MEMBER(float, TextureParameterBlendFactor)
DECLARE_UNIFORM_BUFFER_STRUCT_MEMBER(FVector4, EndColor)
DECLARE_UNIFORM_BUFFER_STRUCT_MEMBER(float4x4, FViewToWorld)
END_UNIFORM_BUFFER_STRUCT(FPixelShaderDynamicParameters)
*/
/*
// ###### <PBR MATERIAL INFORMATION>
//Thanks Antonalog and thanks BRDF guys!
//https://www.shadertoy.com/view/XssGzf
//http://hal.inria.fr/docs/00/70/23/04/PDF/paper.pdf
float gamma = //1.8;
2.2;
float one_pi = 0.31830988618;
float lightIntensity = 10.0;
// gold-paint
//#if 1
float3 rho_d = float3(0.147708, 0.0806975, 0.033172);
float3 rho_s = float3(0.160592, 0.217282, 0.236425);
float3 alpha = float3(0.122506, 0.108069, 0.12187);
float3 p = float3(0.795078, 0.637578, 0.936117);
float3 F_0 = float3(9.16095e-12, 1.81225e-12, 0.0024589);
float3 F_1 = float3(-0.596835, -0.331147, -0.140729);
float3 K_ap = float3(5.98176, 7.35539, 5.29722);
float3 sh_lambda = float3(2.64832, 3.04253, 2.3013);
float3 sh_c = float3(9.3111e-08, 8.80143e-08, 9.65288e-08);
float3 sh_k = float3(24.3593, 24.4037, 25.3623);
float3 sh_theta0 = float3(-0.284195, -0.277297, -0.245352);
#endif
//#if 1 //loads of ifs version
void alum_bronze() {
rho_d = float3(0.0478786, 0.0313514, 0.0200638);
rho_s = float3(0.0364976, 0.664975, 0.268836);
alpha = float3(0.014832, 0.0300126, 0.0490339);
p = float3(0.459076, 0.450056, 0.529272);
F_0 = float3(6.05524, 0.235756, 0.580647);
F_1 = float3(5.05524, 0.182842, 0.476088);
K_ap = float3(46.3841, 24.5961, 14.8261);
sh_lambda = float3(2.60672, 2.97371, 2.7827);
sh_c = float3(1.12717e-07, 1.06401e-07, 5.27952e-08);
sh_k = float3(47.783, 36.2767, 31.6066);
sh_theta0 = float3(0.205635, 0.066289, -0.0661091);
}
void alumina_oxide() {
rho_d = float3(0.316358, 0.292248, 0.25416);
rho_s = float3(0.00863128, 0.00676832, 0.0103309);
alpha = float3(0.000159222, 0.000139421, 0.000117714);
p = float3(0.377727, 0.318496, 0.402598);
F_0 = float3(0.0300766, 1.70375, 1.96622);
F_1 = float3(-0.713784, 0.70375, 1.16019);
K_ap = float3(4381.96, 5413.74, 5710.42);
sh_lambda = float3(3.31076, 4.93831, 2.84538);
sh_c = float3(6.72897e-08, 1.15769e-07, 6.32199e-08);
sh_k = float3(354.275, 367.448, 414.581);
sh_theta0 = float3(0.52701, 0.531166, 0.53301);
}
void aluminium() {
rho_d = float3(0.0305166, 0.0358788, 0.0363463);
rho_s = float3(0.0999739, 0.131797, 0.0830361);
alpha = float3(0.0012241, 0.000926487, 0.000991844);
p = float3(0.537669, 0.474562, 0.435936);
F_0 = float3(0.977854, 0.503108, 1.77905);
F_1 = float3(-0.0221457, -0.0995445, 0.77905);
K_ap = float3(449.321, 658.044, 653.86);
sh_lambda = float3(8.2832e-07, 9.94692e-08, 6.11887e-08);
sh_c = float3(3.54592e-07, 16.0175, 15.88);
sh_k = float3(23.8656, 10.6911, 9.69801);
sh_theta0 = float3(-0.510356, 0.570179, 0.566156);
}
void aventurnine() {
rho_d = float3(0.0548217, 0.0621179, 0.0537826);
rho_s = float3(0.0348169, 0.0872381, 0.111961);
alpha = float3(0.000328039, 0.000856166, 0.00145342);
p = float3(0.387167, 0.504525, 0.652122);
F_0 = float3(0.252033, 0.133897, 0.087172);
F_1 = float3(0.130593, 0.0930416, 0.0567429);
K_ap = float3(2104.51, 676.157, 303.59);
sh_lambda = float3(3.12126, 2.50965e-07, 2.45778e-05);
sh_c = float3(1.03849e-07, 8.53824e-07, 3.20722e-07);
sh_k = float3(251.265, 24.2886, 29.0236);
sh_theta0 = float3(0.510125, -0.41764, -0.245097);
}
void beige_fabric() {
rho_d = float3(0.20926, 0.160666, 0.145337);
rho_s = float3(0.121663, 0.0501577, 0.00177279);
alpha = float3(0.39455, 0.15975, 0.110706);
p = float3(0.474725, 0.0144728, 1.70871e-12);
F_0 = float3(0.0559459, 0.222268, 8.4764);
F_1 = float3(-0.318718, -0.023826, 7.4764);
K_ap = float3(3.8249, 7.32453, 10.0904);
sh_lambda = float3(2.26283, 2.97144, 3.55311);
sh_c = float3(0.0375346, 0.073481, 0.0740222);
sh_k = float3(7.52635, 9.05672, 10.6185);
sh_theta0 = float3(0.217453, 0.407084, 0.450203);
}
void black_fabric() {
rho_d = float3(0.0189017, 0.0112353, 0.0110067);
rho_s = float3(2.20654e-16, 6.76197e-15, 1.57011e-13);
alpha = float3(0.132262, 0.128044, 0.127838);
p = float3(0.189024, 0.18842, 0.188426);
F_0 = float3(1, 1, 1);
F_1 = float3(0, 0, 0);
K_ap = float3(8.1593, 8.38075, 8.39184);
sh_lambda = float3(3.83017, 3.89536, 3.89874);
sh_c = float3(0.00415117, 0.00368324, 0.00365826);
sh_k = float3(12.9974, 13.2597, 13.2737);
sh_theta0 = float3(0.207997, 0.205597, 0.205424);
}
void black_obsidian() {
rho_d = float3(0.00130399, 0.0011376, 0.00107233);
rho_s = float3(0.133029, 0.125362, 0.126188);
alpha = float3(0.000153649, 0.000148939, 0.000179285);
p = float3(0.186234, 0.227495, 0.25745);
F_0 = float3(2.42486e-12, 0.0174133, 0.091766);
F_1 = float3(-0.0800755, -0.048671, 0.0406445);
K_ap = float3(5668.57, 5617.79, 4522.84);
sh_lambda = float3(13.7614, 8.59526, 6.44667);
sh_c = float3(1e10, 1e10, 1e10);
sh_k = float3(117.224, 120.912, 113.366);
sh_theta0 = float3(1.19829, 1.19885, 1.19248);
}
void black_oxidized_steel() {
rho_d = float3(0.0149963, 0.0120489, 0.0102471);
rho_s = float3(0.373438, 0.344382, 0.329202);
alpha = float3(0.187621, 0.195704, 0.200503);
p = float3(0.661367, 0.706913, 0.772267);
F_0 = float3(0.0794166, 0.086518, 0.080815);
F_1 = float3(0.0470402, 0.0517633, 0.0455037);
K_ap = float3(5.1496, 4.91636, 4.69009);
sh_lambda = float3(4.0681, 3.95489, 3.71052);
sh_c = float3(1.07364e-07, 1.05341e-07, 1.16556e-07);
sh_k = float3(20.2383, 20.1786, 20.2553);
sh_theta0 = float3(-0.479617, -0.4885, -0.478388);
}
void black_phenolic() {
rho_d = float3(0.00204717, 0.00196935, 0.00182908);
rho_s = float3(0.177761, 0.293146, 0.230592);
alpha = float3(0.00670804, 0.00652009, 0.00656043);
p = float3(0.706648, 0.677776, 0.673986);
F_0 = float3(0.16777, 0.12335, 0.166663);
F_1 = float3(0.111447, 0.0927321, 0.125663);
K_ap = float3(65.4189, 70.8936, 70.9951);
sh_lambda = float3(1.06318, 1.15283, 1.16529);
sh_c = float3(1.24286e-07, 3.00039e-08, 9.77334e-08);
sh_k = float3(74.0711, 75.1165, 73.792);
sh_theta0 = float3(0.338204, 0.319306, 0.33434);
}
void black_soft_plastic() {
rho_d = float3(0.00820133, 0.00777718, 0.00764537);
rho_s = float3(0.110657, 0.0980322, 0.100579);
alpha = float3(0.0926904, 0.0935964, 0.0949975);
p = float3(0.14163, 0.148703, 0.143694);
F_0 = float3(0.150251, 0.169418, 0.170457);
F_1 = float3(0.100065, 0.113089, 0.114468);
K_ap = float3(11.2419, 11.113, 10.993);
sh_lambda = float3(4.3545, 4.3655, 4.31586);
sh_c = float3(0.00464641, 0.00384785, 0.0046145);
sh_k = float3(14.6751, 14.8089, 14.5436);
sh_theta0 = float3(0.275651, 0.262317, 0.271284);
}
void blue_acrylic() {
rho_d = float3(0.0134885, 0.0373766, 0.10539);
rho_s = float3(0.0864901, 0.0228191, 0.204042);
alpha = float3(0.000174482, 0.000269795, 0.0015211);
p = float3(0.373948, 0.362425, 0.563636);
F_0 = float3(0.0185562, 0.399982, 0.0525861);
F_1 = float3(-0.0209713, 0.241543, 0.0169474);
K_ap = float3(4021.24, 2646.36, 346.898);
sh_lambda = float3(3.38722, 3.62885, 1.83684e-06);
sh_c = float3(9.64334e-08, 9.96105e-08, 3.61787e-07);
sh_k = float3(338.073, 272.828, 23.5039);
sh_theta0 = float3(0.526039, 0.515404, -0.526935);
}
void blue_fabric() {
rho_d = float3(0.0267828, 0.0281546, 0.066668);
rho_s = float3(0.0825614, 0.0853369, 0.0495164);
alpha = float3(0.248706, 0.249248, 0.18736);
p = float3(9.23066e-13, 1.66486e-12, 2.27218e-12);
F_0 = float3(0.201626, 0.213723, 0.56548);
F_1 = float3(0.225891, 0.226267, 0.638493);
K_ap = float3(5.15615, 5.14773, 6.43713);
sh_lambda = float3(2.25846, 2.25536, 2.68382);
sh_c = float3(0.128037, 0.128363, 0.0944915);
sh_k = float3(6.95531, 6.94633, 8.17665);
sh_theta0 = float3(0.407528, 0.407534, 0.411378);
}
void blue_metallic_paint2() {
rho_d = float3(0.010143, 0.0157349, 0.0262717);
rho_s = float3(0.0795798, 0.0234493, 0.0492337);
alpha = float3(0.00149045, 0.00110477, 0.00141008);
p = float3(0.624615, 0.598721, 0.67116);
F_0 = float3(9.36434e-14, 3.61858e-15, 1.15633e-14);
F_1 = float3(-0.210234, -1, -1);
K_ap = float3(314.024, 441.812, 299.726);
sh_lambda = float3(1.20935e-05, 7.51792e-06, 3.86474e-05);
sh_c = float3(3.38901e-07, 2.94502e-07, 3.15718e-07);
sh_k = float3(27.0491, 28.576, 30.6214);
sh_theta0 = float3(-0.326593, -0.274443, -0.187842);
}
void blue_metallic_paint() {
rho_d = float3(0.00390446, 0.00337319, 0.00848198);
rho_s = float3(0.0706771, 0.0415082, 0.104423);
alpha = float3(0.155564, 0.139, 0.15088);
p = float3(1.01719, 1.02602, 1.16153);
F_0 = float3(0.149347, 0.153181, 1.87241e-14);
F_1 = float3(-0.487331, -0.76557, -1);
K_ap = float3(4.4222, 4.59265, 3.93929);
sh_lambda = float3(2.54345, 2.33884, 2.24405);
sh_c = float3(6.04906e-08, 5.81858e-08, 1.2419e-07);
sh_k = float3(23.9533, 25.0641, 24.6856);
sh_theta0 = float3(-0.34053, -0.294595, -0.258117);
}
void blue_rubber() {
rho_d = float3(0.0371302, 0.0732915, 0.146637);
rho_s = float3(0.384232, 0.412357, 0.612608);
alpha = float3(0.218197, 0.2668, 0.478375);
p = float3(0.815054, 1.00146, 1.24995);
F_0 = float3(0.0631713, 0.0622636, 0.0399196);
F_1 = float3(0.0478254, 0.0422186, 0.007015);
K_ap = float3(4.41586, 3.76795, 3.46276);
sh_lambda = float3(3.77807, 3.82679, 3.33186);
sh_c = float3(1.2941e-07, 1.07194e-07, 0.00045665);
sh_k = float3(19.8046, 19.3115, 11.4364);
sh_theta0 = float3(-0.499472, -0.557706, -0.172177);
}
void brass() {
rho_d = float3(0.0301974, 0.0223812, 0.0139381);
rho_s = float3(0.0557826, 0.0376687, 0.0775998);
alpha = float3(0.0002028, 0.000258468, 0.00096108);
p = float3(0.362322, 0.401593, 0.776606);
F_0 = float3(0.639886, 0.12354, 0.0197853);
F_1 = float3(-0.360114, -0.87646, -0.0919344);
K_ap = float3(3517.61, 2612.49, 331.815);
sh_lambda = float3(3.64061, 2.87206, 0.529487);
sh_c = float3(1.01146e-07, 9.83073e-08, 5.48819e-08);
sh_k = float3(312.802, 283.431, 183.091);
sh_theta0 = float3(0.522711, 0.516719, 0.474834);
}
void cherry_235() {
rho_d = float3(0.0497502, 0.0211902, 0.0120688);
rho_s = float3(0.166001, 0.202786, 0.165189);
alpha = float3(0.0182605, 0.0277997, 0.0255721);
p = float3(0.0358348, 0.163231, 0.129135);
F_0 = float3(0.0713408, 0.0571719, 0.0791809);
F_1 = float3(0.0200814, 0.00887306, 0.0251675);
K_ap = float3(54.7448, 33.7294, 37.36);
sh_lambda = float3(6.11314, 6.23697, 6.16351);
sh_c = float3(30.3886, 0.00191869, 0.0495069);
sh_k = float3(18.8114, 25.8454, 23.3753);
sh_theta0 = float3(0.816378, 0.387479, 0.522125);
}
void chrome() {
rho_d = float3(0.00697189, 0.00655268, 0.0101854);
rho_s = float3(0.0930656, 0.041946, 0.104558);
alpha = float3(0.000155335, 0.000156872, 7.39851e-05);
p = float3(0.353854, 0.3327, 0.300437);
F_0 = float3(0.256314, 0.819565, 3.22085e-13);
F_1 = float3(-0.743686, -0.180435, -1);
K_ap = float3(4642.1, 4726.66, 10421.9);
sh_lambda = float3(3.8545, 4.44817, 5.40959);
sh_c = float3(5.30781e-08, 1.04045e-07, 1e10);
sh_k = float3(354.965, 349.356, 272.736);
sh_theta0 = float3(0.526796, 0.528469, 1.00293);
}
void chrome_steel() {
rho_d = float3(0.0206718, 0.0240818, 0.024351);
rho_s = float3(0.129782, 0.109032, 0.0524555);
alpha = float3(5.51292e-05, 3.13288e-05, 4.51944e-05);
p = float3(0.207979, 0.152758, 0.325431);
F_0 = float3(1.18818e-12, 2.06813e-11, 0.580895);
F_1 = float3(-0.316807, -0.265326, -0.419105);
K_ap = float3(15466.8, 28628.9, 16531.2);
sh_lambda = float3(12.8988, 68.7898, 4.68237);
sh_c = float3(1e10, 1e10, 44.7025);
sh_k = float3(197.744, 257.536, 618.155);
sh_theta0 = float3(1.20035, 1.2003, 0.579562);
}
void colonial_maple_223() {
rho_d = float3(0.100723, 0.0356306, 0.0162408);
rho_s = float3(0.059097, 0.0661341, 0.11024);
alpha = float3(0.0197628, 0.0279336, 0.0621265);
p = float3(0.0311867, 0.112022, 0.344348);
F_0 = float3(0.0576683, 0.0617498, 0.0479061);
F_1 = float3(-0.0503364, -0.0382196, -0.0382636);
K_ap = float3(50.7952, 34.6835, 14.201);
sh_lambda = float3(6.03342, 6.01053, 4.56588);
sh_c = float3(18.9034, 0.087246, 1.03757e-07);
sh_k = float3(18.3749, 21.6159, 26.9347);
sh_theta0 = float3(0.801289, 0.544191, -0.139944);
}
void color_changing_paint1() {
rho_d = float3(0.00513496, 0.00500415, 0.00296872);
rho_s = float3(1.53167, 0.430731, 1.48308);
alpha = float3(0.00320129, 0.0023053, 0.0329464);
p = float3(0.167301, 0.100003, 1.04868);
F_0 = float3(0.0208525, 0.109366, 0.0553211);
F_1 = float3(0.0101418, 0.0801275, 0.0357004);
K_ap = float3(279.058, 407.716, 9.71061);
sh_lambda = float3(6.73768, 7.19333, 1.04729);
sh_c = float3(2.66398e+08, 1e10, 4.16363e-08);
sh_k = float3(36.7257, 27.8164, 45.5388);
sh_theta0 = float3(1.01208, 1.19549, 0.131148);
}
void color_changing_paint2() {
rho_d = float3(0.00463528, 0.00544054, 0.0070818);
rho_s = float3(1.35172, 1.47838, 1.29831);
alpha = float3(0.0279961, 0.0267135, 0.0257468);
p = float3(0.720154, 0.717648, 0.694662);
F_0 = float3(0.019073, 0.00825302, 0.0301024);
F_1 = float3(-0.0181694, -0.0198592, -0.000522292);
K_ap = float3(18.6722, 19.4709, 20.7514);
sh_lambda = float3(1.56832, 1.554, 1.60402);
sh_c = float3(1.19918e-07, 9.95358e-08, 9.69838e-08);
sh_k = float3(41.295, 42.1716, 42.3986);
sh_theta0 = float3(0.124794, 0.129237, 0.132024);
}
void color_changing_paint3() {
rho_d = float3(0.00305737, 0.00257341, 0.00263616);
rho_s = float3(0.880793, 0.691268, 0.707821);
alpha = float3(0.014742, 0.0135513, 0.0108894);
p = float3(0.537248, 0.572188, 0.457665);
F_0 = float3(0.055479, 0.0666783, 0.0585094);
F_1 = float3(0.0315282, 0.0457554, 0.0365558);
K_ap = float3(42.1798, 43.3684, 62.0624);
sh_lambda = float3(2.06002, 1.82703, 2.54086);
sh_c = float3(5.0531e-08, 9.99088e-08, 5.726e-08);
sh_k = float3(50.0948, 52.0344, 54.643);
sh_theta0 = float3(0.197971, 0.229219, 0.241049);
}
void dark_blue_paint() {
rho_d = float3(0.00665057, 0.0139696, 0.0472605);
rho_s = float3(0.231099, 0.18931, 0.12528);
alpha = float3(0.130681, 0.112103, 0.0629285);
p = float3(0.238562, 0.17, 0.0157371);
F_0 = float3(0.112486, 0.106018, 0.139316);
F_1 = float3(0.0662142, 0.0682314, 0.10607);
K_ap = float3(8.0828, 9.4312, 16.8231);
sh_lambda = float3(4.05526, 4.09607, 4.54368);
sh_c = float3(0.00104743, 0.0035546, 0.10813);
sh_k = float3(14.347, 13.928, 13.5626);
sh_theta0 = float3(0.11894, 0.226752, 0.524826);
}
void dark_red_paint() {
rho_d = float3(0.237125, 0.0365577, 0.0106149);
rho_s = float3(0.227405, 0.111055, 0.150433);
alpha = float3(0.67372, 0.0706716, 0.20328);
p = float3(1.38127, 1.4345e-13, 0.27723);
F_0 = float3(1.56101e-11, 0.0779523, 0.136566);
F_1 = float3(-0.148315, 0.0560349, 0.0961999);
K_ap = float3(3.95965, 15.1861, 5.71355);
sh_lambda = float3(2.27942, 4.30359, 3.20838);
sh_c = float3(0.0225467, 0.113039, 0.00667899);
sh_k = float3(7.45998, 12.679, 10.9071);
sh_theta0 = float3(0.119045, 0.521154, 0.166378);
}
void dark_specular_fabric() {
rho_d = float3(0.0197229, 0.00949167, 0.00798414);
rho_s = float3(0.556218, 0.401495, 0.378651);
alpha = float3(0.140344, 0.106541, 0.166715);
p = float3(0.249059, 0.177611, 0.434167);
F_0 = float3(0.0351133, 0.0387177, 0.0370533);
F_1 = float3(0.0243153, 0.0293178, 0.0264913);
K_ap = float3(7.60492, 9.81673, 6.19307);
sh_lambda = float3(3.93869, 4.23097, 4.3775);
sh_c = float3(0.00122421, 0.00238545, 8.47126e-06);
sh_k = float3(13.889, 14.5743, 17.2049);
sh_theta0 = float3(0.114655, 0.210179, -0.227628);
}
void delrin() {
rho_d = float3(0.272703, 0.249805, 0.220642);
rho_s = float3(0.536593, 0.727886, 0.64011);
alpha = float3(0.176535, 0.344018, 0.208011);
p = float3(0.762088, 0.823603, 0.85976);
F_0 = float3(0.0398465, 0.0430719, 0.0290162);
F_1 = float3(-0.0121332, -0.0255915, -0.0305128);
K_ap = float3(5.02017, 3.78669, 4.39454);
sh_lambda = float3(3.44325, 3.49289, 3.48886);
sh_c = float3(9.20654e-08, 0.000215686, 1.06338e-07);
sh_k = float3(21.2534, 12.5556, 20.455);
sh_theta0 = float3(-0.438862, -0.184248, -0.478699);
}
void fruitwood_241() {
rho_d = float3(0.0580445, 0.0428667, 0.0259801);
rho_s = float3(0.203894, 0.233494, 0.263882);
alpha = float3(0.00824986, 0.0534794, 0.0472951);
p = float3(0.160382, 1.07206, 0.768335);
F_0 = float3(0.00129482, 0.00689891, 0.01274);
F_1 = float3(-0.0211778, -0.0140791, -0.00665974);
K_ap = float3(110.054, 6.98485, 11.6203);
sh_lambda = float3(6.74678, 1.31986, 1.76021);
sh_c = float3(162.121, 1.18843e-07, 1.0331e-07);
sh_k = float3(32.6966, 36.752, 34.371);
sh_theta0 = float3(0.765181, 0.0514459, 0.0106852);
}
void gold_metallic_paint2() {
rho_d = float3(0.0796008, 0.0538361, 0.0649523);
rho_s = float3(0.633627, 1.77116, 0.0564028);
alpha = float3(0.00376608, 0.00871206, 0.000572055);
p = float3(0.415684, 0.368424, 0.623038);
F_0 = float3(0.0343265, 0.00330259, 4.15759e-12);
F_1 = float3(-0.00929705, -0.0219437, -0.0596944);
K_ap = float3(181.769, 85.527, 795.042);
sh_lambda = float3(2.77279, 3.50114, 0.985212);
sh_c = float3(4.78294e-08, 9.8399e-08, 4.45358e-08);
sh_k = float3(83.871, 57.2291, 216.537);
sh_theta0 = float3(0.365256, 0.276734, 0.491264);
}
void gold_metallic_paint3() {
rho_d = float3(0.0579212, 0.0416649, 0.0271208);
rho_s = float3(0.0729896, 0.0597695, 0.037684);
alpha = float3(0.00146432, 0.00156513, 0.000977438);
p = float3(0.529437, 0.551234, 0.504486);
F_0 = float3(1.84643e-14, 5.7212e-15, 8.68546e-13);
F_1 = float3(-1, -1, -0.648897);
K_ap = float3(382.887, 345.197, 593.725);
sh_lambda = float3(4.97078e-07, 1.12888e-06, 4.15366e-07);
sh_c = float3(3.98586e-07, 3.69533e-07, 16.0596);
sh_k = float3(22.0196, 22.6462, 11.7126);
sh_theta0 = float3(-0.634103, -0.588056, 0.578355);
}
void gold_metallic_paint() {
rho_d = float3(0.0178625, 0.00995704, 0.00335044);
rho_s = float3(0.17127, 0.120714, 0.115473);
alpha = float3(0.127954, 0.127825, 0.109623);
p = float3(0.781093, 0.795517, 0.661313);
F_0 = float3(1.00776e-12, 1.22243e-15, 6.18432e-13);
F_1 = float3(-1, -1, -0.334497);
K_ap = float3(5.90039, 5.83556, 7.14985);
sh_lambda = float3(2.7548, 2.7057, 2.94348);
sh_c = float3(9.46481e-08, 1.06951e-07, 1.10733e-07);
sh_k = float3(23.8811, 23.9059, 24.2972);
sh_theta0 = float3(-0.303345, -0.293778, -0.267019);
}
void gold_paint() {
rho_d = float3(0.147708, 0.0806975, 0.033172);
rho_s = float3(0.160592, 0.217282, 0.236425);
alpha = float3(0.122506, 0.108069, 0.12187);
p = float3(0.795078, 0.637578, 0.936117);
F_0 = float3(9.16095e-12, 1.81225e-12, 0.0024589);
F_1 = float3(-0.596835, -0.331147, -0.140729);
K_ap = float3(5.98176, 7.35539, 5.29722);
sh_lambda = float3(2.64832, 3.04253, 2.3013);
sh_c = float3(9.3111e-08, 8.80143e-08, 9.65288e-08);
sh_k = float3(24.3593, 24.4037, 25.3623);
sh_theta0 = float3(-0.284195, -0.277297, -0.245352);
}
void gray_plastic() {
rho_d = float3(0.103233, 0.104428, 0.0983734);
rho_s = float3(0.494656, 0.517207, 0.52772);
alpha = float3(0.00758705, 0.00848095, 0.00887135);
p = float3(0.557908, 0.556548, 0.545887);
F_0 = float3(0.0428175, 0.0438899, 0.0569098);
F_1 = float3(0.0208304, 0.0221893, 0.0375763);
K_ap = float3(75.6274, 68.3098, 66.5689);
sh_lambda = float3(1.72111, 1.76597, 1.8406);
sh_c = float3(1.06783e-07, 5.31845e-08, 6.53296e-08);
sh_k = float3(65.6538, 63.2018, 61.5805);
sh_theta0 = float3(0.308907, 0.283768, 0.280211);
}
void grease_covered_steel() {
rho_d = float3(0.0196306, 0.0200926, 0.0187026);
rho_s = float3(0.0433721, 0.0311621, 0.0326401);
alpha = float3(0.00019081, 0.000173919, 0.000217638);
p = float3(0.164569, 0.141125, 0.219421);
F_0 = float3(7.12672e-13, 1.06789e-14, 1.61131e-13);
F_1 = float3(-1, -1, -1);
K_ap = float3(4655.4, 5210.63, 3877.45);
sh_lambda = float3(17.2827, 29.2523, 8.54352);
sh_c = float3(1e10, 1e10, 1e10);
sh_k = float3(103.46, 105.572, 99.1097);
sh_theta0 = float3(1.20022, 1.20678, 1.19961);
}
void green_acrylic() {
rho_d = float3(0.0176527, 0.0761863, 0.0432331);
rho_s = float3(0.0517555, 0.15899, 0.0754193);
alpha = float3(0.000185443, 5.19959e-05, 7.95188e-05);
p = float3(0.288191, 0.170979, 0.145492);
F_0 = float3(0.418137, 0.0486445, 0.170328);
F_1 = float3(0.330999, 0.0294954, 0.110218);
K_ap = float3(4223.98, 16977.4, 11351.3);
sh_lambda = float3(5.6545, 26.1353, 1.54193e+07);
sh_c = float3(1e10, 1e10, 4.23355e+06);
sh_k = float3(172.888, 204.112, 403.267);
sh_theta0 = float3(0.995381, 1.19417, 0.646645);
}
void green_fabric() {
rho_d = float3(0.0511324, 0.0490447, 0.0577457);
rho_s = float3(0.043898, 0.108081, 0.118528);
alpha = float3(0.0906425, 0.14646, 0.125546);
p = float3(0.199121, 0.21946, 0.130311);
F_0 = float3(0.117671, 0.0797822, 0.0840896);
F_1 = float3(0.107501, 0.0628391, 0.0668466);
K_ap = float3(11.1681, 7.43507, 8.69777);
sh_lambda = float3(4.65909, 3.72793, 3.72472);
sh_c = float3(0.00055264, 0.00331292, 0.0119365);
sh_k = float3(16.8276, 12.7802, 12.1538);
sh_theta0 = float3(0.153958, 0.17378, 0.291679);
}
void green_latex() {
rho_d = float3(0.0885476, 0.13061, 0.0637004);
rho_s = float3(0.177041, 0.16009, 0.101365);
alpha = float3(0.241826, 0.21913, 0.2567);
p = float3(0.175925, 0.162514, 0.326958);
F_0 = float3(0.0213854, 0.0498004, 0.0677643);
F_1 = float3(-0.0864353, -0.0518848, -0.00668045);
K_ap = float3(5.17117, 5.55867, 4.84094);
sh_lambda = float3(2.61304, 2.75985, 2.84236);
sh_c = float3(0.0417628, 0.0352726, 0.0128547);
sh_k = float3(8.4496, 8.91691, 9.57998);
sh_theta0 = float3(0.296393, 0.295144, 0.18077);
}
void green_metallic_paint2() {
rho_d = float3(0.00536389, 0.0147585, 0.0072232);
rho_s = float3(0.0553207, 0.0656441, 0.0608999);
alpha = float3(0.00131834, 0.00140737, 0.00171711);
p = float3(0.436009, 0.57969, 0.54703);
F_0 = float3(0.291808, 0.194127, 0.199549);
F_1 = float3(0.126008, -0.0681937, 0.0148264);
K_ap = float3(493.87, 362.85, 317.92);
sh_lambda = float3(4.96631e-08, 3.41674e-06, 8.72658e-07);
sh_c = float3(15.5833, 3.60732e-07, 3.78431e-07);
sh_k = float3(8.31751, 25.0069, 21.7501);
sh_theta0 = float3(0.561587, -0.431953, -0.657077);
}
void green_metallic_paint() {
rho_d = float3(0.00368935, 0.0155555, 0.022272);
rho_s = float3(0.185621, 0.436002, 0.322925);
alpha = float3(0.131402, 0.146271, 0.154061);
p = float3(1.28366, 0.865104, 0.944013);
F_0 = float3(0.12483, 0.0443223, 0.0955612);
F_1 = float3(0.028874, -0.118581, -0.139373);
K_ap = float3(3.62502, 5.13725, 4.71161);
sh_lambda = float3(1.97389, 2.72437, 2.63239);
sh_c = float3(5.5607e-08, 1.1239e-07, 9.76666e-08);
sh_k = float3(27.5467, 23.1688, 23.2911);
sh_theta0 = float3(-0.204638, -0.326555, -0.334024);
}
void green_plastic() {
rho_d = float3(0.015387, 0.0851675, 0.0947402);
rho_s = float3(0.0607427, 0.156977, 0.125155);
alpha = float3(0.000302146, 0.00197038, 0.000690284);
p = float3(0.373134, 0.751741, 0.505735);
F_0 = float3(0.116395, 0.0388464, 0.0476683);
F_1 = float3(0.0123694, -0.0038785, 0.00864048);
K_ap = float3(2329.55, 181.586, 833.886);
sh_lambda = float3(3.39581, 0.000128411, 3.06753e-07);
sh_c = float3(6.38801e-08, 2.49751e-07, 5.82332e-07);
sh_k = float3(260.135, 31.8416, 26.4101);
sh_theta0 = float3(0.510576, -0.156086, -0.337325);
}
void hematite() {
rho_d = float3(0.00948374, 0.0117628, 0.00985037);
rho_s = float3(0.0705694, 0.118965, 0.115059);
alpha = float3(0.000908552, 0.000601576, 0.00184248);
p = float3(0.515183, 0.498157, 0.73351);
F_0 = float3(0.235045, 0.0609324, 0.00720315);
F_1 = float3(-0.120178, -0.096611, -0.235146);
K_ap = float3(626.075, 967.655, 201.871);
sh_lambda = float3(3.94735e-07, 3.54792e-07, 0.000101676);
sh_c = float3(5.04376e-07, 16.4874, 2.78427e-07);
sh_k = float3(24.7601, 14.7537, 31.4869);
sh_theta0 = float3(-0.431506, 0.577853, -0.162174);
}
void ipswich_pine_221() {
rho_d = float3(0.0560746, 0.0222518, 0.0105117);
rho_s = float3(0.0991995, 0.106719, 0.110343);
alpha = float3(0.014258, 0.0178759, 0.0188163);
p = float3(0.0625943, 0.113994, 0.118296);
F_0 = float3(1.55288e-13, 6.595e-12, 3.97788e-13);
F_1 = float3(-0.0675784, -0.0696373, -0.0703103);
K_ap = float3(68.7248, 53.3521, 50.6148);
sh_lambda = float3(6.36482, 6.37738, 6.35839);
sh_c = float3(111.962, 1.68378, 0.850892);
sh_k = float3(20.956, 23.9475, 24.0837);
sh_theta0 = float3(0.842456, 0.66795, 0.641354);
}
void light_brown_fabric() {
rho_d = float3(0.0612259, 0.0263619, 0.0187761);
rho_s = float3(3.65487e-12, 9.7449e-12, 4.13685e-12);
alpha = float3(0.147778, 0.137639, 0.13071);
p = float3(0.188292, 0.188374, 0.189026);
F_0 = float3(1, 1, 1);
F_1 = float3(0, 0, 0);
K_ap = float3(7.46192, 7.90085, 8.23842);
sh_lambda = float3(3.59765, 3.74493, 3.85476);
sh_c = float3(0.00660661, 0.0049581, 0.00395337);
sh_k = float3(12.0657, 12.6487, 13.0977);
sh_theta0 = float3(0.221546, 0.213332, 0.206743);
}
void light_red_paint() {
rho_d = float3(0.391162, 0.0458387, 0.0059411);
rho_s = float3(0.522785, 0.144057, 0.214076);
alpha = float3(0.854048, 0.0627781, 0.205965);
p = float3(1.40232, 0.101554, 0.73691);
F_0 = float3(0.0346142, 0.0655657, 0.0725632);
F_1 = float3(-0.0688995, 0.0400933, 0.0252314);
K_ap = float3(4.68691, 16.2538, 4.71913);
sh_lambda = float3(1.72476, 4.88106, 3.96894);
sh_c = float3(0.0969212, 0.0124952, 1.02202e-07);
sh_k = float3(5.57044, 16.1561, 19.9884);
sh_theta0 = float3(0.249637, 0.388724, -0.505514);
}
void maroon_plastic() {
rho_d = float3(0.189951, 0.0353828, 0.0321504);
rho_s = float3(0.127693, 0.100703, 0.115731);
alpha = float3(0.00160715, 0.00110827, 0.00100127);
p = float3(0.684406, 0.645917, 0.569111);
F_0 = float3(0.0479368, 0.0624437, 0.0921161);
F_1 = float3(-0.0134224, 0.00888653, 0.0423901);
K_ap = float3(257.032, 398.91, 515.363);
sh_lambda = float3(4.57088e-05, 2.62643e-05, 3.15876e-06);
sh_c = float3(3.05979e-07, 2.76112e-07, 3.67984e-07);
sh_k = float3(29.9497, 31.8569, 27.4899);
sh_theta0 = float3(-0.211122, -0.159036, -0.309239);
}
void natural_209() {
rho_d = float3(0.0961753, 0.0349012, 0.0121752);
rho_s = float3(0.0781649, 0.0898869, 0.111321);
alpha = float3(0.0137282, 0.0154247, 0.0233645);
p = float3(0.0491415, 0.0673163, 0.149331);
F_0 = float3(0.0522205, 0.0456428, 0.0279324);
F_1 = float3(-0.0277529, -0.0308045, -0.0492147);
K_ap = float3(71.8965, 63.4418, 40.2168);
sh_lambda = float3(6.3511, 6.32932, 6.32009);
sh_c = float3(224.515, 48.774, 0.0171617);
sh_k = float3(20.2337, 21.0421, 25.7335);
sh_theta0 = float3(0.874926, 0.811948, 0.483785);
}
void neoprene_rubber() {
rho_d = float3(0.259523, 0.220477, 0.184871);
rho_s = float3(0.275058, 0.391429, 0.0753145);
alpha = float3(0.143818, 0.207586, 0.0764912);
p = float3(0.770284, 0.774203, 0.700644);
F_0 = float3(0.113041, 0.110436, 0.16895);
F_1 = float3(0.060346, 0.0565499, 0.0788468);
K_ap = float3(5.56845, 4.61088, 8.84784);
sh_lambda = float3(3.02411, 3.82334, 2.38942);
sh_c = float3(5.3042e-08, 1.01087e-07, 6.70643e-08);
sh_k = float3(23.2109, 20.1103, 28.3099);
sh_theta0 = float3(-0.379072, -0.500903, -0.156114);
}
void nickel() {
rho_d = float3(0.0144009, 0.0115339, 0.00989042);
rho_s = float3(0.157696, 0.293022, 0.450103);
alpha = float3(0.00556292, 0.00627392, 0.00660563);
p = float3(0.171288, 0.168324, 0.161023);
F_0 = float3(2.21884, 1.61986, 0.931645);
F_1 = float3(1.21884, 1.22103, 0.698939);
K_ap = float3(160.907, 143.234, 136.933);
sh_lambda = float3(6.76252, 6.76447, 6.76278);
sh_c = float3(16179.3, 3451.04, 3453.27);
sh_k = float3(36.1378, 35.1378, 33.614);
sh_theta0 = float3(0.846825, 0.821209, 0.830948);
}
void nylon() {
rho_d = float3(0.204199, 0.211192, 0.19234);
rho_s = float3(0.156797, 0.303324, 0.236394);
alpha = float3(0.0250344, 0.0436802, 0.0421753);
p = float3(0.528875, 0.617086, 0.620808);
F_0 = float3(0.240279, 0.117115, 0.127421);
F_1 = float3(0.219191, 0.0940848, 0.101339);
K_ap = float3(26.4669, 14.8484, 15.213);
sh_lambda = float3(2.32486, 2.22618, 2.18663);
sh_c = float3(1.17309e-07, 5.34378e-08, 6.68165e-08);
sh_k = float3(39.9707, 33.9774, 34.3152);
sh_theta0 = float3(0.11793, -0.0190508, -0.00222626);
}
void orange_paint() {
rho_d = float3(0.368088, 0.147113, 0.00692426);
rho_s = float3(0.524979, 0.116386, 0.199437);
alpha = float3(0.818115, 0.064743, 0.229391);
p = float3(1.44385, 0.0709512, 0.483597);
F_0 = float3(6.92565e-13, 0.106161, 0.102279);
F_1 = float3(-0.174318, 0.0934385, 0.0625648);
K_ap = float3(4.57466, 16.0185, 4.96427);
sh_lambda = float3(1.84547, 4.70387, 3.6232);
sh_c = float3(0.072629, 0.0299825, 0.000333551);
sh_k = float3(5.96872, 14.9466, 13.2194);
sh_theta0 = float3(0.222125, 0.438216, -0.0759733);
}
void pearl_paint() {
rho_d = float3(0.181967, 0.159068, 0.143348);
rho_s = float3(0.105133, 0.0928717, 0.0802367);
alpha = float3(0.0724063, 0.0808503, 0.0596139);
p = float3(0.194454, 0.203296, 0.091958);
F_0 = float3(0.168966, 0.297431, 0.401185);
F_1 = float3(-0.831034, -0.702569, -0.226546);
K_ap = float3(13.6335, 12.3113, 17.1256);
sh_lambda = float3(5.07525, 4.9097, 4.92468);
sh_c = float3(0.000252814, 0.000258641, 0.0180128);
sh_k = float3(18.9547, 18.2047, 16.1366);
sh_theta0 = float3(0.156731, 0.135808, 0.415562);
}
void pickled_oak_260() {
rho_d = float3(0.181735, 0.14142, 0.125486);
rho_s = float3(0.0283411, 0.0296418, 0.025815);
alpha = float3(0.0105853, 0.0102771, 0.0101188);
p = float3(2.31337e-14, 2.35272e-14, 1.99762e-14);
F_0 = float3(5.38184e-13, 2.15933e-13, 3.55496e-12);
F_1 = float3(-0.309259, -0.291046, -0.329625);
K_ap = float3(95.4759, 98.3089, 99.831);
sh_lambda = float3(6.37433, 6.39032, 6.39857);
sh_c = float3(4641.15, 5970.15, 6818.76);
sh_k = float3(18.1707, 18.2121, 18.2334);
sh_theta0 = float3(1.00563, 1.01274, 1.01645);
}
void pink_fabric2() {
rho_d = float3(0.24261, 0.0829238, 0.0751196);
rho_s = float3(0.161823, 0.0591236, 0.00907967);
alpha = float3(0.220011, 0.148623, 0.111966);
p = float3(6.44517e-12, 3.24286e-13, 3.83556e-11);
F_0 = float3(0.242032, 0.456181, 3.11925);
F_1 = float3(-0.0582931, 0.295844, 2.84268);
K_ap = float3(5.66376, 7.80657, 9.98941);
sh_lambda = float3(2.43742, 3.05804, 3.53392);
sh_c = float3(0.111404, 0.079067, 0.0738938);
sh_k = float3(7.47166, 9.23588, 10.5653);
sh_theta0 = float3(0.408014, 0.422779, 0.448866);
}
void pink_fabric() {
rho_d = float3(0.270553, 0.223977, 0.240993);
rho_s = float3(0.299998, 0.418074, 4.07112e-13);
alpha = float3(0.787023, 0.234345, 0.17346);
p = float3(1.77629, 4.64947e-15, 0.203846);
F_0 = float3(0.121124, 0.0271041, 1);
F_1 = float3(0.0151107, 0.00273969, 0);
K_ap = float3(4.71724, 5.3941, 6.55218);
sh_lambda = float3(2.23471, 2.34423, 3.31887);
sh_c = float3(0.0266324, 0.11955, 0.00966123);
sh_k = float3(7.20596, 7.20326, 11.0696);
sh_theta0 = float3(0.130136, 0.407562, 0.22282);
}
void pink_felt() {
rho_d = float3(0.259533, 0.192978, 0.185581);
rho_s = float3(0.359813, 0.533498, 0.0390541);
alpha = float3(0.46679, 0.203504, 0.314933);
p = float3(0.663613, 1.70267e-13, 0.778919);
F_0 = float3(0.0530603, 0.0108612, 1.12976);
F_1 = float3(-0.124124, -0.0455941, 1.05206);
K_ap = float3(3.6266, 6.02293, 3.92458);
sh_lambda = float3(2.22042, 2.55548, 3.68735);
sh_c = float3(0.0333497, 0.102524, 8.10122e-05);
sh_k = float3(7.40195, 7.81026, 13.5108);
sh_theta0 = float3(0.185696, 0.409228, -0.236166);
}
void pink_jasper() {
rho_d = float3(0.226234, 0.138929, 0.110785);
rho_s = float3(0.0846118, 0.0984038, 0.078693);
alpha = float3(0.00223592, 0.00203213, 0.0013737);
p = float3(0.53138, 0.4995, 0.436111);
F_0 = float3(0.172825, 0.129714, 0.154397);
F_1 = float3(0.0911362, 0.0599408, 0.0851167);
K_ap = float3(253.003, 292.741, 474.2);
sh_lambda = float3(1.64528, 1.86649, 5.29965e-08);
sh_c = float3(5.71153e-08, 6.24765e-08, 15.5452);
sh_k = float3(110.886, 113.953, 8.17872);
sh_theta0 = float3(0.416268, 0.422653, 0.561605);
}
void pink_plastic() {
rho_d = float3(0.354572, 0.0905002, 0.0696372);
rho_s = float3(0.0316585, 0.0444153, 6.36158e-15);
alpha = float3(0.0566727, 0.0369011, 0.142628);
p = float3(0.215149, 0.0621896, 0.189286);
F_0 = float3(0.317781, 0.0925394, 1);
F_1 = float3(0.266863, 0.0652821, 0);
K_ap = float3(16.788, 27.3043, 7.67451);
sh_lambda = float3(5.62766, 5.4919, 3.67439);
sh_c = float3(1.71214e-05, 0.187553, 0.00561921);
sh_k = float3(23.0822, 17.5369, 12.3737);
sh_theta0 = float3(0.0833775, 0.577298, 0.215985);
}
void polyethylene() {
rho_d = float3(0.228049, 0.239339, 0.240326);
rho_s = float3(0.0420869, 0.134269, 0.0867928);
alpha = float3(0.0472725, 0.260465, 0.0719615);
p = float3(2.09548e-13, 0.743064, 2.27838e-13);
F_0 = float3(0.489907, 0.316434, 0.181688);
F_1 = float3(0.424297, 0.244434, 0.0772152);
K_ap = float3(22.178, 4.24558, 14.9332);
sh_lambda = float3(4.92064, 4.37149, 4.27422);
sh_c = float3(0.330549, 9.78063e-07, 0.109488);
sh_k = float3(14.3439, 17.178, 12.5991);
sh_theta0 = float3(0.61045, -0.470479, 0.517652);
}
void polyurethane_foam() {
rho_d = float3(0.0898318, 0.0428583, 0.0340984);
rho_s = float3(4.0852e-12, 8.0217e-14, 4.05682e-14);
alpha = float3(0.154984, 0.142104, 0.139418);
p = float3(0.188586, 0.188095, 0.188124);
F_0 = float3(1, 1, 1);
F_1 = float3(0, 0, 0);
K_ap = float3(7.18433, 7.70043, 7.81983);
sh_lambda = float3(3.50087, 3.67779, 3.7174);
sh_c = float3(0.0079259, 0.00567317, 0.00525063);
sh_k = float3(11.6922, 12.3795, 12.537);
sh_theta0 = float3(0.226848, 0.217315, 0.215132);
}
void pure_rubber() {
rho_d = float3(0.284259, 0.251873, 0.223824);
rho_s = float3(0.542899, 0.598765, 0.142162);
alpha = float3(0.62899, 0.41413, 0.0693873);
p = float3(1.13687, 0.452063, 0.262952);
F_0 = float3(0.0185379, 0.00420901, 0.0353132);
F_1 = float3(-0.0265343, -0.035723, 0.0236736);
K_ap = float3(3.75577, 3.75969, 13.6137);
sh_lambda = float3(2.17187, 2.13584, 5.56595);
sh_c = float3(0.0311422, 0.0526357, 7.8942e-07);
sh_k = float3(7.14885, 7.0586, 23.9264);
sh_theta0 = float3(0.152489, 0.245615, -0.0979145);
}
void purple_paint() {
rho_d = float3(0.290743, 0.0347118, 0.0339802);
rho_s = float3(0.301308, 0.205258, 0.280717);
alpha = float3(0.0339173, 0.00839425, 0.0378011);
p = float3(0.703279, 0.20083, 0.797376);
F_0 = float3(0.0654958, 0.0786512, 0.0696424);
F_1 = float3(0.0299494, 0.0467651, 0.0373649);
K_ap = float3(16.3705, 104.698, 13.2101);
sh_lambda = float3(1.72814, 6.77684, 1.54679);
sh_c = float3(1.10548e-07, 0.177314, 6.66798e-08);
sh_k = float3(38.0847, 41.1712, 38.2781);
sh_theta0 = float3(0.0789738, 0.576929, 0.0587144);
}
void pvc() {
rho_d = float3(0.0322978, 0.0357449, 0.0403426);
rho_s = float3(0.28767, 0.317369, 0.310067);
alpha = float3(0.0171547, 0.0176681, 0.0213663);
p = float3(0.769726, 0.730637, 0.797555);
F_0 = float3(0.0289552, 0.026258, 0.0281305);
F_1 = float3(0.00815373, 0.00651989, 0.00714485);
K_ap = float3(25.8231, 26.9026, 20.5927);
sh_lambda = float3(1.20095, 1.31883, 1.23655);
sh_c = float3(1.02768e-07, 1.09767e-07, 5.97648e-08);
sh_k = float3(51.5975, 50.0184, 48.1953);
sh_theta0 = float3(0.218049, 0.208814, 0.173894);
}
void red_fabric2() {
rho_d = float3(0.155216, 0.0226757, 0.0116884);
rho_s = float3(1.80657e-15, 5.51946e-13, 1.35221e-15);
alpha = float3(0.16689, 0.135884, 0.128307);
p = float3(0.184631, 0.18856, 0.1883);
F_0 = float3(1, 1, 1);
F_1 = float3(0, 0, 0);
K_ap = float3(6.78759, 7.98303, 8.36701);
sh_lambda = float3(3.33819, 3.77225, 3.89063);
sh_c = float3(0.0112096, 0.00468671, 0.00372538);
sh_k = float3(11.0557, 12.7596, 13.2393);
sh_theta0 = float3(0.240935, 0.21164, 0.206003);
}
void red_fabric() {
rho_d = float3(0.201899, 0.0279008, 0.0103965);
rho_s = float3(0.168669, 0.0486346, 0.040485);
alpha = float3(0.324447, 0.228455, 0.109436);
p = float3(0.787411, 0.821197, 0.279212);
F_0 = float3(0.0718348, 0.0644687, 0.0206123);
F_1 = float3(-0.0585917, -0.0062547, -0.050402);
K_ap = float3(3.88129, 4.32067, 9.16355);
sh_lambda = float3(3.59825, 3.93046, 4.66379);
sh_c = float3(0.000130047, 1.04152e-07, 4.59182e-05);
sh_k = float3(13.0776, 19.649, 17.8852);
sh_theta0 = float3(-0.209387, -0.530789, -0.0242035);
}
void red_metallic_paint() {
rho_d = float3(0.0380897, 0.00540095, 0.00281156);
rho_s = float3(0.0416724, 0.07642, 0.108438);
alpha = float3(0.00133258, 0.00106883, 0.00128863);
p = float3(0.693854, 0.52857, 0.539477);
F_0 = float3(2.45718e-16, 0.0598671, 0.0633332);
F_1 = float3(-1, -0.08904, -0.0114056);
K_ap = float3(300.371, 521.418, 425.982);
sh_lambda = float3(6.45857e-05, 6.3446e-07, 8.51754e-07);
sh_c = float3(2.75773e-07, 4.05125e-07, 3.41703e-07);
sh_k = float3(33.0213, 24.3646, 23.5793);
sh_theta0 = float3(-0.121415, -0.469753, -0.532083);
}
void red_phenolic() {
rho_d = float3(0.165227, 0.0256259, 0.00935644);
rho_s = float3(0.240561, 0.360634, 0.475777);
alpha = float3(0.0052844, 0.00467439, 0.00613717);
p = float3(0.568938, 0.509763, 0.575762);
F_0 = float3(0.156419, 0.0972193, 0.069671);
F_1 = float3(0.0752589, 0.0444558, 0.0266428);
K_ap = float3(104.336, 128.839, 89.6357);
sh_lambda = float3(1.57629, 1.92067, 1.57462);
sh_c = float3(6.38793e-08, 6.71457e-08, 5.25172e-08);
sh_k = float3(77.4088, 79.3795, 73.0158);
sh_theta0 = float3(0.343482, 0.352913, 0.324912);
}
void red_plastic() {
rho_d = float3(0.247569, 0.049382, 0.0175621);
rho_s = float3(0.406976, 0.151478, 0.176348);
alpha = float3(0.28723, 0.0572489, 0.0624682);
p = float3(0.939617, 0.0851973, 0.0701483);
F_0 = float3(0.10036, 0.178468, 0.149441);
F_1 = float3(0.0512697, 0.13191, 0.102958);
K_ap = float3(3.80564, 17.8374, 16.5631);
sh_lambda = float3(4.37031, 4.96092, 4.75924);
sh_c = float3(1.03822e-07, 0.0236845, 0.0321546);
sh_k = float3(18.6088, 16.1371, 15.1243);
sh_theta0 = float3(-0.609047, 0.43547, 0.445882);
}
void red_specular_plastic() {
rho_d = float3(0.252589, 0.0397665, 0.0185317);
rho_s = float3(0.0139957, 0.0343278, 0.0527973);
alpha = float3(6.01746e-05, 8.07327e-05, 0.000205705);
p = float3(0.174569, 0.202455, 0.390522);
F_0 = float3(0.441328, 0.179378, 0.150221);
F_1 = float3(0.191312, 0.0691835, 0.0760833);
K_ap = float3(14623.1, 10620.2, 3332.98);
sh_lambda = float3(22.6631, 12.9299, 3.06408);
sh_c = float3(1e10, 1e0, 6.36761e-08);
sh_k = float3(187.799, 162.245, 315.067);
sh_theta0 = float3(1.19812, 1.20136, 0.52102);
}
void silicon_nitrade() {
rho_d = float3(0.0141611, 0.0115865, 0.00842477);
rho_s = float3(0.0710113, 0.0670906, 0.015769);
alpha = float3(6.40406e-05, 0.000138867, 0.00224354);
p = float3(0.159422, 0.283527, 0.734323);
F_0 = float3(0.0516164, 0.10318, 2.36643);
F_1 = float3(-0.0277792, -0.0531505, 1.36643);
K_ap = float3(13926.7, 5668.82, 167.824);
sh_lambda = float3(31.0579, 5.63563, 8.52534e-05);
sh_c = float3(1e10, 1e10, 2.96855e-07);
sh_k = float3(176.231, 148.745, 29.0282);
sh_theta0 = float3(1.20757, 1.14062, -0.241968);
}
void silver_metallic_paint2() {
rho_d = float3(0.0554792, 0.0573803, 0.0563376);
rho_s = float3(0.121338, 0.115673, 0.10966);
alpha = float3(0.029859, 0.0303706, 0.0358666);
p = float3(0.144097, 0.104489, 0.158163);
F_0 = float3(1.03749e-14, 3.52034e-15, 4.41778e-12);
F_1 = float3(-1, -1, -1);
K_ap = float3(31.9005, 32.1514, 26.5685);
sh_lambda = float3(6.08248, 5.89319, 5.95156);
sh_c = float3(0.00761403, 0.0839948, 0.00138703);
sh_k = float3(23.5891, 20.6786, 23.3297);
sh_theta0 = float3(0.435405, 0.54017, 0.34665);
}
void silver_metallic_paint() {
rho_d = float3(0.0189497, 0.0205686, 0.0228822);
rho_s = float3(0.173533, 0.168901, 0.165266);
alpha = float3(0.037822, 0.038145, 0.0381908);
p = float3(0.165579, 0.162955, 0.160835);
F_0 = float3(5.66903e-12, 1.65276e-14, 4.28399e-14);
F_1 = float3(-1, -1, -1);
K_ap = float3(25.1551, 24.9957, 25.0003);
sh_lambda = float3(5.92591, 5.90225, 5.89007);
sh_c = float3(0.000684235, 0.000840795, 0.000995926);
sh_k = float3(23.4725, 23.1898, 23.0144);
sh_theta0 = float3(0.310575, 0.317996, 0.324938);
}
void silver_paint() {
rho_d = float3(0.152796, 0.124616, 0.113375);
rho_s = float3(0.30418, 0.30146, 0.283174);
alpha = float3(0.110819, 0.105318, 0.0785677);
p = float3(0.640378, 0.641115, 0.445228);
F_0 = float3(2.37347e-13, 7.68194e-13, 2.9434e-12);
F_1 = float3(-0.350607, -0.355433, -0.359297);
K_ap = float3(7.21531, 7.46519, 10.8289);
sh_lambda = float3(3.06016, 2.97652, 3.78287);
sh_c = float3(9.71666e-08, 1.09342e-07, 9.82336e-08);
sh_k = float3(24.1475, 24.5083, 25.6757);
sh_theta0 = float3(-0.281384, -0.257633, -0.200968);
}
void special_walnut_224() {
rho_d = float3(0.0121712, 0.00732998, 0.00463072);
rho_s = float3(0.209603, 0.216118, 0.211885);
alpha = float3(0.117091, 0.119932, 0.131119);
p = float3(0.548899, 0.524858, 0.569425);
F_0 = float3(0.0808859, 0.0802614, 0.0789982);
F_1 = float3(0.0327605, 0.0324012, 0.0274637);
K_ap = float3(7.42314, 7.41578, 6.77215);
sh_lambda = float3(3.61532, 3.82778, 3.71096);
sh_c = float3(1.19182e-07, 1.03098e-07, 1.08004e-07);
sh_k = float3(22.9756, 22.7318, 22.2976);
sh_theta0 = float3(-0.31158, -0.332257, -0.35462);
}
void specular_black_phenolic() {
rho_d = float3(0.00212164, 0.00308282, 0.00410253);
rho_s = float3(0.0881574, 0.0923246, 0.0398117);
alpha = float3(0.00119167, 0.000641898, 0.000186605);
p = float3(0.616914, 0.578026, 0.40121);
F_0 = float3(0.122486, 0.0907984, 0.13855);
F_1 = float3(0.0482851, 0.0348218, 0.0481813);
K_ap = float3(395.656, 781.361, 3615.49);
sh_lambda = float3(1.18051e-05, 1.22149, 2.87626);
sh_c = float3(2.88932e-07, 6.09017e-08, 9.79363e-08);
sh_k = float3(28.9748, 200.529, 331.336);
sh_theta0 = float3(-0.257695, 0.487197, 0.524707);
}
void specular_blue_phenolic() {
rho_d = float3(0.00497564, 0.0138836, 0.032815);
rho_s = float3(0.1077, 0.0898232, 0.175296);
alpha = float3(0.000918571, 0.0010348, 0.00176322);
p = float3(0.570978, 0.639916, 0.709385);
F_0 = float3(0.0354139, 0.0488958, 0.023159);
F_1 = float3(-0.0434314, -0.0294427, -0.039938);
K_ap = float3(558.482, 431.708, 222.547);
sh_lambda = float3(3.57872e-06, 2.38985e-05, 6.87316e-05);
sh_c = float3(3.33356e-07, 3.3336e-07, 3.2851e-07);
sh_k = float3(28.5289, 32.1362, 30.3802);
sh_theta0 = float3(-0.272244, -0.141224, -0.19005);
}
void specular_green_phenolic() {
rho_d = float3(0.00781782, 0.0259654, 0.0233739);
rho_s = float3(0.0688449, 0.144658, 0.143654);
alpha = float3(0.000307494, 0.0010353, 0.00155331);
p = float3(0.365481, 0.585805, 0.787512);
F_0 = float3(0.129429, 0.0443676, 5.423e-12);
F_1 = float3(0.047932, -0.0136055, -0.0592743);
K_ap = float3(2313.47, 482.847, 206.646);
sh_lambda = float3(3.55591, 5.3306e-06, 0.000279403);
sh_c = float3(1.03804e-07, 3.47154e-07, 3.16888e-07);
sh_k = float3(256.625, 28.2901, 38.0691);
sh_theta0 = float3(0.511901, -0.277015, 0.00513058);
}
void specular_maroon_phenolic() {
rho_d = float3(0.152486, 0.0263216, 0.00802748);
rho_s = float3(0.0761775, 0.098375, 0.165913);
alpha = float3(0.000342958, 0.000605578, 0.00144136);
p = float3(0.4052, 0.553617, 0.65133);
F_0 = float3(0.0646024, 0.0116325, 0.037551);
F_1 = float3(-0.0555983, -0.0527264, -0.0283844);
K_ap = float3(1961.35, 868.119, 306.537);
sh_lambda = float3(2.81751, 1.361, 2.43015e-05);
sh_c = float3(5.70302e-08, 5.89096e-08, 3.27578e-07);
sh_k = float3(248.591, 203.707, 29.053);
sh_theta0 = float3(0.506511, 0.488814, -0.242746);
}
void specular_orange_phenolic() {
rho_d = float3(0.32771, 0.0540131, 0.00883213);
rho_s = float3(0.051915, 0.0686764, 0.0489478);
alpha = float3(7.91913e-05, 0.000139576, 1.62017e-05);
p = float3(0.253564, 0.354675, 3.55583e-12);
F_0 = float3(0.0768695, 0.0496641, 0.0223538);
F_1 = float3(-0.015514, -0.023864, -0.0433847);
K_ap = float3(10274.5, 5159.16, 61722.9);
sh_lambda = float3(7.4207, 3.83488, 8.72207e+06);
sh_c = float3(1e10, 1.02522e-07, 2.30124e+07);
sh_k = float3(170.364, 373.255, 855.811);
sh_theta0 = float3(1.19475, 0.53082, 0.608547);
}
void specular_red_phenolic() {
rho_d = float3(0.303563, 0.0354891, 0.00899721);
rho_s = float3(0.151819, 0.0938022, 0.196935);
alpha = float3(0.00117843, 0.00056476, 0.00185124);
p = float3(0.570146, 0.524406, 0.732785);
F_0 = float3(0.0287445, 0.0672098, 0.0178433);
F_1 = float3(-0.0386172, 0.0144813, -0.0322308);
K_ap = float3(438.968, 982.441, 201.328);
sh_lambda = float3(2.88657e-06, 8.12418e-07, 9.95633e-05);
sh_c = float3(3.8194e-07, 3.69661e-07, 3.03179e-07);
sh_k = float3(26.0046, 30.0091, 31.3125);
sh_theta0 = float3(-0.376008, -0.21799, -0.162894);
}
void specular_violet_phenolic() {
rho_d = float3(0.0686035, 0.0181856, 0.0210368);
rho_s = float3(0.108459, 0.0471612, 0.171691);
alpha = float3(0.00123271, 0.000443974, 0.00149517);
p = float3(0.657484, 0.546753, 0.653065);
F_0 = float3(0.0403569, 0.121081, 0.035323);
F_1 = float3(-0.0295013, 0.0563904, -0.0275623);
K_ap = float3(351.208, 1193.45, 294.897);
sh_lambda = float3(3.17585e-05, 1.3817, 2.44051e-05);
sh_c = float3(3.02028e-07, 6.19706e-08, 3.40809e-07);
sh_k = float3(31.3319, 234.879, 28.7237);
sh_theta0 = float3(-0.168991, 0.500354, -0.252626);
}
void specular_white_phenolic() {
rho_d = float3(0.282896, 0.231703, 0.127818);
rho_s = float3(0.0678467, 0.0683808, 0.032756);
alpha = float3(2.00918e-05, 3.22307e-05, 9.59333e-05);
p = float3(4.35028e-11, 0.131903, 0.390338);
F_0 = float3(0.0132613, 0.0416359, 0.285115);
F_1 = float3(-0.1025, -0.0828341, 0.0759745);
K_ap = float3(49772.5, 28318.4, 7131.79);
sh_lambda = float3(4.58788e+06, 1.12234e+07, 3.05696);
sh_c = float3(4.5813e+06, 1.00372e+07, 6.93295e-08);
sh_k = float3(767.24, 646.93, 455.184);
sh_theta0 = float3(0.60999, 0.61958, 0.536789);
}
void specular_yellow_phenolic() {
rho_d = float3(0.309395, 0.135278, 0.0159106);
rho_s = float3(0.0607659, 0.141526, 0.110839);
alpha = float3(0.000200174, 0.00179326, 0.00048094);
p = float3(0.355381, 0.767285, 0.505029);
F_0 = float3(0.077039, 0.0175574, 0.038586);
F_1 = float3(-0.0182146, -0.0417745, -0.0114057);
K_ap = float3(3597.35, 190.656, 1192.15);
sh_lambda = float3(3.80702, 0.000181166, 1.69208);
sh_c = float3(1.01181e-07, 3.0765e-07, 1.27637e-07);
sh_k = float3(313.8, 34.1523, 221.08);
sh_theta0 = float3(0.523001, -0.0813947, 0.500075);
}
void ss440() {
rho_d = float3(0.0229923, 0.0187037, 0.0153204);
rho_s = float3(0.127809, 0.14899, 0.0473376);
alpha = float3(4.06782e-05, 4.86278e-05, 8.15367e-05);
p = float3(0.0888931, 0.259135, 0.332727);
F_0 = float3(2.26479e-12, 5.7223e-13, 0.820577);
F_1 = float3(-0.474442, -0.223179, -0.179423);
K_ap = float3(23197.8, 16625.7, 9083.17);
sh_lambda = float3(1.43395e+07, 7.33446, 4.46921);
sh_c = float3(1.06287e+07, 1e10, 9.97795e-08);
sh_k = float3(556.069, 215.021, 479.875);
sh_theta0 = float3(0.627834, 1.20059, 0.540075);
}
void steel() {
rho_d = float3(0.019973, 0.0127074, 0.0246402);
rho_s = float3(0.0615275, 0.0469644, 0.0402151);
alpha = float3(8.63865e-05, 0.000249576, 5.77865e-05);
p = float3(0.3729, 0.583679, 0.471406);
F_0 = float3(0.665193, 0.798139, 0.0115189);
F_1 = float3(-0.334807, -0.201861, -0.988481);
K_ap = float3(8119.74, 1951.31, 10374.2);
sh_lambda = float3(3.40501, 1.12086, 1.88549);
sh_c = float3(1.25096e-07, 9.51373e-08, 1.20412e-07);
sh_k = float3(474.668, 313.81, 603.334);
sh_theta0 = float3(0.539696, 0.519433, 0.545491);
}
void teflon() {
rho_d = float3(0.276442, 0.263098, 0.260294);
rho_s = float3(1.56924, 1.52804, 1.43859);
alpha = float3(0.678586, 0.662167, 0.577852);
p = float3(1.2402, 1.14126, 1.44077);
F_0 = float3(9.40662e-13, 3.57656e-11, 1.50208e-11);
F_1 = float3(-0.0492032, -0.0587316, -0.0548028);
K_ap = float3(3.91532, 3.82834, 3.64944);
sh_lambda = float3(2.09871, 2.05044, 2.90315);
sh_c = float3(0.0378525, 0.0435869, 0.0028469);
sh_k = float3(6.8689, 6.72229, 9.65585);
sh_theta0 = float3(0.166634, 0.181605, -0.0468321);
}
void tungsten_carbide() {
rho_d = float3(0.0151872, 0.0103016, 0.0123192);
rho_s = float3(0.0504358, 0.075701, 0.0556673);
alpha = float3(6.6122e-05, 7.65809e-05, 4.80196e-05);
p = float3(0.255291, 0.270824, 0.26732);
F_0 = float3(5.30357e-14, 5.44537e-12, 1.09586e-11);
F_1 = float3(-1, -1, -1);
K_ap = float3(12280.7, 10423.3, 16683.5);
sh_lambda = float3(7.42976, 6.36068, 6.81602);
sh_c = float3(1e10, 1e10, 1e10);
sh_k = float3(185.623, 173.962, 218.975);
sh_theta0 = float3(1.197, 1.19586, 1.19745);
}
void two_layer_gold() {
rho_d = float3(0.0415046, 0.0312801, 0.0253658);
rho_s = float3(1.58161, 1.18736, 1.63847);
alpha = float3(0.0263104, 0.0293804, 0.0241265);
p = float3(0.355682, 0.354281, 0.36415);
F_0 = float3(0.117355, 0.0614942, 0.0447004);
F_1 = float3(0.0411678, -0.0237579, -0.0100488);
K_ap = float3(30.4478, 27.5367, 32.7278);
sh_lambda = float3(3.91606, 3.99968, 3.79114);
sh_c = float3(9.38513e-08, 6.62806e-08, 6.79906e-08);
sh_k = float3(36.9091, 35.6578, 38.4915);
sh_theta0 = float3(0.0815181, 0.0465613, 0.0922721);
}
void two_layer_silver() {
rho_d = float3(0.0657916, 0.0595705, 0.0581288);
rho_s = float3(1.55275, 2.00145, 1.93045);
alpha = float3(0.0149977, 0.0201665, 0.0225062);
p = float3(0.382631, 0.35975, 0.361657);
F_0 = float3(4.93242e-13, 1.00098e-14, 0.0103259);
F_1 = float3(-0.0401315, -0.0395054, -0.0312454);
K_ap = float3(50.1263, 38.8508, 34.9978);
sh_lambda = float3(3.41873, 3.77545, 3.78138);
sh_c = float3(6.09709e-08, 1.02036e-07, 1.01016e-07);
sh_k = float3(46.6236, 40.8229, 39.1812);
sh_theta0 = float3(0.183797, 0.139103, 0.117092);
}
void violet_acrylic() {
rho_d = float3(0.0599875, 0.023817, 0.0379025);
rho_s = float3(0.134984, 0.13337, 0.295509);
alpha = float3(0.0011295, 0.00126481, 0.00186818);
p = float3(0.523244, 0.551606, 0.478149);
F_0 = float3(0.100325, 0.0939057, 0.0663939);
F_1 = float3(0.0603016, 0.0579001, 0.0353439);
K_ap = float3(498.715, 424.307, 328.834);
sh_lambda = float3(4.79917e-07, 1.39397e-06, 2.03376);
sh_c = float3(4.27008e-07, 3.4655e-07, 1.05578e-07);
sh_k = float3(23.5924, 24.3831, 116.7);
sh_theta0 = float3(-0.515008, -0.476979, 0.432199);
}
void violet_rubber() {
rho_d = float3(0.223179, 0.0553634, 0.113238);
rho_s = float3(0.547456, 0.0966027, 0.185463);
alpha = float3(0.445092, 0.089421, 0.1543);
p = float3(0.923481, 0.782897, 0.800907);
F_0 = float3(0.0518927, 0.113508, 0.094549);
F_1 = float3(-0.0208955, 0.0585063, 0.036751);
K_ap = float3(3.58673, 7.33539, 5.24404);
sh_lambda = float3(2.83007, 2.27788, 3.00009);
sh_c = float3(0.00374266, 9.65628e-08, 1.13746e-07);
sh_k = float3(9.67534, 27.1898, 22.3519);
sh_theta0 = float3(-0.0037936, -0.174481, -0.363226);
}
void white_acrylic() {
rho_d = float3(0.314106, 0.300008, 0.263648);
rho_s = float3(0.015339, 0.0736169, 0.0976209);
alpha = float3(0.00233914, 0.00168956, 0.00117717);
p = float3(0.570501, 0.51337, 0.440543);
F_0 = float3(2.651, 0.38473, 0.249988);
F_1 = float3(2.27139, 0.341493, 0.218093);
K_ap = float3(226.134, 342.423, 548.396);
sh_lambda = float3(1.41218, 2.17179e-07, 4.52325e-08);
sh_c = float3(9.83895e-08, 5.84338e-06, 15.7173);
sh_k = float3(110.209, 18.8595, 8.78916);
sh_theta0 = float3(0.419684, -0.61884, 0.56243);
}
void white_diffuse_bball() {
rho_d = float3(0.284726, 0.239199, 0.177227);
rho_s = float3(0.680658, 0.828508, 0.502128);
alpha = float3(0.689731, 0.601478, 0.209084);
p = float3(1.23085, 0.956833, 0.800488);
F_0 = float3(1.06465e-11, 7.45307e-19, 0.089058);
F_1 = float3(-0.109723, -0.090129, 0.0545089);
K_ap = float3(3.94153, 3.65714, 4.53186);
sh_lambda = float3(2.04845, 2.06125, 3.72838);
sh_c = float3(0.0434345, 0.0439287, 1.06879e-07);
sh_k = float3(6.69695, 6.79535, 20.1466);
sh_theta0 = float3(0.178983, 0.18898, -0.494774);
}
void white_fabric2() {
rho_d = float3(0.10784, 0.102669, 0.113943);
rho_s = float3(0.0375359, 0.0296317, 0.0364218);
alpha = float3(0.0583526, 0.0520763, 0.063905);
p = float3(9.1836e-12, 5.41897e-13, 3.47708e-12);
F_0 = float3(0.0528459, 0.0854122, 0.0860966);
F_1 = float3(0.0578589, 0.0971296, 0.0985717);
K_ap = float3(18.1669, 20.2291, 16.6809);
sh_lambda = float3(4.60692, 4.77932, 4.46485);
sh_c = float3(0.172556, 0.23927, 0.138435);
sh_k = float3(13.5006, 13.9648, 13.1165);
sh_theta0 = float3(0.561147, 0.587176, 0.54153);
}
void white_fabric() {
rho_d = float3(0.290107, 0.219835, 0.160654);
rho_s = float3(0.230066, 0.156787, 2.19005e-12);
alpha = float3(0.479844, 0.196767, 0.162438);
p = float3(0.669662, 2.22894e-13, 0.194582);
F_0 = float3(7.17773e-14, 0.0364632, 1);
F_1 = float3(-0.209237, -0.0528699, 0);
K_ap = float3(3.60967, 6.18732, 6.91147);
sh_lambda = float3(2.17095, 2.60737, 3.42418);
sh_c = float3(0.0379118, 0.0990846, 0.00860197);
sh_k = float3(7.221, 7.95861, 11.4289);
sh_theta0 = float3(0.195346, 0.409992, 0.225019);
}
void white_marble() {
rho_d = float3(0.236183, 0.221746, 0.192889);
rho_s = float3(0.24075, 0.221456, 0.23389);
alpha = float3(0.00430204, 0.00429388, 0.00405907);
p = float3(0.681306, 0.676061, 0.620701);
F_0 = float3(0.118569, 0.167963, 0.140415);
F_1 = float3(0.0620704, 0.102032, 0.071968);
K_ap = float3(103.053, 104.312, 122.169);
sh_lambda = float3(1.0396, 1.05866, 1.26372);
sh_c = float3(1.08288e-07, 6.82995e-08, 5.76023e-08);
sh_k = float3(88.7766, 89.0261, 88.95);
sh_theta0 = float3(0.378101, 0.372681, 0.371975);
}
void white_paint() {
rho_d = float3(0.356024, 0.3536, 0.324889);
rho_s = float3(4.14785, 0.255488, 0.108438);
alpha = float3(0.0654126, 0.0841905, 0.538225);
p = float3(0.796927, 0.7778, 0.888627);
F_0 = float3(0.0770738, 0.25087, 1.75144e-13);
F_1 = float3(0.0782297, 0.226285, -0.367441);
K_ap = float3(8.89985, 7.66809, 3.59697);
sh_lambda = float3(1.96428, 2.23069, 2.23051);
sh_c = float3(5.9674e-08, 1.07673e-07, 0.0280623);
sh_k = float3(31.0512, 27.6872, 7.41492);
sh_theta0 = float3(-0.0896936, -0.151411, 0.154604);
}
void yellow_matte_plastic() {
rho_d = float3(0.276745, 0.108557, 0.0203686);
rho_s = float3(0.806628, 1.99624, 0.977002);
alpha = float3(0.0237573, 0.0265756, 0.0305873);
p = float3(0.558101, 0.537647, 0.710679);
F_0 = float3(0.0624565, 0.0605404, 0.0541077);
F_1 = float3(0.049915, 0.0567466, 0.0473569);
K_ap = float3(26.7398, 24.8437, 17.6137);
sh_lambda = float3(2.1481, 2.32064, 1.65758);
sh_c = float3(5.99553e-08, 5.96103e-08, 6.38097e-08);
sh_k = float3(41.7723, 39.7008, 40.1979);
sh_theta0 = float3(0.11569, 0.0891281, 0.0886802);
}
void yellow_paint() {
rho_d = float3(0.288876, 0.195348, 0.0314583);
rho_s = float3(0.449392, 0.412812, 0.168707);
alpha = float3(0.650734, 0.190849, 0.16131);
p = float3(1.21986, 0.0333524, 0.137577);
F_0 = float3(0.00201415, 7.31639e-13, 0.13481);
F_1 = float3(-0.0897316, -0.0639292, 0.103378);
K_ap = float3(3.83308, 6.31195, 7.06429);
sh_lambda = float3(2.18358, 2.72018, 3.26561);
sh_c = float3(0.0298708, 0.0764778, 0.0198928);
sh_k = float3(7.1694, 8.39507, 10.5682);
sh_theta0 = float3(0.146537, 0.387991, 0.292185);
}
void yellow_phenolic() {
rho_d = float3(0.26924, 0.190177, 0.0858303);
rho_s = float3(0.0861694, 0.0960246, 0.122709);
alpha = float3(0.00126171, 0.00197611, 0.00187166);
p = float3(0.444222, 0.512534, 0.504223);
F_0 = float3(0.0988294, 0.120249, 0.0929719);
F_1 = float3(0.0295258, 0.0539044, 0.0471952);
K_ap = float3(509.34, 294.418, 314.704);
sh_lambda = float3(4.59604e-08, 1.76251, 1.81658);
sh_c = float3(15.6472, 6.5671e-08, 9.96466e-08);
sh_k = float3(8.52565, 116.04, 118.064);
sh_theta0 = float3(0.561753, 0.425536, 0.432459);
}
void yellow_plastic() {
rho_d = float3(0.221083, 0.193042, 0.0403393);
rho_s = float3(0.265199, 0.340361, 0.0670333);
alpha = float3(0.280789, 0.146396, 0.0248514);
p = float3(0.920018, 0.0356237, 7.80502e-12);
F_0 = float3(0.144471, 0.10845, 0.125678);
F_1 = float3(0.113592, 0.0663735, 0.103644);
K_ap = float3(3.85808, 7.84753, 41.2517);
sh_lambda = float3(4.34432, 3.16869, 5.71439);
sh_c = float3(1.04213e-07, 0.055929, 7.84273);
sh_k = float3(18.6813, 9.73614, 16.4495);
sh_theta0 = float3(-0.60265, 0.393386, 0.781122);
}
*/
/*
void SetMat(int i)
{
if (i < 50) { if (i < 25) {
IF(0,alum_bronze)
EIF(1,alumina_oxide)
EIF(2,aluminium)
EIF(3,aventurnine)
EIF(4,beige_fabric)
EIF(5,black_fabric)
EIF(6,black_obsidian)
EIF(7,black_oxidized_steel)
EIF(8,black_phenolic)
EIF(9,black_soft_plastic)
EIF(10,blue_acrylic)
EIF(11,blue_fabric)
EIF(12,blue_metallic_paint2)
EIF(13,blue_metallic_paint)
EIF(14,blue_rubber)
EIF(15,brass)
#ifndef I_HAVE_LAME_SYSTEM
EIF(16,cherry_235)
EIF(17,chrome)
EIF(18,chrome_steel)
EIF(19,colonial_maple_223)
EIF(20,color_changing_paint1)
EIF(21,color_changing_paint2)
EIF(22,color_changing_paint3)
EIF(23,dark_blue_paint)
EIF(24,dark_red_paint) } else {
IF(25,dark_specular_fabric)
EIF(26,delrin)
EIF(27,fruitwood_241)
EIF(28,gold_metallic_paint2)
EIF(29,gold_metallic_paint3)
EIF(30,gold_metallic_paint)
EIF(31,gold_paint)
EIF(32,gray_plastic)
EIF(33,grease_covered_steel)
EIF(34,green_acrylic)
EIF(35,green_fabric)
EIF(36,green_latex)
EIF(37,green_metallic_paint2)
EIF(38,green_metallic_paint)
EIF(39,green_plastic)
EIF(40,hematite)
EIF(41,ipswich_pine_221)
EIF(42,light_brown_fabric)
EIF(43,light_red_paint)
EIF(44,maroon_plastic)
EIF(45,natural_209)
EIF(46,neoprene_rubber)
EIF(47,nickel)
EIF(48,nylon)
EIF(49,orange_paint) } } else { if (i < 75) {
IF(50,pearl_paint)
EIF(51,pickled_oak_260)
EIF(52,pink_fabric2)
EIF(53,pink_fabric)
EIF(54,pink_felt)
EIF(55,pink_jasper)
EIF(56,pink_plastic)
EIF(57,polyethylene)
EIF(58,polyurethane_foam)
EIF(59,pure_rubber)
EIF(60,purple_paint)
EIF(61,pvc)
EIF(62,red_fabric2)
EIF(63,red_fabric)
EIF(64,red_metallic_paint)
EIF(65,red_phenolic)
EIF(66,red_plastic)
EIF(67,red_specular_plastic)
EIF(68,silicon_nitrade)
EIF(69,silver_metallic_paint2)
EIF(70,silver_metallic_paint)
EIF(71,silver_paint)
EIF(72,special_walnut_224)
EIF(73,specular_black_phenolic)
EIF(74,specular_blue_phenolic) } else {
IF(75,specular_green_phenolic)
EIF(76,specular_maroon_phenolic)
EIF(77,specular_orange_phenolic)
EIF(78,specular_red_phenolic)
EIF(79,specular_violet_phenolic)
EIF(80,specular_white_phenolic)
EIF(81,specular_yellow_phenolic)
EIF(82,ss440)
EIF(83,steel)
EIF(84,teflon)
EIF(85,tungsten_carbide)
EIF(86,two_layer_gold)
EIF(87,two_layer_silver)
EIF(88,violet_acrylic)
EIF(89,violet_rubber)
EIF(90,white_acrylic)
EIF(91,white_diffuse_bball)
EIF(92,white_fabric2)
EIF(93,white_fabric)
EIF(94,white_marble)
EIF(95,white_paint)
EIF(96,yellow_matte_plastic)
EIF(97,yellow_paint)
EIF(98,yellow_phenolic)
EIF(99,yellow_plastic)
#endif //I_HAVE_LAME_SYSTEM
} }
}
*/
// ###### </PBR MATERIAL INFORMATION>
/*
To map
[min, max] --> [newmin, newmax]
(val - min)*(newmax-newmin)/(max-min) + newmin
*/
float remapInterval(in float val, in float vmin, in float vmax, in float newmin, in float newmax)
{
if(val<vmin)
{
val = vmin;
}
return (val - vmin)*(newmax - newmin) / (vmax - vmin) + newmin;
}
//TODO: split into multiple .usf files
float sdfSphere(in int render, in float3 pos, in float sig)
{
if(render == 0)
return 9999999;
else
return length(pos)-sig;
}
float sdfPlane(in int render, in float3 pos)
{
if(render == 0)
return 9999999;
else
return pos.y;
}
//Hexagonal Prism - signed - exact //Thanks IQ!
float sdHexPrism(in int render, in float3 p, in float2 h)
{
if(render == 0)
return 9999999;
else
{
float3 q = abs(p);
return max(q.z-h.y,max((q.x*0.866025+q.y*0.5),q.y)-h.x);
}
}
float2 blendOpU(in float2 distAndID1, in float2 distAndID2)
{
if(distAndID1.x < distAndID2.x)
{
return distAndID1;
}
else
{
return distAndID2;
}
}
// polynomial smooth min (k = 0.1);
// THANKS IQ! http://iquilezles.org/www/articles/smin/smin.htm
float smin(in float a, in float b, in float k )
{
float h = clamp( 0.5+0.5*(b-a)/k, 0.0, 1.0 );
return lerp( b.x, a.x, h ) - k*h*(1.0-h);
}
float2 blendOpUSmooth(in float2 distAndID1, in float2 distAndID2, in float k)
{
float smoothD = smin(distAndID1.x, distAndID2.x, k);
float matID = blendOpU(distAndID1, distAndID2).y; // TODO: Do a smooth material blend flag somehow
return float2(smoothD, matID);
}
float2 sampleDistanceFields(in float3 pos, in int orsc)
{
// This is used to prevent certain objects from Casting shadows.
// Note they do still receive shadows from any objects that cast shadows (other than themselves)
// orsc == onlyRenderShadowCasters;
/*
returned value:
.x == distance function result (the surface)
.y == material colorID
material colorID legend:
-infinity, 0.09 == ground layer
0.1, 0.49 == lights layer
[...]
1.0, infinity == object surface material layer
*/
float2 distAndID = blendOpU( float2(sdfPlane(1-orsc, pos),0.09),
float2(sdfSphere(2-orsc,pos - float3(25,300,0),50),1.5)
);
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(-25,300,-25),25),1.5));
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(15,325,-25),25),1.5));
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(-10,335,-40),25),1.5));
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(-100,200,-80),80),1.5));
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(-100,40,-80),60),1.5));
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(-125,215,-145),15),0.6));
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(-75,215,-145),15),0.6));
//
distAndID = blendOpU( distAndID, float2(sdHexPrism(2-orsc, pos - float3(100,200,0),float2(50, 50)),0.6));
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(200,300,0),50),0.6));//0.09
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(200,200,0),50),1.5));
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(280,300,0),50),1.5));
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(280,200,0),50),1.5));
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(380,300,-100), 50),1.5));
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(380,250,-100), 50),1.5));
distAndID = blendOpU( distAndID, float2(sdHexPrism(2-orsc, pos - float3(310,75,0),float2(75, 50)),1.5));
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(-200,300,0),50),0.6));
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(-200,300,-80),25),0.6));
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(-200,323,-70),25),0.6));
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(-280,300,0),50),0.6));
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(-280,200,0),50),0.6));
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(-380,300,-80),50),0.6));
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(-380,200,-100),50),0.6));
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(-480,300,-180),50),0.6));
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(-480,250,-200),50),0.6));
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(-480,500,180),50),0.6));
distAndID = blendOpU( distAndID, float2(sdfSphere(2-orsc,pos - float3(-480,400,200),50),0.6));
//vogel's method for spreading points on a disc
int numPts = 100 + PSVariable.SVP_angleStep_I_numPts_I_yPos_I_xzScale.y;
float sqrtn = sqrt(numPts);
float pi = 3.14159;
float goldenAngle = pi * (3 - sqrt(PSVariable.SVP_angleStep_I_numPts_I_yPos_I_xzScale.x));//sqrt(5) = 2.236068
for(int i = 0; i<numPts; i++)
{
float theta = i * goldenAngle;
float rad = sqrt(i) / sqrtn;
float2 pt = float2(rad * cos(theta), rad * sin(theta));
distAndID = blendOpUSmooth( distAndID, float2(sdfSphere(2-orsc,pos - float3(
-100 + pt.x * PSVariable.SVP_angleStep_I_numPts_I_yPos_I_xzScale.w,
100 + sin(PSVariable.SVP_time)*i*PSVariable.SVP_angleStep_I_numPts_I_yPos_I_xzScale.z,
-80 + pt.y * PSVariable.SVP_angleStep_I_numPts_I_yPos_I_xzScale.w),
25),0.6),
PSVariable.testVarsX3.x
);
}
// point lights
for(int i=0; i < PSVariable.SVP_PointLights_count; i++)
{
distAndID = blendOpU( distAndID,
//float2(sdfSphere(1-orsc,pos - PSVariable.SVP_PointLights_position[i] - float3(0,-33,0),10),0.49)
float2(sdfSphere(1-orsc,pos - PSVariable.SVP_PointLights_position[i],10),0.49)
);
}
return distAndID;
}
// this works with arbitrary shapes and arbitrary shape intersections and blends
// it's just like calcualting normals from voxels, except we sample the distance field neighbours
float3 calcNormal_Multisample(in float3 pos)
{
float2 jitt = float2(PSVariable.SVP_RayTrace_normalSamplingJitter, 0.0);
float3 normal = float3(
sampleDistanceFields(pos+jitt.xyy, 0).x - sampleDistanceFields(pos-jitt.xyy, 0).x,
sampleDistanceFields(pos+jitt.yxy, 0).x - sampleDistanceFields(pos-jitt.yxy, 0).x,
sampleDistanceFields(pos+jitt.yyx, 0).x - sampleDistanceFields(pos-jitt.yyx, 0).x
);
return normalize(normal);
}
// We march through the ray between the surface and light
// We look for either a point of intersection ( df < 0),
// or the distance field value closest to being < 0 (meaning
// the closest the ray ever got to a surface - we use this for soft shadows.
float dfMarchSoftShadow(in float3 rayOrigin, in float3 rayDir, in float2 traceBounds, in float camDistance, in int i)
{
float maxMarch = PSVariable.SVP_PointLights_maxMarch[i];//100;
float shadowScaler = PSVariable.SVP_PointLights_shadowScaler[i];//0.008;//100000;
float2 minMaxStep = PSVariable.SVP_PointLights_minMaxStep[i];
float shadVal = 1.0;
float trace = traceBounds.x;//1
//float2 jitt = float2(minMaxStep.x*10, 0.0);
//float2 jitt = float2(PSVariable.testVarsX3.x, 0.0);
float lvmin = traceBounds.y - PSVariable.SVP_Lights_distToFadeShads.x;
for( int i=0; i < maxMarch; i++ )
{
float dfRes = sampleDistanceFields( rayOrigin + rayDir * trace, 1 ).x;
// If the light is close to object (within the object's distance field halo that contributes to shadows)
// then the ray between the object and the light will end in that shadow field even if the object the field
// belongs to is actually behind the light, beyond the ray.
// With this scaler we fade out all shadows when they get close to the end of the ray max distance.
float lv = remapInterval(trace, lvmin, traceBounds.y, 1, PSVariable.SVP_Lights_distToFadeShads.y);
// Save min shad and scale the shadow blur by distance factor.
shadVal = min( shadVal, dfRes * shadowScaler / (1+trace*lv));
// march slower if we're close to a potential surface, otherwise fast
trace += clamp(dfRes,minMaxStep.x,minMaxStep.y);//2.2, 10
if( dfRes < minMaxStep.x || trace > traceBounds.y )
{
break;
}
//TODO: the further the ray from the surface has travelled towards the light unobstructed,
//the lower the future obstruction should be. IE fade shadows w distance instead of cutting off
}
return saturate(shadVal);
}
// We march along the normal a few times, and for each point that we stop at,
// we cast a ray forwards towards the surface. If we find something closer
// to the screen than the original pos, we add to the occlusion
float calcAO(in float3 pos, in float3 normal, in int numSamples, in int maxDist, in float str)
{
float stepSize = maxDist/numSamples;
float occlusion = 0.0;
float fade = 1;
for(int i=1; i<numSamples+1; i++)
{
float normScale = stepSize*i;
float3 sampleAO = pos + normal * normScale;
float dds = sampleDistanceFields(sampleAO, 0).x;
fade *= str/(normScale*normScale);
occlusion += -(dds-normScale)*fade;
}
//occlusion = clamp(occlusion, 0 , str);
occlusion = saturate(occlusion);
return (1-occlusion);
}
// Anisotropic GGX
// [Burley 2012, "Physically-Based Shading at Disney"]
float D_GGX(in float n_Dot_h, in float roughness)
{
float roughnessSqr = roughness*roughness;
float pi = 3.14159;
float denom = n_Dot_h * n_Dot_h * (roughnessSqr-1.0) + 1.0;
return roughnessSqr / (pi * denom * denom);
}
float3 F_SF(in float l_Dot_h, in float3 F0)
{
float l_Dot_h_5 = pow(1.0 - l_Dot_h, 5);
return F0 + (1 - F0) * l_Dot_h_5;
}
float G1V(in float n_Dot_lv, in float k)
{
return 1.0 / (n_Dot_lv * (1.0-k)+k);
}
float V_Vis(in float roughness, in float n_Dot_l, in float n_Dot_v)
{
float k = roughness / 2.0;
return G1V(n_Dot_l, k) * G1V(n_Dot_v, k);
}
float3 Diffuse_Lambert(in float3 F0diff, in float3 F0, in float n_Dot_l)
{
float3 diffuse = F0 + ( 1.0 - F0 ) * pow( 1.0 - n_Dot_l, 5.0);
return F0diff * ( 1 - diffuse);
}
// I use Cook-Torrance BRDF: Specular = D*F*G
// D: GGX Distribution, F: Schlick-Fresnel, G/V: Schlick approximation of Smith solved with GGX
//Survey on various BRDFs, and general documentation:
//http://www.codinglabs.net/article_physically_based_rendering_cook_torrance.aspx
//http://graphicrants.blogspot.de/2013/08/specular-brdf-reference.html
//https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/BRDF.usf
//https://disney-animation.s3.amazonaws.com/library/s2012_pbs_disney_brdf_notes_v2.pdf
//http://simonstechblog.blogspot.de/2011/12/microfacet-brdf.html
//+ various shadertoys
// for ex this one has realistic material values: https://www.shadertoy.com/view/XssGzf
float3 calcBRDF(
in float3 lightDir,//the direction from surface to light
in float3 viewDir,//the direction from surface to eye
in float3 normal,//surface normal
in float matRoughness,
in float3 F0diff,//diffuseReflectance,
in float3 F0,//specReflectance,
in float3 lightIntensity,
in float occlusion
)
{
// half way vector between surface to light and surface to view
float3 halfVector = normalize(lightDir+viewDir);
// dots
float stop = 0.01;
float l_Dot_h = max( abs( dot(lightDir, halfVector) ), stop)-stop;//0.001
float n_Dot_h = max( abs( dot(normal, halfVector) ), stop)-stop;
float n_Dot_l = max( abs( dot(normal, lightDir) ), stop)-stop;
float n_Dot_v = max( abs( dot(normal, viewDir) ), stop)-stop;
float roughness = matRoughness * matRoughness;
// Normal Distribution Function
// You'll often find the Beckmann solution for the D term.
// I use GGX because it's more high quality (albeit more costly)
// http://www.neilblevins.com/cg_education/ggx/ggx.htm
// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/
// D_GGXaniso https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/BRDF.usf
// I implemented classic GGX Distribution. TODO: Optimize.
float D = D_GGX(n_Dot_h, roughness);
float3 F = F_SF(l_Dot_h, F0);
float V = V_Vis(roughness, n_Dot_l, n_Dot_v);
float3 spec = n_Dot_l * D * F * V;
float3 lambDiff = Diffuse_Lambert(F0diff, F0, n_Dot_l);// * abs(n_Dot_l);
return (lambDiff + spec ) * occlusion * lightIntensity * n_Dot_l;
}
float3 calcFloorColor(in float3 pos, in float colorID)
{
// checker pattern
float checkerSize = 0.015;
float patt = fmod(abs(floor(checkerSize*pos.x) + floor(checkerSize*pos.z)), 2);
return saturate(float3(0.4,0.4,0.4)+patt*float3(colorID,colorID,colorID));
}
float4 dfRaytracer(float3 rayOri, float3 rayDir)
{
//RAYMARCH INTO DISTANCE FIELDS
//{
float maxMarch = PSVariable.SVP_RayTrace_maxMarch;//100
float2 traceBounds = float2(0,10000);
float dfThresh = 0.01;
float trace = traceBounds.x;
float colorID = -1.0;
float2 dfRes = float2(0,0);
float2 minMaxStep = PSVariable.SVP_RayTrace_minMaxStep;
// marching the ray front to back and stopping when I find the first surface.
for(int i=0; i<maxMarch; i++)
{
dfRes = sampleDistanceFields(rayOri+rayDir*trace, 0);
// if the distance result is 0 then we've found a surface and we break
// if we reach the max distance we want to march towards we also break
if((dfRes.x) < minMaxStep.x || trace > traceBounds.y)
{
break;
}
// instead of marching the ray a fixed step at a time,
// we march based on the distance function result from our last attempt
trace += clamp(dfRes.x,minMaxStep.x,minMaxStep.y);
colorID = dfRes.y;
}
//}
//COMPUTE FRAGMENT COLOR
//{
float3 color = float3(0.0, 0.0, 0.0);
float3 skyAmbColor = float3(0.5, 0.7, 0.8);
// sky
if(trace > traceBounds.y)
//if(abs(dfRes.x) > dfThresh)
{
colorID = -1.0;
color = skyAmbColor + rayDir.y*0.5;
}
if(colorID > -0.99)
{
float3 pos = rayOri + rayDir * trace;
float3 normal = calcNormal_Multisample(pos);
float3 viewReflection = reflect(rayDir, normal);
// material of current surface
//{
float roughnessSlider = 0.0;
float3 F0diff = float3(0.0,0.0,0.0);
float metallicSlider = 0;// 0-1
// Calculate colour at normal incidence
// conductor (metal) vs dielectric materials
float3 F0 = float3(0.0,0.0,0.0);
// if ground, generate some floor texture
if(colorID < 0.10)
{
color = calcFloorColor(pos, colorID);
roughnessSlider = 0.6;
F0diff = float3(9.16095e-12, 1.81225e-12, 0.0024589);//F0 for diffuse
//TODO: Get material sampler
metallicSlider = 0.2;
float3 ior = float3(9.16095e-12, 1.81225e-12, 0.0024589);//gold paint index of refraction
F0 = abs ((1.0 - ior) / (1.0 + ior));
F0 = F0 * F0;
F0 = lerp(color, F0, metallicSlider);
F0diff = F0;
}
else if( colorID == 0.6)
{
//color = float3(colorID,colorID,colorID); //TODO: make a color sampler
color = float3(0.5,0.5,0.5); //TODO: make a color sampler
roughnessSlider = 0.6;
F0diff = float3(9.16095e-12, 1.81225e-12, 0.0024589);//F0 for diffuse
//TODO: Get material sampler
metallicSlider = 0.2;
float3 ior = float3(9.16095e-12, 1.81225e-12, 0.0024589);//gold paint index of refraction
F0 = abs ((1.0 - ior) / (1.0 + ior));
F0 = F0 * F0;
F0 = lerp(color, F0, metallicSlider);
F0diff = F0;
}
else
{
//color = float3(colorID,colorID,colorID); //TODO: make a color sampler
color = float3(0.97,0.76,0.22); //TODO: make a color sampler
roughnessSlider = 0.6;
F0diff = float3(9.16095e-12, 1.81225e-12, 0.0024589);//F0 for diffuse
//TODO: Get material sampler
metallicSlider = 0.8;
float3 ior = float3(9.16095e-12, 1.81225e-12, 0.0024589);//gold paint index of refraction
F0 = abs ((1.0 - ior) / (1.0 + ior));
F0 = F0 * F0;
F0 = lerp(color, F0, metallicSlider);
F0diff = F0;
}
//}
//NOTE: If you want to turn off calcAO for unlit objects, you need to check if the current sample(pos) is itself unlit.
// (float3 pos, float3 normal, int numSamples, int maxDist, float str) //6, 64, 7
float occlusion = calcAO(pos, normal,
PSVariable.AO_nSamples_I_maxDist_I_Str.x,
PSVariable.AO_nSamples_I_maxDist_I_Str.y,
PSVariable.AO_nSamples_I_maxDist_I_Str.z
);
float3 finalLight = float3(0.0,0.0,0.0);
// "directional light's direction for the first directional light"
//float3 dirLightDir_01 = normalize(float3(-0.5,0.8,-0.5));
float3 viewDir = normalize(rayOri - pos);
float camDistance = distance(pos, rayOri);
// point lights
for(int i=0; i < PSVariable.SVP_PointLights_count; i++)
{
if(PSVariable.SVP_PointLights_isOn[i] == 0)
{
continue;
}
float lightSize = PSVariable.SVP_PointLights_size[i];
float3 pointLight_DirRev = normalize(PSVariable.SVP_PointLights_position[i] - pos);
float distToLight = distance(pos, PSVariable.SVP_PointLights_position[i]);
float attenuation = 1;///(distToLight*distToLight);
float3 lightColorAndIntensity = PSVariable.SVP_PointLights_color[i]*lightSize;// float3(0.6,0.57,0.45)
/*
float diffuse = saturate(dot(normal, pointLight_DirRev)) * lightColorAndIntensity.x;
float3 diffuseColor = float3(0.7,0.7,0.2);
finalLight += diffuseColor * diffuse * attenuation * occlusion;
// TODO: irradiance of material? float3 diffuse = color * irradiance;
*/
float3 lightDir = pointLight_DirRev;// for point: normalize(lightPos - pos);
float currentShad = 1.0;
if(PSVariable.SVP_PointLights_castsShadows[i] == 1)
{
float2 shdBounds = float2(
PSVariable.SVP_PointLights_minMaxShadowRayDist[i].x,
min(
distToLight,
PSVariable.SVP_PointLights_minMaxShadowRayDist[i].y
)
);
currentShad = dfMarchSoftShadow(pos, lightDir, shdBounds, camDistance, i);
}
finalLight += attenuation *
currentShad *
calcBRDF(lightDir, viewDir, normal,
roughnessSlider,
F0diff, F0,
lightColorAndIntensity,
occlusion
);
}
float ambientIntensity = saturate(0.5 + 0.5 * normal.y);
float3 ambient = 0.20 * ambientIntensity * skyAmbColor;
finalLight += ambient;// * occlusion;
color = (color * finalLight);
//}
}
return float4(color,1);
}
//Texture2D<uint> T0DitheredSelectiveRaytracingTexture;
sampler2D T0DitheredSelectiveRaytracingTexture;
//float4x4 FViewToWorld;
void MainVertexShader(
float4 InPosition : ATTRIBUTE0,
float2 InUV : ATTRIBUTE1,
out float4 OutPosition : SV_POSITION,
out float2 OutUV : TEXCOORD0,
out float4 OutVPos : TEXCOORD1
//out float4 OutScreenRay : TEXCOORD2,
)
{
OutPosition = InPosition;
OutUV.xy = InUV*2-int2(1,1);
OutUV.y *=-1;
OutUV /=2;
OutVPos = float4(InPosition.xy,0,1);
}
void MainPixelShader(
in float4 pos : SV_POSITION,
in float2 uv : TEXCOORD0,//float2
in float4 inVPos : TEXCOORD1,
//in float4 inScreenRay : TEXCOORD2,
out float4 OutColor : SV_Target0
)
{
/*
//First we need to unpack the uint material and retrieve the underlying R8G8B8A8_UINT values.
float sizeX, sizeY;
TextureParameter.GetDimensions(sizeX, sizeY);
uint packedValue = TextureParameter.Load(int3(sizeX * uv.x, sizeY * uv.y, 0));
uint r = (packedValue & 0x000000FF);
uint g = (packedValue & 0x0000FF00) >> 8;
uint b = (packedValue & 0x00FF0000) >> 16;
uint a = (packedValue & 0xFF000000) >> 24;
//Here we will just blend using the TextureParameterBlendFactor between our simple color change shader and the input from the compute shader
float alpha = length(uv) / length(float2(1, 1));
OutColor = lerp(PSConstant.StartColor, PSVariable.EndColor, alpha) * (1.0 - PSVariable.TextureParameterBlendFactor)
+ float4(r, g, b, a) / 255.0 * PSVariable.TextureParameterBlendFactor;
*/
//float depth = CalcSceneDepth(uv);
//
float4 col = float4(0,0.05,0,0.05);
float3 fragWorldPos = mul(PSVariable.FViewToWorld,float4(uv.x,uv.y,0,1)).xyz;
float3 rayDir = normalize(mul(PSVariable.FViewToWorld,float4(uv.x,-uv.y,-2,0)).xyz);
//TODO: move to vert
OutColor = float4(0,0,0,1);
if(PSVariable.SVP_RaytracerRunFlag == 0.0)
{
OutColor = dfRaytracer(fragWorldPos.xyz, rayDir);
}
else if(PSVariable.SVP_RaytracerRunFlag == 1.0)
{
float2 uvTiled = uv;
if(uvTiled.x<0)
{
uvTiled.x = 1 + uvTiled.x;
}
if(uvTiled.y<0)
{
uvTiled.y = 1 + uvTiled.y;
}
float val = tex2D(T0DitheredSelectiveRaytracingTexture, abs(uvTiled)).x;
// I'm using a lookup noise texture and an interval which is set from the c++ side,
// to only raytrace a percentage of the pixels in the screen in one frame.
// Otherwise you'll lag with a distance field raytracer like this. Your GPU doesn't have one compute thread per screen pixel... Unless you're from the future.
if(val > PSVariable.SVP_NoiseIntervalVars.x &&
val < PSVariable.SVP_NoiseIntervalVars.y)
{
OutColor = dfRaytracer(fragWorldPos.xyz, rayDir);
}
else
{
clip(-1);
}
}
else if(PSVariable.SVP_RaytracerRunFlag == 2.0)
{
float mod = fmod(abs(floor(PSVariable.testVarsX3.z * (fragWorldPos.x + fragWorldPos.y + fragWorldPos.z))), PSVariable.SVP_NoiseIntervalVars.z);
clip(-mod);
OutColor = dfRaytracer(fragWorldPos.xyz, rayDir);
}
else if(PSVariable.SVP_RaytracerRunFlag == 3.0)
{
float mod = fmod(abs(floor(PSVariable.testVarsX3.z * (fragWorldPos.x + fragWorldPos.y + fragWorldPos.z))), PSVariable.SVP_NoiseIntervalVars.z);
if(mod == 0.0)
{
OutColor = dfRaytracer(fragWorldPos.xyz, rayDir);
}
}
else if(PSVariable.SVP_RaytracerRunFlag == 4.0)
{
OutColor.rgb = tex2D(T0DitheredSelectiveRaytracingTexture, uv).xyz;
/*
float sizeX, sizeY;
T0DitheredSelectiveRaytracingTexture.GetDimensions(sizeX, sizeY);
//get screen width and height
uint packedValue = T0DitheredSelectiveRaytracingTexture.Load(int3(sizeX * uv.x, sizeY * uv.y, 0));
uint r = (packedValue & 0x000000FF);
uint g = (packedValue & 0x0000FF00) >> 8;
uint b = (packedValue & 0x00FF0000) >> 16;
//uint a = (packedValue & 0xFF000000) >> 24;
OutColor.rgb = float3(r, g, b) / 255.0;
*/
}
else if(PSVariable.SVP_RaytracerRunFlag == 5.0)
{
OutColor.xy = uv;
}
else
{
OutColor.xy = normalize(fragWorldPos.xy);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment