Register Amiga FAQ Rules & Help Members List  /  Moderators List Today's Posts Mark Forums Read

 02 August 2017, 22:09 #1 emufan Registered User   Join Date: Feb 2012 Location: #DrainTheSwamp Posts: 4,125 Blink vs Fade I have a blinking plugin, which i want to fade over time. the blinking one just alternates between max and min value at the given interval. the simple code doing the blink is this: Code: ``` //Find which value to use if((defInst->frame % (defInst->period * 2)) < defInst->period) fResult = defInst->fPer1; else fResult = defInst->fPer2;``` frame = current frame period = interval ( lets say we can make it the last frame in scene) fPer1 = min value fPer2 = max value is there a simple way to make it fade ?
 02 August 2017, 22:33 #2 Photon Moderator   Join Date: Nov 2004 Location: Hult / Sweden Posts: 4,452 Code: ``` fFactor = (defInst->fPer2-defInst->fPer1) / defInst->period; if((defInst->frame % (defInst->period * 2)) < defInst->period) fResult = defInst->fPer1 + (frame % (defInst->period)) * fFactor; else fResult = defInst->fPer2 - (frame % (defInst->period)) * fFactor;```
 02 August 2017, 22:57 #3 emufan Registered User   Join Date: Feb 2012 Location: #DrainTheSwamp Posts: 4,125 *crazy* stuff - thanks alot. we now have envelope on surface attributes. Last edited by emufan; 05 August 2017 at 17:41.
 05 August 2017, 17:44 #4 emufan Registered User   Join Date: Feb 2012 Location: #DrainTheSwamp Posts: 4,125 i've extended the version above, to do the animation only in a given interval, defining start and end frame. somehow it does work, but it looks a bit odd, not sure where i made a mistake: Code: ```XCALL_(void) evaluate(LWInstance inst, ShaderAccess *sa) { BLINKER *defInst = (BLINKER *)(inst); //To hold the result float fResult; float fFactor; int start = defInst->period1; int end = defInst->period2; // if ((defInst->frame < start) || (defInst->frame > end)) // return (NULL); //Find which value to use fFactor = (defInst->fPer2-defInst->fPer1) / (defInst->period2-defInst->period1); if((defInst->frame % (defInst->period1 * 2)) < defInst->period1) fResult = defInst->fPer1 + (defInst->frame % (defInst->period1)) * fFactor; else fResult = defInst->fPer2 - (defInst->frame % (defInst->period1)) * fFactor; //Put it onto the surface switch(defInst->uChannel) { case LUMINOUS: if ((defInst->frame < start) || (defInst->frame > end)) break; sa->luminous = fResult; break; case DIFFUSE: if ((defInst->frame < start) || (defInst->frame > end)) break; sa->diffuse = fResult; break; case SPECULAR: if ((defInst->frame < start) || (defInst->frame > end)) break; sa->specular = fResult; break; case MIRROR: if ((defInst->frame < start) || (defInst->frame > end)) break; sa->mirror = fResult; break; case TRANSP: if ((defInst->frame < start) || (defInst->frame > end)) break; sa->transparency = fResult; break; } return; }``` fPer1 and fPer2 are min max value of the surface attribute (eg. luminosity) frame is the current frame. #1) i've added the whole fucntion, since i think it must be of importance, where it checks, if we are in the range (start -> end). but it does still some weird blinking at some point, instead of fading all the time. does it look right, is the math with period1/period2 and start/end correct? or is there something wrong? Last edited by emufan; 05 August 2017 at 18:55.
 06 August 2017, 16:25 #5 emufan Registered User   Join Date: Feb 2012 Location: #DrainTheSwamp Posts: 4,125 i replaced all (defInst->period1) with (defInst->period2 - defInst->period1) it's looking better now, but not yet perfect #1) removing the range check made it work as i want it to do needs some more tests with the desired range, but looking good for now. Attached Images   Last edited by emufan; 06 August 2017 at 16:40.

 Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 Similar Threads Thread Thread Starter Forum Replies Last Post appiah4 support.Hardware 2 27 January 2017 11:06 MethodGit Coders. General 9 08 January 2014 14:30 DeAdLy_cOoKiE Nostalgia & memories 2 02 July 2005 13:17 redblade Coders. General 0 29 March 2005 12:02 Galahad/FLT Retrogaming General Discussion 12 25 July 2002 19:15

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home News Main     Amiga scene     Retrogaming General Discussion     Nostalgia & memories Support     New to Emulation or Amiga scene         Member Introductions     support.WinUAE     support.WinFellow     support.OtherUAE     support.FS-UAE     support.Hardware         Hardware mods         Hardware pics     support.Games     support.Demos     support.Apps     support.Amiga Forever     support.Amix     support.Other Requests     request.UAE Wishlist     request.Old Rare Games     request.Demos     request.Apps     request.Modules     request.Music     request.Other     Looking for a game name ?     Games images which need to be WHDified abime.net - Hall Of Light     HOL news     HOL suggestions and feedback     HOL data problems     HOL contributions abime.net - Amiga Magazine Rack     AMR news     AMR suggestions and feedback     AMR data problems     AMR contributions abime.net - Home Projects     project.Amiga Lore     project.EAB     project.IRC     project.Mods Jukebox     project.Wiki abime.net - Hosted Projects     project.aGTW     project.APoV     project.ClassicWB     project.Jambo!     project.Green Amiga Alien GUIDES     project.Maptapper     project.Sprites     project.WinUAE - Kaillera Other Projects     project.Amiga Demo DVD     project.Amiga Game Factory     project.CARE     project.EAB File Server     project.CD32 Conversion     project.Game Cover Art         GCA.Feedback and Suggestions         GCA.Work in Progress         GCA.Cover Requests         GCA.Usefull Programs         GCA.Helpdesk     project.KGLoad     project.MAGE     project.Missing Full Shareware Games     project.SPS (was CAPS)     project.TOSEC (amiga only)     project.WHDLoad         project.Killergorilla's WHD packs Misc     Amiga websites reviews     MarketPlace         Swapshop     EAB's competition Coders     Coders. General         Coders. Releases         Coders. Tutorials     Coders. Asm / Hardware     Coders. System         Coders. Scripting         Coders. Nextgen     Coders. Language         Coders. C/C++         Coders. AMOS         Coders. Blitz Basic Off Topic     OT - General     OT - Technical     OT - Entertainment     OT - Sports     OT - Adult     OT - Gaming

All times are GMT +2. The time now is 21:07.

 -- EAB3 skin ---- EAB2 skin ---- Mobile skin Archive - Top