Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Announcements and Showcase
Dynamic shading & height maps

Robo
Guest
Quote
2020-01-19 18:54:47

Check my dynamic shading on height maps - both work well together.

https://youtu.be/Q_yqqJ7nDTA

The code to do this easily is here:

// sunlight angle

var tod = ccbGetCopperCubeVariable("TOD");
// set up a variable as 'TOD' to be between 0-24 (24 hr time).
tod = tod - (-0.04);
if (tod > 24) {
tod = 0;
}
ccbSetCopperCubeVariable("TOD", tod);


if (tod >= 0 && tod <= 6) {
var angleX = -(tod / 6);
var angleY = -((tod / 6) -1);
} else if (tod <= 12) {
var angleX = ((tod-6) / 6) - 1;
var angleY = (-tod / 6) + 1;
} else if (tod <= 18) {
var angleX = (tod-12) / 6;
var angleY = ((tod-12) / 6) - 1;
} else if (tod <= 24) {
var angleX = -((tod-18) / 6) +1;
var angleY = ((tod-18) / 6);
}

var sun = ccbGetSceneNodeFromName("sunLight");
// name of directional light used
ccbSetSceneNodeProperty(sun, "Direction", angleX, angleY, 0.0);


creaturefreak
Registered User
Quote
2020-01-20 05:10:38

Good work Robo! thanks for sharing.

CF


Robo
Guest
Quote
2020-01-21 13:41:57

wrote:
Good work Robo! thanks for sharing.

CF


cheers!

I settled on 384 x 384 png file size for loading the height map into CC. It produced about 220k polygons which I am fine with to use in my game and still quite large size.

I had a problem using this technique in that it would cause the skybox sides to light up but if you go to irrLict Properties and uncheck the 'normalise normals' fixes that problem.


count2rfeit
Registered User
Quote
2020-01-21 20:18:01

that's a lot of math to work out... but the outcome sure looks worth the work... good video,thanks


raulc96
Registered User
Quote
2020-01-22 20:54:56

Make a video how to create a texture changer for day/night cycle.


Robo
Guest
Quote
2020-01-23 09:58:07

wrote:
that's a lot of math to work out... but the outcome sure looks worth the work... good video,thanks


cheers - yes, took about 40 mins of dedicated concentration - not an easy task to work out the correct formula for each stage. after couple of errors was working nicely.

The movement of the directional light through 360 degrees covers 4 main periods so broke down my 24 hours into 4 parts also.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "?nternational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact