Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
I found a good way to dynamically change skybox lighting after quite a bit of trial and error. You can now dynamically adjust Ambient & Emissive (glow) on textures like skyboxes etc. You have to convert an RGB value into HEX as below to run: at every 50ms intervals or so run with variable ambient as 'amb' : var node = ccbGetSceneNodeFromName("SkyBox"); if (amb > 50) { amb = (amb - 1); var rgbToHex = function (rgb) { var hex = Number(rgb).toString(16); if (hex.length < 2) { hex = "0" + hex; } var color = (hex+hex+hex); ccbSetSceneNodeMaterialProperty(node, 0, "Ambient", color); ccbSetSceneNodeMaterialProperty(node, 1, "Ambient", color); ccbSetSceneNodeMaterialProperty(node, 2, "Ambient", color); ccbSetSceneNodeMaterialProperty(node, 3, "Ambient", color); ccbSetSceneNodeMaterialProperty(node, 4, "Ambient", color); ccbSetSceneNodeMaterialProperty(node, 5, "Ambient", color); ccbSetCopperCubeVariable("skyAmb", amb); return hex; }; rgbToHex(amb); } This will darken a skybox and can also do the same by replacing "Ambient" with "Emissive". I tried very hard but unable to adjust the alpha also this way...might not be possible....post an update anyone who figures that out. |
||||
|
By the way, not only for lighting but change it to any color you want this way...I am going to use it for sunset/sunrise cloud darkening and maybe organge/yellow adjust as well to skybox... |
||||
|
Do not understand! Can I now dynamically change or the type of lighting? what to say during the game? is the amb variable defined as? before checking if it's bigger than 50? |
||||
|
wrote: Do not understand! Can I now dynamically change or the type of lighting? what to say during the game? is the amb variable defined as? before checking if it's bigger than 50? Yes, if you make a skybox with dynamic lighting (or select 'lighting' in irrLict properties) you can dynamically adjust its lighting using the code above. You could also use it for just changing the color only and use the default root scene node "AmbientLight" setting instead to do the lighting . I have this code "var color = (hex+hex+hex);" which makes the lighting change intensity only as all 3 RGB numbers are the same. To get the color you want instead then add another 2 lines I think (havent tested yet) to run the function and get each hex output to then input into the Emissive/Ambient section as the new hex color. |
|