addpbr.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. window.preparePBR = function() {
  2. var pbr = new BABYLON.PBRMaterial("pbr", scene);
  3. pbr.albedoTexture = new BABYLON.Texture("textures/amiga.jpg", scene);
  4. pbr.albedoTexture.uScale = 5;
  5. pbr.albedoTexture.vScale = 5;
  6. pbr.reflectionTexture = new BABYLON.CubeTexture("textures/skybox/TropicalSunnyDay", scene);
  7. pbr.reflectivityColor = new BABYLON.Color3(0.3, 0.3, 0.3);
  8. pbr.microSurface = 0.9;
  9. registerButtonUI("pbr", "Default", function() {
  10. setRangeValues({
  11. "directIntensity": 1,
  12. "emissiveIntensity": 1,
  13. "environmentIntensity": 1,
  14. "specularIntensity": 1,
  15. "ShadowIntensity": 1,
  16. "ShadeIntensity": 1,
  17. "cameraExposure": 1,
  18. "cameraContrast": 1,
  19. "microSurface": 0.9,
  20. "reflectivityColorR": 0.3,
  21. "reflectivityColorG": 0.3,
  22. "reflectivityColorB": 0.3,
  23. "albedoColorR": 1,
  24. "albedoColorG": 1,
  25. "albedoColorB": 1,
  26. "albedoColorLevel": 0
  27. });
  28. });
  29. registerButtonUI("pbr", "Rough Gold", function() {
  30. setRangeValues({
  31. "directIntensity": 1.3439461727881254,
  32. "emissiveIntensity": 1,
  33. "environmentIntensity": 0.3685013699580344,
  34. "specularIntensity": 1,
  35. "ShadowIntensity": 1,
  36. "ShadeIntensity": 1,
  37. "cameraExposure": 0.7153261887420668,
  38. "cameraContrast": 1.6474178892241538,
  39. "microSurface": 0.42269274789303946,
  40. "reflectivityColorR": 1,
  41. "reflectivityColorG": 0.8453854957860789,
  42. "reflectivityColorB": 0.5093989525890475,
  43. "albedoColorR": 0,
  44. "albedoColorG": 0,
  45. "albedoColorB": 0,
  46. "albedoColorLevel": 1
  47. });
  48. });
  49. registerButtonUI("pbr", "Plastic", function() {
  50. setRangeValues({
  51. "directIntensity": 0.9971213540040931,
  52. "emissiveIntensity": 1,
  53. "environmentIntensity": 0.3685013699580344,
  54. "specularIntensity": 1,
  55. "ShadowIntensity": 0.975444802830091,
  56. "ShadeIntensity": 0.8020323934380749,
  57. "cameraExposure": 0.7586792910900708,
  58. "cameraContrast": 1.5823882357021477,
  59. "microSurface": 0.8562237713730799,
  60. "reflectivityColorR": 0.05,
  61. "reflectivityColorG": 0.05,
  62. "reflectivityColorB": 0.05,
  63. "albedoColorR": 0.20592723615301922,
  64. "albedoColorG": 0.942929976069088,
  65. "albedoColorB": 1,
  66. "albedoColorLevel": 1
  67. });
  68. });
  69. registerButtonUI("pbr", "Shiny Copper", function() {
  70. setRangeValues({
  71. "directIntensity": 1.2355634169181153,
  72. "emissiveIntensity": 0.910415149308085,
  73. "environmentIntensity": 0.21676551174002023,
  74. "specularIntensity": 1,
  75. "ShadowIntensity": 1.018797905178095,
  76. "ShadeIntensity": 0.975444802830091,
  77. "cameraExposure": 1.0621510075260991,
  78. "cameraContrast": 1.0404744563520971,
  79. "microSurface": 0.888738598134083,
  80. "reflectivityColorR": 0.98,
  81. "reflectivityColorG": 0.78,
  82. "reflectivityColorB": 0.706,
  83. "albedoColorR": 0.1,
  84. "albedoColorG": 0.1,
  85. "albedoColorB": 0.1,
  86. "albedoColorLevel": 1
  87. });
  88. });
  89. registerRangeUI("pbr", "directIntensity", 0, 2, function(value) {
  90. pbr.directIntensity = value;
  91. }, function() {
  92. return pbr.directIntensity;
  93. });
  94. registerRangeUI("pbr", "emissiveIntensity", 0, 2, function(value) {
  95. pbr.emissiveIntensity = value;
  96. }, function() {
  97. return pbr.emissiveIntensity;
  98. });
  99. registerRangeUI("pbr", "environmentIntensity", 0, 2, function(value) {
  100. pbr.environmentIntensity = value;
  101. }, function() {
  102. return pbr.environmentIntensity;
  103. });
  104. registerRangeUI("pbr", "specularIntensity", 0, 2, function(value) {
  105. pbr.specularIntensity = value;
  106. }, function() {
  107. return pbr.specularIntensity;
  108. });
  109. registerRangeUI("pbr", "ShadowIntensity", 0, 2, function(value) {
  110. pbr.overloadedShadowIntensity = value;
  111. }, function() {
  112. return pbr.overloadedShadowIntensity;
  113. });
  114. registerRangeUI("pbr", "ShadeIntensity", 0, 2, function(value) {
  115. pbr.overloadedShadeIntensity = value;
  116. }, function() {
  117. return pbr.overloadedShadeIntensity;
  118. });
  119. registerRangeUI("pbr", "cameraExposure", 0, 2, function(value) {
  120. pbr.cameraExposure = value;
  121. }, function() {
  122. return pbr.cameraExposure;
  123. });
  124. registerRangeUI("pbr", "cameraContrast", 0, 2, function(value) {
  125. pbr.cameraContrast = value;
  126. }, function() {
  127. return pbr.cameraContrast;
  128. });
  129. registerRangeUI("pbr", "microSurface", 0, 1, function(value) {
  130. pbr.microSurface = value;
  131. }, function() {
  132. return pbr.microSurface;
  133. });
  134. registerRangeUI("pbr", "reflectivityColorR", 0, 1, function(value) {
  135. pbr.reflectivityColor.r = value;
  136. }, function() {
  137. return pbr.reflectivityColor.r;
  138. });
  139. registerRangeUI("pbr", "reflectivityColorG", 0, 1, function(value) {
  140. pbr.reflectivityColor.g = value;
  141. }, function() {
  142. return pbr.reflectivityColor.g;
  143. });
  144. registerRangeUI("pbr", "reflectivityColorB", 0, 1, function(value) {
  145. pbr.reflectivityColor.b = value;
  146. }, function() {
  147. return pbr.reflectivityColor.b;
  148. });
  149. registerRangeUI("pbr", "albedoColorR", 0, 1, function(value) {
  150. pbr.overloadedAlbedo.r = value;
  151. }, function() {
  152. return pbr.overloadedAlbedo.r;
  153. });
  154. registerRangeUI("pbr", "albedoColorG", 0, 1, function(value) {
  155. pbr.overloadedAlbedo.g = value;
  156. }, function() {
  157. return pbr.overloadedAlbedo.g;
  158. });
  159. registerRangeUI("pbr", "albedoColorB", 0, 1, function(value) {
  160. pbr.overloadedAlbedo.b = value;
  161. }, function() {
  162. return pbr.overloadedAlbedo.b;
  163. });
  164. registerRangeUI("pbr", "albedoColorLevel", 0, 1, function(value) {
  165. pbr.overloadedAlbedoIntensity = value;
  166. }, function() {
  167. return pbr.overloadedAlbedoIntensity;
  168. });
  169. return pbr;
  170. }