Hi folks,
How would I go about making a scene node transparent when the camera goes near it. I.e., it fades away to tranparent as I get near to it, and is completely transparent as I am about to intersect it.
Cheers.
Transparency?
First, get the distance from the camera.
This is easily done by node->getPosition().getDistanceFrom(camera->getPosition());
Then use this scalar value to interpolate making the node transparent. There are two methods for making the node transparent and both are described here:
http://irrlicht.sourceforge.net/phpBB2/ ... ansparency
If you are familiar with shaders I recommend just writing one that takes the World position of both the camera and the object and uses this value to interpolate the alpha value of the pixels in the pixel shader. NOTE: In Irrlicht to use transparency in shaders you usually have to set the Base Material of the shader to EMT_ALPHA_TRANSPARENT_ALPHA_CHANNEL.
Cheers
- BlindSide
EDIT: Oh wait, it would probably just be faster to pass the actual distance to the shader.
This is easily done by node->getPosition().getDistanceFrom(camera->getPosition());
Then use this scalar value to interpolate making the node transparent. There are two methods for making the node transparent and both are described here:
http://irrlicht.sourceforge.net/phpBB2/ ... ansparency
If you are familiar with shaders I recommend just writing one that takes the World position of both the camera and the object and uses this value to interpolate the alpha value of the pixels in the pixel shader. NOTE: In Irrlicht to use transparency in shaders you usually have to set the Base Material of the shader to EMT_ALPHA_TRANSPARENT_ALPHA_CHANNEL.
Cheers
- BlindSide
EDIT: Oh wait, it would probably just be faster to pass the actual distance to the shader.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net