steve3d Posted December 19, 2013 Posted December 19, 2013 I found this when I'm writing sprite fade in/out script. sometime when color.w > 1 for example, color.w = 1.007, the sprite will disappear randomly. means it will not always disappear, only sometime. for example in this code float t=0, d=0.8, t2; while(t<d) { t += engine.game.getIFps(); t2 = t/d; if(t2 < 0.5) { mask_color.w = 1 - t2 * 2; info_s[1].setColor(mask_color); }else { if(info_s[1].getTexture() != xn.getArg("sprite")) info_s[1].setTexture(xn.getArg("sprite")); mask_color.w = t2*2 - 1; if(mask_color.w > 1) mask_color.w = 1; info_s[1].setColor(mask_color); } wait; } in this code I want the sprite fade out and load another texture then fade in, if you write this in update() function vec4 c = info_s[1].getColor(); engine.message("mask alpha: %.3f", c.w); and try some time, you will see when the alpha > 1.0f, then sometime the sprite disappeared.
silent Posted December 19, 2013 Posted December 19, 2013 Hi Steve, Please, try to use saturate function: https://developer.unigine.com/en/docs/1.0/scripting/core/math.common#saturate_variable For example: info_s[1].setColor(saturate(mask_color)); How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
steve3d Posted December 20, 2013 Author Posted December 20, 2013 thanks, this solved problem, but why don't add this check in C++ part, so other people won't have my problems.
Recommended Posts