1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801 |
- #include "api__vis_milk2.h"
- #include "plugin.h"
- #include "resource.h"
- #include "support.h"
- #include "ns-eel2/ns-eel.h"
- #include "utility.h"
- #include <assert.h>
- #include <math.h>
- #define D3DCOLOR_RGBA_01(r,g,b,a) D3DCOLOR_RGBA(((int)(r*255)),((int)(g*255)),((int)(b*255)),((int)(a*255)))
- #define FRAND ((warand() % 7381)/7380.0f)
- #define VERT_CLIP 0.75f
- int g_title_font_sizes[] =
- {
-
- 6, 8, 10, 12, 14, 16,
- 20, 26, 32, 38, 44, 50, 56,
- 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144,
- 160, 192, 224, 256, 288, 320, 352, 384, 416, 448,
- 480, 512
- };
- static void MungeFPCW( WORD *pwOldCW )
- {
- #if 0
- BOOL ret = FALSE;
- WORD wTemp, wSave;
-
- __asm fstcw wSave
- if (wSave & 0x300 ||
- 0x3f != (wSave & 0x3f) ||
- wSave & 0xC00)
- {
- __asm
- {
- mov ax, wSave
- and ax, not 300h ;; single mode
- or ax, 3fh ;; disable all exceptions
- and ax, not 0xC00 ;; round to nearest mode
- mov wTemp, ax
- fldcw wTemp
- }
- ret = TRUE;
- }
- if (pwOldCW) *pwOldCW = wSave;
-
- #else
- _controlfp(_PC_24, _MCW_PC);
- _controlfp(_RC_NEAR, _MCW_RC);
- _controlfp(_EM_ZERODIVIDE, _EM_ZERODIVIDE);
- #endif
- }
- void RestoreFPCW(WORD wSave)
- {
- __asm fldcw wSave
- }
- int GetNumToSpawn(float fTime, float fDeltaT, float fRate, float fRegularity, int iNumSpawnedSoFar)
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- float fNumToSpawnReg;
- float fNumToSpawnIrreg;
- float fNumToSpawn;
-
- fNumToSpawnReg = ((fTime + fDeltaT) * fRate) - iNumSpawnedSoFar;
-
- if (fDeltaT <= 1.0f / fRate)
- {
-
- if ((warand() % 16384)/16384.0f < fDeltaT * fRate)
- fNumToSpawnIrreg = 1.0f;
- else
- fNumToSpawnIrreg = 0.0f;
- }
- else
- {
-
- fNumToSpawnIrreg = fDeltaT * fRate;
- fNumToSpawnIrreg *= 2.0f*(warand() % 16384)/16384.0f;
- }
-
- fNumToSpawn = fNumToSpawnReg*fRegularity + fNumToSpawnIrreg*(1.0f - fRegularity);
-
- return (int)(fNumToSpawn + 0.49f);
- }
- bool CPlugin::OnResizeTextWindow()
- {
-
- return true;
- }
- void CPlugin::ClearGraphicsWindow()
- {
-
-
- }
- bool CPlugin::RenderStringToTitleTexture()
- {
- if (!m_lpDDSTitle)
- return false;
- if (m_supertext.szTextW[0]==0)
- return false;
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
- if (!lpDevice)
- return false;
- wchar_t szTextToDraw[512];
- swprintf(szTextToDraw, L" %s ", m_supertext.szTextW);
-
-
- LPDIRECT3DSURFACE9 pBackBuffer=NULL;
- lpDevice->GetRenderTarget( 0, &pBackBuffer );
-
-
- {
- lpDevice->SetTexture(0, NULL);
- IDirect3DSurface9* pNewTarget = NULL;
- if (m_lpDDSTitle->GetSurfaceLevel(0, &pNewTarget) != D3D_OK)
- {
- SafeRelease(pBackBuffer);
-
- return false;
- }
- lpDevice->SetRenderTarget(0, pNewTarget);
-
- pNewTarget->Release();
- lpDevice->SetTexture(0, NULL);
- }
-
- {
- lpDevice->SetVertexShader( NULL );
- lpDevice->SetFVF( WFVERTEX_FORMAT );
- lpDevice->SetTexture(0, NULL);
- lpDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
-
- WFVERTEX verts[4];
- for (int i=0; i<4; i++)
- {
- verts[i].x = (i%2==0) ? -1.f : 1.f;
- verts[i].y = (i/2==0) ? -1.f : 1.f;
- verts[i].z = 0;
- verts[i].Diffuse = 0xFF000000;
- }
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, verts, sizeof(WFVERTEX));
- }
-
- bool ret = true;
-
- RECT rect;
- rect.left = 0;
- rect.right = m_nTitleTexSizeX;
- rect.top = m_nTitleTexSizeY* 1/21;
- rect.bottom = m_nTitleTexSizeY*17/21;
- if (!m_supertext.bIsSongTitle)
- {
-
- HFONT gdi_font = NULL;
- LPD3DXFONT d3dx_font = NULL;
- int lo = 0;
- int hi = sizeof(g_title_font_sizes)/sizeof(int) - 1;
-
-
-
-
-
- RECT temp;
- while (1)
- {
- int mid = (lo+hi)/2;
-
- gdi_font = CreateFontW( g_title_font_sizes[mid], 0, 0, 0, m_supertext.bBold ? 900 : 400, m_supertext.bItal, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
- m_fontinfo[SONGTITLE_FONT].bAntiAliased ? ANTIALIASED_QUALITY : DEFAULT_QUALITY,
- DEFAULT_PITCH, m_supertext.nFontFace );
- if (gdi_font)
- {
-
- if (pCreateFontW(
- lpDevice,
- g_title_font_sizes[mid],
- 0,
- m_supertext.bBold ? 900 : 400,
- 1,
- m_supertext.bItal,
- DEFAULT_CHARSET,
- OUT_DEFAULT_PRECIS,
- ANTIALIASED_QUALITY,
- DEFAULT_PITCH,
- m_supertext.nFontFace,
- &d3dx_font
- ) == D3D_OK)
- {
- if (lo == hi-1)
- break;
-
- temp = rect;
- int h = d3dx_font->DrawTextW(NULL, szTextToDraw, -1, &temp, DT_SINGLELINE | DT_CALCRECT , 0xFFFFFFFF);
-
- if (temp.right >= rect.right || h > rect.bottom-rect.top)
- hi = mid;
- else
- lo = mid;
- SafeRelease(d3dx_font);
- }
- DeleteObject(gdi_font); gdi_font=NULL;
- }
- }
- if (gdi_font && d3dx_font)
- {
-
- int h = d3dx_font->DrawTextW(NULL, szTextToDraw, -1, &temp, DT_SINGLELINE | DT_CALCRECT | DT_CENTER, 0xFFFFFFFF);
- temp.left = 0;
- temp.right = m_nTitleTexSizeX;
- temp.top = m_nTitleTexSizeY/2 - h/2;
- temp.bottom = m_nTitleTexSizeY/2 + h/2;
- m_supertext.nFontSizeUsed = d3dx_font->DrawTextW(NULL, szTextToDraw, -1, &temp, DT_SINGLELINE | DT_CENTER, 0xFFFFFFFF);
-
- ret = true;
- }
- else
- {
- ret = false;
- }
-
- SafeRelease(d3dx_font);
- if (gdi_font) DeleteObject(gdi_font); gdi_font=NULL;
- }
- else
- {
- wchar_t* str = m_supertext.szTextW;
-
-
- int h;
- int max_its = 6;
- int it = 0;
- while (it < max_its)
- {
- it++;
- if (!str[0])
- break;
- RECT temp = rect;
- h = m_d3dx_title_font_doublesize->DrawTextW(NULL, str, -1, &temp, DT_SINGLELINE | DT_CALCRECT , 0xFFFFFFFF);
- if (temp.right-temp.left <= m_nTitleTexSizeX)
- break;
-
-
-
-
-
- int len = wcslen(str);
- float fPercentToKeep = 0.91f * m_nTitleTexSizeX / (float)(temp.right-temp.left);
- if (len > 8)
- lstrcpyW( &str[ (int)(len*fPercentToKeep) ], L"...");
- break;
- }
-
- RECT temp;
- temp.left = 0;
- temp.right = m_nTitleTexSizeX;
- temp.top = m_nTitleTexSizeY/2 - h/2;
- temp.bottom = m_nTitleTexSizeY/2 + h/2;
-
- m_supertext.nFontSizeUsed = m_d3dx_title_font_doublesize->DrawTextW(NULL, str, -1, &temp, DT_SINGLELINE | DT_CENTER , 0xFFFFFFFF);
- }
-
- lpDevice->SetTexture(0, NULL);
- lpDevice->SetRenderTarget( 0, pBackBuffer );
-
- SafeRelease(pBackBuffer);
-
- return ret;
- }
- void CPlugin::LoadPerFrameEvallibVars(CState* pState)
- {
-
-
-
-
-
-
-
- *pState->var_pf_zoom = (double)pState->m_fZoom.eval(-1);
- *pState->var_pf_zoomexp = (double)pState->m_fZoomExponent.eval(-1);
- *pState->var_pf_rot = (double)pState->m_fRot.eval(-1);
- *pState->var_pf_warp = (double)pState->m_fWarpAmount.eval(-1);
- *pState->var_pf_cx = (double)pState->m_fRotCX.eval(-1);
- *pState->var_pf_cy = (double)pState->m_fRotCY.eval(-1);
- *pState->var_pf_dx = (double)pState->m_fXPush.eval(-1);
- *pState->var_pf_dy = (double)pState->m_fYPush.eval(-1);
- *pState->var_pf_sx = (double)pState->m_fStretchX.eval(-1);
- *pState->var_pf_sy = (double)pState->m_fStretchY.eval(-1);
-
- *pState->var_pf_time = (double)(GetTime() - m_fStartTime);
- *pState->var_pf_fps = (double)GetFps();
- *pState->var_pf_bass = (double)mysound.imm_rel[0];
- *pState->var_pf_mid = (double)mysound.imm_rel[1];
- *pState->var_pf_treb = (double)mysound.imm_rel[2];
- *pState->var_pf_bass_att = (double)mysound.avg_rel[0];
- *pState->var_pf_mid_att = (double)mysound.avg_rel[1];
- *pState->var_pf_treb_att = (double)mysound.avg_rel[2];
- *pState->var_pf_frame = (double)GetFrame();
-
- for (int vi=0; vi<NUM_Q_VAR; vi++)
- *pState->var_pf_q[vi] = pState->q_values_after_init_code[vi];
- *pState->var_pf_monitor = pState->monitor_after_init_code;
- *pState->var_pf_progress = (GetTime() - m_fPresetStartTime) / (m_fNextPresetTime - m_fPresetStartTime);
-
- *pState->var_pf_decay = (double)pState->m_fDecay.eval(GetTime());
- *pState->var_pf_wave_a = (double)pState->m_fWaveAlpha.eval(GetTime());
- *pState->var_pf_wave_r = (double)pState->m_fWaveR.eval(GetTime());
- *pState->var_pf_wave_g = (double)pState->m_fWaveG.eval(GetTime());
- *pState->var_pf_wave_b = (double)pState->m_fWaveB.eval(GetTime());
- *pState->var_pf_wave_x = (double)pState->m_fWaveX.eval(GetTime());
- *pState->var_pf_wave_y = (double)pState->m_fWaveY.eval(GetTime());
- *pState->var_pf_wave_mystery= (double)pState->m_fWaveParam.eval(GetTime());
- *pState->var_pf_wave_mode = (double)pState->m_nWaveMode;
- *pState->var_pf_ob_size = (double)pState->m_fOuterBorderSize.eval(GetTime());
- *pState->var_pf_ob_r = (double)pState->m_fOuterBorderR.eval(GetTime());
- *pState->var_pf_ob_g = (double)pState->m_fOuterBorderG.eval(GetTime());
- *pState->var_pf_ob_b = (double)pState->m_fOuterBorderB.eval(GetTime());
- *pState->var_pf_ob_a = (double)pState->m_fOuterBorderA.eval(GetTime());
- *pState->var_pf_ib_size = (double)pState->m_fInnerBorderSize.eval(GetTime());
- *pState->var_pf_ib_r = (double)pState->m_fInnerBorderR.eval(GetTime());
- *pState->var_pf_ib_g = (double)pState->m_fInnerBorderG.eval(GetTime());
- *pState->var_pf_ib_b = (double)pState->m_fInnerBorderB.eval(GetTime());
- *pState->var_pf_ib_a = (double)pState->m_fInnerBorderA.eval(GetTime());
- *pState->var_pf_mv_x = (double)pState->m_fMvX.eval(GetTime());
- *pState->var_pf_mv_y = (double)pState->m_fMvY.eval(GetTime());
- *pState->var_pf_mv_dx = (double)pState->m_fMvDX.eval(GetTime());
- *pState->var_pf_mv_dy = (double)pState->m_fMvDY.eval(GetTime());
- *pState->var_pf_mv_l = (double)pState->m_fMvL.eval(GetTime());
- *pState->var_pf_mv_r = (double)pState->m_fMvR.eval(GetTime());
- *pState->var_pf_mv_g = (double)pState->m_fMvG.eval(GetTime());
- *pState->var_pf_mv_b = (double)pState->m_fMvB.eval(GetTime());
- *pState->var_pf_mv_a = (double)pState->m_fMvA.eval(GetTime());
- *pState->var_pf_echo_zoom = (double)pState->m_fVideoEchoZoom.eval(GetTime());
- *pState->var_pf_echo_alpha = (double)pState->m_fVideoEchoAlpha.eval(GetTime());
- *pState->var_pf_echo_orient = (double)pState->m_nVideoEchoOrientation;
-
- *pState->var_pf_wave_usedots = (double)pState->m_bWaveDots;
- *pState->var_pf_wave_thick = (double)pState->m_bWaveThick;
- *pState->var_pf_wave_additive = (double)pState->m_bAdditiveWaves;
- *pState->var_pf_wave_brighten = (double)pState->m_bMaximizeWaveColor;
- *pState->var_pf_darken_center = (double)pState->m_bDarkenCenter;
- *pState->var_pf_gamma = (double)pState->m_fGammaAdj.eval(GetTime());
- *pState->var_pf_wrap = (double)pState->m_bTexWrap;
- *pState->var_pf_invert = (double)pState->m_bInvert;
- *pState->var_pf_brighten = (double)pState->m_bBrighten;
- *pState->var_pf_darken = (double)pState->m_bDarken;
- *pState->var_pf_solarize = (double)pState->m_bSolarize;
- *pState->var_pf_meshx = (double)m_nGridX;
- *pState->var_pf_meshy = (double)m_nGridY;
- *pState->var_pf_pixelsx = (double)GetWidth();
- *pState->var_pf_pixelsy = (double)GetHeight();
- *pState->var_pf_aspectx = (double)m_fInvAspectX;
- *pState->var_pf_aspecty = (double)m_fInvAspectY;
-
- *pState->var_pf_blur1min = (double)pState->m_fBlur1Min.eval(GetTime());
- *pState->var_pf_blur2min = (double)pState->m_fBlur2Min.eval(GetTime());
- *pState->var_pf_blur3min = (double)pState->m_fBlur3Min.eval(GetTime());
- *pState->var_pf_blur1max = (double)pState->m_fBlur1Max.eval(GetTime());
- *pState->var_pf_blur2max = (double)pState->m_fBlur2Max.eval(GetTime());
- *pState->var_pf_blur3max = (double)pState->m_fBlur3Max.eval(GetTime());
- *pState->var_pf_blur1_edge_darken = (double)pState->m_fBlur1EdgeDarken.eval(GetTime());
- }
- void CPlugin::RunPerFrameEquations(int code)
- {
-
-
-
-
-
- m_fSnapPoint = 0.5f;
- if (m_pState->m_bBlending)
- {
- switch(code)
- {
- case 4:
- case 6:
- case 12:
- case 14:
-
- m_fSnapPoint = -0.01f;
- break;
- case 1:
- case 3:
- case 9:
- case 11:
-
- m_fSnapPoint = 1.01f;
- break;
- case 0:
- case 2:
- case 8:
- case 10:
-
- m_fSnapPoint = 0.5f;
- break;
- case 5:
- case 7:
- case 13:
- case 15:
-
- m_fSnapPoint = 0.5f;
- break;
- }
- }
- int num_reps = (m_pState->m_bBlending) ? 2 : 1;
- for (int rep=0; rep<num_reps; rep++)
- {
- CState *pState;
- if (rep==0)
- pState = m_pState;
- else
- pState = m_pOldState;
-
-
-
- LoadPerFrameEvallibVars(pState);
-
-
- *pState->var_pv_time = *pState->var_pf_time;
- *pState->var_pv_fps = *pState->var_pf_fps;
- *pState->var_pv_frame = *pState->var_pf_frame;
- *pState->var_pv_progress = *pState->var_pf_progress;
- *pState->var_pv_bass = *pState->var_pf_bass;
- *pState->var_pv_mid = *pState->var_pf_mid;
- *pState->var_pv_treb = *pState->var_pf_treb;
- *pState->var_pv_bass_att = *pState->var_pf_bass_att;
- *pState->var_pv_mid_att = *pState->var_pf_mid_att;
- *pState->var_pv_treb_att = *pState->var_pf_treb_att;
- *pState->var_pv_meshx = (double)m_nGridX;
- *pState->var_pv_meshy = (double)m_nGridY;
- *pState->var_pv_pixelsx = (double)GetWidth();
- *pState->var_pv_pixelsy = (double)GetHeight();
- *pState->var_pv_aspectx = (double)m_fInvAspectX;
- *pState->var_pv_aspecty = (double)m_fInvAspectY;
-
-
- #ifndef _NO_EXPR_
- if (pState->m_pf_codehandle)
- {
- if (pState->m_pf_codehandle)
- {
- NSEEL_code_execute(pState->m_pf_codehandle);
- }
- }
- #endif
-
- pState->monitor_after_init_code = *pState->var_pf_monitor;
-
- for (int vi=0; vi<NUM_Q_VAR; vi++)
- *pState->var_pv_q[vi] = *pState->var_pf_q[vi];
-
- *pState->var_pf_gamma = max(0 , min( 8, *pState->var_pf_gamma ));
- *pState->var_pf_echo_zoom = max(0.001, min( 1000, *pState->var_pf_echo_zoom));
-
- }
- if (m_pState->m_bBlending)
- {
-
-
- double mix = (double)CosineInterp(m_pState->m_fBlendProgress);
- double mix2 = 1.0 - mix;
- *m_pState->var_pf_decay = mix*(*m_pState->var_pf_decay ) + mix2*(*m_pOldState->var_pf_decay );
- *m_pState->var_pf_wave_a = mix*(*m_pState->var_pf_wave_a ) + mix2*(*m_pOldState->var_pf_wave_a );
- *m_pState->var_pf_wave_r = mix*(*m_pState->var_pf_wave_r ) + mix2*(*m_pOldState->var_pf_wave_r );
- *m_pState->var_pf_wave_g = mix*(*m_pState->var_pf_wave_g ) + mix2*(*m_pOldState->var_pf_wave_g );
- *m_pState->var_pf_wave_b = mix*(*m_pState->var_pf_wave_b ) + mix2*(*m_pOldState->var_pf_wave_b );
- *m_pState->var_pf_wave_x = mix*(*m_pState->var_pf_wave_x ) + mix2*(*m_pOldState->var_pf_wave_x );
- *m_pState->var_pf_wave_y = mix*(*m_pState->var_pf_wave_y ) + mix2*(*m_pOldState->var_pf_wave_y );
- *m_pState->var_pf_wave_mystery = mix*(*m_pState->var_pf_wave_mystery) + mix2*(*m_pOldState->var_pf_wave_mystery);
-
- *m_pState->var_pf_ob_size = mix*(*m_pState->var_pf_ob_size ) + mix2*(*m_pOldState->var_pf_ob_size );
- *m_pState->var_pf_ob_r = mix*(*m_pState->var_pf_ob_r ) + mix2*(*m_pOldState->var_pf_ob_r );
- *m_pState->var_pf_ob_g = mix*(*m_pState->var_pf_ob_g ) + mix2*(*m_pOldState->var_pf_ob_g );
- *m_pState->var_pf_ob_b = mix*(*m_pState->var_pf_ob_b ) + mix2*(*m_pOldState->var_pf_ob_b );
- *m_pState->var_pf_ob_a = mix*(*m_pState->var_pf_ob_a ) + mix2*(*m_pOldState->var_pf_ob_a );
- *m_pState->var_pf_ib_size = mix*(*m_pState->var_pf_ib_size ) + mix2*(*m_pOldState->var_pf_ib_size );
- *m_pState->var_pf_ib_r = mix*(*m_pState->var_pf_ib_r ) + mix2*(*m_pOldState->var_pf_ib_r );
- *m_pState->var_pf_ib_g = mix*(*m_pState->var_pf_ib_g ) + mix2*(*m_pOldState->var_pf_ib_g );
- *m_pState->var_pf_ib_b = mix*(*m_pState->var_pf_ib_b ) + mix2*(*m_pOldState->var_pf_ib_b );
- *m_pState->var_pf_ib_a = mix*(*m_pState->var_pf_ib_a ) + mix2*(*m_pOldState->var_pf_ib_a );
- *m_pState->var_pf_mv_x = mix*(*m_pState->var_pf_mv_x ) + mix2*(*m_pOldState->var_pf_mv_x );
- *m_pState->var_pf_mv_y = mix*(*m_pState->var_pf_mv_y ) + mix2*(*m_pOldState->var_pf_mv_y );
- *m_pState->var_pf_mv_dx = mix*(*m_pState->var_pf_mv_dx ) + mix2*(*m_pOldState->var_pf_mv_dx );
- *m_pState->var_pf_mv_dy = mix*(*m_pState->var_pf_mv_dy ) + mix2*(*m_pOldState->var_pf_mv_dy );
- *m_pState->var_pf_mv_l = mix*(*m_pState->var_pf_mv_l ) + mix2*(*m_pOldState->var_pf_mv_l );
- *m_pState->var_pf_mv_r = mix*(*m_pState->var_pf_mv_r ) + mix2*(*m_pOldState->var_pf_mv_r );
- *m_pState->var_pf_mv_g = mix*(*m_pState->var_pf_mv_g ) + mix2*(*m_pOldState->var_pf_mv_g );
- *m_pState->var_pf_mv_b = mix*(*m_pState->var_pf_mv_b ) + mix2*(*m_pOldState->var_pf_mv_b );
- *m_pState->var_pf_mv_a = mix*(*m_pState->var_pf_mv_a ) + mix2*(*m_pOldState->var_pf_mv_a );
- *m_pState->var_pf_echo_zoom = mix*(*m_pState->var_pf_echo_zoom ) + mix2*(*m_pOldState->var_pf_echo_zoom );
- *m_pState->var_pf_echo_alpha = mix*(*m_pState->var_pf_echo_alpha ) + mix2*(*m_pOldState->var_pf_echo_alpha );
- *m_pState->var_pf_echo_orient = (mix < m_fSnapPoint) ? *m_pOldState->var_pf_echo_orient : *m_pState->var_pf_echo_orient;
-
- *m_pState->var_pf_wave_usedots = (mix < m_fSnapPoint) ? *m_pOldState->var_pf_wave_usedots : *m_pState->var_pf_wave_usedots ;
- *m_pState->var_pf_wave_thick = (mix < m_fSnapPoint) ? *m_pOldState->var_pf_wave_thick : *m_pState->var_pf_wave_thick ;
- *m_pState->var_pf_wave_additive= (mix < m_fSnapPoint) ? *m_pOldState->var_pf_wave_additive : *m_pState->var_pf_wave_additive;
- *m_pState->var_pf_wave_brighten= (mix < m_fSnapPoint) ? *m_pOldState->var_pf_wave_brighten : *m_pState->var_pf_wave_brighten;
- *m_pState->var_pf_darken_center= (mix < m_fSnapPoint) ? *m_pOldState->var_pf_darken_center : *m_pState->var_pf_darken_center;
- *m_pState->var_pf_gamma = mix*(*m_pState->var_pf_gamma ) + mix2*(*m_pOldState->var_pf_gamma );
- *m_pState->var_pf_wrap = (mix < m_fSnapPoint) ? *m_pOldState->var_pf_wrap : *m_pState->var_pf_wrap ;
- *m_pState->var_pf_invert = (mix < m_fSnapPoint) ? *m_pOldState->var_pf_invert : *m_pState->var_pf_invert ;
- *m_pState->var_pf_brighten = (mix < m_fSnapPoint) ? *m_pOldState->var_pf_brighten : *m_pState->var_pf_brighten ;
- *m_pState->var_pf_darken = (mix < m_fSnapPoint) ? *m_pOldState->var_pf_darken : *m_pState->var_pf_darken ;
- *m_pState->var_pf_solarize = (mix < m_fSnapPoint) ? *m_pOldState->var_pf_solarize : *m_pState->var_pf_solarize ;
-
- *m_pState->var_pf_blur1min = mix*(*m_pState->var_pf_blur1min ) + mix2*(*m_pOldState->var_pf_blur1min );
- *m_pState->var_pf_blur2min = mix*(*m_pState->var_pf_blur2min ) + mix2*(*m_pOldState->var_pf_blur2min );
- *m_pState->var_pf_blur3min = mix*(*m_pState->var_pf_blur3min ) + mix2*(*m_pOldState->var_pf_blur3min );
- *m_pState->var_pf_blur1max = mix*(*m_pState->var_pf_blur1max ) + mix2*(*m_pOldState->var_pf_blur1max );
- *m_pState->var_pf_blur2max = mix*(*m_pState->var_pf_blur2max ) + mix2*(*m_pOldState->var_pf_blur2max );
- *m_pState->var_pf_blur3max = mix*(*m_pState->var_pf_blur3max ) + mix2*(*m_pOldState->var_pf_blur3max );
- *m_pState->var_pf_blur1_edge_darken = mix*(*m_pState->var_pf_blur1_edge_darken) + mix2*(*m_pOldState->var_pf_blur1_edge_darken);
- }
- }
- void CPlugin::RenderFrame(int bRedraw)
- {
- int i;
- float fDeltaT = 1.0f/GetFps();
- if (bRedraw)
- {
-
- IDirect3DTexture9* pTemp = m_lpVS[0];
- m_lpVS[0] = m_lpVS[1];
- m_lpVS[1] = pTemp;
- }
-
-
- if (GetFrame()==0)
- {
- m_fStartTime = GetTime();
- m_fPresetStartTime = GetTime();
- }
- if (m_fNextPresetTime < 0)
- {
- float dt = m_fTimeBetweenPresetsRand * (warand()%1000)*0.001f;
- m_fNextPresetTime = GetTime() + m_fBlendTimeAuto + m_fTimeBetweenPresets + dt;
- }
-
-
-
-
-
- if (!bRedraw)
- {
- m_rand_frame = D3DXVECTOR4(FRAND, FRAND, FRAND, FRAND);
-
- if (m_fNextPresetTime < GetTime())
- {
- if (m_nLoadingPreset==0)
- LoadRandomPreset(m_fBlendTimeAuto);
- }
-
- if (m_fTimeBetweenRandomSongTitles > 0 &&
- !m_supertext.bRedrawSuperText &&
- GetTime() >= m_supertext.fStartTime + m_supertext.fDuration + 1.0f/GetFps())
- {
- int n = GetNumToSpawn(GetTime(), fDeltaT, 1.0f/m_fTimeBetweenRandomSongTitles, 0.5f, m_nSongTitlesSpawned);
- if (n > 0)
- {
- LaunchSongTitleAnim();
- m_nSongTitlesSpawned += n;
- }
- }
-
- if (m_fTimeBetweenRandomCustomMsgs > 0 &&
- !m_supertext.bRedrawSuperText &&
- GetTime() >= m_supertext.fStartTime + m_supertext.fDuration + 1.0f/GetFps())
- {
- int n = GetNumToSpawn(GetTime(), fDeltaT, 1.0f/m_fTimeBetweenRandomCustomMsgs, 0.5f, m_nCustMsgsSpawned);
- if (n > 0)
- {
- LaunchCustomMessage(-1);
- m_nCustMsgsSpawned += n;
- }
- }
-
- if (m_pState->m_bBlending)
- {
- m_pState->m_fBlendProgress = (GetTime() - m_pState->m_fBlendStartTime) / m_pState->m_fBlendDuration;
- if (m_pState->m_fBlendProgress > 1.0f)
- {
- m_pState->m_bBlending = false;
- }
- }
-
- static float m_fHardCutThresh;
- if (GetFrame() == 0)
- m_fHardCutThresh = m_fHardCutLoudnessThresh*2.0f;
- if (GetFps() > 1.0f && !m_bHardCutsDisabled && !m_bPresetLockedByUser && !m_bPresetLockedByCode)
- {
- if (mysound.imm_rel[0] + mysound.imm_rel[1] + mysound.imm_rel[2] > m_fHardCutThresh*3.0f)
- {
- if (m_nLoadingPreset==0)
- LoadRandomPreset(0.0f);
- m_fHardCutThresh *= 2.0f;
- }
- else
- {
-
- float k = -1.3863f / (m_fHardCutHalflife*GetFps());
-
- float single_frame_multiplier = expf(k);
- m_fHardCutThresh = (m_fHardCutThresh - m_fHardCutLoudnessThresh)*single_frame_multiplier + m_fHardCutLoudnessThresh;
- }
- }
-
- float scale = m_pState->m_fWaveScale.eval(GetTime()) / 128.0f;
- mysound.fWave[0][0] *= scale;
- mysound.fWave[1][0] *= scale;
- float mix2 = m_pState->m_fWaveSmoothing.eval(GetTime());
- float mix1 = scale*(1.0f - mix2);
- for (i=1; i<576; i++)
- {
- mysound.fWave[0][i] = mysound.fWave[0][i]*mix1 + mysound.fWave[0][i-1]*mix2;
- mysound.fWave[1][i] = mysound.fWave[1][i]*mix1 + mysound.fWave[1][i-1]*mix2;
- }
- }
- bool bOldPresetUsesWarpShader = (m_pOldState->m_nWarpPSVersion > 0);
- bool bNewPresetUsesWarpShader = (m_pState->m_nWarpPSVersion > 0);
- bool bOldPresetUsesCompShader = (m_pOldState->m_nCompPSVersion > 0);
- bool bNewPresetUsesCompShader = (m_pState->m_nCompPSVersion > 0);
-
- int code = (bOldPresetUsesWarpShader ? 8 : 0) |
- (bOldPresetUsesCompShader ? 4 : 0) |
- (bNewPresetUsesWarpShader ? 2 : 0) |
- (bNewPresetUsesCompShader ? 1 : 0);
- RunPerFrameEquations(code);
-
-
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
- if (!lpDevice)
- return;
-
- LPDIRECT3DSURFACE9 pBackBuffer=NULL;
- lpDevice->GetRenderTarget( 0, &pBackBuffer );
-
-
- {
- DWORD texaddr = (*m_pState->var_pf_wrap > m_fSnapPoint) ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP;
- lpDevice->SetRenderState(D3DRS_WRAP0, 0);
-
-
- lpDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
- lpDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
- lpDevice->SetSamplerState(0, D3DSAMP_ADDRESSW, D3DTADDRESS_WRAP);
- lpDevice->SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
- lpDevice->SetSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
- lpDevice->SetSamplerState(1, D3DSAMP_ADDRESSW, D3DTADDRESS_WRAP);
- lpDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_GOURAUD );
- lpDevice->SetRenderState( D3DRS_SPECULARENABLE, FALSE );
- lpDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
- lpDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
- lpDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
- lpDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
- lpDevice->SetRenderState( D3DRS_COLORVERTEX, TRUE );
- lpDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
- lpDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
- lpDevice->SetRenderState( D3DRS_AMBIENT, 0xFFFFFFFF );
- lpDevice->SetRenderState( D3DRS_CLIPPING, TRUE );
-
- lpDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
- lpDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
- lpDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
- lpDevice->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
- lpDevice->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
- lpDevice->SetSamplerState(1, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
-
-
-
- lpDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
- lpDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
- lpDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
- lpDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
- lpDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
- lpDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE );
- lpDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
-
-
-
-
-
-
-
-
-
- }
-
- if (m_supertext.bRedrawSuperText)
- {
- if (!RenderStringToTitleTexture())
- m_supertext.fStartTime = -1.0f;
- m_supertext.bRedrawSuperText = false;
- }
-
- {
- lpDevice->SetTexture(0, NULL);
- IDirect3DSurface9* pNewTarget = NULL;
- if (m_lpVS[0]->GetSurfaceLevel(0, &pNewTarget) != D3D_OK)
- return;
- lpDevice->SetRenderTarget(0, pNewTarget );
-
- pNewTarget->Release();
- lpDevice->SetTexture(0, NULL);
- }
-
- DrawMotionVectors();
- lpDevice->SetTexture(0, NULL);
- lpDevice->SetTexture(1, NULL);
-
- if (m_nFramesSinceResize == 0)
- {
- IDirect3DSurface9* pNewTarget = NULL;
- if (m_lpVS[0]->GetSurfaceLevel(0, &pNewTarget) != D3D_OK)
- return;
- lpDevice->SetRenderTarget(0, pNewTarget );
-
- pNewTarget->Release();
- lpDevice->Clear(0, NULL, D3DCLEAR_TARGET, 0x00000000, 1.0f, 0);
- }
-
- {
- IDirect3DSurface9* pNewTarget = NULL;
- if (m_lpVS[1]->GetSurfaceLevel(0, &pNewTarget) != D3D_OK)
- return;
- lpDevice->SetRenderTarget(0, pNewTarget );
-
- pNewTarget->Release();
- }
- if (m_bAutoGamma && GetFrame()==0)
- {
- if (strstr(GetDriverDescription(), "nvidia") ||
- strstr(GetDriverDescription(), "nVidia") ||
- strstr(GetDriverDescription(), "NVidia") ||
- strstr(GetDriverDescription(), "NVIDIA"))
- m_n16BitGamma = 2;
- else if (strstr(GetDriverDescription(), "ATI RAGE MOBILITY M"))
- m_n16BitGamma = 2;
- else
- m_n16BitGamma = 0;
- }
- ComputeGridAlphaValues();
-
- if (!m_pState->m_bBlending)
- {
-
- if (bNewPresetUsesWarpShader)
- WarpedBlit_Shaders(1, false, false, false, false);
- else
- WarpedBlit_NoShaders(1, false, false, false, false);
- }
- else
- {
-
-
-
-
-
- if (bOldPresetUsesWarpShader && bNewPresetUsesWarpShader)
- {
- WarpedBlit_Shaders (0, false, false, true, true);
- WarpedBlit_Shaders (1, true, false, true, false);
- }
- else if (!bOldPresetUsesWarpShader && bNewPresetUsesWarpShader)
- {
- WarpedBlit_NoShaders(0, false, false, true, true);
- WarpedBlit_Shaders (1, true, false, true, false);
- }
- else if (bOldPresetUsesWarpShader && !bNewPresetUsesWarpShader)
- {
- WarpedBlit_Shaders (0, false, false, true, true);
- WarpedBlit_NoShaders(1, true, false, true, false);
- }
- else if (!bOldPresetUsesWarpShader && !bNewPresetUsesWarpShader)
- {
-
-
-
- WarpedBlit_NoShaders(1, false, false, false, false);
- }
- }
- if (m_nMaxPSVersion > 0)
- BlurPasses();
-
- DrawCustomShapes();
- DrawCustomWaves();
- DrawWave(mysound.fWave[0], mysound.fWave[1]);
- DrawSprites();
- float fProgress = (GetTime() - m_supertext.fStartTime) / m_supertext.fDuration;
-
- if (m_supertext.fStartTime >= 0 &&
- fProgress >= 1.0f &&
- !m_supertext.bRedrawSuperText)
- {
- ShowSongTitleAnim(m_nTexSizeX, m_nTexSizeY, 1.0f);
- }
-
- lpDevice->SetTexture(0, NULL);
- lpDevice->SetRenderTarget(0, pBackBuffer );
-
- SafeRelease(pBackBuffer);
-
-
-
- if (!m_pState->m_bBlending)
- {
-
- if (bNewPresetUsesCompShader)
- ShowToUser_Shaders(1, false, false, false, false);
- else
- ShowToUser_NoShaders();
- }
- else
- {
-
-
-
-
-
-
-
-
- if (bOldPresetUsesCompShader && bNewPresetUsesCompShader)
- {
- ShowToUser_Shaders (0, false, false, true, true);
- ShowToUser_Shaders (1, true, false, true, false);
- }
- else if (!bOldPresetUsesCompShader && bNewPresetUsesCompShader)
- {
- ShowToUser_NoShaders();
- ShowToUser_Shaders (1, true, false, true, false);
- }
- else if (bOldPresetUsesCompShader && !bNewPresetUsesCompShader)
- {
-
-
-
- ShowToUser_NoShaders();
- ShowToUser_Shaders (0, true, true, true, true);
- }
- else if (!bOldPresetUsesCompShader && !bNewPresetUsesCompShader)
- {
-
- ShowToUser_NoShaders();
- }
- }
-
- if (m_supertext.fStartTime >= 0 &&
- !m_supertext.bRedrawSuperText)
- {
- ShowSongTitleAnim(GetWidth(), GetHeight(), min(fProgress, 0.9999f));
- if (fProgress >= 1.0f)
- m_supertext.fStartTime = -1.0f;
- }
- DrawUserSprites();
-
- IDirect3DTexture9* pTemp = m_lpVS[0];
- m_lpVS[0] = m_lpVS[1];
- m_lpVS[1] = pTemp;
-
- }
- void CPlugin::DrawMotionVectors()
- {
-
- if ((float)*m_pState->var_pf_mv_a >= 0.001f)
- {
-
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
- if (!lpDevice)
- return;
- lpDevice->SetTexture(0, NULL);
- lpDevice->SetVertexShader(NULL);
- lpDevice->SetFVF(WFVERTEX_FORMAT);
-
- int x,y;
- int nX = (int)(*m_pState->var_pf_mv_x);
- int nY = (int)(*m_pState->var_pf_mv_y);
- float dx = (float)*m_pState->var_pf_mv_x - nX;
- float dy = (float)*m_pState->var_pf_mv_y - nY;
- if (nX > 64) { nX = 64; dx = 0; }
- if (nY > 48) { nY = 48; dy = 0; }
- if (nX > 0 && nY > 0)
- {
-
- float dx2 = (float)(*m_pState->var_pf_mv_dx);
- float dy2 = (float)(*m_pState->var_pf_mv_dy);
- float len_mult = (float)*m_pState->var_pf_mv_l;
- if (dx < 0) dx = 0;
- if (dy < 0) dy = 0;
- if (dx > 1) dx = 1;
- if (dy > 1) dy = 1;
-
-
- float inv_texsize = 1.0f/(float)m_nTexSizeX;
- float min_len = 1.0f*inv_texsize;
- WFVERTEX v[(64+1)*2];
- ZeroMemory(v, sizeof(WFVERTEX)*(64+1)*2);
- v[0].Diffuse = D3DCOLOR_RGBA_01((float)*m_pState->var_pf_mv_r,(float)*m_pState->var_pf_mv_g,(float)*m_pState->var_pf_mv_b,(float)*m_pState->var_pf_mv_a);
- for (x=1; x<(nX+1)*2; x++)
- v[x].Diffuse = v[0].Diffuse;
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
- for (y=0; y<nY; y++)
- {
- float fy = (y + 0.25f)/(float)(nY + dy + 0.25f - 1.0f);
-
- fy -= dy2;
- if (fy > 0.0001f && fy < 0.9999f)
- {
- int n = 0;
- for (x=0; x<nX; x++)
- {
-
- float fx = (x + 0.25f)/(float)(nX + dx + 0.25f - 1.0f);
-
- fx += dx2;
- if (fx > 0.0001f && fx < 0.9999f)
- {
- float fx2, fy2;
- ReversePropagatePoint(fx, fy, &fx2, &fy2);
-
-
-
-
-
- {
- float dx = (fx2 - fx);
- float dy = (fy2 - fy);
- dx *= len_mult;
- dy *= len_mult;
- float len = sqrtf(dx*dx + dy*dy);
- if (len > min_len)
- {
- }
- else if (len > 0.00000001f)
- {
- len = min_len/len;
- dx *= len;
- dy *= len;
- }
- else
- {
- dx = min_len;
- dy = min_len;
- }
-
- fx2 = fx + dx;
- fy2 = fy + dy;
- }
-
- v[n].x = fx * 2.0f - 1.0f;
- v[n].y = fy * 2.0f - 1.0f;
- v[n+1].x = fx2 * 2.0f - 1.0f;
- v[n+1].y = fy2 * 2.0f - 1.0f;
-
-
-
-
-
- n += 2;
- }
- }
-
- lpDevice->DrawPrimitiveUP(D3DPT_LINELIST, n/2, v, sizeof(WFVERTEX));
- }
- }
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- }
- }
- }
-
- bool CPlugin::ReversePropagatePoint(float fx, float fy, float *fx2, float *fy2)
- {
-
- int y0 = (int)(fy*m_nGridY);
- float dy = fy*m_nGridY - y0;
-
- int x0 = (int)(fx*m_nGridX);
- float dx = fx*m_nGridX - x0;
- int x1 = x0 + 1;
- int y1 = y0 + 1;
- if (x0 < 0) return false;
- if (y0 < 0) return false;
-
-
-
-
- if (x1 > m_nGridX) return false;
- if (y1 > m_nGridY) return false;
- float tu, tv;
- tu = m_verts[y0*(m_nGridX+1)+x0].tu * (1-dx)*(1-dy);
- tv = m_verts[y0*(m_nGridX+1)+x0].tv * (1-dx)*(1-dy);
- tu += m_verts[y0*(m_nGridX+1)+x1].tu * (dx)*(1-dy);
- tv += m_verts[y0*(m_nGridX+1)+x1].tv * (dx)*(1-dy);
- tu += m_verts[y1*(m_nGridX+1)+x0].tu * (1-dx)*(dy);
- tv += m_verts[y1*(m_nGridX+1)+x0].tv * (1-dx)*(dy);
- tu += m_verts[y1*(m_nGridX+1)+x1].tu * (dx)*(dy);
- tv += m_verts[y1*(m_nGridX+1)+x1].tv * (dx)*(dy);
- *fx2 = tu;
- *fy2 = 1.0f - tv;
- return true;
- }
- void CPlugin::GetSafeBlurMinMax(CState* pState, float* blur_min, float* blur_max)
- {
- blur_min[0] = (float)*pState->var_pf_blur1min;
- blur_min[1] = (float)*pState->var_pf_blur2min;
- blur_min[2] = (float)*pState->var_pf_blur3min;
- blur_max[0] = (float)*pState->var_pf_blur1max;
- blur_max[1] = (float)*pState->var_pf_blur2max;
- blur_max[2] = (float)*pState->var_pf_blur3max;
-
-
- const float fMinDist = 0.1f;
- if (blur_max[0] - blur_min[0] < fMinDist) {
- float avg = (blur_min[0] + blur_max[0])*0.5f;
- blur_min[0] = avg - fMinDist*0.5f;
- blur_max[0] = avg - fMinDist*0.5f;
- }
- blur_max[1] = min(blur_max[0], blur_max[1]);
- blur_min[1] = max(blur_min[0], blur_min[1]);
- if (blur_max[1] - blur_min[1] < fMinDist) {
- float avg = (blur_min[1] + blur_max[1])*0.5f;
- blur_min[1] = avg - fMinDist*0.5f;
- blur_max[1] = avg - fMinDist*0.5f;
- }
- blur_max[2] = min(blur_max[1], blur_max[2]);
- blur_min[2] = max(blur_min[1], blur_min[2]);
- if (blur_max[2] - blur_min[2] < fMinDist) {
- float avg = (blur_min[2] + blur_max[2])*0.5f;
- blur_min[2] = avg - fMinDist*0.5f;
- blur_max[2] = avg - fMinDist*0.5f;
- }
- }
- void CPlugin::BlurPasses()
- {
- #if (NUM_BLUR_TEX>0)
-
-
-
-
-
-
-
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
- if (!lpDevice)
- return;
- int passes = min(NUM_BLUR_TEX, m_nHighestBlurTexUsedThisFrame*2);
- if (passes==0)
- return;
- LPDIRECT3DSURFACE9 pBackBuffer=NULL;
- lpDevice->GetRenderTarget( 0, &pBackBuffer );
-
- lpDevice->SetVertexShader( m_BlurShaders[0].vs.ptr );
- lpDevice->SetVertexDeclaration(m_pMyVertDecl);
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- DWORD wrap = D3DTADDRESS_CLAMP;
- lpDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, wrap);
- lpDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, wrap);
- lpDevice->SetSamplerState(0, D3DSAMP_ADDRESSW, wrap);
- lpDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
- lpDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
- lpDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
- lpDevice->SetSamplerState(0, D3DSAMP_MAXANISOTROPY, 1);
- IDirect3DSurface9* pNewTarget = NULL;
-
- for (int i=0; i<16; i++)
- lpDevice->SetTexture(i, NULL);
-
- MYVERTEX v[4];
-
- v[0].x = -1;
- v[0].y = -1;
- v[1].x = 1;
- v[1].y = -1;
- v[2].x = -1;
- v[2].y = 1;
- v[3].x = 1;
- v[3].y = 1;
- v[0].tu = 0;
- v[0].tv = 0;
- v[1].tu = 1;
- v[1].tv = 0;
- v[2].tu = 0;
- v[2].tv = 1;
- v[3].tu = 1;
- v[3].tv = 1;
- const float w[8] = { 4.0f, 3.8f, 3.5f, 2.9f, 1.9f, 1.2f, 0.7f, 0.3f };
- float edge_darken = (float)*m_pState->var_pf_blur1_edge_darken;
- float blur_min[3], blur_max[3];
- GetSafeBlurMinMax(m_pState, blur_min, blur_max);
- float fscale[3];
- float fbias[3];
-
-
- float temp_min, temp_max;
- fscale[0] = 1.0f / (blur_max[0] - blur_min[0]);
- fbias [0] = -blur_min[0] * fscale[0];
- temp_min = (blur_min[1] - blur_min[0]) / (blur_max[0] - blur_min[0]);
- temp_max = (blur_max[1] - blur_min[0]) / (blur_max[0] - blur_min[0]);
- fscale[1] = 1.0f / (temp_max - temp_min);
- fbias [1] = -temp_min * fscale[1];
- temp_min = (blur_min[2] - blur_min[1]) / (blur_max[1] - blur_min[1]);
- temp_max = (blur_max[2] - blur_min[1]) / (blur_max[1] - blur_min[1]);
- fscale[2] = 1.0f / (temp_max - temp_min);
- fbias [2] = -temp_min * fscale[2];
-
- for (int i=0; i<passes; i++)
- {
-
- if (m_lpBlur[i]->GetSurfaceLevel(0, &pNewTarget) != D3D_OK)
- return;
- lpDevice->SetRenderTarget(0, pNewTarget);
- pNewTarget->Release();
-
-
- lpDevice->SetTexture(0, (i==0) ? m_lpVS[0] : m_lpBlur[i-1]);
-
- lpDevice->SetPixelShader (m_BlurShaders[i%2].ps.ptr);
-
- LPD3DXCONSTANTTABLE pCT = m_BlurShaders[i%2].ps.CT;
- D3DXHANDLE* h = m_BlurShaders[i%2].ps.params.const_handles;
- int srcw = (i==0) ? GetWidth() : m_nBlurTexW[i-1];
- int srch = (i==0) ? GetHeight() : m_nBlurTexH[i-1];
- D3DXVECTOR4 srctexsize = D3DXVECTOR4( (float)srcw, (float)srch, 1.0f/(float)srcw, 1.0f/(float)srch );
- float fscale_now = fscale[i/2];
- float fbias_now = fbias[i/2];
- if (i%2==0)
- {
-
-
- const float w1 = w[0] + w[1];
- const float w2 = w[2] + w[3];
- const float w3 = w[4] + w[5];
- const float w4 = w[6] + w[7];
- const float d1 = 0 + 2*w[1]/w1;
- const float d2 = 2 + 2*w[3]/w2;
- const float d3 = 4 + 2*w[5]/w3;
- const float d4 = 6 + 2*w[7]/w4;
- const float w_div = 0.5f/(w1+w2+w3+w4);
-
-
-
-
-
-
- if (h[0]) pCT->SetVector( lpDevice, h[0], &srctexsize );
- if (h[1]) pCT->SetVector( lpDevice, h[1], &D3DXVECTOR4( w1,w2,w3,w4 ));
- if (h[2]) pCT->SetVector( lpDevice, h[2], &D3DXVECTOR4( d1,d2,d3,d4 ));
- if (h[3]) pCT->SetVector( lpDevice, h[3], &D3DXVECTOR4( fscale_now,fbias_now,w_div,0));
- }
- else
- {
-
-
- const float w1 = w[0]+w[1] + w[2]+w[3];
- const float w2 = w[4]+w[5] + w[6]+w[7];
- const float d1 = 0 + 2*((w[2]+w[3])/w1);
- const float d2 = 2 + 2*((w[6]+w[7])/w2);
- const float w_div = 1.0f/((w1+w2)*2);
-
-
-
-
-
- if (h[0]) pCT->SetVector( lpDevice, h[0], &srctexsize );
- if (h[5]) pCT->SetVector( lpDevice, h[5], &D3DXVECTOR4( w1,w2,d1,d2 ));
- if (h[6])
- {
-
-
- if (i==1)
- pCT->SetVector( lpDevice, h[6], &D3DXVECTOR4( w_div,(1-edge_darken),edge_darken,5.0f ));
- else
- pCT->SetVector( lpDevice, h[6], &D3DXVECTOR4( w_div,1.0f,0.0f,5.0f ));
- }
- }
-
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, v, sizeof(MYVERTEX));
-
- lpDevice->SetTexture(0, NULL);
- }
-
- lpDevice->SetRenderTarget(0, pBackBuffer);
- pBackBuffer->Release();
- lpDevice->SetPixelShader( NULL );
- lpDevice->SetVertexShader( NULL );
- lpDevice->SetTexture(0, NULL);
- lpDevice->SetFVF( MYVERTEX_FORMAT );
- #endif
- m_nHighestBlurTexUsedThisFrame = 0;
- }
- void CPlugin::ComputeGridAlphaValues()
- {
- float fBlend = m_pState->m_fBlendProgress;
-
-
- bool bBlending = m_pState->m_bBlending;
-
- float fWarpTime = GetTime() * m_pState->m_fWarpAnimSpeed;
- float fWarpScaleInv = 1.0f / m_pState->m_fWarpScale.eval(GetTime());
- float f[4];
- f[0] = 11.68f + 4.0f*cosf(fWarpTime*1.413f + 10);
- f[1] = 8.77f + 3.0f*cosf(fWarpTime*1.113f + 7);
- f[2] = 10.54f + 3.0f*cosf(fWarpTime*1.233f + 3);
- f[3] = 11.49f + 4.0f*cosf(fWarpTime*0.933f + 5);
-
- float texel_offset_x = 0.5f / (float)m_nTexSizeX;
- float texel_offset_y = 0.5f / (float)m_nTexSizeY;
- int num_reps = (m_pState->m_bBlending) ? 2 : 1;
- int start_rep = 0;
-
- for (int rep=start_rep; rep<num_reps; rep++)
- {
-
-
-
- CState *pState;
- if (rep==0)
- pState = m_pState;
- else
- pState = m_pOldState;
-
- float fZoom = (float)(*pState->var_pf_zoom);
- float fZoomExp = (float)(*pState->var_pf_zoomexp);
- float fRot = (float)(*pState->var_pf_rot);
- float fWarp = (float)(*pState->var_pf_warp);
- float fCX = (float)(*pState->var_pf_cx);
- float fCY = (float)(*pState->var_pf_cy);
- float fDX = (float)(*pState->var_pf_dx);
- float fDY = (float)(*pState->var_pf_dy);
- float fSX = (float)(*pState->var_pf_sx);
- float fSY = (float)(*pState->var_pf_sy);
-
- int n = 0;
- for (int y=0; y<=m_nGridY; y++)
- {
- for (int x=0; x<=m_nGridX; x++)
- {
-
-
-
-
-
- if (pState->m_pp_codehandle)
- {
-
-
-
- *pState->var_pv_x = (double)(m_verts[n].x* 0.5f*m_fAspectX + 0.5f);
- *pState->var_pv_y = (double)(m_verts[n].y*-0.5f*m_fAspectY + 0.5f);
- *pState->var_pv_rad = (double)m_vertinfo[n].rad;
- *pState->var_pv_ang = (double)m_vertinfo[n].ang;
- *pState->var_pv_zoom = *pState->var_pf_zoom;
- *pState->var_pv_zoomexp = *pState->var_pf_zoomexp;
- *pState->var_pv_rot = *pState->var_pf_rot;
- *pState->var_pv_warp = *pState->var_pf_warp;
- *pState->var_pv_cx = *pState->var_pf_cx;
- *pState->var_pv_cy = *pState->var_pf_cy;
- *pState->var_pv_dx = *pState->var_pf_dx;
- *pState->var_pv_dy = *pState->var_pf_dy;
- *pState->var_pv_sx = *pState->var_pf_sx;
- *pState->var_pv_sy = *pState->var_pf_sy;
-
-
-
-
-
-
-
- #ifndef _NO_EXPR_
- NSEEL_code_execute(pState->m_pp_codehandle);
- #endif
- fZoom = (float)(*pState->var_pv_zoom);
- fZoomExp = (float)(*pState->var_pv_zoomexp);
- fRot = (float)(*pState->var_pv_rot);
- fWarp = (float)(*pState->var_pv_warp);
- fCX = (float)(*pState->var_pv_cx);
- fCY = (float)(*pState->var_pv_cy);
- fDX = (float)(*pState->var_pv_dx);
- fDY = (float)(*pState->var_pv_dy);
- fSX = (float)(*pState->var_pv_sx);
- fSY = (float)(*pState->var_pv_sy);
- }
- float fZoom2 = powf(fZoom, powf(fZoomExp, m_vertinfo[n].rad*2.0f - 1.0f));
-
- float fZoom2Inv = 1.0f/fZoom2;
- float u = m_verts[n].x*m_fAspectX*0.5f*fZoom2Inv + 0.5f;
- float v = -m_verts[n].y*m_fAspectY*0.5f*fZoom2Inv + 0.5f;
-
-
-
-
-
- u = (u - fCX)/fSX + fCX;
- v = (v - fCY)/fSY + fCY;
-
-
-
- u += fWarp*0.0035f*sinf(fWarpTime*0.333f + fWarpScaleInv*(m_verts[n].x*f[0] - m_verts[n].y*f[3]));
- v += fWarp*0.0035f*cosf(fWarpTime*0.375f - fWarpScaleInv*(m_verts[n].x*f[2] + m_verts[n].y*f[1]));
- u += fWarp*0.0035f*cosf(fWarpTime*0.753f - fWarpScaleInv*(m_verts[n].x*f[1] - m_verts[n].y*f[2]));
- v += fWarp*0.0035f*sinf(fWarpTime*0.825f + fWarpScaleInv*(m_verts[n].x*f[0] + m_verts[n].y*f[3]));
-
-
- float u2 = u - fCX;
- float v2 = v - fCY;
-
- float cos_rot = cosf(fRot);
- float sin_rot = sinf(fRot);
- u = u2*cos_rot - v2*sin_rot + fCX;
- v = u2*sin_rot + v2*cos_rot + fCY;
-
- u -= fDX;
- v -= fDY;
-
- u = (u-0.5f)*m_fInvAspectX + 0.5f;
- v = (v-0.5f)*m_fInvAspectY + 0.5f;
-
- u += texel_offset_x;
- v += texel_offset_y;
-
- if (rep==0)
- {
-
- m_verts[n].tu = u;
- m_verts[n].tv = v;
- m_verts[n].Diffuse = 0xFFFFFFFF;
- }
- else
- {
-
- float mix2 = m_vertinfo[n].a*fBlend + m_vertinfo[n].c;
- mix2 = max(0,min(1,mix2));
-
-
- m_verts[n].tu = m_verts[n].tu*(mix2) + u*(1-mix2);
- m_verts[n].tv = m_verts[n].tv*(mix2) + v*(1-mix2);
-
- m_verts[n].Diffuse = 0x00FFFFFF | (((DWORD)(mix2*255))<<24);
- }
- n++;
- }
- }
- }
- }
- void CPlugin::WarpedBlit_NoShaders(int nPass, bool bAlphaBlend, bool bFlipAlpha, bool bCullTiles, bool bFlipCulling)
- {
- MungeFPCW(NULL);
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
- if (!lpDevice)
- return;
- if (!wcscmp(m_pState->m_szDesc, INVALID_PRESET_DESC))
- {
-
- lpDevice->Clear(0, NULL, D3DCLEAR_TARGET, 0x00000000, 1.0f, 0);
- return;
- }
- lpDevice->SetTexture(0, m_lpVS[0]);
- lpDevice->SetVertexShader( NULL );
- lpDevice->SetPixelShader( NULL );
- lpDevice->SetFVF( MYVERTEX_FORMAT );
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
-
- lpDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
- lpDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
- lpDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
- lpDevice->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
- lpDevice->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
- lpDevice->SetSamplerState(1, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
-
-
-
- lpDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
- lpDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
- lpDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
- lpDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
- lpDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
- lpDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE );
- lpDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
- DWORD texaddr = (*m_pState->var_pf_wrap > m_fSnapPoint) ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP;
- lpDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, texaddr);
- lpDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, texaddr);
- lpDevice->SetSamplerState(0, D3DSAMP_ADDRESSW, texaddr);
-
- float fDecay = (float)(*m_pState->var_pf_decay);
-
-
- if (m_n16BitGamma > 0 &&
- (GetBackBufFormat()==D3DFMT_R5G6B5 || GetBackBufFormat()==D3DFMT_X1R5G5B5 || GetBackBufFormat()==D3DFMT_A1R5G5B5 || GetBackBufFormat()==D3DFMT_A4R4G4B4) &&
- fDecay < 0.9999f)
- {
- fDecay = min(fDecay, (32.0f - m_n16BitGamma)/32.0f);
- }
- D3DCOLOR cDecay = D3DCOLOR_RGBA_01(fDecay,fDecay,fDecay,1);
-
- int poly;
- for (poly=0; poly<(m_nGridX+1)*2; poly++)
- m_verts_temp[poly].Diffuse = cDecay;
- if (bAlphaBlend)
- {
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- if (bFlipAlpha)
- {
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_INVSRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCALPHA);
- }
- else
- {
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
- }
- }
- else
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- int nAlphaTestValue = 0;
- if (bFlipCulling)
- nAlphaTestValue = 1-nAlphaTestValue;
-
-
-
-
-
- MYVERTEX tempv[1024 * 3];
- int max_prims_per_batch = min( GetCaps()->MaxPrimitiveCount, (sizeof(tempv)/sizeof(tempv[0]))/3) - 4;
- int primCount = m_nGridX*m_nGridY*2;
- int src_idx = 0;
- int prims_sent = 0;
- while (src_idx < primCount*3)
- {
- int prims_queued = 0;
- int i=0;
- while (prims_queued < max_prims_per_batch && src_idx < primCount*3)
- {
-
- for (int j=0; j<3; j++)
- {
- tempv[i++] = m_verts[ m_indices_list[src_idx++] ];
-
- tempv[i-1].y *= -1;
- tempv[i-1].Diffuse = (cDecay & 0x00FFFFFF) | (tempv[i-1].Diffuse & 0xFF000000);
- }
- if (bCullTiles)
- {
- DWORD d1 = (tempv[i-3].Diffuse >> 24);
- DWORD d2 = (tempv[i-2].Diffuse >> 24);
- DWORD d3 = (tempv[i-1].Diffuse >> 24);
- bool bIsNeeded;
- if (nAlphaTestValue)
- bIsNeeded = ((d1 & d2 & d3) < 255);
- else
- bIsNeeded = ((d1|d2|d3) > 0);
- if (!bIsNeeded)
- i -= 3;
- else
- prims_queued++;
- }
- else
- prims_queued++;
- }
- if (prims_queued > 0)
- lpDevice->DrawPrimitiveUP( D3DPT_TRIANGLELIST, prims_queued, tempv, sizeof(MYVERTEX) );
- }
-
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- }
- void CPlugin::WarpedBlit_Shaders(int nPass, bool bAlphaBlend, bool bFlipAlpha, bool bCullTiles, bool bFlipCulling)
- {
-
-
- MungeFPCW(NULL);
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
- if (!lpDevice)
- return;
- if (!wcscmp(m_pState->m_szDesc, INVALID_PRESET_DESC))
- {
-
- lpDevice->Clear(0, NULL, D3DCLEAR_TARGET, 0x00000000, 1.0f, 0);
- return;
- }
-
-
-
-
-
- lpDevice->SetVertexShader( NULL );
- lpDevice->SetFVF( MYVERTEX_FORMAT );
-
- float texel_offset_x = 0.5f / (float)m_nTexSizeX;
- float texel_offset_y = 0.5f / (float)m_nTexSizeY;
- int nAlphaTestValue = 0;
- if (bFlipCulling)
- nAlphaTestValue = 1-nAlphaTestValue;
- if (bAlphaBlend)
- {
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- if (bFlipAlpha)
- {
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_INVSRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCALPHA);
- }
- else
- {
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
- }
- }
- else
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- int pass = nPass;
- {
-
-
- PShaderInfo* si = (pass==0) ? &m_OldShaders.warp : &m_shaders.warp;
- CState* state = (pass==0) ? m_pOldState : m_pState;
- lpDevice->SetVertexDeclaration(m_pMyVertDecl);
- lpDevice->SetVertexShader(m_fallbackShaders_vs.warp.ptr);
- lpDevice->SetPixelShader (si->ptr);
-
- ApplyShaderParams( &(si->params), si->CT, state );
-
-
-
-
-
-
-
- MYVERTEX tempv[1024 * 3];
- int max_prims_per_batch = min( GetCaps()->MaxPrimitiveCount, (sizeof(tempv)/sizeof(tempv[0]))/3) - 4;
- for (int half=0; half<2; half++)
- {
-
- float new_ang = half ? 3.1415926535897932384626433832795f : -3.1415926535897932384626433832795f;
- int y_offset = (m_nGridY/2) * (m_nGridX+1);
- for (int x=0; x<m_nGridX/2; x++)
- m_verts[y_offset + x].ang = new_ang;
-
- int primCount = m_nGridX*m_nGridY*2 / 2;
- int src_idx = 0;
- int src_idx_offset = half * primCount*3;
- int prims_sent = 0;
- while (src_idx < primCount*3)
- {
- int prims_queued = 0;
- int i=0;
- while (prims_queued < max_prims_per_batch && src_idx < primCount*3)
- {
-
- for (int j=0; j<3; j++)
- tempv[i++] = m_verts[ m_indices_list[src_idx_offset + src_idx++] ];
- if (bCullTiles)
- {
- DWORD d1 = (tempv[i-3].Diffuse >> 24);
- DWORD d2 = (tempv[i-2].Diffuse >> 24);
- DWORD d3 = (tempv[i-1].Diffuse >> 24);
- bool bIsNeeded;
- if (nAlphaTestValue)
- bIsNeeded = ((d1 & d2 & d3) < 255);
- else
- bIsNeeded = ((d1|d2|d3) > 0);
- if (!bIsNeeded)
- i -= 3;
- else
- prims_queued++;
- }
- else
- prims_queued++;
- }
- if (prims_queued > 0)
- lpDevice->DrawPrimitiveUP( D3DPT_TRIANGLELIST, prims_queued, tempv, sizeof(MYVERTEX) );
- }
- }
- }
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- RestoreShaderParams();
- }
- void CPlugin::DrawCustomShapes()
- {
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
- if (!lpDevice)
- return;
-
-
- int num_reps = (m_pState->m_bBlending) ? 2 : 1;
- for (int rep=0; rep<num_reps; rep++)
- {
- CState *pState = (rep==0) ? m_pState : m_pOldState;
- float alpha_mult = 1;
- if (num_reps==2)
- alpha_mult = (rep==0) ? m_pState->m_fBlendProgress : (1-m_pState->m_fBlendProgress);
- for (int i=0; i<MAX_CUSTOM_SHAPES; i++)
- {
- if (pState->m_shape[i].enabled)
- {
-
- for (int instance=0; instance<pState->m_shape[i].instances; instance++)
- {
-
- LoadCustomShapePerFrameEvallibVars(pState, i, instance);
- #ifndef _NO_EXPR_
- if (pState->m_shape[i].m_pf_codehandle)
- {
- NSEEL_code_execute(pState->m_shape[i].m_pf_codehandle);
- }
- #endif
-
-
- int sides = (int)(*pState->m_shape[i].var_pf_sides);
- if (sides<3) sides=3;
- if (sides>100) sides=100;
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, ((int)(*pState->m_shape[i].var_pf_additive) != 0) ? D3DBLEND_ONE : D3DBLEND_INVSRCALPHA);
- SPRITEVERTEX v[512];
- WFVERTEX v2[512];
- v[0].x = (float)(*pState->m_shape[i].var_pf_x* 2-1);
- v[0].y = (float)(*pState->m_shape[i].var_pf_y*-2+1);
- v[0].z = 0;
- v[0].tu = 0.5f;
- v[0].tv = 0.5f;
- v[0].Diffuse =
- ((((int)(*pState->m_shape[i].var_pf_a * 255 * alpha_mult)) & 0xFF) << 24) |
- ((((int)(*pState->m_shape[i].var_pf_r * 255)) & 0xFF) << 16) |
- ((((int)(*pState->m_shape[i].var_pf_g * 255)) & 0xFF) << 8) |
- ((((int)(*pState->m_shape[i].var_pf_b * 255)) & 0xFF) );
- v[1].Diffuse =
- ((((int)(*pState->m_shape[i].var_pf_a2 * 255 * alpha_mult)) & 0xFF) << 24) |
- ((((int)(*pState->m_shape[i].var_pf_r2 * 255)) & 0xFF) << 16) |
- ((((int)(*pState->m_shape[i].var_pf_g2 * 255)) & 0xFF) << 8) |
- ((((int)(*pState->m_shape[i].var_pf_b2 * 255)) & 0xFF) );
-
- int j = 1;
- for (j=1; j<sides+1; j++)
- {
- float t = (j-1)/(float)sides;
- v[j].x = v[0].x + (float)*pState->m_shape[i].var_pf_rad*cosf(t*3.1415927f*2 + (float)*pState->m_shape[i].var_pf_ang + 3.1415927f*0.25f)*m_fAspectY;
- v[j].y = v[0].y + (float)*pState->m_shape[i].var_pf_rad*sinf(t*3.1415927f*2 + (float)*pState->m_shape[i].var_pf_ang + 3.1415927f*0.25f);
- v[j].z = 0;
- v[j].tu = 0.5f + 0.5f*cosf(t*3.1415927f*2 + (float)*pState->m_shape[i].var_pf_tex_ang + 3.1415927f*0.25f)/((float)*pState->m_shape[i].var_pf_tex_zoom) * m_fAspectY;
- v[j].tv = 0.5f + 0.5f*sinf(t*3.1415927f*2 + (float)*pState->m_shape[i].var_pf_tex_ang + 3.1415927f*0.25f)/((float)*pState->m_shape[i].var_pf_tex_zoom);
- v[j].Diffuse = v[1].Diffuse;
- }
- v[sides+1] = v[1];
- if ((int)(*pState->m_shape[i].var_pf_textured) != 0)
- {
-
- lpDevice->SetTexture(0, m_lpVS[0]);
- lpDevice->SetVertexShader( NULL );
- lpDevice->SetFVF( SPRITEVERTEX_FORMAT );
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, sides, (void*)v, sizeof(SPRITEVERTEX));
- }
- else
- {
-
- for (j=0; j < sides+2; j++)
- {
- v2[j].x = v[j].x;
- v2[j].y = v[j].y;
- v2[j].z = v[j].z;
- v2[j].Diffuse = v[j].Diffuse;
- }
- lpDevice->SetTexture(0, NULL);
- lpDevice->SetVertexShader( NULL );
- lpDevice->SetFVF( WFVERTEX_FORMAT );
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, sides, (void*)v2, sizeof(WFVERTEX));
- }
-
- if (*pState->m_shape[i].var_pf_border_a > 0)
- {
- lpDevice->SetTexture(0, NULL);
- lpDevice->SetVertexShader( NULL );
- lpDevice->SetFVF( WFVERTEX_FORMAT );
- v2[0].Diffuse =
- ((((int)(*pState->m_shape[i].var_pf_border_a * 255 * alpha_mult)) & 0xFF) << 24) |
- ((((int)(*pState->m_shape[i].var_pf_border_r * 255)) & 0xFF) << 16) |
- ((((int)(*pState->m_shape[i].var_pf_border_g * 255)) & 0xFF) << 8) |
- ((((int)(*pState->m_shape[i].var_pf_border_b * 255)) & 0xFF) );
- for (j=0; j<sides+2; j++)
- {
- v2[j].x = v[j].x;
- v2[j].y = v[j].y;
- v2[j].z = v[j].z;
- v2[j].Diffuse = v2[0].Diffuse;
- }
-
- int its = ((int)(*pState->m_shape[i].var_pf_thick) != 0) ? 4 : 1;
- float x_inc = 2.0f / (float)m_nTexSizeX;
- float y_inc = 2.0f / (float)m_nTexSizeY;
- for (int it=0; it<its; it++)
- {
- switch(it)
- {
- case 0: break;
- case 1: for (j=0; j<sides+2; j++) v2[j].x += x_inc; break;
- case 2: for (j=0; j<sides+2; j++) v2[j].y += y_inc; break;
- case 3: for (j=0; j<sides+2; j++) v2[j].x -= x_inc; break;
- }
- lpDevice->DrawPrimitiveUP(D3DPT_LINESTRIP, sides, (void*)&v2[1], sizeof(WFVERTEX));
- }
- }
- lpDevice->SetTexture(0, m_lpVS[0]);
- lpDevice->SetVertexShader( NULL );
- lpDevice->SetFVF( SPRITEVERTEX_FORMAT );
- }
- }
- }
- }
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
- }
- void CPlugin::LoadCustomShapePerFrameEvallibVars(CState* pState, int i, int instance)
- {
- *pState->m_shape[i].var_pf_time = (double)(GetTime() - m_fStartTime);
- *pState->m_shape[i].var_pf_frame = (double)GetFrame();
- *pState->m_shape[i].var_pf_fps = (double)GetFps();
- *pState->m_shape[i].var_pf_progress = (GetTime() - m_fPresetStartTime) / (m_fNextPresetTime - m_fPresetStartTime);
- *pState->m_shape[i].var_pf_bass = (double)mysound.imm_rel[0];
- *pState->m_shape[i].var_pf_mid = (double)mysound.imm_rel[1];
- *pState->m_shape[i].var_pf_treb = (double)mysound.imm_rel[2];
- *pState->m_shape[i].var_pf_bass_att = (double)mysound.avg_rel[0];
- *pState->m_shape[i].var_pf_mid_att = (double)mysound.avg_rel[1];
- *pState->m_shape[i].var_pf_treb_att = (double)mysound.avg_rel[2];
- int vi = 0;
- for (vi=0; vi<NUM_Q_VAR; vi++)
- *pState->m_shape[i].var_pf_q[vi] = *pState->var_pf_q[vi];
- for (vi=0; vi<NUM_T_VAR; vi++)
- *pState->m_shape[i].var_pf_t[vi] = pState->m_shape[i].t_values_after_init_code[vi];
- *pState->m_shape[i].var_pf_x = pState->m_shape[i].x;
- *pState->m_shape[i].var_pf_y = pState->m_shape[i].y;
- *pState->m_shape[i].var_pf_rad = pState->m_shape[i].rad;
- *pState->m_shape[i].var_pf_ang = pState->m_shape[i].ang;
- *pState->m_shape[i].var_pf_tex_zoom = pState->m_shape[i].tex_zoom;
- *pState->m_shape[i].var_pf_tex_ang = pState->m_shape[i].tex_ang;
- *pState->m_shape[i].var_pf_sides = pState->m_shape[i].sides;
- *pState->m_shape[i].var_pf_additive = pState->m_shape[i].additive;
- *pState->m_shape[i].var_pf_textured = pState->m_shape[i].textured;
- *pState->m_shape[i].var_pf_instances = pState->m_shape[i].instances;
- *pState->m_shape[i].var_pf_instance = instance;
- *pState->m_shape[i].var_pf_thick = pState->m_shape[i].thickOutline;
- *pState->m_shape[i].var_pf_r = pState->m_shape[i].r;
- *pState->m_shape[i].var_pf_g = pState->m_shape[i].g;
- *pState->m_shape[i].var_pf_b = pState->m_shape[i].b;
- *pState->m_shape[i].var_pf_a = pState->m_shape[i].a;
- *pState->m_shape[i].var_pf_r2 = pState->m_shape[i].r2;
- *pState->m_shape[i].var_pf_g2 = pState->m_shape[i].g2;
- *pState->m_shape[i].var_pf_b2 = pState->m_shape[i].b2;
- *pState->m_shape[i].var_pf_a2 = pState->m_shape[i].a2;
- *pState->m_shape[i].var_pf_border_r = pState->m_shape[i].border_r;
- *pState->m_shape[i].var_pf_border_g = pState->m_shape[i].border_g;
- *pState->m_shape[i].var_pf_border_b = pState->m_shape[i].border_b;
- *pState->m_shape[i].var_pf_border_a = pState->m_shape[i].border_a;
- }
- void CPlugin::LoadCustomWavePerFrameEvallibVars(CState* pState, int i)
- {
- *pState->m_wave[i].var_pf_time = (double)(GetTime() - m_fStartTime);
- *pState->m_wave[i].var_pf_frame = (double)GetFrame();
- *pState->m_wave[i].var_pf_fps = (double)GetFps();
- *pState->m_wave[i].var_pf_progress = (GetTime() - m_fPresetStartTime) / (m_fNextPresetTime - m_fPresetStartTime);
- *pState->m_wave[i].var_pf_bass = (double)mysound.imm_rel[0];
- *pState->m_wave[i].var_pf_mid = (double)mysound.imm_rel[1];
- *pState->m_wave[i].var_pf_treb = (double)mysound.imm_rel[2];
- *pState->m_wave[i].var_pf_bass_att = (double)mysound.avg_rel[0];
- *pState->m_wave[i].var_pf_mid_att = (double)mysound.avg_rel[1];
- *pState->m_wave[i].var_pf_treb_att = (double)mysound.avg_rel[2];
- int vi = 0;
- for (vi=0; vi<NUM_Q_VAR; vi++)
- *pState->m_wave[i].var_pf_q[vi] = *pState->var_pf_q[vi];
- for (vi=0; vi<NUM_T_VAR; vi++)
- *pState->m_wave[i].var_pf_t[vi] = pState->m_wave[i].t_values_after_init_code[vi];
- *pState->m_wave[i].var_pf_r = pState->m_wave[i].r;
- *pState->m_wave[i].var_pf_g = pState->m_wave[i].g;
- *pState->m_wave[i].var_pf_b = pState->m_wave[i].b;
- *pState->m_wave[i].var_pf_a = pState->m_wave[i].a;
- *pState->m_wave[i].var_pf_samples = pState->m_wave[i].samples;
- }
- int SmoothWave(WFVERTEX* vi, int nVertsIn, WFVERTEX* vo)
- {
- const float c1 = -0.15f;
- const float c2 = 1.15f;
- const float c3 = 1.15f;
- const float c4 = -0.15f;
- const float inv_sum = 1.0f/(c1+c2+c3+c4);
- int j = 0;
- int i_below = 0;
- int i_above;
- int i_above2 = 1;
- for (int i=0; i<nVertsIn-1; i++)
- {
- i_above = i_above2;
- i_above2 = min(nVertsIn-1,i+2);
- vo[j] = vi[i];
- vo[j+1].x = (c1*vi[i_below].x + c2*vi[i].x + c3*vi[i_above].x + c4*vi[i_above2].x)*inv_sum;
- vo[j+1].y = (c1*vi[i_below].y + c2*vi[i].y + c3*vi[i_above].y + c4*vi[i_above2].y)*inv_sum;
- vo[j+1].z = 0;
- vo[j+1].Diffuse = vi[i].Diffuse;
- i_below = i;
- j += 2;
- }
- vo[j++] = vi[nVertsIn-1];
- return j;
- }
- void CPlugin::DrawCustomWaves()
- {
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
- if (!lpDevice)
- return;
- lpDevice->SetTexture(0, NULL);
- lpDevice->SetVertexShader( NULL );
- lpDevice->SetFVF( WFVERTEX_FORMAT );
-
- int num_reps = (m_pState->m_bBlending) ? 2 : 1;
- for (int rep=0; rep<num_reps; rep++)
- {
- CState *pState = (rep==0) ? m_pState : m_pOldState;
- float alpha_mult = 1;
- if (num_reps==2)
- alpha_mult = (rep==0) ? m_pState->m_fBlendProgress : (1-m_pState->m_fBlendProgress);
- for (int i=0; i<MAX_CUSTOM_WAVES; i++)
- {
- if (pState->m_wave[i].enabled)
- {
- int nSamples = pState->m_wave[i].samples;
- int max_samples = pState->m_wave[i].bSpectrum ? 512 : NUM_WAVEFORM_SAMPLES;
- if (nSamples > max_samples)
- nSamples = max_samples;
- nSamples -= pState->m_wave[i].sep;
-
- LoadCustomWavePerFrameEvallibVars(pState, i);
-
-
- *pState->m_wave[i].var_pp_time = *pState->m_wave[i].var_pf_time;
- *pState->m_wave[i].var_pp_fps = *pState->m_wave[i].var_pf_fps;
- *pState->m_wave[i].var_pp_frame = *pState->m_wave[i].var_pf_frame;
- *pState->m_wave[i].var_pp_progress = *pState->m_wave[i].var_pf_progress;
- *pState->m_wave[i].var_pp_bass = *pState->m_wave[i].var_pf_bass;
- *pState->m_wave[i].var_pp_mid = *pState->m_wave[i].var_pf_mid;
- *pState->m_wave[i].var_pp_treb = *pState->m_wave[i].var_pf_treb;
- *pState->m_wave[i].var_pp_bass_att = *pState->m_wave[i].var_pf_bass_att;
- *pState->m_wave[i].var_pp_mid_att = *pState->m_wave[i].var_pf_mid_att;
- *pState->m_wave[i].var_pp_treb_att = *pState->m_wave[i].var_pf_treb_att;
- NSEEL_code_execute(pState->m_wave[i].m_pf_codehandle);
- int vi = 0;
- for (vi=0; vi<NUM_Q_VAR; vi++)
- *pState->m_wave[i].var_pp_q[vi] = *pState->m_wave[i].var_pf_q[vi];
- for (vi=0; vi<NUM_T_VAR; vi++)
- *pState->m_wave[i].var_pp_t[vi] = *pState->m_wave[i].var_pf_t[vi];
- nSamples = (int)*pState->m_wave[i].var_pf_samples;
- nSamples = min(512, nSamples);
- if ((nSamples >= 2) || (pState->m_wave[i].bUseDots && nSamples >= 1))
- {
- int j;
- float tempdata[2][512];
- float mult = ((pState->m_wave[i].bSpectrum) ? 0.15f : 0.004f) * pState->m_wave[i].scaling * pState->m_fWaveScale.eval(-1);
- float *pdata1 = (pState->m_wave[i].bSpectrum) ? m_sound.fSpectrum[0] : m_sound.fWaveform[0];
- float *pdata2 = (pState->m_wave[i].bSpectrum) ? m_sound.fSpectrum[1] : m_sound.fWaveform[1];
-
-
- int j0 = (pState->m_wave[i].bSpectrum) ? 0 : (max_samples - nSamples)/2 - pState->m_wave[i].sep/2;
- int j1 = (pState->m_wave[i].bSpectrum) ? 0 : (max_samples - nSamples)/2 + pState->m_wave[i].sep/2;
- float t = (pState->m_wave[i].bSpectrum) ? (max_samples - pState->m_wave[i].sep)/(float)nSamples : 1;
- float mix1 = powf(pState->m_wave[i].smoothing*0.98f, 0.5f);
- float mix2 = 1-mix1;
-
- tempdata[0][0] = pdata1[j0];
- tempdata[1][0] = pdata2[j1];
- for (j=1; j<nSamples; j++)
- {
- tempdata[0][j] = pdata1[(int)(j*t)+j0]*mix2 + tempdata[0][j-1]*mix1;
- tempdata[1][j] = pdata2[(int)(j*t)+j1]*mix2 + tempdata[1][j-1]*mix1;
- }
-
- for (j=nSamples-2; j>=0; j--)
- {
- tempdata[0][j] = tempdata[0][j]*mix2 + tempdata[0][j+1]*mix1;
- tempdata[1][j] = tempdata[1][j]*mix2 + tempdata[1][j+1]*mix1;
- }
-
- for (j=0; j<nSamples; j++)
- {
- tempdata[0][j] *= mult;
- tempdata[1][j] *= mult;
- }
-
-
-
- WFVERTEX v[1024];
- float j_mult = 1.0f/(float)(nSamples-1);
- for (j=0; j<nSamples; j++)
- {
- float t = j*j_mult;
- float value1 = tempdata[0][j];
- float value2 = tempdata[1][j];
- *pState->m_wave[i].var_pp_sample = t;
- *pState->m_wave[i].var_pp_value1 = value1;
- *pState->m_wave[i].var_pp_value2 = value2;
- *pState->m_wave[i].var_pp_x = 0.5f + value1;
- *pState->m_wave[i].var_pp_y = 0.5f + value2;
- *pState->m_wave[i].var_pp_r = *pState->m_wave[i].var_pf_r;
- *pState->m_wave[i].var_pp_g = *pState->m_wave[i].var_pf_g;
- *pState->m_wave[i].var_pp_b = *pState->m_wave[i].var_pf_b;
- *pState->m_wave[i].var_pp_a = *pState->m_wave[i].var_pf_a;
- #ifndef _NO_EXPR_
- NSEEL_code_execute(pState->m_wave[i].m_pp_codehandle);
- #endif
- v[j].x = (float)(*pState->m_wave[i].var_pp_x* 2-1)*m_fInvAspectX;
- v[j].y = (float)(*pState->m_wave[i].var_pp_y*-2+1)*m_fInvAspectY;
- v[j].z = 0;
- v[j].Diffuse =
- ((((int)(*pState->m_wave[i].var_pp_a * 255 * alpha_mult)) & 0xFF) << 24) |
- ((((int)(*pState->m_wave[i].var_pp_r * 255)) & 0xFF) << 16) |
- ((((int)(*pState->m_wave[i].var_pp_g * 255)) & 0xFF) << 8) |
- ((((int)(*pState->m_wave[i].var_pp_b * 255)) & 0xFF) );
- }
-
-
-
-
- WFVERTEX v2[2048];
- WFVERTEX *pVerts = v;
- if (!pState->m_wave[i].bUseDots)
- {
- nSamples = SmoothWave(v, nSamples, v2);
- pVerts = v2;
- }
-
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, pState->m_wave[i].bAdditive ? D3DBLEND_ONE : D3DBLEND_INVSRCALPHA);
-
- float ptsize = (float)((m_nTexSizeX >= 1024) ? 2 : 1) + (pState->m_wave[i].bDrawThick ? 1 : 0);
- if (pState->m_wave[i].bUseDots)
- lpDevice->SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&ptsize) );
- int its = (pState->m_wave[i].bDrawThick && !pState->m_wave[i].bUseDots) ? 4 : 1;
- float x_inc = 2.0f / (float)m_nTexSizeX;
- float y_inc = 2.0f / (float)m_nTexSizeY;
- for (int it=0; it<its; it++)
- {
- switch(it)
- {
- case 0: break;
- case 1: for (j=0; j<nSamples; j++) pVerts[j].x += x_inc; break;
- case 2: for (j=0; j<nSamples; j++) pVerts[j].y += y_inc; break;
- case 3: for (j=0; j<nSamples; j++) pVerts[j].x -= x_inc; break;
- }
- lpDevice->DrawPrimitiveUP(pState->m_wave[i].bUseDots ? D3DPT_POINTLIST : D3DPT_LINESTRIP, nSamples - (pState->m_wave[i].bUseDots ? 0 : 1), (void*)pVerts, sizeof(WFVERTEX));
- }
- ptsize = 1.0f;
- if (pState->m_wave[i].bUseDots)
- lpDevice->SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&ptsize) );
- }
- }
- }
- }
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
- }
- void CPlugin::DrawWave(float *fL, float *fR)
- {
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
- if (!lpDevice)
- return;
- lpDevice->SetTexture(0, NULL);
- lpDevice->SetVertexShader( NULL );
- lpDevice->SetFVF( WFVERTEX_FORMAT );
- int i;
- WFVERTEX v1[576+1], v2[576+1];
-
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, (*m_pState->var_pf_wave_additive) ? D3DBLEND_ONE : D3DBLEND_INVSRCALPHA);
-
-
-
- float cr = (float)(*m_pState->var_pf_wave_r);
- float cg = (float)(*m_pState->var_pf_wave_g);
- float cb = (float)(*m_pState->var_pf_wave_b);
- float cx = (float)(*m_pState->var_pf_wave_x);
- float cy = (float)(*m_pState->var_pf_wave_y);
- float fWaveParam = (float)(*m_pState->var_pf_wave_mystery);
-
- if (cr < 0) cr = 0;
- if (cg < 0) cg = 0;
- if (cb < 0) cb = 0;
- if (cr > 1) cr = 1;
- if (cg > 1) cg = 1;
- if (cb > 1) cb = 1;
-
- if (*m_pState->var_pf_wave_brighten)
- {
- float fMaximizeWaveColorAmount = 1.0f;
- float max = cr;
- if (max < cg) max = cg;
- if (max < cb) max = cb;
- if (max > 0.01f)
- {
- cr = cr/max*fMaximizeWaveColorAmount + cr*(1.0f - fMaximizeWaveColorAmount);
- cg = cg/max*fMaximizeWaveColorAmount + cg*(1.0f - fMaximizeWaveColorAmount);
- cb = cb/max*fMaximizeWaveColorAmount + cb*(1.0f - fMaximizeWaveColorAmount);
- }
- }
- float fWavePosX = cx*2.0f - 1.0f;
- float fWavePosY = cy*2.0f - 1.0f;
- float bass_rel = mysound.imm[0];
- float mid_rel = mysound.imm[1];
- float treble_rel = mysound.imm[2];
- int sample_offset = 0;
- int new_wavemode = (int)(*m_pState->var_pf_wave_mode) % NUM_WAVES;
- int its = (m_pState->m_bBlending && (new_wavemode != m_pState->m_nOldWaveMode)) ? 2 : 1;
- int nVerts1 = 0;
- int nVerts2 = 0;
- int nBreak1 = -1;
- int nBreak2 = -1;
- float alpha1, alpha2;
- for (int it=0; it<its; it++)
- {
- int wave = (it==0) ? new_wavemode : m_pState->m_nOldWaveMode;
- int nVerts = NUM_WAVEFORM_SAMPLES;
- int nBreak = -1;
- float fWaveParam2 = fWaveParam;
-
- if ((wave==0 || wave==1 || wave==4) && (fWaveParam2 < -1 || fWaveParam2 > 1))
- {
-
-
- fWaveParam2 = fWaveParam2*0.5f + 0.5f;
- fWaveParam2 -= floorf(fWaveParam2);
- fWaveParam2 = fabsf(fWaveParam2);
- fWaveParam2 = fWaveParam2*2-1;
- }
- WFVERTEX *v = (it==0) ? v1 : v2;
- ZeroMemory(v, sizeof(WFVERTEX)*nVerts);
- float alpha = (float)(*m_pState->var_pf_wave_a);
- switch(wave)
- {
- case 0:
-
- nVerts /= 2;
- sample_offset = (NUM_WAVEFORM_SAMPLES-nVerts)/2;
- if (m_pState->m_bModWaveAlphaByVolume)
- alpha *= ((mysound.imm_rel[0] + mysound.imm_rel[1] + mysound.imm_rel[2])*0.333f - m_pState->m_fModWaveAlphaStart.eval(GetTime()))/(m_pState->m_fModWaveAlphaEnd.eval(GetTime()) - m_pState->m_fModWaveAlphaStart.eval(GetTime()));
- if (alpha < 0) alpha = 0;
- if (alpha > 1) alpha = 1;
-
- {
- float inv_nverts_minus_one = 1.0f/(float)(nVerts-1);
- for (i=0; i<nVerts; i++)
- {
- float rad = 0.5f + 0.4f*fR[i+sample_offset] + fWaveParam2;
- float ang = (i)*inv_nverts_minus_one*6.28f + GetTime()*0.2f;
- if (i < nVerts/10)
- {
- float mix = i/(nVerts*0.1f);
- mix = 0.5f - 0.5f*cosf(mix * 3.1416f);
- float rad_2 = 0.5f + 0.4f*fR[i + nVerts + sample_offset] + fWaveParam2;
- rad = rad_2*(1.0f-mix) + rad*(mix);
- }
- v[i].x = rad*cosf(ang) *m_fAspectY + fWavePosX;
- v[i].y = rad*sinf(ang) *m_fAspectX + fWavePosY;
-
- }
- }
-
- if (!m_pState->m_bBlending)
- {
- nVerts++;
- memcpy(&v[nVerts-1], &v[0], sizeof(WFVERTEX));
- }
- break;
- case 1:
-
- alpha *= 1.25f;
- if (m_pState->m_bModWaveAlphaByVolume)
- alpha *= ((mysound.imm_rel[0] + mysound.imm_rel[1] + mysound.imm_rel[2])*0.333f - m_pState->m_fModWaveAlphaStart.eval(GetTime()))/(m_pState->m_fModWaveAlphaEnd.eval(GetTime()) - m_pState->m_fModWaveAlphaStart.eval(GetTime()));
- if (alpha < 0) alpha = 0;
- if (alpha > 1) alpha = 1;
-
- nVerts /= 2;
- for (i=0; i<nVerts; i++)
- {
- float rad = 0.53f + 0.43f*fR[i] + fWaveParam2;
- float ang = fL[i+32] * 1.57f + GetTime()*2.3f;
- v[i].x = rad*cosf(ang) *m_fAspectY + fWavePosX;
- v[i].y = rad*sinf(ang) *m_fAspectX + fWavePosY;
-
- }
- break;
-
- case 2:
-
-
-
- switch(m_nTexSizeX)
- {
- case 256: alpha *= 0.07f; break;
- case 512: alpha *= 0.09f; break;
- case 1024: alpha *= 0.11f; break;
- case 2048: alpha *= 0.13f; break;
- }
- if (m_pState->m_bModWaveAlphaByVolume)
- alpha *= ((mysound.imm_rel[0] + mysound.imm_rel[1] + mysound.imm_rel[2])*0.333f - m_pState->m_fModWaveAlphaStart.eval(GetTime()))/(m_pState->m_fModWaveAlphaEnd.eval(GetTime()) - m_pState->m_fModWaveAlphaStart.eval(GetTime()));
- if (alpha < 0) alpha = 0;
- if (alpha > 1) alpha = 1;
-
-
- for (i=0; i<nVerts; i++)
- {
- v[i].x = fR[i ] *m_fAspectY + fWavePosX;
- v[i].y = fL[i+32] *m_fAspectX + fWavePosY;
-
- }
- break;
- case 3:
-
-
-
- switch(m_nTexSizeX)
- {
- case 256: alpha = 0.075f; break;
- case 512: alpha = 0.150f; break;
- case 1024: alpha = 0.220f; break;
- case 2048: alpha = 0.330f; break;
- }
- alpha *= 1.3f;
- alpha *= powf(treble_rel, 2.0f);
- if (m_pState->m_bModWaveAlphaByVolume)
- alpha *= ((mysound.imm_rel[0] + mysound.imm_rel[1] + mysound.imm_rel[2])*0.333f - m_pState->m_fModWaveAlphaStart.eval(GetTime()))/(m_pState->m_fModWaveAlphaEnd.eval(GetTime()) - m_pState->m_fModWaveAlphaStart.eval(GetTime()));
- if (alpha < 0) alpha = 0;
- if (alpha > 1) alpha = 1;
-
- for (i=0; i<nVerts; i++)
- {
- v[i].x = fR[i ] *m_fAspectY + fWavePosX;
- v[i].y = fL[i+32] *m_fAspectX + fWavePosY;
-
- }
- break;
- case 4:
-
- if (nVerts > m_nTexSizeX/3)
- nVerts = m_nTexSizeX/3;
- sample_offset = (NUM_WAVEFORM_SAMPLES-nVerts)/2;
-
- if (m_pState->m_bModWaveAlphaByVolume)
- alpha *= ((mysound.imm_rel[0] + mysound.imm_rel[1] + mysound.imm_rel[2])*0.333f - m_pState->m_fModWaveAlphaStart.eval(GetTime()))/(m_pState->m_fModWaveAlphaEnd.eval(GetTime()) - m_pState->m_fModWaveAlphaStart.eval(GetTime()));
- if (alpha < 0) alpha = 0;
- if (alpha > 1) alpha = 1;
-
- {
- float w1 = 0.45f + 0.5f*(fWaveParam2*0.5f + 0.5f);
- float w2 = 1.0f - w1;
- float inv_nverts = 1.0f/(float)(nVerts);
- for (i=0; i<nVerts; i++)
- {
- v[i].x = -1.0f + 2.0f*(i*inv_nverts) + fWavePosX;
- v[i].y = fL[i+sample_offset]*0.47f + fWavePosY;
- v[i].x += fR[i+25+sample_offset]*0.44f;
-
-
- if (i>1)
- {
- v[i].x = v[i].x*w2 + w1*(v[i-1].x*2.0f - v[i-2].x);
- v[i].y = v[i].y*w2 + w1*(v[i-1].y*2.0f - v[i-2].y);
- }
- }
-
- }
- break;
- case 5:
-
- switch(m_nTexSizeX)
- {
- case 256: alpha *= 0.07f; break;
- case 512: alpha *= 0.09f; break;
- case 1024: alpha *= 0.11f; break;
- case 2048: alpha *= 0.13f; break;
- }
- if (m_pState->m_bModWaveAlphaByVolume)
- alpha *= ((mysound.imm_rel[0] + mysound.imm_rel[1] + mysound.imm_rel[2])*0.333f - m_pState->m_fModWaveAlphaStart.eval(GetTime()))/(m_pState->m_fModWaveAlphaEnd.eval(GetTime()) - m_pState->m_fModWaveAlphaStart.eval(GetTime()));
- if (alpha < 0) alpha = 0;
- if (alpha > 1) alpha = 1;
-
-
- {
- float cos_rot = cosf(GetTime()*0.3f);
- float sin_rot = sinf(GetTime()*0.3f);
- for (i=0; i<nVerts; i++)
- {
- float x0 = (fR[i]*fL[i+32] + fL[i]*fR[i+32]);
- float y0 = (fR[i]*fR[i] - fL[i+32]*fL[i+32]);
- v[i].x = (x0*cos_rot - y0*sin_rot)*m_fAspectY + fWavePosX;
- v[i].y = (x0*sin_rot + y0*cos_rot)*m_fAspectX + fWavePosY;
-
- }
- }
- break;
- case 6:
- case 7:
- case 8:
-
-
-
-
-
-
-
-
-
-
- nVerts /= 2;
- if (nVerts > m_nTexSizeX/3)
- nVerts = m_nTexSizeX/3;
- if (wave==8)
- nVerts = 256;
- else
- sample_offset = (NUM_WAVEFORM_SAMPLES-nVerts)/2;
- if (m_pState->m_bModWaveAlphaByVolume)
- alpha *= ((mysound.imm_rel[0] + mysound.imm_rel[1] + mysound.imm_rel[2])*0.333f - m_pState->m_fModWaveAlphaStart.eval(GetTime()))/(m_pState->m_fModWaveAlphaEnd.eval(GetTime()) - m_pState->m_fModWaveAlphaStart.eval(GetTime()));
- if (alpha < 0) alpha = 0;
- if (alpha > 1) alpha = 1;
-
- {
- float ang = 1.57f*fWaveParam2;
- float dx = cosf(ang);
- float dy = sinf(ang);
- float edge_x[2], edge_y[2];
-
-
-
-
- edge_x[0] = fWavePosX*cosf(ang + 1.57f) - dx*3.0f;
- edge_y[0] = fWavePosX*sinf(ang + 1.57f) - dy*3.0f;
- edge_x[1] = fWavePosX*cosf(ang + 1.57f) + dx*3.0f;
- edge_y[1] = fWavePosX*sinf(ang + 1.57f) + dy*3.0f;
- for (i=0; i<2; i++)
- {
-
-
-
- for (int j=0; j<4; j++)
- {
- float t;
- bool bClip = false;
- switch(j)
- {
- case 0:
- if (edge_x[i] > 1.1f)
- {
- t = (1.1f - edge_x[1-i]) / (edge_x[i] - edge_x[1-i]);
- bClip = true;
- }
- break;
- case 1:
- if (edge_x[i] < -1.1f)
- {
- t = (-1.1f - edge_x[1-i]) / (edge_x[i] - edge_x[1-i]);
- bClip = true;
- }
- break;
- case 2:
- if (edge_y[i] > 1.1f)
- {
- t = (1.1f - edge_y[1-i]) / (edge_y[i] - edge_y[1-i]);
- bClip = true;
- }
- break;
- case 3:
- if (edge_y[i] < -1.1f)
- {
- t = (-1.1f - edge_y[1-i]) / (edge_y[i] - edge_y[1-i]);
- bClip = true;
- }
- break;
- }
- if (bClip)
- {
- float dx = edge_x[i] - edge_x[1-i];
- float dy = edge_y[i] - edge_y[1-i];
- edge_x[i] = edge_x[1-i] + dx*t;
- edge_y[i] = edge_y[1-i] + dy*t;
- }
- }
- }
- dx = (edge_x[1] - edge_x[0]) / (float)nVerts;
- dy = (edge_y[1] - edge_y[0]) / (float)nVerts;
- float ang2 = atan2f(dy,dx);
- float perp_dx = cosf(ang2 + 1.57f);
- float perp_dy = sinf(ang2 + 1.57f);
- if (wave == 6)
- for (i=0; i<nVerts; i++)
- {
- v[i].x = edge_x[0] + dx*i + perp_dx*0.25f*fL[i + sample_offset];
- v[i].y = edge_y[0] + dy*i + perp_dy*0.25f*fL[i + sample_offset];
-
- }
- else if (wave == 8)
-
- for (i=0; i<nVerts; i++)
- {
- float f = 0.1f*logf(mysound.fSpecLeft[i*2] + mysound.fSpecLeft[i*2+1]);
- v[i].x = edge_x[0] + dx*i + perp_dx*f;
- v[i].y = edge_y[0] + dy*i + perp_dy*f;
-
- }
- else
- {
- float sep = powf(fWavePosY*0.5f + 0.5f, 2.0f);
- for (i=0; i<nVerts; i++)
- {
- v[i].x = edge_x[0] + dx*i + perp_dx*(0.25f*fL[i + sample_offset] + sep);
- v[i].y = edge_y[0] + dy*i + perp_dy*(0.25f*fL[i + sample_offset] + sep);
-
- }
-
-
- for (i=0; i<nVerts; i++)
- {
- v[i+nVerts].x = edge_x[0] + dx*i + perp_dx*(0.25f*fR[i + sample_offset] - sep);
- v[i+nVerts].y = edge_y[0] + dy*i + perp_dy*(0.25f*fR[i + sample_offset] - sep);
-
- }
- nBreak = nVerts;
- nVerts *= 2;
- }
- }
- break;
- }
- if (it==0)
- {
- nVerts1 = nVerts;
- nBreak1 = nBreak;
- alpha1 = alpha;
- }
- else
- {
- nVerts2 = nVerts;
- nBreak2 = nBreak;
- alpha2 = alpha;
- }
- }
-
-
-
-
-
-
- float mix = CosineInterp(m_pState->m_fBlendProgress);
- float mix2 = 1.0f - mix;
-
- if (nVerts2 > 0)
- {
-
-
- float m = (nVerts2-1)/(float)nVerts1;
- float x,y;
- for (int i=0; i<nVerts1; i++)
- {
- float fIdx = i*m;
- int nIdx = (int)fIdx;
- float t = fIdx - nIdx;
- if (nIdx == nBreak2-1)
- {
- x = v2[nIdx].x;
- y = v2[nIdx].y;
- nBreak1 = i+1;
- }
- else
- {
- x = v2[nIdx].x*(1-t) + v2[nIdx+1].x*(t);
- y = v2[nIdx].y*(1-t) + v2[nIdx+1].y*(t);
- }
- v1[i].x = v1[i].x*(mix) + x*(mix2);
- v1[i].y = v1[i].y*(mix) + y*(mix2);
- }
- }
-
- if (nVerts2 > 0)
- {
- alpha1 = alpha1*(mix) + alpha2*(1.0f-mix);
- }
-
-
-
- v1[0].Diffuse = D3DCOLOR_RGBA_01(cr, cg, cb, alpha1);
- for (i=0; i<nVerts1; i++)
- {
- v1[i].Diffuse = v1[0].Diffuse;
- v1[i].y = -v1[i].y;
- }
-
-
- if (alpha1 < 0.004f)
- goto SKIP_DRAW_WAVE;
-
- WFVERTEX* pVerts = v1;
- WFVERTEX vTess[(576+3)*2];
- if (1)
- {
- if (nBreak1==-1)
- {
- nVerts1 = SmoothWave(v1, nVerts1, vTess);
- }
- else
- {
- int oldBreak = nBreak1;
- nBreak1 = SmoothWave(v1, nBreak1, vTess);
- nVerts1 = SmoothWave(&v1[oldBreak], nVerts1-oldBreak, &vTess[nBreak1]) + nBreak1;
- }
- pVerts = vTess;
- }
-
- {
-
- float x_inc = 2.0f / (float)m_nTexSizeX;
- float y_inc = 2.0f / (float)m_nTexSizeY;
- int drawing_its = ((*m_pState->var_pf_wave_thick || *m_pState->var_pf_wave_usedots) && (m_nTexSizeX >= 512)) ? 4 : 1;
- for (int it=0; it<drawing_its; it++)
- {
- int j;
- switch(it)
- {
- case 0: break;
- case 1: for (j=0; j<nVerts1; j++) pVerts[j].x += x_inc; break;
- case 2: for (j=0; j<nVerts1; j++) pVerts[j].y += y_inc; break;
- case 3: for (j=0; j<nVerts1; j++) pVerts[j].x -= x_inc; break;
- }
- if (nBreak1 == -1)
- {
- if (*m_pState->var_pf_wave_usedots)
- lpDevice->DrawPrimitiveUP(D3DPT_POINTLIST, nVerts1, (void*)pVerts, sizeof(WFVERTEX));
- else
- lpDevice->DrawPrimitiveUP(D3DPT_LINESTRIP, nVerts1-1, (void*)pVerts, sizeof(WFVERTEX));
- }
- else
- {
- if (*m_pState->var_pf_wave_usedots)
- {
- lpDevice->DrawPrimitiveUP(D3DPT_POINTLIST, nBreak1, (void*)pVerts, sizeof(WFVERTEX));
- lpDevice->DrawPrimitiveUP(D3DPT_POINTLIST, nVerts1-nBreak1, (void*)&pVerts[nBreak1], sizeof(WFVERTEX));
- }
- else
- {
- lpDevice->DrawPrimitiveUP(D3DPT_LINESTRIP, nBreak1-1, (void*)pVerts, sizeof(WFVERTEX));
- lpDevice->DrawPrimitiveUP(D3DPT_LINESTRIP, nVerts1-nBreak1-1, (void*)&pVerts[nBreak1], sizeof(WFVERTEX));
- }
- }
- }
- }
- SKIP_DRAW_WAVE:
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- }
- void CPlugin::DrawSprites()
- {
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
- if (!lpDevice)
- return;
- lpDevice->SetTexture(0, NULL);
- lpDevice->SetVertexShader( NULL );
- lpDevice->SetFVF( WFVERTEX_FORMAT );
- if (*m_pState->var_pf_darken_center)
- {
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
- WFVERTEX v3[6];
- ZeroMemory(v3, sizeof(WFVERTEX)*6);
-
- v3[0].Diffuse = D3DCOLOR_RGBA_01(0, 0, 0, 3.0f/32.0f);
- v3[1].Diffuse = D3DCOLOR_RGBA_01(0, 0, 0, 0.0f/32.0f);
- v3[2].Diffuse = v3[1].Diffuse;
- v3[3].Diffuse = v3[1].Diffuse;
- v3[4].Diffuse = v3[1].Diffuse;
- v3[5].Diffuse = v3[1].Diffuse;
-
- float fHalfSize = 0.05f;
- v3[0].x = 0.0f;
- v3[1].x = 0.0f - fHalfSize*m_fAspectY;
- v3[2].x = 0.0f;
- v3[3].x = 0.0f + fHalfSize*m_fAspectY;
- v3[4].x = 0.0f;
- v3[5].x = v3[1].x;
- v3[0].y = 0.0f;
- v3[1].y = 0.0f;
- v3[2].y = 0.0f - fHalfSize;
- v3[3].y = 0.0f;
- v3[4].y = 0.0f + fHalfSize;
- v3[5].y = v3[1].y;
-
-
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 4, (LPVOID)v3, sizeof(WFVERTEX));
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- }
-
- {
- float fOuterBorderSize = (float)*m_pState->var_pf_ob_size;
- float fInnerBorderSize = (float)*m_pState->var_pf_ib_size;
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
- for (int it=0; it<2; it++)
- {
- WFVERTEX v3[4];
- ZeroMemory(v3, sizeof(WFVERTEX)*4);
-
- float r = (it==0) ? (float)*m_pState->var_pf_ob_r : (float)*m_pState->var_pf_ib_r;
- float g = (it==0) ? (float)*m_pState->var_pf_ob_g : (float)*m_pState->var_pf_ib_g;
- float b = (it==0) ? (float)*m_pState->var_pf_ob_b : (float)*m_pState->var_pf_ib_b;
- float a = (it==0) ? (float)*m_pState->var_pf_ob_a : (float)*m_pState->var_pf_ib_a;
- if (a > 0.001f)
- {
- v3[0].Diffuse = D3DCOLOR_RGBA_01(r,g,b,a);
- v3[1].Diffuse = v3[0].Diffuse;
- v3[2].Diffuse = v3[0].Diffuse;
- v3[3].Diffuse = v3[0].Diffuse;
-
- float fInnerRad = (it==0) ? 1.0f - fOuterBorderSize : 1.0f - fOuterBorderSize - fInnerBorderSize;
- float fOuterRad = (it==0) ? 1.0f : 1.0f - fOuterBorderSize;
- v3[0].x = fInnerRad;
- v3[1].x = fOuterRad;
- v3[2].x = fOuterRad;
- v3[3].x = fInnerRad;
- v3[0].y = fInnerRad;
- v3[1].y = fOuterRad;
- v3[2].y = -fOuterRad;
- v3[3].y = -fInnerRad;
- for (int rot=0; rot<4; rot++)
- {
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, (LPVOID)v3, sizeof(WFVERTEX));
-
- for (int v=0; v<4; v++)
- {
- float t = 1.570796327f;
- float x = v3[v].x;
- float y = v3[v].y;
- v3[v].x = x*cosf(t) - y*sinf(t);
- v3[v].y = x*sinf(t) + y*cosf(t);
- }
- }
- }
- }
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- }
- }
- void CPlugin::DrawUserSprites()
- {
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
- if (!lpDevice)
- return;
- lpDevice->SetTexture(0, NULL);
- lpDevice->SetVertexShader( NULL );
- lpDevice->SetFVF( SPRITEVERTEX_FORMAT );
-
-
-
-
-
- lpDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
- lpDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
- lpDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
- lpDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
- lpDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
- lpDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE );
- lpDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
-
- for (int iSlot=0; iSlot < NUM_TEX; iSlot++)
- {
- if (m_texmgr.m_tex[iSlot].pSurface)
- {
- int k;
-
- *(m_texmgr.m_tex[iSlot].var_time) = (double)(GetTime() - m_texmgr.m_tex[iSlot].fStartTime);
- *(m_texmgr.m_tex[iSlot].var_frame) = (double)(GetFrame() - m_texmgr.m_tex[iSlot].nStartFrame);
- *(m_texmgr.m_tex[iSlot].var_fps) = (double)GetFps();
- *(m_texmgr.m_tex[iSlot].var_progress) = (double)m_pState->m_fBlendProgress;
- *(m_texmgr.m_tex[iSlot].var_bass) = (double)mysound.imm_rel[0];
- *(m_texmgr.m_tex[iSlot].var_mid) = (double)mysound.imm_rel[1];
- *(m_texmgr.m_tex[iSlot].var_treb) = (double)mysound.imm_rel[2];
- *(m_texmgr.m_tex[iSlot].var_bass_att) = (double)mysound.avg_rel[0];
- *(m_texmgr.m_tex[iSlot].var_mid_att) = (double)mysound.avg_rel[1];
- *(m_texmgr.m_tex[iSlot].var_treb_att) = (double)mysound.avg_rel[2];
-
- #ifndef _NO_EXPR_
- if (m_texmgr.m_tex[iSlot].m_codehandle)
- {
- NSEEL_code_execute(m_texmgr.m_tex[iSlot].m_codehandle);
- }
- #endif
- bool bKillSprite = (*m_texmgr.m_tex[iSlot].var_done != 0.0);
- bool bBurnIn = (*m_texmgr.m_tex[iSlot].var_burn != 0.0);
-
- LPDIRECT3DSURFACE9 pBackBuffer=NULL;
- lpDevice->GetRenderTarget( 0, &pBackBuffer );
-
- if ( bBurnIn)
- {
-
- lpDevice->SetTexture(0, NULL);
- IDirect3DSurface9* pNewTarget = NULL;
- if (m_lpVS[1]->GetSurfaceLevel(0, &pNewTarget) != D3D_OK)
- return;
- lpDevice->SetRenderTarget(0, pNewTarget );
-
- pNewTarget->Release();
- lpDevice->SetTexture(0, NULL);
- }
-
- if (lpDevice->SetTexture(0, m_texmgr.m_tex[iSlot].pSurface) != D3D_OK)
- return;
- SPRITEVERTEX v3[4];
- ZeroMemory(v3, sizeof(SPRITEVERTEX)*4);
-
- float x = min(1000.0f, max(-1000.0f, (float)(*m_texmgr.m_tex[iSlot].var_x) * 2.0f - 1.0f ));
- float y = min(1000.0f, max(-1000.0f, (float)(*m_texmgr.m_tex[iSlot].var_y) * 2.0f - 1.0f ));
- float sx = min(1000.0f, max(-1000.0f, (float)(*m_texmgr.m_tex[iSlot].var_sx) ));
- float sy = min(1000.0f, max(-1000.0f, (float)(*m_texmgr.m_tex[iSlot].var_sy) ));
- float rot = (float)(*m_texmgr.m_tex[iSlot].var_rot);
- int flipx = (*m_texmgr.m_tex[iSlot].var_flipx == 0.0) ? 0 : 1;
- int flipy = (*m_texmgr.m_tex[iSlot].var_flipy == 0.0) ? 0 : 1;
- float repeatx = min(100.0f, max(0.01f, (float)(*m_texmgr.m_tex[iSlot].var_repeatx) ));
- float repeaty = min(100.0f, max(0.01f, (float)(*m_texmgr.m_tex[iSlot].var_repeaty) ));
- int blendmode = min(4, max(0, ((int)(*m_texmgr.m_tex[iSlot].var_blendmode))));
- float r = min(1.0f, max(0.0f, ((float)(*m_texmgr.m_tex[iSlot].var_r))));
- float g = min(1.0f, max(0.0f, ((float)(*m_texmgr.m_tex[iSlot].var_g))));
- float b = min(1.0f, max(0.0f, ((float)(*m_texmgr.m_tex[iSlot].var_b))));
- float a = min(1.0f, max(0.0f, ((float)(*m_texmgr.m_tex[iSlot].var_a))));
-
- v3[0+flipx].x = -sx;
- v3[1-flipx].x = sx;
- v3[2+flipx].x = -sx;
- v3[3-flipx].x = sx;
- v3[0+flipy*2].y = -sy;
- v3[1+flipy*2].y = -sy;
- v3[2-flipy*2].y = sy;
- v3[3-flipy*2].y = sy;
-
- {
- float aspect = m_texmgr.m_tex[iSlot].img_h / (float)m_texmgr.m_tex[iSlot].img_w;
- if (aspect < 1)
- for (k=0; k<4; k++) v3[k].y *= aspect;
- else
- for (k=0; k<4; k++) v3[k].x /= aspect;
- }
-
- {
- float cos_rot = cosf(rot);
- float sin_rot = sinf(rot);
- for (k=0; k<4; k++)
- {
- float x2 = v3[k].x*cos_rot - v3[k].y*sin_rot;
- float y2 = v3[k].x*sin_rot + v3[k].y*cos_rot;
- v3[k].x = x2;
- v3[k].y = y2;
- }
- }
-
- for (k=0; k<4; k++)
- {
- v3[k].x += x;
- v3[k].y += y;
- }
-
- {
- float aspect = GetWidth() / (float)(GetHeight());
-
- if (aspect > 1)
- for (k=0; k<4; k++) v3[k].y *= aspect;
- else
- for (k=0; k<4; k++) v3[k].x /= aspect;
- }
-
- if (bKillSprite && bBurnIn)
- {
- float aspect = GetWidth()/(float)(GetHeight()*4.0f/3.0f);
- if (aspect < 1.0f)
- for (k=0; k<4; k++) v3[k].x *= aspect;
- else
- for (k=0; k<4; k++) v3[k].y /= aspect;
- }
-
-
-
- {
- float dtu = 0.5f;
- float dtv = 0.5f;
- v3[0].tu = -dtu;
- v3[1].tu = dtu;
- v3[2].tu = -dtu;
- v3[3].tu = dtu;
- v3[0].tv = -dtv;
- v3[1].tv = -dtv;
- v3[2].tv = dtv;
- v3[3].tv = dtv;
-
- for (k=0; k<4; k++)
- {
- v3[k].tu = (v3[k].tu - 0.0f)*repeatx + 0.5f;
- v3[k].tv = (v3[k].tv - 0.0f)*repeaty + 0.5f;
- }
- }
-
-
-
-
-
-
- switch(blendmode)
- {
- case 0:
- default:
-
-
- lpDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
- lpDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
- for (k=0; k<4; k++) v3[k].Diffuse = D3DCOLOR_RGBA_01(r,g,b,a);
- break;
- case 1:
-
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
-
-
- for (k=0; k<4; k++) v3[k].Diffuse = D3DCOLOR_RGBA_01(r*a,g*a,b*a,1);
- break;
- case 2:
-
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
- for (k=0; k<4; k++) v3[k].Diffuse = D3DCOLOR_RGBA_01(r*a,g*a,b*a,1);
- break;
- case 3:
-
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCCOLOR);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR);
- for (k=0; k<4; k++) v3[k].Diffuse = D3DCOLOR_RGBA_01(1,1,1,1);
- break;
- case 4:
-
-
-
- lpDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
- lpDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
- lpDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
- lpDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
- lpDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
- lpDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
- lpDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
- lpDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
-
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
- for (k=0; k<4; k++) v3[k].Diffuse = D3DCOLOR_RGBA_01(r,g,b,a);
- break;
- }
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (LPVOID)v3, sizeof(SPRITEVERTEX));
- if ( bBurnIn)
- {
-
- lpDevice->SetTexture(0, NULL);
- lpDevice->SetRenderTarget( 0, pBackBuffer );
-
- lpDevice->SetTexture(0, m_texmgr.m_tex[iSlot].pSurface);
-
- {
- float aspect = GetWidth()/(float)(GetHeight()*4.0f/3.0f);
- if (aspect < 1.0f)
- for (k=0; k<4; k++) v3[k].x /= aspect;
- else
- for (k=0; k<4; k++) v3[k].y *= aspect;
- }
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (LPVOID)v3, sizeof(SPRITEVERTEX));
- }
- SafeRelease(pBackBuffer);
-
- if (bKillSprite)
- {
- KillSprite(iSlot);
- }
- lpDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
- lpDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE );
- lpDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
- }
- }
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
-
- lpDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
- lpDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
- lpDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
- lpDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
- lpDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
- lpDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE );
- lpDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
- }
- void CPlugin::UvToMathSpace(float u, float v, float* rad, float* ang)
- {
-
-
-
-
-
-
-
- float px = (u*2-1) * m_fAspectX;
- float py = (v*2-1) * m_fAspectY;
-
- *rad = sqrtf(px*px + py*py) / sqrtf(m_fAspectX*m_fAspectX + m_fAspectY*m_fAspectY);
- *ang = atan2f(py, px);
- if (*ang < 0)
- *ang += 6.2831853071796f;
- }
- void CPlugin::RestoreShaderParams()
- {
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
- int i = 0;
- for (i=0; i<2; i++)
- {
- lpDevice->SetSamplerState(i, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
- lpDevice->SetSamplerState(i, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
- lpDevice->SetSamplerState(i, D3DSAMP_ADDRESSW, D3DTADDRESS_WRAP);
- lpDevice->SetSamplerState(i, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
- lpDevice->SetSamplerState(i, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
- lpDevice->SetSamplerState(i, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
- }
- for (i=0; i<4; i++)
- lpDevice->SetTexture( i, NULL );
- lpDevice->SetVertexShader(NULL);
-
- lpDevice->SetPixelShader(NULL);
- }
- void CPlugin::ApplyShaderParams(CShaderParams* p, LPD3DXCONSTANTTABLE pCT, CState* pState)
- {
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
-
-
-
- int i = 0;
- for (i=0; i<sizeof(p->m_texture_bindings)/sizeof(p->m_texture_bindings[0]); i++)
- {
- if (p->m_texcode[i] == TEX_VS)
- lpDevice->SetTexture(i, m_lpVS[0]);
- else
- lpDevice->SetTexture(i, p->m_texture_bindings[i].texptr);
-
- if (p->m_texcode[i]==TEX_VS || p->m_texture_bindings[i].texptr)
- {
- bool bAniso = false;
- DWORD HQFilter = bAniso ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR;
- DWORD wrap = p->m_texture_bindings[i].bWrap ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP;
- DWORD filter = p->m_texture_bindings[i].bBilinear ? HQFilter : D3DTEXF_POINT;
- lpDevice->SetSamplerState(i, D3DSAMP_ADDRESSU, wrap);
- lpDevice->SetSamplerState(i, D3DSAMP_ADDRESSV, wrap);
- lpDevice->SetSamplerState(i, D3DSAMP_ADDRESSW, wrap);
- lpDevice->SetSamplerState(i, D3DSAMP_MAGFILTER, filter);
- lpDevice->SetSamplerState(i, D3DSAMP_MINFILTER, filter);
- lpDevice->SetSamplerState(i, D3DSAMP_MIPFILTER, filter);
-
- }
-
- if (p->m_texcode[i] >= TEX_BLUR1 && p->m_texcode[i] <= TEX_BLUR_LAST)
- m_nHighestBlurTexUsedThisFrame = max(m_nHighestBlurTexUsedThisFrame, ((int)p->m_texcode[i] - (int)TEX_BLUR1) + 1);
- }
-
- int N = p->texsize_params.size();
- for (i=0; i<N; i++)
- {
- TexSizeParamInfo* q = &(p->texsize_params[i]);
- pCT->SetVector( lpDevice, q->texsize_param, &D3DXVECTOR4((float)q->w,(float)q->h,1.0f/q->w,1.0f/q->h));
- }
- float time_since_preset_start = GetTime() - pState->GetPresetStartTime();
- float time_since_preset_start_wrapped = time_since_preset_start - (int)(time_since_preset_start/10000)*10000;
- float time = GetTime() - m_fStartTime;
- float progress = (GetTime() - m_fPresetStartTime) / (m_fNextPresetTime - m_fPresetStartTime);
- float mip_x = logf((float)GetWidth())/logf(2.0f);
- float mip_y = logf((float)GetWidth())/logf(2.0f);
- float mip_avg = 0.5f*(mip_x + mip_y);
- float aspect_x = 1;
- float aspect_y = 1;
- if (GetWidth() > GetHeight())
- aspect_y = GetHeight()/(float)GetWidth();
- else
- aspect_x = GetWidth()/(float)GetHeight();
-
- float blur_min[3], blur_max[3];
- GetSafeBlurMinMax(pState, blur_min, blur_max);
-
- if (p->rand_frame ) pCT->SetVector( lpDevice, p->rand_frame , &m_rand_frame );
- if (p->rand_preset) pCT->SetVector( lpDevice, p->rand_preset, &pState->m_rand_preset );
- D3DXHANDLE* h = p->const_handles;
- if (h[0]) pCT->SetVector( lpDevice, h[0], &D3DXVECTOR4( aspect_x, aspect_y, 1.0f/aspect_x, 1.0f/aspect_y ));
- if (h[1]) pCT->SetVector( lpDevice, h[1], &D3DXVECTOR4(0, 0, 0, 0 ));
- if (h[2]) pCT->SetVector( lpDevice, h[2], &D3DXVECTOR4(time_since_preset_start_wrapped, GetFps(), (float)GetFrame(), progress));
- if (h[3]) pCT->SetVector( lpDevice, h[3], &D3DXVECTOR4(mysound.imm_rel[0], mysound.imm_rel[1], mysound.imm_rel[2], 0.3333f*(mysound.imm_rel[0], mysound.imm_rel[1], mysound.imm_rel[2]) ));
- if (h[4]) pCT->SetVector( lpDevice, h[4], &D3DXVECTOR4(mysound.avg_rel[0], mysound.avg_rel[1], mysound.avg_rel[2], 0.3333f*(mysound.avg_rel[0], mysound.avg_rel[1], mysound.avg_rel[2]) ));
- if (h[5]) pCT->SetVector( lpDevice, h[5], &D3DXVECTOR4( blur_max[0]-blur_min[0], blur_min[0], blur_max[1]-blur_min[1], blur_min[1] ));
- if (h[6]) pCT->SetVector( lpDevice, h[6], &D3DXVECTOR4( blur_max[2]-blur_min[2], blur_min[2], blur_min[0], blur_max[0] ));
- if (h[7]) pCT->SetVector( lpDevice, h[7], &D3DXVECTOR4((float)m_nTexSizeX, (float)m_nTexSizeY, 1.0f/(float)m_nTexSizeX, 1.0f/(float)m_nTexSizeY ));
- if (h[8]) pCT->SetVector( lpDevice, h[8], &D3DXVECTOR4( 0.5f+0.5f*cosf(time* 0.329f+1.2f),
- 0.5f+0.5f*cosf(time* 1.293f+3.9f),
- 0.5f+0.5f*cosf(time* 5.070f+2.5f),
- 0.5f+0.5f*cosf(time*20.051f+5.4f)
- ));
- if (h[9]) pCT->SetVector( lpDevice, h[9], &D3DXVECTOR4( 0.5f+0.5f*sinf(time* 0.329f+1.2f),
- 0.5f+0.5f*sinf(time* 1.293f+3.9f),
- 0.5f+0.5f*sinf(time* 5.070f+2.5f),
- 0.5f+0.5f*sinf(time*20.051f+5.4f)
- ));
- if (h[10]) pCT->SetVector( lpDevice, h[10], &D3DXVECTOR4( 0.5f+0.5f*cosf(time*0.0050f+2.7f),
- 0.5f+0.5f*cosf(time*0.0085f+5.3f),
- 0.5f+0.5f*cosf(time*0.0133f+4.5f),
- 0.5f+0.5f*cosf(time*0.0217f+3.8f)
- ));
- if (h[11]) pCT->SetVector( lpDevice, h[11], &D3DXVECTOR4( 0.5f+0.5f*sinf(time*0.0050f+2.7f),
- 0.5f+0.5f*sinf(time*0.0085f+5.3f),
- 0.5f+0.5f*sinf(time*0.0133f+4.5f),
- 0.5f+0.5f*sinf(time*0.0217f+3.8f)
- ));
- if (h[12]) pCT->SetVector( lpDevice, h[12], &D3DXVECTOR4( mip_x, mip_y, mip_avg, 0 ));
- if (h[13]) pCT->SetVector( lpDevice, h[13], &D3DXVECTOR4( blur_min[1], blur_max[1], blur_min[2], blur_max[2] ));
-
- int num_q_float4s = sizeof(p->q_const_handles)/sizeof(p->q_const_handles[0]);
- for (i=0; i<num_q_float4s; i++)
- {
- if (p->q_const_handles[i])
- pCT->SetVector( lpDevice, p->q_const_handles[i], &D3DXVECTOR4(
- (float)*pState->var_pf_q[i*4+0],
- (float)*pState->var_pf_q[i*4+1],
- (float)*pState->var_pf_q[i*4+2],
- (float)*pState->var_pf_q[i*4+3] ));
- }
-
- for (i=0; i<20; i++)
- {
- if (p->rot_mat[i])
- {
- D3DXMATRIX mx,my,mz,mxlate,temp;
- pMatrixRotationX(&mx, pState->m_rot_base[i].x + pState->m_rot_speed[i].x*time);
- pMatrixRotationY(&my, pState->m_rot_base[i].y + pState->m_rot_speed[i].y*time);
- pMatrixRotationZ(&mz, pState->m_rot_base[i].z + pState->m_rot_speed[i].z*time);
- pMatrixTranslation(&mxlate, pState->m_xlate[i].x, pState->m_xlate[i].y, pState->m_xlate[i].z);
- pMatrixMultiply(&temp, &mx, &mxlate);
- pMatrixMultiply(&temp, &temp, &mz);
- pMatrixMultiply(&temp, &temp, &my);
- pCT->SetMatrix(lpDevice, p->rot_mat[i], &temp);
- }
- }
-
- for (i=20; i<24; i++)
- {
- if (p->rot_mat[i])
- {
- D3DXMATRIX mx,my,mz,mxlate,temp;
- pMatrixRotationX(&mx, FRAND * 6.28f);
- pMatrixRotationY(&my, FRAND * 6.28f);
- pMatrixRotationZ(&mz, FRAND * 6.28f);
- pMatrixTranslation(&mxlate, FRAND, FRAND, FRAND);
- pMatrixMultiply(&temp, &mx, &mxlate);
- pMatrixMultiply(&temp, &temp, &mz);
- pMatrixMultiply(&temp, &temp, &my);
- pCT->SetMatrix(lpDevice, p->rot_mat[i], &temp);
- }
- }
- }
- void CPlugin::ShowToUser_NoShaders()
- {
-
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
- if (!lpDevice)
- return;
- lpDevice->SetTexture(0, m_lpVS[1]);
- lpDevice->SetVertexShader( NULL );
- lpDevice->SetPixelShader( NULL );
- lpDevice->SetFVF( SPRITEVERTEX_FORMAT );
-
- lpDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
- lpDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
- lpDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
- lpDevice->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
- lpDevice->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
- lpDevice->SetSamplerState(1, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
-
-
-
- lpDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
- lpDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
- lpDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
- lpDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
- lpDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
- lpDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE );
- lpDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
- float fZoom = 1.0f;
- SPRITEVERTEX v3[4];
- ZeroMemory(v3, sizeof(SPRITEVERTEX)*4);
-
-
-
- float fOnePlusInvWidth = 1.0f + 1.0f/(float)GetWidth();
- float fOnePlusInvHeight = 1.0f + 1.0f/(float)GetHeight();
- v3[0].x = -fOnePlusInvWidth;
- v3[1].x = fOnePlusInvWidth;
- v3[2].x = -fOnePlusInvWidth;
- v3[3].x = fOnePlusInvWidth;
- v3[0].y = fOnePlusInvHeight;
- v3[1].y = fOnePlusInvHeight;
- v3[2].y = -fOnePlusInvHeight;
- v3[3].y = -fOnePlusInvHeight;
-
- float aspect = GetWidth() / (float)(GetHeight()*m_fInvAspectY);
- float x_aspect_mult = 1.0f;
- float y_aspect_mult = 1.0f;
- if (aspect>1)
- y_aspect_mult = aspect;
- else
- x_aspect_mult = 1.0f/aspect;
- for (int n=0; n<4; n++)
- {
- v3[n].x *= x_aspect_mult;
- v3[n].y *= y_aspect_mult;
- }
-
- {
- float shade[4][3] = {
- { 1.0f, 1.0f, 1.0f },
- { 1.0f, 1.0f, 1.0f },
- { 1.0f, 1.0f, 1.0f },
- { 1.0f, 1.0f, 1.0f } };
- float fShaderAmount = m_pState->m_fShader.eval(GetTime());
- if (fShaderAmount > 0.001f)
- {
- for (int i=0; i<4; i++)
- {
- shade[i][0] = 0.6f + 0.3f*sinf(GetTime()*30.0f*0.0143f + 3 + i*21 + m_fRandStart[3]);
- shade[i][1] = 0.6f + 0.3f*sinf(GetTime()*30.0f*0.0107f + 1 + i*13 + m_fRandStart[1]);
- shade[i][2] = 0.6f + 0.3f*sinf(GetTime()*30.0f*0.0129f + 6 + i*9 + m_fRandStart[2]);
- float max = ((shade[i][0] > shade[i][1]) ? shade[i][0] : shade[i][1]);
- if (shade[i][2] > max) max = shade[i][2];
- for (int k=0; k<3; k++)
- {
- shade[i][k] /= max;
- shade[i][k] = 0.5f + 0.5f*shade[i][k];
- }
- for (int k=0; k<3; k++)
- {
- shade[i][k] = shade[i][k]*(fShaderAmount) + 1.0f*(1.0f - fShaderAmount);
- }
- v3[i].Diffuse = D3DCOLOR_RGBA_01(shade[i][0],shade[i][1],shade[i][2],1);
- }
- }
- float fVideoEchoZoom = (float)(*m_pState->var_pf_echo_zoom);
- float fVideoEchoAlpha = (float)(*m_pState->var_pf_echo_alpha);
- int nVideoEchoOrientation = (int) (*m_pState->var_pf_echo_orient) % 4;
- float fGammaAdj = (float)(*m_pState->var_pf_gamma);
- if (m_pState->m_bBlending &&
- m_pState->m_fVideoEchoAlpha.eval(GetTime()) > 0.01f &&
- m_pState->m_fVideoEchoAlphaOld > 0.01f &&
- m_pState->m_nVideoEchoOrientation != m_pState->m_nVideoEchoOrientationOld)
- {
- if (m_pState->m_fBlendProgress < m_fSnapPoint)
- {
- nVideoEchoOrientation = m_pState->m_nVideoEchoOrientationOld;
- fVideoEchoAlpha *= 1.0f - 2.0f*CosineInterp(m_pState->m_fBlendProgress);
- }
- else
- {
- fVideoEchoAlpha *= 2.0f*CosineInterp(m_pState->m_fBlendProgress) - 1.0f;
- }
- }
- if (fVideoEchoAlpha > 0.001f)
- {
-
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
- for (int i=0; i<2; i++)
- {
- fZoom = (i==0) ? 1.0f : fVideoEchoZoom;
- float temp_lo = 0.5f - 0.5f/fZoom;
- float temp_hi = 0.5f + 0.5f/fZoom;
- v3[0].tu = temp_lo;
- v3[0].tv = temp_hi;
- v3[1].tu = temp_hi;
- v3[1].tv = temp_hi;
- v3[2].tu = temp_lo;
- v3[2].tv = temp_lo;
- v3[3].tu = temp_hi;
- v3[3].tv = temp_lo;
-
- if (i==1)
- {
- for (int j=0; j<4; j++)
- {
- if (nVideoEchoOrientation % 2)
- v3[j].tu = 1.0f - v3[j].tu;
- if (nVideoEchoOrientation >= 2)
- v3[j].tv = 1.0f - v3[j].tv;
- }
- }
- float mix = (i==1) ? fVideoEchoAlpha : 1.0f - fVideoEchoAlpha;
- for (int k=0; k<4; k++)
- v3[k].Diffuse = D3DCOLOR_RGBA_01(mix*shade[k][0],mix*shade[k][1],mix*shade[k][2],1);
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
- if (i==0)
- {
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
- }
- if (fGammaAdj > 0.001f)
- {
-
- int nRedraws = (int)(fGammaAdj - 0.0001f);
- float gamma;
- for (int nRedraw=0; nRedraw < nRedraws; nRedraw++)
- {
- if (nRedraw == nRedraws-1)
- gamma = fGammaAdj - (int)(fGammaAdj - 0.0001f);
- else
- gamma = 1.0f;
- for (int k=0; k<4; k++)
- v3[k].Diffuse = D3DCOLOR_RGBA_01(gamma*mix*shade[k][0],gamma*mix*shade[k][1],gamma*mix*shade[k][2],1);
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
- }
- }
- }
- }
- else
- {
-
- v3[0].tu = 0; v3[1].tu = 1; v3[2].tu = 0; v3[3].tu = 1;
- v3[0].tv = 1; v3[1].tv = 1; v3[2].tv = 0; v3[3].tv = 0;
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
-
- int nPasses = (int)(fGammaAdj - 0.001f) + 1;
- float gamma;
- for (int nPass=0; nPass < nPasses; nPass++)
- {
- if (nPass == nPasses - 1)
- gamma = fGammaAdj - (float)nPass;
- else
- gamma = 1.0f;
- for (int k=0; k<4; k++)
- v3[k].Diffuse = D3DCOLOR_RGBA_01(gamma*shade[k][0],gamma*shade[k][1],gamma*shade[k][2],1);
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
- if (nPass==0)
- {
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
- }
- }
- }
- SPRITEVERTEX v3[4];
- ZeroMemory(v3, sizeof(SPRITEVERTEX)*4);
- float fOnePlusInvWidth = 1.0f + 1.0f/(float)GetWidth();
- float fOnePlusInvHeight = 1.0f + 1.0f/(float)GetHeight();
- v3[0].x = -fOnePlusInvWidth;
- v3[1].x = fOnePlusInvWidth;
- v3[2].x = -fOnePlusInvWidth;
- v3[3].x = fOnePlusInvWidth;
- v3[0].y = fOnePlusInvHeight;
- v3[1].y = fOnePlusInvHeight;
- v3[2].y = -fOnePlusInvHeight;
- v3[3].y = -fOnePlusInvHeight;
- for (int i=0; i<4; i++) v3[i].Diffuse = D3DCOLOR_RGBA_01(1,1,1,1);
- if (*m_pState->var_pf_brighten &&
- (GetCaps()->SrcBlendCaps & D3DPBLENDCAPS_INVDESTCOLOR ) &&
- (GetCaps()->DestBlendCaps & D3DPBLENDCAPS_DESTCOLOR)
- )
- {
-
-
-
- lpDevice->SetTexture(0, NULL);
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
-
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_INVDESTCOLOR);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
-
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_DESTCOLOR);
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
-
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_INVDESTCOLOR);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
- }
- if (*m_pState->var_pf_darken &&
- (GetCaps()->DestBlendCaps & D3DPBLENDCAPS_DESTCOLOR)
- )
- {
-
-
-
- lpDevice->SetTexture(0, NULL);
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_DESTCOLOR);
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
-
-
-
- }
-
- if (*m_pState->var_pf_solarize &&
- (GetCaps()->SrcBlendCaps & D3DPBLENDCAPS_DESTCOLOR ) &&
- (GetCaps()->DestBlendCaps & D3DPBLENDCAPS_INVDESTCOLOR)
- )
- {
-
-
- lpDevice->SetTexture(0, NULL);
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVDESTCOLOR);
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_DESTCOLOR);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
- }
- if (*m_pState->var_pf_invert &&
- (GetCaps()->SrcBlendCaps & D3DPBLENDCAPS_INVDESTCOLOR )
- )
- {
-
-
- lpDevice->SetTexture(0, NULL);
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_INVDESTCOLOR);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
-
- lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, (void*)v3, sizeof(SPRITEVERTEX));
- }
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- }
- }
- void CPlugin::ShowToUser_Shaders(int nPass, bool bAlphaBlend, bool bFlipAlpha, bool bCullTiles, bool bFlipCulling)
- {
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
- if (!lpDevice)
- return;
-
- lpDevice->SetVertexShader( NULL );
- lpDevice->SetFVF( MYVERTEX_FORMAT );
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- float fZoom = 1.0f;
- float aspect = GetWidth() / (float)(GetHeight()*m_fInvAspectY);
- float x_aspect_mult = 1.0f;
- float y_aspect_mult = 1.0f;
- if (aspect>1)
- y_aspect_mult = aspect;
- else
- x_aspect_mult = 1.0f/aspect;
-
- float shade[4][3] = {
- { 1.0f, 1.0f, 1.0f },
- { 1.0f, 1.0f, 1.0f },
- { 1.0f, 1.0f, 1.0f },
- { 1.0f, 1.0f, 1.0f } };
- float fShaderAmount = 1;
- if (fShaderAmount > 0.001f || m_pState->m_bBlending)
- {
-
- for (int i=0; i<4; i++)
- {
- shade[i][0] = 0.6f + 0.3f*sinf(GetTime()*30.0f*0.0143f + 3 + i*21 + m_fRandStart[3]);
- shade[i][1] = 0.6f + 0.3f*sinf(GetTime()*30.0f*0.0107f + 1 + i*13 + m_fRandStart[1]);
- shade[i][2] = 0.6f + 0.3f*sinf(GetTime()*30.0f*0.0129f + 6 + i*9 + m_fRandStart[2]);
- float max = ((shade[i][0] > shade[i][1]) ? shade[i][0] : shade[i][1]);
- if (shade[i][2] > max) max = shade[i][2];
- for (int k=0; k<3; k++)
- {
- shade[i][k] /= max;
- shade[i][k] = 0.5f + 0.5f*shade[i][k];
- }
-
-
-
-
- }
-
- for (int j=0; j<FCGSY; j++)
- {
- for (int i=0; i<FCGSX; i++)
- {
- MYVERTEX* p = &m_comp_verts[i + j*FCGSX];
- float x = p->x*0.5f + 0.5f;
- float y = p->y*0.5f + 0.5f;
- float col[3] = { 1, 1, 1 };
- if (fShaderAmount > 0.001f)
- {
- for (int c=0; c<3; c++)
- col[c] = shade[0][c]*( x)*( y) +
- shade[1][c]*(1-x)*( y) +
- shade[2][c]*( x)*(1-y) +
- shade[3][c]*(1-x)*(1-y);
- }
-
-
-
- double alpha = 1;
- if (m_pState->m_bBlending)
- {
- x *= (m_nGridX + 1);
- y *= (m_nGridY + 1);
- x = max(min(x,m_nGridX-1),0);
- y = max(min(y,m_nGridY-1),0);
- int nx = (int)x;
- int ny = (int)y;
- double dx = x - nx;
- double dy = y - ny;
- double alpha00 = (m_verts[(ny )*(m_nGridX+1) + (nx )].Diffuse >> 24);
- double alpha01 = (m_verts[(ny )*(m_nGridX+1) + (nx+1)].Diffuse >> 24);
- double alpha10 = (m_verts[(ny+1)*(m_nGridX+1) + (nx )].Diffuse >> 24);
- double alpha11 = (m_verts[(ny+1)*(m_nGridX+1) + (nx+1)].Diffuse >> 24);
- alpha = alpha00*(1-dx)*(1-dy) +
- alpha01*( dx)*(1-dy) +
- alpha10*(1-dx)*( dy) +
- alpha11*( dx)*( dy);
- alpha /= 255.0f;
-
-
-
- }
- p->Diffuse = D3DCOLOR_RGBA_01(col[0],col[1],col[2],alpha);
- }
- }
- }
- int nAlphaTestValue = 0;
- if (bFlipCulling)
- nAlphaTestValue = 1-nAlphaTestValue;
- if (bAlphaBlend)
- {
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- if (bFlipAlpha)
- {
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_INVSRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCALPHA);
- }
- else
- {
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
- }
- }
- else
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
-
-
- int pass = nPass;
- {
-
-
- PShaderInfo* si = (pass==0) ? &m_OldShaders.comp : &m_shaders.comp;
- CState* state = (pass==0) ? m_pOldState : m_pState;
- lpDevice->SetVertexDeclaration(m_pMyVertDecl);
- lpDevice->SetVertexShader(m_fallbackShaders_vs.comp.ptr);
- lpDevice->SetPixelShader (si->ptr);
-
- ApplyShaderParams( &(si->params), si->CT, state );
-
-
-
-
-
- MYVERTEX tempv[1024 * 3];
- int primCount = (FCGSX-2)*(FCGSY-2)*2;
- int max_prims_per_batch = min( GetCaps()->MaxPrimitiveCount, (sizeof(tempv)/sizeof(tempv[0]))/3) - 4;
- int src_idx = 0;
- while (src_idx < primCount*3)
- {
- int prims_queued = 0;
- int i=0;
- while (prims_queued < max_prims_per_batch && src_idx < primCount*3)
- {
-
- for (int j=0; j<3; j++)
- tempv[i++] = m_comp_verts[ m_comp_indices[src_idx++] ];
- if (bCullTiles)
- {
- DWORD d1 = (tempv[i-3].Diffuse >> 24);
- DWORD d2 = (tempv[i-2].Diffuse >> 24);
- DWORD d3 = (tempv[i-1].Diffuse >> 24);
- bool bIsNeeded;
- if (nAlphaTestValue)
- bIsNeeded = ((d1 & d2 & d3) < 255);
- else
- bIsNeeded = ((d1|d2|d3) > 0);
- if (!bIsNeeded)
- i -= 3;
- else
- prims_queued++;
- }
- else
- prims_queued++;
- }
- if (prims_queued > 0)
- lpDevice->DrawPrimitiveUP( D3DPT_TRIANGLELIST, prims_queued, tempv, sizeof(MYVERTEX) );
- }
- }
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- RestoreShaderParams();
- }
- void CPlugin::ShowSongTitleAnim(int w, int h, float fProgress)
- {
- int i,x,y;
- if (!m_lpDDSTitle)
- return;
- LPDIRECT3DDEVICE9 lpDevice = GetDevice();
- if (!lpDevice)
- return;
- lpDevice->SetTexture(0, m_lpDDSTitle);
- lpDevice->SetVertexShader( NULL );
- lpDevice->SetFVF( SPRITEVERTEX_FORMAT );
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
- SPRITEVERTEX v3[128];
- ZeroMemory(v3, sizeof(SPRITEVERTEX)*128);
- if (m_supertext.bIsSongTitle)
- {
-
- float fSizeX = 50.0f / (float)m_supertext.nFontSizeUsed * powf(1.5f, m_supertext.fFontSize - 2.0f);
- float fSizeY = fSizeX * m_nTitleTexSizeY/(float)m_nTitleTexSizeX;
- if (fSizeX > 0.88f)
- {
- fSizeY *= 0.88f/fSizeX;
- fSizeX = 0.88f;
- }
-
- if (fProgress < 1.0f)
- {
-
-
- }
- else
- {
-
-
-
-
-
-
-
-
- }
-
-
- i = 0;
- float vert_clip = VERT_CLIP;
- for (y=0; y<8; y++)
- {
- for (x=0; x<16; x++)
- {
- v3[i].tu = x/15.0f;
- v3[i].tv = (y/7.0f - 0.5f)*vert_clip + 0.5f;
- v3[i].x = (v3[i].tu*2.0f - 1.0f)*fSizeX;
- v3[i].y = (v3[i].tv*2.0f - 1.0f)*fSizeY;
- if (fProgress >= 1.0f)
- v3[i].y += 1.0f/(float)m_nTexSizeY;
- i++;
- }
- }
-
- float ramped_progress = max(0.0f, 1-fProgress*1.5f);
- float t2 = powf(ramped_progress, 1.8f)*1.3f;
- for (y=0; y<8; y++)
- {
- for (x=0; x<16; x++)
- {
- i = y*16+x;
- v3[i].x += t2*0.070f*sinf(GetTime()*0.31f + v3[i].x*0.39f - v3[i].y*1.94f);
- v3[i].x += t2*0.044f*sinf(GetTime()*0.81f - v3[i].x*1.91f + v3[i].y*0.27f);
- v3[i].x += t2*0.061f*sinf(GetTime()*1.31f + v3[i].x*0.61f + v3[i].y*0.74f);
- v3[i].y += t2*0.061f*sinf(GetTime()*0.37f + v3[i].x*1.83f + v3[i].y*0.69f);
- v3[i].y += t2*0.070f*sinf(GetTime()*0.67f + v3[i].x*0.42f - v3[i].y*1.39f);
- v3[i].y += t2*0.087f*sinf(GetTime()*1.07f + v3[i].x*3.55f + v3[i].y*0.89f);
- }
- }
-
- float scale = 1.01f/(powf(fProgress, 0.21f) + 0.01f);
- for (i=0; i<128; i++)
- {
- v3[i].x *= scale;
- v3[i].y *= scale;
- }
- }
- else
- {
-
- float fSizeX = (float)m_nTexSizeX/1024.0f * 100.0f / (float)m_supertext.nFontSizeUsed * powf(1.033f, m_supertext.fFontSize - 50.0f);
- float fSizeY = fSizeX * m_nTitleTexSizeY/(float)m_nTitleTexSizeX;
-
- if (fProgress < 1.0f)
- {
-
-
- }
- else
- {
-
-
-
-
-
-
-
- }
-
- i = 0;
- float vert_clip = VERT_CLIP;
- for (y=0; y<8; y++)
- {
- for (x=0; x<16; x++)
- {
- v3[i].tu = x/15.0f;
- v3[i].tv = (y/7.0f - 0.5f)*vert_clip + 0.5f;
- v3[i].x = (v3[i].tu*2.0f - 1.0f)*fSizeX;
- v3[i].y = (v3[i].tv*2.0f - 1.0f)*fSizeY;
- if (fProgress >= 1.0f)
- v3[i].y += 1.0f/(float)m_nTexSizeY;
- i++;
- }
- }
-
-
- {
- float t = (1.0f)*(1-fProgress) + (fProgress)*(m_supertext.fGrowth);
- float dx = (m_supertext.fX*2-1);
- float dy = (m_supertext.fY*2-1);
- if (w!=h)
- {
- float aspect = w/(float)(h*4.0f/3.0f);
- if (aspect < 1)
- dx /= aspect;
- else
- dy *= aspect;
- }
- for (i=0; i<128; i++)
- {
-
- v3[i].x = (v3[i].x)*t + dx;
- v3[i].y = (v3[i].y)*t + dy;
- }
- }
- }
- WORD indices[7*15*6];
- i = 0;
- for (y=0; y<7; y++)
- {
- for (x=0; x<15; x++)
- {
- indices[i++] = y*16 + x;
- indices[i++] = y*16 + x + 1;
- indices[i++] = y*16 + x + 16;
- indices[i++] = y*16 + x + 1;
- indices[i++] = y*16 + x + 16;
- indices[i++] = y*16 + x + 17;
- }
- }
-
-
-
- for (i=0; i<128; i++)
-
- v3[i].y *= m_fInvAspectY;
- for (int it=0; it<2; it++)
- {
-
- {
- float t;
-
- if (m_supertext.bIsSongTitle)
- t = powf(fProgress, 0.3f)*1.0f;
- else
- t = CosineInterp(min(1.0f, (fProgress/m_supertext.fFadeTime)));
-
- if (it==0)
- v3[0].Diffuse = D3DCOLOR_RGBA_01(t,t,t,t);
- else
- v3[0].Diffuse = D3DCOLOR_RGBA_01(t*m_supertext.nColorR/255.0f,t*m_supertext.nColorG/255.0f,t*m_supertext.nColorB/255.0f,t);
- for (i=1; i<128; i++)
- v3[i].Diffuse = v3[0].Diffuse;
- }
-
- float offset_x = 0, offset_y = 0;
- switch(it)
- {
- case 0:
- offset_x = 2.0f/(float)m_nTitleTexSizeX;
- offset_y = 2.0f/(float)m_nTitleTexSizeY;
- break;
- case 1:
- offset_x = -4.0f/(float)m_nTitleTexSizeX;
- offset_y = -4.0f/(float)m_nTitleTexSizeY;
- break;
- }
- for (i=0; i<128; i++)
- {
- v3[i].x += offset_x;
- v3[i].y += offset_y;
- }
-
- if (it == 0)
- {
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR);
- }
- else
- {
- lpDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
- lpDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
- }
-
- lpDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 128, 15*7*6/3, indices, D3DFMT_INDEX16, v3, sizeof(SPRITEVERTEX));
- }
- lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
- }
|