addpbr.js 4.9 KB

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