I am looking for a way to achieve a fading effect on an object in an OpenGL ES scene. I want to be able to control the period over which the fading effect takes place.
Can anyone suggest how I might achieve this effect ?
Thanks in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could update the objects alpha value during the update loop. Gradually decreasing the alpha value a small amount per loop would achieve a fading effect.
To control the period, try using an elapsed value representing the time passed since the last loop along with a calculated coefficient detemined by the time period which you want it to run.
To get the coefficient use something like:
coefficient = (maxAlpha – minAlpha) / fadeTimeInSeconds;
Then in your update loop use something like:
objectsAlpha -= coefficient * timeElapsed
Where timeElapsed is a float representing time passed in seconds since the last update loop.
I’ve posted this via my phone so sorry for the short answer and not too detailed psuedo code. Also its not specifically opengl.