I’m working on a solar system project and I have the whole solar system in one blueprint . How do I make the planets have different materials based on whether they’re facing the sun or not?
I’m really confused … Your help would be appreciated !!
why would you need to change the actual material?
makes no sense to begin with.
makes even less sense if you consider the fact that the planets move within the solar system, so one side isn’t always towards the sun.
Though it probably isn’t impossible to have a heliosyncronous orbit, you would often only find this behaviour in man made objects like artificial satellites that have a specific scientific purpose.
The planets are orbiting the sun and orbiting around their z axis as well ! so each time a side of the planet is facing the sun . Hope that explains why I want to change the material based on whether the side is facing the sun or not.
Hi, better use one material and change that depending on whether its facing the sun or not.
Basically you know the position of the sun, the position of the planet and the position of the pixel currently getting rendered. From that you know whether or not this pixel is on the planet side facing the sun or not. So get the vector from the planet position to the pixel position do a dot product from that with the vector from the sun to the planet. If the dot product is -1 then both vectors are directly opposing each other and as long as the dot product is negative the pixel is on the planet side facing the sun.
So you could do an if to check if the dot product is negative and then you can do a lerp with the result from the dot product times -1 as alpha.
@EntrpriseCustomr
Sure, this material here
gives this result
The sphere trigger is just to visualize the “sun” position. If you really wanna use this, then it might be better to use a material parameter collection for the “sun” position inside the material instead of an vector parameter. Then you wouldn’t need to have a reference to the material to change the “sun” position.
And this is the alpha value from the last lerp.
The material is set to “unlit” but you can do the same with a “default lit” material.
And if you would want to add some variation to it you could use additional normal maps.
Further you could maybe do some additional logic based on the distance from the planet to the sun cause doesn’t make much sense to have a fiery surface on a planet that is hundreds of million kilometers away from the sun =)