123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364 |
- {
- "__type__": "cc.EffectAsset",
- "_name": "builtin-toon",
- "_objFlags": 0,
- "__editorExtras__": {},
- "_native": "",
- "techniques": [
- {
- "passes": [
- {
- "rasterizerState": {
- "cullMode": 1
- },
- "program": "builtin-toon|silhouette-edge-vs|silhouette-edge-fs",
- "depthStencilState": {
- "depthFunc": 3,
- "depthTest": true,
- "depthWrite": true
- },
- "switch": "USE_OUTLINE_PASS",
- "properties": {
- "lineWidth": {
- "value": [
- 10
- ],
- "type": 13,
- "handleInfo": [
- "outlineParams",
- 0,
- 13
- ]
- },
- "depthBias": {
- "value": [
- 0
- ],
- "type": 13,
- "handleInfo": [
- "outlineParams",
- 1,
- 13
- ]
- },
- "baseColor": {
- "editor": {
- "type": "color"
- },
- "type": 16
- },
- "baseColorMap": {
- "value": "grey",
- "type": 28
- },
- "outlineParams": {
- "type": 16,
- "editor": {
- "visible": false,
- "deprecated": true
- },
- "value": [
- 10,
- 0,
- 0,
- 0
- ]
- }
- }
- },
- {
- "program": "builtin-toon|toon-vs|toon-fs",
- "properties": {
- "tilingOffset": {
- "value": [
- 1,
- 1,
- 0,
- 0
- ],
- "type": 16
- },
- "mainColor": {
- "value": [
- 0.6,
- 0.6,
- 0.6,
- 1
- ],
- "linear": true,
- "editor": {
- "displayName": "BaseColor",
- "type": "color"
- },
- "type": 16,
- "handleInfo": [
- "baseColor",
- 0,
- 16
- ]
- },
- "colorScale": {
- "value": [
- 1,
- 1,
- 1
- ],
- "type": 15,
- "handleInfo": [
- "colorScaleAndCutoff",
- 0,
- 15
- ]
- },
- "alphaThreshold": {
- "value": [
- 0.5
- ],
- "editor": {
- "parent": "USE_ALPHA_TEST"
- },
- "type": 13,
- "handleInfo": [
- "colorScaleAndCutoff",
- 3,
- 13
- ]
- },
- "shadeColor1": {
- "value": [
- 0.4,
- 0.4,
- 0.4,
- 1
- ],
- "linear": true,
- "editor": {
- "type": "color"
- },
- "type": 16
- },
- "shadeColor2": {
- "value": [
- 0.2,
- 0.2,
- 0.2,
- 1
- ],
- "linear": true,
- "editor": {
- "type": "color"
- },
- "type": 16
- },
- "specular": {
- "value": [
- 1,
- 1,
- 1,
- 0.3
- ],
- "linear": true,
- "editor": {
- "type": "color"
- },
- "type": 16
- },
- "baseStep": {
- "value": [
- 0.8
- ],
- "type": 13,
- "handleInfo": [
- "shadeParams",
- 0,
- 13
- ]
- },
- "baseFeather": {
- "value": [
- 0.001
- ],
- "type": 13,
- "handleInfo": [
- "shadeParams",
- 1,
- 13
- ]
- },
- "shadeStep": {
- "value": [
- 0.5
- ],
- "type": 13,
- "handleInfo": [
- "shadeParams",
- 2,
- 13
- ]
- },
- "shadeFeather": {
- "value": [
- 0.001
- ],
- "type": 13,
- "handleInfo": [
- "shadeParams",
- 3,
- 13
- ]
- },
- "shadowCover": {
- "value": [
- 0.5
- ],
- "editor": {
- "slide": true,
- "range": [
- 0,
- 1
- ],
- "step": 0.001
- },
- "type": 13,
- "handleInfo": [
- "miscParams",
- 0,
- 13
- ]
- },
- "emissive": {
- "value": [
- 0,
- 0,
- 0,
- 1
- ],
- "linear": true,
- "editor": {
- "type": "color"
- },
- "type": 16
- },
- "emissiveScale": {
- "value": [
- 1,
- 1,
- 1
- ],
- "type": 15,
- "handleInfo": [
- "emissiveScaleAndStrenth",
- 0,
- 15
- ]
- },
- "normalStrength": {
- "value": [
- 1
- ],
- "editor": {
- "parent": "USE_NORMAL_MAP"
- },
- "slide": true,
- "range": [
- 0,
- 5
- ],
- "step": 0.001,
- "type": 13,
- "handleInfo": [
- "emissiveScaleAndStrenth",
- 3,
- 13
- ]
- },
- "normalMap": {
- "value": "normal",
- "type": 28
- },
- "mainTexture": {
- "value": "white",
- "editor": {
- "displayName": "BaseColorMap"
- },
- "type": 28,
- "handleInfo": [
- "baseColorMap",
- 0,
- 28
- ]
- },
- "shadeMap1": {
- "value": "white",
- "type": 28
- },
- "shadeMap2": {
- "value": "white",
- "type": 28
- },
- "specularMap": {
- "value": "white",
- "type": 28
- },
- "emissiveMap": {
- "value": "grey",
- "type": 28
- },
- "baseColor": {
- "type": 16,
- "editor": {
- "visible": false,
- "deprecated": true
- },
- "value": [
- 0.6,
- 0.6,
- 0.6,
- 1
- ]
- },
- "colorScaleAndCutoff": {
- "type": 16,
- "editor": {
- "visible": false,
- "deprecated": true
- },
- "value": [
- 1,
- 1,
- 1,
- 0.5
- ]
- },
- "shadeParams": {
- "type": 16,
- "editor": {
- "visible": false,
- "deprecated": true
- },
- "value": [
- 0.8,
- 0.001,
- 0.5,
- 0.001
- ]
- },
- "miscParams": {
- "type": 16,
- "editor": {
- "visible": false,
- "deprecated": true
- },
- "value": [
- 0.5,
- 0,
- 0,
- 0
- ]
- },
- "emissiveScaleAndStrenth": {
- "type": 16,
- "editor": {
- "visible": false,
- "deprecated": true
- },
- "value": [
- 1,
- 1,
- 1,
- 1
- ]
- },
- "baseColorMap": {
- "type": 28,
- "editor": {
- "visible": false,
- "deprecated": true
- },
- "value": "white"
- }
- }
- },
- {
- "phase": "forward-add",
- "propertyIndex": 1,
- "embeddedMacros": {
- "CC_FORWARD_ADD": true
- },
- "blendState": {
- "targets": [
- {
- "blend": true,
- "blendSrc": 1,
- "blendDst": 1,
- "blendSrcAlpha": 0,
- "blendDstAlpha": 1
- }
- ]
- },
- "program": "builtin-toon|toon-vs|toon-fs",
- "depthStencilState": {
- "depthFunc": 2,
- "depthTest": true,
- "depthWrite": false
- },
- "properties": {
- "tilingOffset": {
- "value": [
- 1,
- 1,
- 0,
- 0
- ],
- "type": 16
- },
- "mainColor": {
- "value": [
- 0.6,
- 0.6,
- 0.6,
- 1
- ],
- "linear": true,
- "editor": {
- "displayName": "BaseColor",
- "type": "color"
- },
- "type": 16,
- "handleInfo": [
- "baseColor",
- 0,
- 16
- ]
- },
- "colorScale": {
- "value": [
- 1,
- 1,
- 1
- ],
- "type": 15,
- "handleInfo": [
- "colorScaleAndCutoff",
- 0,
- 15
- ]
- },
- "alphaThreshold": {
- "value": [
- 0.5
- ],
- "editor": {
- "parent": "USE_ALPHA_TEST"
- },
- "type": 13,
- "handleInfo": [
- "colorScaleAndCutoff",
- 3,
- 13
- ]
- },
- "shadeColor1": {
- "value": [
- 0.4,
- 0.4,
- 0.4,
- 1
- ],
- "linear": true,
- "editor": {
- "type": "color"
- },
- "type": 16
- },
- "shadeColor2": {
- "value": [
- 0.2,
- 0.2,
- 0.2,
- 1
- ],
- "linear": true,
- "editor": {
- "type": "color"
- },
- "type": 16
- },
- "specular": {
- "value": [
- 1,
- 1,
- 1,
- 0.3
- ],
- "linear": true,
- "editor": {
- "type": "color"
- },
- "type": 16
- },
- "baseStep": {
- "value": [
- 0.8
- ],
- "type": 13,
- "handleInfo": [
- "shadeParams",
- 0,
- 13
- ]
- },
- "baseFeather": {
- "value": [
- 0.001
- ],
- "type": 13,
- "handleInfo": [
- "shadeParams",
- 1,
- 13
- ]
- },
- "shadeStep": {
- "value": [
- 0.5
- ],
- "type": 13,
- "handleInfo": [
- "shadeParams",
- 2,
- 13
- ]
- },
- "shadeFeather": {
- "value": [
- 0.001
- ],
- "type": 13,
- "handleInfo": [
- "shadeParams",
- 3,
- 13
- ]
- },
- "shadowCover": {
- "value": [
- 0.5
- ],
- "editor": {
- "slide": true,
- "range": [
- 0,
- 1
- ],
- "step": 0.001
- },
- "type": 13,
- "handleInfo": [
- "miscParams",
- 0,
- 13
- ]
- },
- "emissive": {
- "value": [
- 0,
- 0,
- 0,
- 1
- ],
- "linear": true,
- "editor": {
- "type": "color"
- },
- "type": 16
- },
- "emissiveScale": {
- "value": [
- 1,
- 1,
- 1
- ],
- "type": 15,
- "handleInfo": [
- "emissiveScaleAndStrenth",
- 0,
- 15
- ]
- },
- "normalStrength": {
- "value": [
- 1
- ],
- "editor": {
- "parent": "USE_NORMAL_MAP"
- },
- "slide": true,
- "range": [
- 0,
- 5
- ],
- "step": 0.001,
- "type": 13,
- "handleInfo": [
- "emissiveScaleAndStrenth",
- 3,
- 13
- ]
- },
- "normalMap": {
- "value": "normal",
- "type": 28
- },
- "mainTexture": {
- "value": "white",
- "editor": {
- "displayName": "BaseColorMap"
- },
- "type": 28,
- "handleInfo": [
- "baseColorMap",
- 0,
- 28
- ]
- },
- "shadeMap1": {
- "value": "white",
- "type": 28
- },
- "shadeMap2": {
- "value": "white",
- "type": 28
- },
- "specularMap": {
- "value": "white",
- "type": 28
- },
- "emissiveMap": {
- "value": "grey",
- "type": 28
- },
- "baseColor": {
- "type": 16,
- "editor": {
- "visible": false,
- "deprecated": true
- },
- "value": [
- 0.6,
- 0.6,
- 0.6,
- 1
- ]
- },
- "colorScaleAndCutoff": {
- "type": 16,
- "editor": {
- "visible": false,
- "deprecated": true
- },
- "value": [
- 1,
- 1,
- 1,
- 0.5
- ]
- },
- "shadeParams": {
- "type": 16,
- "editor": {
- "visible": false,
- "deprecated": true
- },
- "value": [
- 0.8,
- 0.001,
- 0.5,
- 0.001
- ]
- },
- "miscParams": {
- "type": 16,
- "editor": {
- "visible": false,
- "deprecated": true
- },
- "value": [
- 0.5,
- 0,
- 0,
- 0
- ]
- },
- "emissiveScaleAndStrenth": {
- "type": 16,
- "editor": {
- "visible": false,
- "deprecated": true
- },
- "value": [
- 1,
- 1,
- 1,
- 1
- ]
- },
- "baseColorMap": {
- "type": 28,
- "editor": {
- "visible": false,
- "deprecated": true
- },
- "value": "white"
- }
- }
- },
- {
- "phase": "shadow-caster",
- "propertyIndex": 1,
- "rasterizerState": {
- "cullMode": 1
- },
- "program": "builtin-toon|shadow-caster-vs|shadow-caster-fs",
- "properties": {
- "tilingOffset": {
- "value": [
- 1,
- 1,
- 0,
- 0
- ],
- "type": 16
- },
- "mainColor": {
- "value": [
- 0.6,
- 0.6,
- 0.6,
- 1
- ],
- "editor": {
- "displayName": "BaseColor",
- "type": "color"
- },
- "type": 16,
- "handleInfo": [
- "baseColor",
- 0,
- 16
- ]
- },
- "colorScale": {
- "value": [
- 1,
- 1,
- 1
- ],
- "type": 15,
- "handleInfo": [
- "colorScaleAndCutoff",
- 0,
- 15
- ]
- },
- "alphaThreshold": {
- "value": [
- 0.5
- ],
- "editor": {
- "parent": "USE_ALPHA_TEST"
- },
- "type": 13,
- "handleInfo": [
- "colorScaleAndCutoff",
- 3,
- 13
- ]
- },
- "shadeColor1": {
- "value": [
- 0.4,
- 0.4,
- 0.4,
- 1
- ],
- "editor": {
- "type": "color"
- },
- "type": 16
- },
- "shadeColor2": {
- "value": [
- 0.2,
- 0.2,
- 0.2,
- 1
- ],
- "editor": {
- "type": "color"
- },
- "type": 16
- },
- "specular": {
- "value": [
- 1,
- 1,
- 1,
- 0.3
- ],
- "editor": {
- "type": "color"
- },
- "type": 16
- },
- "baseStep": {
- "value": [
- 0.8
- ],
- "type": 13,
- "handleInfo": [
- "shadeParams",
- 0,
- 13
- ]
- },
- "baseFeather": {
- "value": [
- 0.001
- ],
- "type": 13,
- "handleInfo": [
- "shadeParams",
- 1,
- 13
- ]
- },
- "shadeStep": {
- "value": [
- 0.5
- ],
- "type": 13,
- "handleInfo": [
- "shadeParams",
- 2,
- 13
- ]
- },
- "shadeFeather": {
- "value": [
- 0.001
- ],
- "type": 13,
- "handleInfo": [
- "shadeParams",
- 3,
- 13
- ]
- },
- "emissive": {
- "value": [
- 0,
- 0,
- 0,
- 1
- ],
- "editor": {
- "type": "color"
- },
- "type": 16
- },
- "emissiveScale": {
- "value": [
- 1,
- 1,
- 1
- ],
- "type": 15,
- "handleInfo": [
- "emissiveScaleAndStrenth",
- 0,
- 15
- ]
- },
- "normalStrenth": {
- "value": [
- 1
- ],
- "editor": {
- "parent": "USE_NORMAL_MAP"
- },
- "type": 13,
- "handleInfo": [
- "emissiveScaleAndStrenth",
- 3,
- 13
- ]
- },
- "mainTexture": {
- "value": "white",
- "editor": {
- "displayName": "BaseColorMap"
- },
- "type": 28,
- "handleInfo": [
- "baseColorMap",
- 0,
- 28
- ]
- },
- "baseColor": {
- "type": 16,
- "editor": {
- "visible": false,
- "deprecated": true
- },
- "value": [
- 0.6,
- 0.6,
- 0.6,
- 1
- ]
- },
- "colorScaleAndCutoff": {
- "type": 16,
- "editor": {
- "visible": false,
- "deprecated": true
- },
- "value": [
- 1,
- 1,
- 1,
- 0.5
- ]
- },
- "shadeParams": {
- "type": 16,
- "editor": {
- "visible": false,
- "deprecated": true
- },
- "value": [
- 0.8,
- 0.001,
- 0.5,
- 0.001
- ]
- },
- "emissiveScaleAndStrenth": {
- "type": 16,
- "editor": {
- "visible": false,
- "deprecated": true
- },
- "value": [
- 1,
- 1,
- 1,
- 1
- ]
- },
- "baseColorMap": {
- "type": 28,
- "editor": {
- "visible": false,
- "deprecated": true
- },
- "value": "white"
- }
- }
- },
- {
- "phase": "planar-shadow",
- "propertyIndex": 0,
- "blendState": {
- "targets": [
- {
- "blend": true,
- "blendSrc": 2,
- "blendDst": 4,
- "blendDstAlpha": 4
- }
- ]
- },
- "program": "builtin-toon|planar-shadow-vs|planar-shadow-fs",
- "depthStencilState": {
- "depthTest": true,
- "depthWrite": false,
- "stencilTestFront": true,
- "stencilFuncFront": 5,
- "stencilPassOpFront": 2,
- "stencilRefBack": 128,
- "stencilRefFront": 128,
- "stencilReadMaskBack": 128,
- "stencilReadMaskFront": 128,
- "stencilWriteMaskBack": 128,
- "stencilWriteMaskFront": 128
- }
- },
- {
- "phase": "deferred-forward",
- "rasterizerState": {
- "cullMode": 1
- },
- "propertyIndex": 0,
- "program": "builtin-toon|silhouette-edge-vs|silhouette-edge-fs",
- "depthStencilState": {
- "depthFunc": 3,
- "depthTest": true,
- "depthWrite": true
- },
- "switch": "USE_OUTLINE_PASS"
- },
- {
- "phase": "deferred-forward",
- "propertyIndex": 1,
- "program": "builtin-toon|toon-vs|toon-fs"
- }
- ]
- }
- ],
- "shaders": [
- {
- "blocks": [
- {
- "name": "OutlineVert",
- "members": [
- {
- "name": "outlineParams",
- "type": 16,
- "count": 1
- }
- ],
- "defines": [],
- "stageFlags": 1,
- "binding": 0
- },
- {
- "name": "OutlineFrag",
- "members": [
- {
- "name": "baseColor",
- "type": 16,
- "count": 1
- }
- ],
- "defines": [],
- "stageFlags": 16,
- "binding": 1
- }
- ],
- "samplerTextures": [
- {
- "name": "baseColorMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_BASE_COLOR_MAP"
- ],
- "stageFlags": 16,
- "binding": 2
- }
- ],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": [],
- "attributes": [
- {
- "name": "a_position",
- "defines": [],
- "format": 32,
- "location": 0
- },
- {
- "name": "a_normal",
- "defines": [],
- "format": 32,
- "location": 1
- },
- {
- "name": "a_texCoord",
- "defines": [],
- "format": 21,
- "location": 2
- },
- {
- "name": "a_tangent",
- "defines": [],
- "format": 44,
- "location": 3
- },
- {
- "name": "a_color",
- "defines": [],
- "format": 44,
- "location": 6
- },
- {
- "name": "a_texCoord1",
- "defines": [],
- "format": 21,
- "location": 7
- },
- {
- "name": "a_joints",
- "defines": [
- "CC_USE_SKINNING"
- ],
- "location": 4
- },
- {
- "name": "a_weights",
- "defines": [
- "CC_USE_SKINNING"
- ],
- "format": 44,
- "location": 5
- },
- {
- "name": "a_jointAnimInfo",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_BAKED_ANIMATION"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 8
- },
- {
- "name": "a_matWorld0",
- "defines": [
- "USE_INSTANCING"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 9
- },
- {
- "name": "a_matWorld1",
- "defines": [
- "USE_INSTANCING"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 10
- },
- {
- "name": "a_matWorld2",
- "defines": [
- "USE_INSTANCING"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 11
- },
- {
- "name": "a_lightingMapUVParam",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_LIGHTMAP"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 12
- },
- {
- "name": "a_localShadowBiasAndProbeId",
- "defines": [
- "USE_INSTANCING"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 13
- },
- {
- "name": "a_reflectionProbeData",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_REFLECTION_PROBE"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 14
- },
- {
- "name": "a_sh_linear_const_r",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_LIGHT_PROBE"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 15
- },
- {
- "name": "a_sh_linear_const_g",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_LIGHT_PROBE"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 16
- },
- {
- "name": "a_sh_linear_const_b",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_LIGHT_PROBE"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 17
- },
- {
- "name": "a_vertexId",
- "defines": [
- "CC_USE_MORPH"
- ],
- "format": 11,
- "location": 18
- }
- ],
- "varyings": [
- {
- "name": "v_worldPos",
- "type": 15,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 0
- },
- {
- "name": "v_normal",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 1
- },
- {
- "name": "v_uv",
- "type": 14,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 2
- },
- {
- "name": "v_color",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 3
- },
- {
- "name": "v_tangent",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 4
- },
- {
- "name": "v_uv1",
- "type": 14,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 5
- },
- {
- "name": "v_luv",
- "type": 15,
- "count": 1,
- "defines": [
- "CC_USE_LIGHTMAP",
- "!CC_FORWARD_ADD"
- ],
- "stageFlags": 17,
- "location": 6
- },
- {
- "name": "v_shadowBiasAndProbeId",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 7
- },
- {
- "name": "v_reflectionProbeData",
- "type": 16,
- "count": 1,
- "defines": [
- "CC_USE_REFLECTION_PROBE",
- "USE_INSTANCING"
- ],
- "stageFlags": 17,
- "location": 8
- },
- {
- "name": "v_fogFactor",
- "type": 13,
- "count": 1,
- "defines": [
- "CC_USE_FOG",
- "!CC_USE_ACCURATE_FOG"
- ],
- "stageFlags": 17,
- "location": 9
- },
- {
- "name": "v_localPos",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 10
- },
- {
- "name": "v_clipPos",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 11
- },
- {
- "name": "v_sh_linear_const_r",
- "type": 16,
- "count": 1,
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "USE_INSTANCING"
- ],
- "stageFlags": 17,
- "location": 12
- },
- {
- "name": "v_sh_linear_const_g",
- "type": 16,
- "count": 1,
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "USE_INSTANCING"
- ],
- "stageFlags": 17,
- "location": 13
- },
- {
- "name": "v_sh_linear_const_b",
- "type": 16,
- "count": 1,
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "USE_INSTANCING"
- ],
- "stageFlags": 17,
- "location": 14
- }
- ],
- "fragColors": [
- {
- "name": "fragColorX",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 16,
- "location": 0
- }
- ],
- "descriptors": [
- {
- "rate": 0,
- "blocks": [
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCLocal",
- "members": [
- {
- "name": "cc_matWorld",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matWorldIT",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_lightingMapUVParam",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_localShadowBias",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeData1",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeData2",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeBlendData1",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeBlendData2",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- }
- ],
- "defines": [
- "!USE_INSTANCING"
- ],
- "stageFlags": 17
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCMorph",
- "members": [
- {
- "name": "cc_displacementWeights",
- "typename": "vec4",
- "type": 16,
- "count": 15,
- "isArray": true
- },
- {
- "name": "cc_displacementTextureInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1
- }
- ],
- "defines": [
- "CC_USE_MORPH"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCSkinningTexture",
- "members": [
- {
- "name": "cc_jointTextureInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- }
- ],
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCSkinningAnimation",
- "members": [
- {
- "name": "cc_jointAnimInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- }
- ],
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCSkinning",
- "members": [
- {
- "name": "cc_joints",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "precision": "highp ",
- "isArray": true
- }
- ],
- "defines": [
- "CC_USE_SKINNING",
- "!CC_USE_BAKED_ANIMATION",
- "!CC_USE_REAL_TIME_JOINT_TEXTURE"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCForwardLight",
- "members": [
- {
- "name": "cc_lightPos",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_lightColor",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "isArray": true
- },
- {
- "name": "cc_lightSizeRangeAngle",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "isArray": true
- },
- {
- "name": "cc_lightDir",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "isArray": true
- },
- {
- "name": "cc_lightBoundingSizeVS",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "isArray": true
- }
- ],
- "defines": [
- "CC_FORWARD_ADD",
- "CC_ENABLE_CLUSTERED_LIGHT_CULLING"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCSH",
- "members": [
- {
- "name": "cc_sh_linear_const_r",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_linear_const_g",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_linear_const_b",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_r",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_g",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_b",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_a",
- "typename": "vec4",
- "type": 16,
- "count": 1
- }
- ],
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "!USE_INSTANCING"
- ],
- "stageFlags": 16
- }
- ],
- "samplerTextures": [
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_PositionDisplacements",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_POSITION"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_NormalDisplacements",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_NORMAL"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_TangentDisplacements",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_TANGENT"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_jointTexture",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "precision": "highp ",
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_realtimeJoint",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "precision": "highp ",
- "defines": [
- "CC_USE_SKINNING",
- "!CC_USE_BAKED_ANIMATION",
- "CC_USE_REAL_TIME_JOINT_TEXTURE"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_reflectionProbeCubemap",
- "typename": "samplerCube",
- "type": 31,
- "count": 1,
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_reflectionProbePlanarMap",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_reflectionProbeDataMap",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_reflectionProbeBlendCubemap",
- "typename": "samplerCube",
- "type": 31,
- "count": 1,
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_lightingMap",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_LIGHTMAP",
- "!CC_FORWARD_ADD"
- ],
- "stageFlags": 16
- }
- ],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- },
- {
- "rate": 1,
- "blocks": [
- {
- "name": "OutlineVert",
- "members": [
- {
- "name": "outlineParams",
- "type": 16,
- "count": 1
- }
- ],
- "defines": [],
- "stageFlags": 1,
- "binding": 0
- },
- {
- "name": "OutlineFrag",
- "members": [
- {
- "name": "baseColor",
- "type": 16,
- "count": 1
- }
- ],
- "defines": [],
- "stageFlags": 16,
- "binding": 1
- }
- ],
- "samplerTextures": [
- {
- "name": "baseColorMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_BASE_COLOR_MAP"
- ],
- "stageFlags": 16,
- "binding": 2
- }
- ],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- },
- {
- "rate": 2,
- "blocks": [],
- "samplerTextures": [],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- },
- {
- "rate": 3,
- "blocks": [
- {
- "tags": {
- "builtin": "global"
- },
- "name": "CCGlobal",
- "members": [
- {
- "name": "cc_time",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_screenSize",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_nativeSize",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_probeInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_debug_view_mode",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- }
- ],
- "defines": [],
- "stageFlags": 17
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "CCCamera",
- "members": [
- {
- "name": "cc_matView",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matViewInv",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matProj",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matProjInv",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matViewProj",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matViewProjInv",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_cameraPos",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_surfaceTransform",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_screenScale",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_exposure",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_mainLitDir",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_mainLitColor",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_ambientSky",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_ambientGround",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_fogColor",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_fogBase",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_fogAdd",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_nearFar",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_viewPort",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- }
- ],
- "defines": [],
- "stageFlags": 17
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "CCShadow",
- "members": [
- {
- "name": "cc_matLightView",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matLightViewProj",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_shadowInvProjDepthInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_shadowProjDepthInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_shadowProjInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_shadowNFLSInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_shadowWHPBInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_shadowLPNNInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_shadowColor",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "lowp "
- },
- {
- "name": "cc_planarNDInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- }
- ],
- "defines": [],
- "stageFlags": 17
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "CCCSM",
- "members": [
- {
- "name": "cc_csmViewDir0",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmViewDir1",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmViewDir2",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmAtlas",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_matCSMViewProj",
- "typename": "mat4",
- "type": 25,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmProjDepthInfo",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmProjInfo",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmSplitsInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- }
- ],
- "defines": [
- "CC_SUPPORT_CASCADED_SHADOW_MAP"
- ],
- "stageFlags": 16
- }
- ],
- "samplerTextures": [
- {
- "tags": {
- "builtin": "global"
- },
- "name": "cc_environment",
- "typename": "samplerCube",
- "type": 31,
- "count": 1,
- "defines": [],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "cc_diffuseMap",
- "typename": "samplerCube",
- "type": 31,
- "count": 1,
- "defines": [
- "CC_USE_IBL",
- "CC_USE_DIFFUSEMAP"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "cc_shadowMap",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "precision": "highp ",
- "defines": [
- "CC_RECEIVE_SHADOW"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "cc_spotShadowMap",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "precision": "highp ",
- "defines": [
- "CC_RECEIVE_SHADOW"
- ],
- "stageFlags": 16
- }
- ],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- }
- ],
- "hash": 3857170659,
- "glsl4": {
- "vert": "#extension GL_EXT_shader_explicit_arithmetic_types_int32: require\nprecision highp float;\n#define CC_SURFACES_USE_TANGENT_SPACE 0\n#define CC_SURFACES_USE_VERTEX_COLOR 0\n#define CC_SURFACES_USE_SECOND_UV 0\n#define CC_SURFACES_USE_LIGHT_MAP 0\n#define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec3 a_normal;\nlayout(location = 2) in vec2 a_texCoord;\n#if CC_SURFACES_USE_TANGENT_SPACE\n layout(location = 3) in vec4 a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n layout(location = 6) in vec4 a_color;\n#endif\n#if CC_SURFACES_USE_SECOND_UV || CC_USE_LIGHTMAP\n layout(location = 7) in vec2 a_texCoord1;\n#endif\n#if CC_USE_SKINNING\n layout(location = 4) in u32vec4 a_joints;\n layout(location = 5) in vec4 a_weights;\n#endif\n#if USE_INSTANCING\n #if CC_USE_BAKED_ANIMATION\n layout(location = 8) in highp vec4 a_jointAnimInfo;\n #endif\n layout(location = 9) in vec4 a_matWorld0;\n layout(location = 10) in vec4 a_matWorld1;\n layout(location = 11) in vec4 a_matWorld2;\n #if CC_USE_LIGHTMAP\n layout(location = 12) in vec4 a_lightingMapUVParam;\n #endif\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n layout(location = 13) in vec4 a_localShadowBiasAndProbeId;\n #endif\n #if CC_USE_REFLECTION_PROBE\n layout(location = 14) in vec4 a_reflectionProbeData;\n #endif\n #if CC_USE_LIGHT_PROBE\n layout(location = 15) in vec4 a_sh_linear_const_r;\n layout(location = 16) in vec4 a_sh_linear_const_g;\n layout(location = 17) in vec4 a_sh_linear_const_b;\n #endif\n#endif\n#if CC_USE_MORPH\n#endif\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nlayout(location = 0) out highp vec3 v_worldPos;\nlayout(location = 1) out vec4 v_normal;\nlayout(location = 2) out vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n layout(location = 3) out lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n layout(location = 4) out mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n layout(location = 5) out mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n layout(location = 6) out mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n layout(location = 7) out mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n layout(location = 8) out mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n layout(location = 9) out mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n layout(location = 10) out highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n layout(location = 11) out highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n layout(location = 12) out mediump vec4 v_sh_linear_const_r;\n layout(location = 13) out mediump vec4 v_sh_linear_const_g;\n layout(location = 14) out mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define VSOutput_worldPos v_worldPos\n#define VSOutput_worldNormal v_normal.xyz\n#define VSOutput_faceSideSign v_normal.w\n#define VSOutput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define VSOutput_vertexColor v_color\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define VSOutput_worldTangent v_tangent.xyz\n #define VSOutput_mirrorNormal v_tangent.w\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define VSOutput_texcoord1 v_uv1\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define VSOutput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define VSOutput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define VSOutput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define VSOutput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define VSOutput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define VSOutput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define VSOutput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define VSOutput_clipPos v_clipPos\n#endif\nstruct SurfacesStandardVertexIntermediate\n{\n highp vec4 position;\n vec3 normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n vec4 tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n vec4 color;\n#endif\n vec2 texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n vec2 texCoord1;\n#endif\n highp vec4 clipPos;\n highp vec3 worldPos;\n vec4 worldNormal;\n #if CC_SURFACES_USE_TANGENT_SPACE\n vec3 worldTangent, worldBinormal;\n #endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n vec4 shadowBiasAndProbeId;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n float fogFactor;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n vec3 lightmapUV;\n#endif\n};\n#if CC_USE_MORPH\n int getVertexId() {\n return gl_VertexIndex;\n }\n#endif\nlayout(set = 0, binding = 0) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\nlayout(set = 0, binding = 2) uniform CCShadow {\n highp mat4 cc_matLightView;\n highp mat4 cc_matLightViewProj;\n highp vec4 cc_shadowInvProjDepthInfo;\n highp vec4 cc_shadowProjDepthInfo;\n highp vec4 cc_shadowProjInfo;\n mediump vec4 cc_shadowNFLSInfo;\n mediump vec4 cc_shadowWHPBInfo;\n mediump vec4 cc_shadowLPNNInfo;\n lowp vec4 cc_shadowColor;\n mediump vec4 cc_planarNDInfo;\n};\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\n#if !USE_INSTANCING\n layout(set = 2, binding = 0) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n highp vec4 cc_localShadowBias;\n highp vec4 cc_reflectionProbeData1;\n highp vec4 cc_reflectionProbeData2;\n highp vec4 cc_reflectionProbeBlendData1;\n highp vec4 cc_reflectionProbeBlendData2;\n };\n#endif\nvoid CCGetWorldMatrixFull(out mat4 matWorld, out mat4 matWorldIT)\n{\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n vec3 scale = 1.0 / vec3(length(a_matWorld0.xyz), length(a_matWorld1.xyz), length(a_matWorld2.xyz));\n vec3 scale2 = scale * scale;\n matWorldIT = mat4(\n vec4(a_matWorld0.xyz * scale2.x, 0.0),\n vec4(a_matWorld1.xyz * scale2.y, 0.0),\n vec4(a_matWorld2.xyz * scale2.z, 0.0),\n vec4(0.0, 0.0, 0.0, 1.0)\n );\n #else\n matWorld = cc_matWorld;\n matWorldIT = cc_matWorldIT;\n #endif\n}\n#if CC_USE_MORPH\n layout(set = 2, binding = 4) uniform CCMorph {\n vec4 cc_displacementWeights[15];\n vec4 cc_displacementTextureInfo;\n };\n #if CC_MORPH_TARGET_HAS_POSITION\n layout(set = 2, binding = 8) uniform sampler2D cc_PositionDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n layout(set = 2, binding = 9) uniform sampler2D cc_NormalDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n layout(set = 2, binding = 10) uniform sampler2D cc_TangentDisplacements;\n #endif\n vec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n }\n vec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n }\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\n ivec2 texSize = textureSize(tex, 0);\n return texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n }\n #else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture(tex, x)),\n decode32(texture(tex, y)),\n decode32(texture(tex, z)),\n 1.0\n );\n }\n #endif\n float getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n }\n vec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n #if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n #else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n #endif\n }\n #if CC_MORPH_TARGET_HAS_POSITION\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n #endif\n void applyMorph (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n int vertexId = getVertexId();\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n normal.xyz = normal.xyz + getNormalDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n tangent.xyz = tangent.xyz + getTangentDisplacement(vertexId);\n #endif\n }\n void applyMorph (inout vec4 position) {\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n #endif\n }\n#endif\n#if CC_USE_SKINNING\n #if CC_USE_BAKED_ANIMATION\n layout(set = 2, binding = 3) uniform CCSkinningTexture {\n highp vec4 cc_jointTextureInfo;\n };\n layout(set = 2, binding = 2) uniform CCSkinningAnimation {\n highp vec4 cc_jointAnimInfo;\n };\n layout(set = 2, binding = 7) uniform highp sampler2D cc_jointTexture;\n void CCGetJointTextureCoords(float pixelsPerJoint, float jointIdx, out highp float x, out highp float y, out highp float invSize)\n {\n #if USE_INSTANCING\n highp float temp = pixelsPerJoint * (a_jointAnimInfo.x * a_jointAnimInfo.y + jointIdx) + a_jointAnimInfo.z;\n #else\n highp float temp = pixelsPerJoint * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + jointIdx) + cc_jointTextureInfo.z;\n #endif\n invSize = cc_jointTextureInfo.w;\n highp float tempY = floor(temp * invSize);\n x = floor(temp - tempY * cc_jointTextureInfo.x);\n y = (tempY + 0.5) * invSize;\n }\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n layout(set = 2, binding = 7) uniform highp sampler2D cc_realtimeJoint;\n #else\n layout(set = 2, binding = 3) uniform CCSkinning {\n highp vec4 cc_joints[CC_JOINT_UNIFORM_CAPACITY * 3];\n };\n #endif\n #endif\n #if CC_USE_BAKED_ANIMATION\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(3.0, i, x, y, invSize);\n vec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(12.0, i, x, y, invSize);\n vec4 v1 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n float x = i;\n vec4 v1 = texture(cc_realtimeJoint, vec2( x / 256.0, 0.5 / 3.0));\n vec4 v2 = texture(cc_realtimeJoint, vec2( x / 256.0, 1.5 / 3.0));\n vec4 v3 = texture(cc_realtimeJoint, vec2( x / 256.0, 2.5 / 3.0));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n float x = 4.0 * i;\n vec4 v1 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 0.5 / 3.0)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 1.5 / 3.0)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 2.5 / 3.0)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #endif\n mat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n }\n void CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n }\n void CCSkin (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n mat4 m = skinMatrix();\n position = m * position;\n normal = (m * vec4(normal, 0.0)).xyz;\n tangent.xyz = (m * vec4(tangent.xyz, 0.0)).xyz;\n }\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #if CC_USE_FOG != 4\n float LinearFog(vec4 pos, vec3 cameraPos, float fogStart, float fogEnd) {\n vec4 wPos = pos;\n float cam_dis = distance(cameraPos, wPos.xyz);\n return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n }\n float ExpFog(vec4 pos, vec3 cameraPos, float fogStart, float fogDensity, float fogAtten) {\n vec4 wPos = pos;\n float cam_dis = max(distance(cameraPos, wPos.xyz) - fogStart, 0.0) / fogAtten * 4.;\n float f = exp(-cam_dis * fogDensity);\n return f;\n }\n float ExpSquaredFog(vec4 pos, vec3 cameraPos, float fogStart, float fogDensity, float fogAtten) {\n vec4 wPos = pos;\n float cam_dis = max(distance(cameraPos, wPos.xyz) - fogStart, 0.0) / fogAtten * 4.;\n float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\n return f;\n }\n float LayeredFog(vec4 pos, vec3 cameraPos, float fogTop, float fogRange, float fogAtten) {\n vec4 wPos = pos;\n vec3 camWorldProj = cameraPos.xyz;\n camWorldProj.y = 0.;\n vec3 worldPosProj = wPos.xyz;\n worldPosProj.y = 0.;\n float fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\n float fDeltaY, fDensityIntegral;\n if (cameraPos.y > fogTop) {\n if (wPos.y < fogTop) {\n fDeltaY = (fogTop - wPos.y) / fogRange * 2.0;\n fDensityIntegral = fDeltaY * fDeltaY * 0.5;\n }\n else {\n fDeltaY = 0.;\n fDensityIntegral = 0.;\n }\n }\n else {\n if (wPos.y < fogTop) {\n float fDeltaA = (fogTop - cameraPos.y) / fogRange * 2.;\n float fDeltaB = (fogTop - wPos.y) / fogRange * 2.;\n fDeltaY = abs(fDeltaA - fDeltaB);\n fDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n }\n else {\n fDeltaY = abs(fogTop - cameraPos.y) / fogRange * 2.;\n fDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n }\n }\n float fDensity;\n if (fDeltaY != 0.) {\n fDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n }\n else {\n fDensity = 0.;\n }\n float f = exp(-fDensity);\n return f;\n }\n #endif\n void CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n {\n #if CC_USE_FOG == 0\n \tfactor = LinearFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.y);\n #elif CC_USE_FOG == 1\n \tfactor = ExpFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z);\n #elif CC_USE_FOG == 2\n \tfactor = ExpSquaredFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z);\n #elif CC_USE_FOG == 3\n \tfactor = LayeredFog(pos, cc_cameraPos.xyz, cc_fogAdd.x, cc_fogAdd.y, cc_fogAdd.z);\n #else\n \tfactor = 1.0;\n #endif\n }\n#endif\n layout(set = 1, binding = 0) uniform OutlineVert {\n vec4 outlineParams;\n};\n #define CC_SURFACES_VERTEX_MODIFY_LOCAL_POS\n vec3 SurfacesVertexModifyLocalPos(in SurfacesStandardVertexIntermediate In)\n {\n float width = outlineParams.x * 0.001;\n vec3 localPos = In.position.xyz;\n #if USE_POSITION_SCALING\n vec3 dir = normalize(localPos);\n float flip = dot(dir, normalize(In.normal)) < 0.0 ? -1.0 : 1.0;\n localPos += flip * dir * width * 2.0;\n #else\n localPos += normalize(In.normal) * width;\n #endif\n return localPos;\n }\n #define CC_SURFACES_VERTEX_MODIFY_CLIP_POS\n vec4 SurfacesVertexModifyClipPos(in SurfacesStandardVertexIntermediate In)\n {\n vec4 clipPos = In.clipPos;\n float scaleZ = cc_nearFar.z == 0.0 ? 0.5 : 1.0;\n clipPos.z -= outlineParams.y * 0.002 * scaleZ;\n return clipPos;\n }\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_POS\nvec3 SurfacesVertexModifyLocalPos(in SurfacesStandardVertexIntermediate In)\n{\n return vec3(In.position.xyz);\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_NORMAL\nvec3 SurfacesVertexModifyLocalNormal(in SurfacesStandardVertexIntermediate In)\n{\n return In.normal.xyz;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_TANGENT\n #if CC_SURFACES_USE_TANGENT_SPACE\n vec4 SurfacesVertexModifyLocalTangent(in SurfacesStandardVertexIntermediate In)\n {\n return In.tangent;\n }\n #endif\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_SHARED_DATA\nvoid SurfacesVertexModifyLocalSharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_POS\nvec3 SurfacesVertexModifyWorldPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.worldPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_CLIP_POS\nvec4 SurfacesVertexModifyClipPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.clipPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_UV\nvoid SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_NORMAL\nvec3 SurfacesVertexModifyWorldNormal(in SurfacesStandardVertexIntermediate In)\n{\n vec3 worldNormal = In.worldNormal.xyz;\n #if CC_SURFACES_USE_TWO_SIDED\n worldNormal.xyz *= In.worldNormal.w;\n #endif\n return worldNormal;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHADOW_BIAS\nvec2 SurfacesVertexModifyShadowBias(in SurfacesStandardVertexIntermediate In, vec2 originShadowBias)\n{\n return originShadowBias;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHARED_DATA\nvoid SurfacesVertexModifySharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\nvoid CCSurfacesVertexInput(out SurfacesStandardVertexIntermediate In)\n{\n In.position = vec4(a_position, 1.0);\n In.normal = a_normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n In.tangent = a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n In.color = a_color;\n#endif\n In.texCoord = a_texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = a_texCoord1;\n#endif\n}\nvoid CCSurfacesVertexOutput(in SurfacesStandardVertexIntermediate In)\n{\n gl_Position = In.clipPos;\n VSOutput_worldNormal = In.worldNormal.xyz;\n VSOutput_faceSideSign = In.worldNormal.w;\n VSOutput_worldPos = In.worldPos;\n#if CC_SURFACES_USE_TANGENT_SPACE\n VSOutput_worldTangent = In.worldTangent.xyz;\n VSOutput_mirrorNormal = In.tangent.w > 0.0 ? 1.0 : -1.0;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n VSOutput_vertexColor = In.color;\n#endif\n VSOutput_texcoord = In.texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n VSOutput_texcoord1 = In.texCoord1;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n VSOutput_fogFactor = In.fogFactor;\n#endif\n#if CC_RECEIVE_SHADOW\n VSOutput_shadowBias = In.shadowBiasAndProbeId.xy;\n#endif\n#if CC_USE_REFLECTION_PROBE\n VSOutput_reflectionProbeId = In.shadowBiasAndProbeId.z;\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n VSOutput_reflectionProbeBlendId = In.shadowBiasAndProbeId.w;\n #endif\n #if USE_INSTANCING\n v_reflectionProbeData = a_reflectionProbeData;\n #endif\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n VSOutput_lightMapUV = In.lightmapUV;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n VSOutput_localPos = In.position;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n VSOutput_clipPos = In.clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n v_sh_linear_const_r = a_sh_linear_const_r;\n v_sh_linear_const_g = a_sh_linear_const_g;\n v_sh_linear_const_b = a_sh_linear_const_b;\n #endif\n#endif\n}\nvoid CCSurfacesVertexAnimation(inout SurfacesStandardVertexIntermediate In)\n{\nvec4 temp = vec4(0.0);\n#if CC_USE_MORPH\n #if CC_SURFACES_USE_TANGENT_SPACE\n applyMorph(In.position, In.normal, In.tangent);\n #else\n applyMorph(In.position, In.normal, temp);\n #endif\n#endif\n#if CC_USE_SKINNING\n #if CC_SURFACES_USE_TANGENT_SPACE\n CCSkin(In.position, In.normal, In.tangent);\n #else\n CCSkin(In.position, In.normal, temp);\n #endif\n#endif\n}\nvoid CCSurfacesVertexWorldTransform(inout SurfacesStandardVertexIntermediate In)\n{\n mat4 matWorld, matWorldIT;\n CCGetWorldMatrixFull(matWorld, matWorldIT);\n In.worldPos = (matWorld * In.position).xyz;\n In.worldNormal.xyz = normalize((matWorldIT * vec4(In.normal.xyz, 0.0)).xyz);\n #if CC_SURFACES_USE_TANGENT_SPACE\n In.worldTangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\n In.worldBinormal = cross(In.worldNormal.xyz, In.worldTangent) * In.tangent.w;\n #endif\n}\nvoid CCSurfacesVertexTransformUV(inout SurfacesStandardVertexIntermediate In)\n{\n #if CC_SURFACES_FLIP_UV\n In.texCoord = cc_cameraPos.w > 1.0 ? vec2(In.texCoord.x, 1.0 - In.texCoord.y) : In.texCoord;\n #if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = cc_cameraPos.w > 1.0 ? vec2(In.texCoord1.x, 1.0 - In.texCoord1.y) : In.texCoord1;\n #endif\n #endif\n}\nvoid CCSurfacesVertexTransferFog(inout SurfacesStandardVertexIntermediate In)\n{\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n CC_TRANSFER_FOG_BASE(vec4(In.worldPos, 1.0), In.fogFactor);\n#endif\n}\nvoid CCSurfacesVertexTransferShadow(inout SurfacesStandardVertexIntermediate In)\n{\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n In.shadowBiasAndProbeId = vec4(0.0);\n #endif\n #if CC_RECEIVE_SHADOW\n In.shadowBiasAndProbeId.xy = vec2(cc_shadowWHPBInfo.w, cc_shadowLPNNInfo.z);\n #if USE_INSTANCING\n In.shadowBiasAndProbeId.xy += a_localShadowBiasAndProbeId.xy;\n #else\n In.shadowBiasAndProbeId.xy += cc_localShadowBias.xy;\n #endif\n #endif\n #if CC_USE_REFLECTION_PROBE\n #if USE_INSTANCING\n In.shadowBiasAndProbeId.zw = a_localShadowBiasAndProbeId.zw;\n #else\n In.shadowBiasAndProbeId.zw = cc_localShadowBias.zw;\n #endif\n #endif\n}\nvoid CCSurfacesVertexTransferLightMapUV(inout SurfacesStandardVertexIntermediate In)\n{\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #if USE_INSTANCING\n In.lightmapUV.xy = a_lightingMapUVParam.xy + a_texCoord1 * a_lightingMapUVParam.z;\n In.lightmapUV.z = a_lightingMapUVParam.w;\n #else\n In.lightmapUV.xy = cc_lightingMapUVParam.xy + a_texCoord1 * cc_lightingMapUVParam.z;\n In.lightmapUV.z = cc_lightingMapUVParam.w;\n #endif\n#endif\n}\nvoid main()\n{\n SurfacesStandardVertexIntermediate In;\n CCSurfacesVertexInput(In);\n CCSurfacesVertexAnimation(In);\n In.position.xyz = SurfacesVertexModifyLocalPos(In);\n In.normal.xyz = SurfacesVertexModifyLocalNormal(In);\n #if CC_SURFACES_USE_TANGENT_SPACE\n In.tangent = SurfacesVertexModifyLocalTangent(In);\n #endif\n SurfacesVertexModifyLocalSharedData(In);\n CCSurfacesVertexWorldTransform(In);\n In.worldPos = SurfacesVertexModifyWorldPos(In);\n In.clipPos = cc_matProj * cc_matView * vec4(In.worldPos, 1.0);\n In.clipPos = SurfacesVertexModifyClipPos(In);\n vec3 viewDirect = normalize(cc_cameraPos.xyz - In.worldPos);\n In.worldNormal.w = dot(In.worldNormal.xyz, viewDirect) < 0.0 ? -1.0 : 1.0;\n In.worldNormal.xyz = SurfacesVertexModifyWorldNormal(In);\n SurfacesVertexModifyUV(In);\n SurfacesVertexModifySharedData(In);\n CCSurfacesVertexTransformUV(In);\n CCSurfacesVertexTransferFog(In);\n CCSurfacesVertexTransferLightMapUV(In);\n CCSurfacesVertexTransferShadow(In);\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n In.shadowBiasAndProbeId.xy = SurfacesVertexModifyShadowBias(In, In.shadowBiasAndProbeId.xy);\n #endif\n CCSurfacesVertexOutput(In);\n}",
- "frag": "\nprecision highp float;\n#define CC_SURFACES_USE_TANGENT_SPACE 0\n#define CC_SURFACES_USE_VERTEX_COLOR 0\n#define CC_SURFACES_USE_SECOND_UV 0\n#define CC_SURFACES_USE_LIGHT_MAP 0\n#define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nlayout(location = 0) in highp vec3 v_worldPos;\nlayout(location = 1) in vec4 v_normal;\nlayout(location = 2) in vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n layout(location = 3) in lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n layout(location = 4) in mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n layout(location = 5) in mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n layout(location = 6) in mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n layout(location = 7) in mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n layout(location = 8) in mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n layout(location = 9) in mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n layout(location = 10) in highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n layout(location = 11) in highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n layout(location = 12) in mediump vec4 v_sh_linear_const_r;\n layout(location = 13) in mediump vec4 v_sh_linear_const_g;\n layout(location = 14) in mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define FSInput_worldPos v_worldPos\n#define FSInput_worldNormal v_normal.xyz\n#define FSInput_faceSideSign v_normal.w\n#define FSInput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define FSInput_vertexColor v_color\n#else\n #define FSInput_vertexColor vec4(1.0)\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define FSInput_worldTangent v_tangent.xyz\n #define FSInput_mirrorNormal v_tangent.w\n#else\n #define FSInput_worldTangent vec3(1.0, 1.0, 1.0)\n #define FSInput_mirrorNormal 1.0\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define FSInput_texcoord1 v_uv1\n#else\n #define FSInput_texcoord1 vec2(0.0, 0.0)\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define FSInput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define FSInput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define FSInput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define FSInput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define FSInput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define FSInput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define FSInput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define FSInput_clipPos v_clipPos\n#endif\nlayout(set = 0, binding = 0) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_WORLD_POS CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR CC_SURFACES_DEBUG_VIEW_WORLD_POS + 1\n#define CC_SURFACES_DEBUG_VIEW_FACE_SIDE CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR + 1\n#define CC_SURFACES_DEBUG_VIEW_UV0 CC_SURFACES_DEBUG_VIEW_FACE_SIDE + 1\n#define CC_SURFACES_DEBUG_VIEW_UV1 CC_SURFACES_DEBUG_VIEW_UV0 + 1\n#define CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP CC_SURFACES_DEBUG_VIEW_UV1 + 1\n#define CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP + 1\n#define CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_BASE_COLOR CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR CC_SURFACES_DEBUG_VIEW_BASE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSPARENCY CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_METALLIC CC_SURFACES_DEBUG_VIEW_TRANSPARENCY + 1\n#define CC_SURFACES_DEBUG_VIEW_ROUGHNESS CC_SURFACES_DEBUG_VIEW_METALLIC + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY CC_SURFACES_DEBUG_VIEW_ROUGHNESS + 1\n#define CC_SURFACES_DEBUG_VIEW_IOR CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_IOR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_ALL CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_DIRECT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_ALL CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_EMISSIVE CC_SURFACES_DEBUG_VIEW_ENV_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_LIGHT_MAP CC_SURFACES_DEBUG_VIEW_EMISSIVE + 1\n#define CC_SURFACES_DEBUG_VIEW_SHADOW CC_SURFACES_DEBUG_VIEW_LIGHT_MAP + 1\n#define CC_SURFACES_DEBUG_VIEW_AO CC_SURFACES_DEBUG_VIEW_SHADOW + 1\n#define CC_SURFACES_DEBUG_VIEW_FRESNEL CC_SURFACES_DEBUG_VIEW_AO + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_FRESNEL + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_FOG CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL + 1\n#define IS_DEBUG_VIEW_ENABLE_WITH_CAMERA (cc_surfaceTransform.y != 3.0)\n#define IS_DEBUG_VIEW_LIGHTING_ENABLE_WITH_ALBEDO (UnpackBitFromFloat(cc_debug_view_mode.w, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_MISC_ENABLE_CSM_LAYER_COLORATION (UnpackBitFromFloat(cc_debug_view_mode.w, 7) && IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_EMISSIVE (UnpackBitFromFloat(cc_debug_view_mode.y, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_LIGHT_MAP (UnpackBitFromFloat(cc_debug_view_mode.y, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_SHADOW (UnpackBitFromFloat(cc_debug_view_mode.y, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_AO (UnpackBitFromFloat(cc_debug_view_mode.y, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_NORMAL_MAP (UnpackBitFromFloat(cc_debug_view_mode.z, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FOG (UnpackBitFromFloat(cc_debug_view_mode.z, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TONE_MAPPING (UnpackBitFromFloat(cc_debug_view_mode.z, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION (UnpackBitFromFloat(cc_debug_view_mode.z, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FRESNEL (UnpackBitFromFloat(cc_debug_view_mode.z, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.z, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_2ND_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TT (UnpackBitFromFloat(cc_debug_view_mode.w, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#if (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\n #if CC_FORWARD_ADD\n #if CC_PIPELINE_TYPE == 0\n #define LIGHTS_PER_PASS 1\n #else\n #define LIGHTS_PER_PASS 10\n #endif\n #if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\n layout(set = 2, binding = 1) uniform CCForwardLight {\n highp vec4 cc_lightPos[LIGHTS_PER_PASS];\n vec4 cc_lightColor[LIGHTS_PER_PASS];\n vec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\n vec4 cc_lightDir[LIGHTS_PER_PASS];\n vec4 cc_lightBoundingSizeVS[LIGHTS_PER_PASS];\n };\n #endif\n #endif\n#endif\n#if CC_USE_LIGHT_PROBE\n #if !USE_INSTANCING\n layout(set = 2, binding = 6) uniform CCSH {\n vec4 cc_sh_linear_const_r;\n vec4 cc_sh_linear_const_g;\n vec4 cc_sh_linear_const_b;\n vec4 cc_sh_quadratic_r;\n vec4 cc_sh_quadratic_g;\n vec4 cc_sh_quadratic_b;\n vec4 cc_sh_quadratic_a;\n };\n #endif\n#endif\nlayout(set = 0, binding = 2) uniform CCShadow {\n highp mat4 cc_matLightView;\n highp mat4 cc_matLightViewProj;\n highp vec4 cc_shadowInvProjDepthInfo;\n highp vec4 cc_shadowProjDepthInfo;\n highp vec4 cc_shadowProjInfo;\n mediump vec4 cc_shadowNFLSInfo;\n mediump vec4 cc_shadowWHPBInfo;\n mediump vec4 cc_shadowLPNNInfo;\n lowp vec4 cc_shadowColor;\n mediump vec4 cc_planarNDInfo;\n};\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n layout(set = 0, binding = 3) uniform CCCSM {\n highp vec4 cc_csmViewDir0[4];\n highp vec4 cc_csmViewDir1[4];\n highp vec4 cc_csmViewDir2[4];\n highp vec4 cc_csmAtlas[4];\n highp mat4 cc_matCSMViewProj[4];\n highp vec4 cc_csmProjDepthInfo[4];\n highp vec4 cc_csmProjInfo[4];\n highp vec4 cc_csmSplitsInfo;\n };\n#endif\nlayout(set = 0, binding = 5) uniform samplerCube cc_environment;\n#if CC_USE_IBL\n #if CC_USE_DIFFUSEMAP\n layout(set = 0, binding = 7) uniform samplerCube cc_diffuseMap;\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n layout(set = 2, binding = 15) uniform samplerCube cc_reflectionProbeCubemap;\n layout(set = 2, binding = 16) uniform sampler2D cc_reflectionProbePlanarMap;\n layout(set = 2, binding = 17) uniform sampler2D cc_reflectionProbeDataMap;\n layout(set = 2, binding = 18) uniform samplerCube cc_reflectionProbeBlendCubemap;\n#endif\n#define UnpackBitFromFloat(value, bit) (mod(floor(value / pow(10.0, float(bit))), 10.0) > 0.0)\nvec4 packRGBE (vec3 rgb) {\n highp float maxComp = max(max(rgb.r, rgb.g), rgb.b);\n highp float e = 128.0;\n if (maxComp > 0.0001) {\n e = log(maxComp) / log(1.1);\n e = ceil(e);\n e = clamp(e + 128.0, 0.0, 255.0);\n }\n highp float sc = 1.0 / pow(1.1, e - 128.0);\n vec3 encode = clamp(rgb * sc, vec3(0.0), vec3(1.0)) * 255.0;\n vec3 encode_rounded = floor(encode) + step(encode - floor(encode), vec3(0.5));\n return vec4(encode_rounded, e) / 255.0;\n}\nvec3 SRGBToLinear (vec3 gamma) {\n#ifdef CC_USE_SURFACE_SHADER\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION) {\n return gamma;\n }\n #endif\n#endif\n return gamma * gamma;\n}\nvec3 LinearToSRGB(vec3 linear) {\n#ifdef CC_USE_SURFACE_SHADER\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION) {\n return linear;\n }\n #endif\n#endif\n return sqrt(linear);\n}\n#if defined(CC_USE_METAL) || defined(CC_USE_WGPU)\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y) y = -y\n#else\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y)\n#endif\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n#endif\n#if CC_RECEIVE_SHADOW\n layout(set = 0, binding = 4) uniform highp sampler2D cc_shadowMap;\n layout(set = 0, binding = 6) uniform highp sampler2D cc_spotShadowMap;\n #if CC_SUPPORT_CASCADED_SHADOW_MAP\n #else\n #endif\n#endif\n#if CC_USE_FOG != 4\n#endif\n#if CC_USE_LIGHT_PROBE\n #if CC_USE_LIGHT_PROBE\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n layout(set = 2, binding = 0) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n highp vec4 cc_localShadowBias;\n highp vec4 cc_reflectionProbeData1;\n highp vec4 cc_reflectionProbeData2;\n highp vec4 cc_reflectionProbeBlendData1;\n highp vec4 cc_reflectionProbeBlendData2;\n };\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n layout(set = 2, binding = 11) uniform sampler2D cc_lightingMap;\n#endif\nlayout(set = 1, binding = 1) uniform OutlineFrag {\n vec4 baseColor;\n};\n#if USE_BASE_COLOR_MAP\n layout(set = 1, binding = 2) uniform sampler2D baseColorMap;\n#endif\n#define CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TRANSPARENCY\nvec4 SurfacesFragmentModifyBaseColorAndTransparency()\n{\n vec4 color = vec4(cc_mainLitColor.rgb, 1.0);\n color.rgb = SRGBToLinear(baseColor.rgb);\n #if USE_BASE_COLOR_MAP\n vec4 texColor = texture(baseColorMap, FSInput_texcoord);\n texColor.rgb = SRGBToLinear(texColor.rgb);\n color *= texColor;\n #endif\n return color;\n}\nlayout(location = 0) out vec4 fragColorX;\nvoid main () {\n vec4 color = SurfacesFragmentModifyBaseColorAndTransparency();\n #if CC_USE_RGBE_OUTPUT\n color = packRGBE(color.rgb);\n #elif !CC_USE_FLOAT_OUTPUT\n color.rgb = LinearToSRGB(color.rgb);\n #endif\n fragColorX = color;\n}"
- },
- "glsl3": {
- "vert": "\nprecision highp float;\n#define CC_SURFACES_USE_TANGENT_SPACE 0\n#define CC_SURFACES_USE_VERTEX_COLOR 0\n#define CC_SURFACES_USE_SECOND_UV 0\n#define CC_SURFACES_USE_LIGHT_MAP 0\n#define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\n#if CC_SURFACES_USE_TANGENT_SPACE\n in vec4 a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n in vec4 a_color;\n#endif\n#if CC_SURFACES_USE_SECOND_UV || CC_USE_LIGHTMAP\n in vec2 a_texCoord1;\n#endif\n#if CC_USE_SKINNING\n in vec4 a_joints;\n in vec4 a_weights;\n#endif\n#if USE_INSTANCING\n #if CC_USE_BAKED_ANIMATION\n in highp vec4 a_jointAnimInfo;\n #endif\n in vec4 a_matWorld0;\n in vec4 a_matWorld1;\n in vec4 a_matWorld2;\n #if CC_USE_LIGHTMAP\n in vec4 a_lightingMapUVParam;\n #endif\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n in vec4 a_localShadowBiasAndProbeId;\n #endif\n #if CC_USE_REFLECTION_PROBE\n in vec4 a_reflectionProbeData;\n #endif\n #if CC_USE_LIGHT_PROBE\n in vec4 a_sh_linear_const_r;\n in vec4 a_sh_linear_const_g;\n in vec4 a_sh_linear_const_b;\n #endif\n#endif\n#if CC_USE_MORPH\n in float a_vertexId;\n#endif\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nout highp vec3 v_worldPos;\nout vec4 v_normal;\nout vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n out lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n out mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n out mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n out mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n out mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n out mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n out mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n out highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n out highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n out mediump vec4 v_sh_linear_const_r;\n out mediump vec4 v_sh_linear_const_g;\n out mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define VSOutput_worldPos v_worldPos\n#define VSOutput_worldNormal v_normal.xyz\n#define VSOutput_faceSideSign v_normal.w\n#define VSOutput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define VSOutput_vertexColor v_color\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define VSOutput_worldTangent v_tangent.xyz\n #define VSOutput_mirrorNormal v_tangent.w\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define VSOutput_texcoord1 v_uv1\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define VSOutput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define VSOutput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define VSOutput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define VSOutput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define VSOutput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define VSOutput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define VSOutput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define VSOutput_clipPos v_clipPos\n#endif\nstruct SurfacesStandardVertexIntermediate\n{\n highp vec4 position;\n vec3 normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n vec4 tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n vec4 color;\n#endif\n vec2 texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n vec2 texCoord1;\n#endif\n highp vec4 clipPos;\n highp vec3 worldPos;\n vec4 worldNormal;\n #if CC_SURFACES_USE_TANGENT_SPACE\n vec3 worldTangent, worldBinormal;\n #endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n vec4 shadowBiasAndProbeId;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n float fogFactor;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n vec3 lightmapUV;\n#endif\n};\n#if CC_USE_MORPH\n int getVertexId() {\n return int(a_vertexId);\n }\n#endif\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightView;\n highp mat4 cc_matLightViewProj;\n highp vec4 cc_shadowInvProjDepthInfo;\n highp vec4 cc_shadowProjDepthInfo;\n highp vec4 cc_shadowProjInfo;\n mediump vec4 cc_shadowNFLSInfo;\n mediump vec4 cc_shadowWHPBInfo;\n mediump vec4 cc_shadowLPNNInfo;\n lowp vec4 cc_shadowColor;\n mediump vec4 cc_planarNDInfo;\n};\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\n#if !USE_INSTANCING\n layout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n highp vec4 cc_localShadowBias;\n highp vec4 cc_reflectionProbeData1;\n highp vec4 cc_reflectionProbeData2;\n highp vec4 cc_reflectionProbeBlendData1;\n highp vec4 cc_reflectionProbeBlendData2;\n };\n#endif\nvoid CCGetWorldMatrixFull(out mat4 matWorld, out mat4 matWorldIT)\n{\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n vec3 scale = 1.0 / vec3(length(a_matWorld0.xyz), length(a_matWorld1.xyz), length(a_matWorld2.xyz));\n vec3 scale2 = scale * scale;\n matWorldIT = mat4(\n vec4(a_matWorld0.xyz * scale2.x, 0.0),\n vec4(a_matWorld1.xyz * scale2.y, 0.0),\n vec4(a_matWorld2.xyz * scale2.z, 0.0),\n vec4(0.0, 0.0, 0.0, 1.0)\n );\n #else\n matWorld = cc_matWorld;\n matWorldIT = cc_matWorldIT;\n #endif\n}\n#if CC_USE_MORPH\n layout(std140) uniform CCMorph {\n vec4 cc_displacementWeights[15];\n vec4 cc_displacementTextureInfo;\n };\n #if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n #endif\n vec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n }\n vec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n }\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\n ivec2 texSize = textureSize(tex, 0);\n return texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n }\n #else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture(tex, x)),\n decode32(texture(tex, y)),\n decode32(texture(tex, z)),\n 1.0\n );\n }\n #endif\n float getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n }\n vec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n #if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n #else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n #endif\n }\n #if CC_MORPH_TARGET_HAS_POSITION\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n #endif\n void applyMorph (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n int vertexId = getVertexId();\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n normal.xyz = normal.xyz + getNormalDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n tangent.xyz = tangent.xyz + getTangentDisplacement(vertexId);\n #endif\n }\n void applyMorph (inout vec4 position) {\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n #endif\n }\n#endif\n#if CC_USE_SKINNING\n #if CC_USE_BAKED_ANIMATION\n layout(std140) uniform CCSkinningTexture {\n highp vec4 cc_jointTextureInfo;\n };\n layout(std140) uniform CCSkinningAnimation {\n highp vec4 cc_jointAnimInfo;\n };\n uniform highp sampler2D cc_jointTexture;\n void CCGetJointTextureCoords(float pixelsPerJoint, float jointIdx, out highp float x, out highp float y, out highp float invSize)\n {\n #if USE_INSTANCING\n highp float temp = pixelsPerJoint * (a_jointAnimInfo.x * a_jointAnimInfo.y + jointIdx) + a_jointAnimInfo.z;\n #else\n highp float temp = pixelsPerJoint * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + jointIdx) + cc_jointTextureInfo.z;\n #endif\n invSize = cc_jointTextureInfo.w;\n highp float tempY = floor(temp * invSize);\n x = floor(temp - tempY * cc_jointTextureInfo.x);\n y = (tempY + 0.5) * invSize;\n }\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n uniform highp sampler2D cc_realtimeJoint;\n #else\n layout(std140) uniform CCSkinning {\n highp vec4 cc_joints[CC_JOINT_UNIFORM_CAPACITY * 3];\n };\n #endif\n #endif\n #if CC_USE_BAKED_ANIMATION\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(3.0, i, x, y, invSize);\n vec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(12.0, i, x, y, invSize);\n vec4 v1 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n float x = i;\n vec4 v1 = texture(cc_realtimeJoint, vec2( x / 256.0, 0.5 / 3.0));\n vec4 v2 = texture(cc_realtimeJoint, vec2( x / 256.0, 1.5 / 3.0));\n vec4 v3 = texture(cc_realtimeJoint, vec2( x / 256.0, 2.5 / 3.0));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n float x = 4.0 * i;\n vec4 v1 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 0.5 / 3.0)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 1.5 / 3.0)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 2.5 / 3.0)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #endif\n mat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n }\n void CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n }\n void CCSkin (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n mat4 m = skinMatrix();\n position = m * position;\n normal = (m * vec4(normal, 0.0)).xyz;\n tangent.xyz = (m * vec4(tangent.xyz, 0.0)).xyz;\n }\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #if CC_USE_FOG != 4\n float LinearFog(vec4 pos, vec3 cameraPos, float fogStart, float fogEnd) {\n vec4 wPos = pos;\n float cam_dis = distance(cameraPos, wPos.xyz);\n return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n }\n float ExpFog(vec4 pos, vec3 cameraPos, float fogStart, float fogDensity, float fogAtten) {\n vec4 wPos = pos;\n float cam_dis = max(distance(cameraPos, wPos.xyz) - fogStart, 0.0) / fogAtten * 4.;\n float f = exp(-cam_dis * fogDensity);\n return f;\n }\n float ExpSquaredFog(vec4 pos, vec3 cameraPos, float fogStart, float fogDensity, float fogAtten) {\n vec4 wPos = pos;\n float cam_dis = max(distance(cameraPos, wPos.xyz) - fogStart, 0.0) / fogAtten * 4.;\n float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\n return f;\n }\n float LayeredFog(vec4 pos, vec3 cameraPos, float fogTop, float fogRange, float fogAtten) {\n vec4 wPos = pos;\n vec3 camWorldProj = cameraPos.xyz;\n camWorldProj.y = 0.;\n vec3 worldPosProj = wPos.xyz;\n worldPosProj.y = 0.;\n float fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\n float fDeltaY, fDensityIntegral;\n if (cameraPos.y > fogTop) {\n if (wPos.y < fogTop) {\n fDeltaY = (fogTop - wPos.y) / fogRange * 2.0;\n fDensityIntegral = fDeltaY * fDeltaY * 0.5;\n }\n else {\n fDeltaY = 0.;\n fDensityIntegral = 0.;\n }\n }\n else {\n if (wPos.y < fogTop) {\n float fDeltaA = (fogTop - cameraPos.y) / fogRange * 2.;\n float fDeltaB = (fogTop - wPos.y) / fogRange * 2.;\n fDeltaY = abs(fDeltaA - fDeltaB);\n fDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n }\n else {\n fDeltaY = abs(fogTop - cameraPos.y) / fogRange * 2.;\n fDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n }\n }\n float fDensity;\n if (fDeltaY != 0.) {\n fDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n }\n else {\n fDensity = 0.;\n }\n float f = exp(-fDensity);\n return f;\n }\n #endif\n void CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n {\n #if CC_USE_FOG == 0\n \tfactor = LinearFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.y);\n #elif CC_USE_FOG == 1\n \tfactor = ExpFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z);\n #elif CC_USE_FOG == 2\n \tfactor = ExpSquaredFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z);\n #elif CC_USE_FOG == 3\n \tfactor = LayeredFog(pos, cc_cameraPos.xyz, cc_fogAdd.x, cc_fogAdd.y, cc_fogAdd.z);\n #else\n \tfactor = 1.0;\n #endif\n }\n#endif\n layout(std140) uniform OutlineVert {\n vec4 outlineParams;\n};\n #define CC_SURFACES_VERTEX_MODIFY_LOCAL_POS\n vec3 SurfacesVertexModifyLocalPos(in SurfacesStandardVertexIntermediate In)\n {\n float width = outlineParams.x * 0.001;\n vec3 localPos = In.position.xyz;\n #if USE_POSITION_SCALING\n vec3 dir = normalize(localPos);\n float flip = dot(dir, normalize(In.normal)) < 0.0 ? -1.0 : 1.0;\n localPos += flip * dir * width * 2.0;\n #else\n localPos += normalize(In.normal) * width;\n #endif\n return localPos;\n }\n #define CC_SURFACES_VERTEX_MODIFY_CLIP_POS\n vec4 SurfacesVertexModifyClipPos(in SurfacesStandardVertexIntermediate In)\n {\n vec4 clipPos = In.clipPos;\n float scaleZ = cc_nearFar.z == 0.0 ? 0.5 : 1.0;\n clipPos.z -= outlineParams.y * 0.002 * scaleZ;\n return clipPos;\n }\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_POS\nvec3 SurfacesVertexModifyLocalPos(in SurfacesStandardVertexIntermediate In)\n{\n return vec3(In.position.xyz);\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_NORMAL\nvec3 SurfacesVertexModifyLocalNormal(in SurfacesStandardVertexIntermediate In)\n{\n return In.normal.xyz;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_TANGENT\n #if CC_SURFACES_USE_TANGENT_SPACE\n vec4 SurfacesVertexModifyLocalTangent(in SurfacesStandardVertexIntermediate In)\n {\n return In.tangent;\n }\n #endif\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_SHARED_DATA\nvoid SurfacesVertexModifyLocalSharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_POS\nvec3 SurfacesVertexModifyWorldPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.worldPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_CLIP_POS\nvec4 SurfacesVertexModifyClipPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.clipPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_UV\nvoid SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_NORMAL\nvec3 SurfacesVertexModifyWorldNormal(in SurfacesStandardVertexIntermediate In)\n{\n vec3 worldNormal = In.worldNormal.xyz;\n #if CC_SURFACES_USE_TWO_SIDED\n worldNormal.xyz *= In.worldNormal.w;\n #endif\n return worldNormal;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHADOW_BIAS\nvec2 SurfacesVertexModifyShadowBias(in SurfacesStandardVertexIntermediate In, vec2 originShadowBias)\n{\n return originShadowBias;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHARED_DATA\nvoid SurfacesVertexModifySharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\nvoid CCSurfacesVertexInput(out SurfacesStandardVertexIntermediate In)\n{\n In.position = vec4(a_position, 1.0);\n In.normal = a_normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n In.tangent = a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n In.color = a_color;\n#endif\n In.texCoord = a_texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = a_texCoord1;\n#endif\n}\nvoid CCSurfacesVertexOutput(in SurfacesStandardVertexIntermediate In)\n{\n gl_Position = In.clipPos;\n VSOutput_worldNormal = In.worldNormal.xyz;\n VSOutput_faceSideSign = In.worldNormal.w;\n VSOutput_worldPos = In.worldPos;\n#if CC_SURFACES_USE_TANGENT_SPACE\n VSOutput_worldTangent = In.worldTangent.xyz;\n VSOutput_mirrorNormal = In.tangent.w > 0.0 ? 1.0 : -1.0;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n VSOutput_vertexColor = In.color;\n#endif\n VSOutput_texcoord = In.texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n VSOutput_texcoord1 = In.texCoord1;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n VSOutput_fogFactor = In.fogFactor;\n#endif\n#if CC_RECEIVE_SHADOW\n VSOutput_shadowBias = In.shadowBiasAndProbeId.xy;\n#endif\n#if CC_USE_REFLECTION_PROBE\n VSOutput_reflectionProbeId = In.shadowBiasAndProbeId.z;\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n VSOutput_reflectionProbeBlendId = In.shadowBiasAndProbeId.w;\n #endif\n #if USE_INSTANCING\n v_reflectionProbeData = a_reflectionProbeData;\n #endif\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n VSOutput_lightMapUV = In.lightmapUV;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n VSOutput_localPos = In.position;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n VSOutput_clipPos = In.clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n v_sh_linear_const_r = a_sh_linear_const_r;\n v_sh_linear_const_g = a_sh_linear_const_g;\n v_sh_linear_const_b = a_sh_linear_const_b;\n #endif\n#endif\n}\nvoid CCSurfacesVertexAnimation(inout SurfacesStandardVertexIntermediate In)\n{\nvec4 temp = vec4(0.0);\n#if CC_USE_MORPH\n #if CC_SURFACES_USE_TANGENT_SPACE\n applyMorph(In.position, In.normal, In.tangent);\n #else\n applyMorph(In.position, In.normal, temp);\n #endif\n#endif\n#if CC_USE_SKINNING\n #if CC_SURFACES_USE_TANGENT_SPACE\n CCSkin(In.position, In.normal, In.tangent);\n #else\n CCSkin(In.position, In.normal, temp);\n #endif\n#endif\n}\nvoid CCSurfacesVertexWorldTransform(inout SurfacesStandardVertexIntermediate In)\n{\n mat4 matWorld, matWorldIT;\n CCGetWorldMatrixFull(matWorld, matWorldIT);\n In.worldPos = (matWorld * In.position).xyz;\n In.worldNormal.xyz = normalize((matWorldIT * vec4(In.normal.xyz, 0.0)).xyz);\n #if CC_SURFACES_USE_TANGENT_SPACE\n In.worldTangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\n In.worldBinormal = cross(In.worldNormal.xyz, In.worldTangent) * In.tangent.w;\n #endif\n}\nvoid CCSurfacesVertexTransformUV(inout SurfacesStandardVertexIntermediate In)\n{\n #if CC_SURFACES_FLIP_UV\n In.texCoord = cc_cameraPos.w > 1.0 ? vec2(In.texCoord.x, 1.0 - In.texCoord.y) : In.texCoord;\n #if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = cc_cameraPos.w > 1.0 ? vec2(In.texCoord1.x, 1.0 - In.texCoord1.y) : In.texCoord1;\n #endif\n #endif\n}\nvoid CCSurfacesVertexTransferFog(inout SurfacesStandardVertexIntermediate In)\n{\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n CC_TRANSFER_FOG_BASE(vec4(In.worldPos, 1.0), In.fogFactor);\n#endif\n}\nvoid CCSurfacesVertexTransferShadow(inout SurfacesStandardVertexIntermediate In)\n{\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n In.shadowBiasAndProbeId = vec4(0.0);\n #endif\n #if CC_RECEIVE_SHADOW\n In.shadowBiasAndProbeId.xy = vec2(cc_shadowWHPBInfo.w, cc_shadowLPNNInfo.z);\n #if USE_INSTANCING\n In.shadowBiasAndProbeId.xy += a_localShadowBiasAndProbeId.xy;\n #else\n In.shadowBiasAndProbeId.xy += cc_localShadowBias.xy;\n #endif\n #endif\n #if CC_USE_REFLECTION_PROBE\n #if USE_INSTANCING\n In.shadowBiasAndProbeId.zw = a_localShadowBiasAndProbeId.zw;\n #else\n In.shadowBiasAndProbeId.zw = cc_localShadowBias.zw;\n #endif\n #endif\n}\nvoid CCSurfacesVertexTransferLightMapUV(inout SurfacesStandardVertexIntermediate In)\n{\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #if USE_INSTANCING\n In.lightmapUV.xy = a_lightingMapUVParam.xy + a_texCoord1 * a_lightingMapUVParam.z;\n In.lightmapUV.z = a_lightingMapUVParam.w;\n #else\n In.lightmapUV.xy = cc_lightingMapUVParam.xy + a_texCoord1 * cc_lightingMapUVParam.z;\n In.lightmapUV.z = cc_lightingMapUVParam.w;\n #endif\n#endif\n}\nvoid main()\n{\n SurfacesStandardVertexIntermediate In;\n CCSurfacesVertexInput(In);\n CCSurfacesVertexAnimation(In);\n In.position.xyz = SurfacesVertexModifyLocalPos(In);\n In.normal.xyz = SurfacesVertexModifyLocalNormal(In);\n #if CC_SURFACES_USE_TANGENT_SPACE\n In.tangent = SurfacesVertexModifyLocalTangent(In);\n #endif\n SurfacesVertexModifyLocalSharedData(In);\n CCSurfacesVertexWorldTransform(In);\n In.worldPos = SurfacesVertexModifyWorldPos(In);\n In.clipPos = cc_matProj * cc_matView * vec4(In.worldPos, 1.0);\n In.clipPos = SurfacesVertexModifyClipPos(In);\n vec3 viewDirect = normalize(cc_cameraPos.xyz - In.worldPos);\n In.worldNormal.w = dot(In.worldNormal.xyz, viewDirect) < 0.0 ? -1.0 : 1.0;\n In.worldNormal.xyz = SurfacesVertexModifyWorldNormal(In);\n SurfacesVertexModifyUV(In);\n SurfacesVertexModifySharedData(In);\n CCSurfacesVertexTransformUV(In);\n CCSurfacesVertexTransferFog(In);\n CCSurfacesVertexTransferLightMapUV(In);\n CCSurfacesVertexTransferShadow(In);\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n In.shadowBiasAndProbeId.xy = SurfacesVertexModifyShadowBias(In, In.shadowBiasAndProbeId.xy);\n #endif\n CCSurfacesVertexOutput(In);\n}",
- "frag": "\nprecision highp float;\n#define CC_SURFACES_USE_TANGENT_SPACE 0\n#define CC_SURFACES_USE_VERTEX_COLOR 0\n#define CC_SURFACES_USE_SECOND_UV 0\n#define CC_SURFACES_USE_LIGHT_MAP 0\n#define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nin highp vec3 v_worldPos;\nin vec4 v_normal;\nin vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n in lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n in mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n in mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n in mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n in mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n in mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n in mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n in highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n in highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n in mediump vec4 v_sh_linear_const_r;\n in mediump vec4 v_sh_linear_const_g;\n in mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define FSInput_worldPos v_worldPos\n#define FSInput_worldNormal v_normal.xyz\n#define FSInput_faceSideSign v_normal.w\n#define FSInput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define FSInput_vertexColor v_color\n#else\n #define FSInput_vertexColor vec4(1.0)\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define FSInput_worldTangent v_tangent.xyz\n #define FSInput_mirrorNormal v_tangent.w\n#else\n #define FSInput_worldTangent vec3(1.0, 1.0, 1.0)\n #define FSInput_mirrorNormal 1.0\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define FSInput_texcoord1 v_uv1\n#else\n #define FSInput_texcoord1 vec2(0.0, 0.0)\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define FSInput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define FSInput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define FSInput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define FSInput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define FSInput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define FSInput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define FSInput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define FSInput_clipPos v_clipPos\n#endif\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_WORLD_POS CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR CC_SURFACES_DEBUG_VIEW_WORLD_POS + 1\n#define CC_SURFACES_DEBUG_VIEW_FACE_SIDE CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR + 1\n#define CC_SURFACES_DEBUG_VIEW_UV0 CC_SURFACES_DEBUG_VIEW_FACE_SIDE + 1\n#define CC_SURFACES_DEBUG_VIEW_UV1 CC_SURFACES_DEBUG_VIEW_UV0 + 1\n#define CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP CC_SURFACES_DEBUG_VIEW_UV1 + 1\n#define CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP + 1\n#define CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_BASE_COLOR CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR CC_SURFACES_DEBUG_VIEW_BASE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSPARENCY CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_METALLIC CC_SURFACES_DEBUG_VIEW_TRANSPARENCY + 1\n#define CC_SURFACES_DEBUG_VIEW_ROUGHNESS CC_SURFACES_DEBUG_VIEW_METALLIC + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY CC_SURFACES_DEBUG_VIEW_ROUGHNESS + 1\n#define CC_SURFACES_DEBUG_VIEW_IOR CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_IOR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_ALL CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_DIRECT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_ALL CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_EMISSIVE CC_SURFACES_DEBUG_VIEW_ENV_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_LIGHT_MAP CC_SURFACES_DEBUG_VIEW_EMISSIVE + 1\n#define CC_SURFACES_DEBUG_VIEW_SHADOW CC_SURFACES_DEBUG_VIEW_LIGHT_MAP + 1\n#define CC_SURFACES_DEBUG_VIEW_AO CC_SURFACES_DEBUG_VIEW_SHADOW + 1\n#define CC_SURFACES_DEBUG_VIEW_FRESNEL CC_SURFACES_DEBUG_VIEW_AO + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_FRESNEL + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_FOG CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL + 1\n#define IS_DEBUG_VIEW_ENABLE_WITH_CAMERA (cc_surfaceTransform.y != 3.0)\n#define IS_DEBUG_VIEW_LIGHTING_ENABLE_WITH_ALBEDO (UnpackBitFromFloat(cc_debug_view_mode.w, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_MISC_ENABLE_CSM_LAYER_COLORATION (UnpackBitFromFloat(cc_debug_view_mode.w, 7) && IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_EMISSIVE (UnpackBitFromFloat(cc_debug_view_mode.y, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_LIGHT_MAP (UnpackBitFromFloat(cc_debug_view_mode.y, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_SHADOW (UnpackBitFromFloat(cc_debug_view_mode.y, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_AO (UnpackBitFromFloat(cc_debug_view_mode.y, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_NORMAL_MAP (UnpackBitFromFloat(cc_debug_view_mode.z, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FOG (UnpackBitFromFloat(cc_debug_view_mode.z, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TONE_MAPPING (UnpackBitFromFloat(cc_debug_view_mode.z, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION (UnpackBitFromFloat(cc_debug_view_mode.z, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FRESNEL (UnpackBitFromFloat(cc_debug_view_mode.z, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.z, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_2ND_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TT (UnpackBitFromFloat(cc_debug_view_mode.w, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#if (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\n #if CC_FORWARD_ADD\n #if CC_PIPELINE_TYPE == 0\n #define LIGHTS_PER_PASS 1\n #else\n #define LIGHTS_PER_PASS 10\n #endif\n #if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\n layout(std140) uniform CCForwardLight {\n highp vec4 cc_lightPos[LIGHTS_PER_PASS];\n vec4 cc_lightColor[LIGHTS_PER_PASS];\n vec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\n vec4 cc_lightDir[LIGHTS_PER_PASS];\n vec4 cc_lightBoundingSizeVS[LIGHTS_PER_PASS];\n };\n #endif\n #endif\n#endif\n#if CC_USE_LIGHT_PROBE\n #if !USE_INSTANCING\n layout(std140) uniform CCSH {\n vec4 cc_sh_linear_const_r;\n vec4 cc_sh_linear_const_g;\n vec4 cc_sh_linear_const_b;\n vec4 cc_sh_quadratic_r;\n vec4 cc_sh_quadratic_g;\n vec4 cc_sh_quadratic_b;\n vec4 cc_sh_quadratic_a;\n };\n #endif\n#endif\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightView;\n highp mat4 cc_matLightViewProj;\n highp vec4 cc_shadowInvProjDepthInfo;\n highp vec4 cc_shadowProjDepthInfo;\n highp vec4 cc_shadowProjInfo;\n mediump vec4 cc_shadowNFLSInfo;\n mediump vec4 cc_shadowWHPBInfo;\n mediump vec4 cc_shadowLPNNInfo;\n lowp vec4 cc_shadowColor;\n mediump vec4 cc_planarNDInfo;\n};\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n layout(std140) uniform CCCSM {\n highp vec4 cc_csmViewDir0[4];\n highp vec4 cc_csmViewDir1[4];\n highp vec4 cc_csmViewDir2[4];\n highp vec4 cc_csmAtlas[4];\n highp mat4 cc_matCSMViewProj[4];\n highp vec4 cc_csmProjDepthInfo[4];\n highp vec4 cc_csmProjInfo[4];\n highp vec4 cc_csmSplitsInfo;\n };\n#endif\nuniform samplerCube cc_environment;\n#if CC_USE_IBL\n #if CC_USE_DIFFUSEMAP\n uniform samplerCube cc_diffuseMap;\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n uniform samplerCube cc_reflectionProbeCubemap;\n uniform sampler2D cc_reflectionProbePlanarMap;\n uniform sampler2D cc_reflectionProbeDataMap;\n uniform samplerCube cc_reflectionProbeBlendCubemap;\n#endif\n#define UnpackBitFromFloat(value, bit) (mod(floor(value / pow(10.0, float(bit))), 10.0) > 0.0)\nvec4 packRGBE (vec3 rgb) {\n highp float maxComp = max(max(rgb.r, rgb.g), rgb.b);\n highp float e = 128.0;\n if (maxComp > 0.0001) {\n e = log(maxComp) / log(1.1);\n e = ceil(e);\n e = clamp(e + 128.0, 0.0, 255.0);\n }\n highp float sc = 1.0 / pow(1.1, e - 128.0);\n vec3 encode = clamp(rgb * sc, vec3(0.0), vec3(1.0)) * 255.0;\n vec3 encode_rounded = floor(encode) + step(encode - floor(encode), vec3(0.5));\n return vec4(encode_rounded, e) / 255.0;\n}\nvec3 SRGBToLinear (vec3 gamma) {\n#ifdef CC_USE_SURFACE_SHADER\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION) {\n return gamma;\n }\n #endif\n#endif\n return gamma * gamma;\n}\nvec3 LinearToSRGB(vec3 linear) {\n#ifdef CC_USE_SURFACE_SHADER\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION) {\n return linear;\n }\n #endif\n#endif\n return sqrt(linear);\n}\n#if defined(CC_USE_METAL) || defined(CC_USE_WGPU)\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y) y = -y\n#else\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y)\n#endif\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n#endif\n#if CC_RECEIVE_SHADOW\n uniform highp sampler2D cc_shadowMap;\n uniform highp sampler2D cc_spotShadowMap;\n #if CC_SUPPORT_CASCADED_SHADOW_MAP\n #else\n #endif\n#endif\n#if CC_USE_FOG != 4\n#endif\n#if CC_USE_LIGHT_PROBE\n #if CC_USE_LIGHT_PROBE\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n layout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n highp vec4 cc_localShadowBias;\n highp vec4 cc_reflectionProbeData1;\n highp vec4 cc_reflectionProbeData2;\n highp vec4 cc_reflectionProbeBlendData1;\n highp vec4 cc_reflectionProbeBlendData2;\n };\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n uniform sampler2D cc_lightingMap;\n#endif\nlayout(std140) uniform OutlineFrag {\n vec4 baseColor;\n};\n#if USE_BASE_COLOR_MAP\n uniform sampler2D baseColorMap;\n#endif\n#define CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TRANSPARENCY\nvec4 SurfacesFragmentModifyBaseColorAndTransparency()\n{\n vec4 color = vec4(cc_mainLitColor.rgb, 1.0);\n color.rgb = SRGBToLinear(baseColor.rgb);\n #if USE_BASE_COLOR_MAP\n vec4 texColor = texture(baseColorMap, FSInput_texcoord);\n texColor.rgb = SRGBToLinear(texColor.rgb);\n color *= texColor;\n #endif\n return color;\n}\nlayout(location = 0) out vec4 fragColorX;\nvoid main () {\n vec4 color = SurfacesFragmentModifyBaseColorAndTransparency();\n #if CC_USE_RGBE_OUTPUT\n color = packRGBE(color.rgb);\n #elif !CC_USE_FLOAT_OUTPUT\n color.rgb = LinearToSRGB(color.rgb);\n #endif\n fragColorX = color;\n}"
- },
- "glsl1": {
- "vert": "\nprecision highp float;\n#define CC_SURFACES_USE_TANGENT_SPACE 0\n#define CC_SURFACES_USE_VERTEX_COLOR 0\n#define CC_SURFACES_USE_SECOND_UV 0\n#define CC_SURFACES_USE_LIGHT_MAP 0\n#define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\n#if CC_SURFACES_USE_TANGENT_SPACE\n attribute vec4 a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n attribute vec4 a_color;\n#endif\n#if CC_SURFACES_USE_SECOND_UV || CC_USE_LIGHTMAP\n attribute vec2 a_texCoord1;\n#endif\n#if CC_USE_SKINNING\n attribute vec4 a_joints;\n attribute vec4 a_weights;\n#endif\n#if USE_INSTANCING\n #if CC_USE_BAKED_ANIMATION\n attribute highp vec4 a_jointAnimInfo;\n #endif\n attribute vec4 a_matWorld0;\n attribute vec4 a_matWorld1;\n attribute vec4 a_matWorld2;\n #if CC_USE_LIGHTMAP\n attribute vec4 a_lightingMapUVParam;\n #endif\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n attribute vec4 a_localShadowBiasAndProbeId;\n #endif\n #if CC_USE_REFLECTION_PROBE\n attribute vec4 a_reflectionProbeData;\n #endif\n #if CC_USE_LIGHT_PROBE\n attribute vec4 a_sh_linear_const_r;\n attribute vec4 a_sh_linear_const_g;\n attribute vec4 a_sh_linear_const_b;\n #endif\n#endif\n#if CC_USE_MORPH\n attribute float a_vertexId;\n#endif\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nvarying highp vec3 v_worldPos;\nvarying vec4 v_normal;\nvarying vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n varying lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n varying mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n varying mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n varying mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n varying mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n varying mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n varying mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n varying highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n varying highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n varying mediump vec4 v_sh_linear_const_r;\n varying mediump vec4 v_sh_linear_const_g;\n varying mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define VSOutput_worldPos v_worldPos\n#define VSOutput_worldNormal v_normal.xyz\n#define VSOutput_faceSideSign v_normal.w\n#define VSOutput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define VSOutput_vertexColor v_color\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define VSOutput_worldTangent v_tangent.xyz\n #define VSOutput_mirrorNormal v_tangent.w\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define VSOutput_texcoord1 v_uv1\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define VSOutput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define VSOutput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define VSOutput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define VSOutput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define VSOutput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define VSOutput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define VSOutput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define VSOutput_clipPos v_clipPos\n#endif\nstruct SurfacesStandardVertexIntermediate\n{\n highp vec4 position;\n vec3 normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n vec4 tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n vec4 color;\n#endif\n vec2 texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n vec2 texCoord1;\n#endif\n highp vec4 clipPos;\n highp vec3 worldPos;\n vec4 worldNormal;\n #if CC_SURFACES_USE_TANGENT_SPACE\n vec3 worldTangent, worldBinormal;\n #endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n vec4 shadowBiasAndProbeId;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n float fogFactor;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n vec3 lightmapUV;\n#endif\n};\n#if CC_USE_MORPH\n int getVertexId() {\n return int(a_vertexId);\n }\n#endif\nuniform highp mat4 cc_matView;\n uniform highp mat4 cc_matProj;\n uniform highp vec4 cc_cameraPos;\n uniform mediump vec4 cc_fogBase;\n uniform mediump vec4 cc_fogAdd;\n uniform mediump vec4 cc_nearFar;\nuniform mediump vec4 cc_shadowWHPBInfo;\n uniform mediump vec4 cc_shadowLPNNInfo;\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\n#if !USE_INSTANCING\n uniform highp mat4 cc_matWorld;\n uniform highp mat4 cc_matWorldIT;\n uniform highp vec4 cc_lightingMapUVParam;\n uniform highp vec4 cc_localShadowBias;\n#endif\nvoid CCGetWorldMatrixFull(out mat4 matWorld, out mat4 matWorldIT)\n{\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n vec3 scale = 1.0 / vec3(length(a_matWorld0.xyz), length(a_matWorld1.xyz), length(a_matWorld2.xyz));\n vec3 scale2 = scale * scale;\n matWorldIT = mat4(\n vec4(a_matWorld0.xyz * scale2.x, 0.0),\n vec4(a_matWorld1.xyz * scale2.y, 0.0),\n vec4(a_matWorld2.xyz * scale2.z, 0.0),\n vec4(0.0, 0.0, 0.0, 1.0)\n );\n #else\n matWorld = cc_matWorld;\n matWorldIT = cc_matWorldIT;\n #endif\n}\n#if CC_USE_MORPH\n uniform vec4 cc_displacementWeights[15];\n uniform vec4 cc_displacementTextureInfo;\n #if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n #endif\n vec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n }\n vec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n }\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\n return texture2D(tex, uv);\n }\n #else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture2D(tex, x)),\n decode32(texture2D(tex, y)),\n decode32(texture2D(tex, z)),\n 1.0\n );\n }\n #endif\n float getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n }\n vec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n #if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n #else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n #endif\n }\n #if CC_MORPH_TARGET_HAS_POSITION\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n #endif\n void applyMorph (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n int vertexId = getVertexId();\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n normal.xyz = normal.xyz + getNormalDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n tangent.xyz = tangent.xyz + getTangentDisplacement(vertexId);\n #endif\n }\n void applyMorph (inout vec4 position) {\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n #endif\n }\n#endif\n#if CC_USE_SKINNING\n #if CC_USE_BAKED_ANIMATION\n uniform highp vec4 cc_jointTextureInfo;\n uniform highp vec4 cc_jointAnimInfo;\n uniform highp sampler2D cc_jointTexture;\n void CCGetJointTextureCoords(float pixelsPerJoint, float jointIdx, out highp float x, out highp float y, out highp float invSize)\n {\n #if USE_INSTANCING\n highp float temp = pixelsPerJoint * (a_jointAnimInfo.x * a_jointAnimInfo.y + jointIdx) + a_jointAnimInfo.z;\n #else\n highp float temp = pixelsPerJoint * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + jointIdx) + cc_jointTextureInfo.z;\n #endif\n invSize = cc_jointTextureInfo.w;\n highp float tempY = floor(temp * invSize);\n x = floor(temp - tempY * cc_jointTextureInfo.x);\n y = (tempY + 0.5) * invSize;\n }\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n uniform highp sampler2D cc_realtimeJoint;\n #else\n uniform highp vec4 cc_joints[CC_JOINT_UNIFORM_CAPACITY * 3];\n #endif\n #endif\n #if CC_USE_BAKED_ANIMATION\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(3.0, i, x, y, invSize);\n vec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(12.0, i, x, y, invSize);\n vec4 v1 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n float x = i;\n vec4 v1 = texture2D(cc_realtimeJoint, vec2( x / 256.0, 0.5 / 3.0));\n vec4 v2 = texture2D(cc_realtimeJoint, vec2( x / 256.0, 1.5 / 3.0));\n vec4 v3 = texture2D(cc_realtimeJoint, vec2( x / 256.0, 2.5 / 3.0));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n float x = 4.0 * i;\n vec4 v1 = vec4(\n decode32(texture2D(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 0.5 / 3.0)))\n );\n vec4 v2 = vec4(\n decode32(texture2D(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 1.5 / 3.0)))\n );\n vec4 v3 = vec4(\n decode32(texture2D(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 2.5 / 3.0)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #endif\n mat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n }\n void CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n }\n void CCSkin (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n mat4 m = skinMatrix();\n position = m * position;\n normal = (m * vec4(normal, 0.0)).xyz;\n tangent.xyz = (m * vec4(tangent.xyz, 0.0)).xyz;\n }\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #if CC_USE_FOG != 4\n float LinearFog(vec4 pos, vec3 cameraPos, float fogStart, float fogEnd) {\n vec4 wPos = pos;\n float cam_dis = distance(cameraPos, wPos.xyz);\n return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n }\n float ExpFog(vec4 pos, vec3 cameraPos, float fogStart, float fogDensity, float fogAtten) {\n vec4 wPos = pos;\n float cam_dis = max(distance(cameraPos, wPos.xyz) - fogStart, 0.0) / fogAtten * 4.;\n float f = exp(-cam_dis * fogDensity);\n return f;\n }\n float ExpSquaredFog(vec4 pos, vec3 cameraPos, float fogStart, float fogDensity, float fogAtten) {\n vec4 wPos = pos;\n float cam_dis = max(distance(cameraPos, wPos.xyz) - fogStart, 0.0) / fogAtten * 4.;\n float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\n return f;\n }\n float LayeredFog(vec4 pos, vec3 cameraPos, float fogTop, float fogRange, float fogAtten) {\n vec4 wPos = pos;\n vec3 camWorldProj = cameraPos.xyz;\n camWorldProj.y = 0.;\n vec3 worldPosProj = wPos.xyz;\n worldPosProj.y = 0.;\n float fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\n float fDeltaY, fDensityIntegral;\n if (cameraPos.y > fogTop) {\n if (wPos.y < fogTop) {\n fDeltaY = (fogTop - wPos.y) / fogRange * 2.0;\n fDensityIntegral = fDeltaY * fDeltaY * 0.5;\n }\n else {\n fDeltaY = 0.;\n fDensityIntegral = 0.;\n }\n }\n else {\n if (wPos.y < fogTop) {\n float fDeltaA = (fogTop - cameraPos.y) / fogRange * 2.;\n float fDeltaB = (fogTop - wPos.y) / fogRange * 2.;\n fDeltaY = abs(fDeltaA - fDeltaB);\n fDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n }\n else {\n fDeltaY = abs(fogTop - cameraPos.y) / fogRange * 2.;\n fDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n }\n }\n float fDensity;\n if (fDeltaY != 0.) {\n fDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n }\n else {\n fDensity = 0.;\n }\n float f = exp(-fDensity);\n return f;\n }\n #endif\n void CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n {\n #if CC_USE_FOG == 0\n \tfactor = LinearFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.y);\n #elif CC_USE_FOG == 1\n \tfactor = ExpFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z);\n #elif CC_USE_FOG == 2\n \tfactor = ExpSquaredFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z);\n #elif CC_USE_FOG == 3\n \tfactor = LayeredFog(pos, cc_cameraPos.xyz, cc_fogAdd.x, cc_fogAdd.y, cc_fogAdd.z);\n #else\n \tfactor = 1.0;\n #endif\n }\n#endif\n uniform vec4 outlineParams;\n #define CC_SURFACES_VERTEX_MODIFY_LOCAL_POS\n vec3 SurfacesVertexModifyLocalPos(in SurfacesStandardVertexIntermediate In)\n {\n float width = outlineParams.x * 0.001;\n vec3 localPos = In.position.xyz;\n #if USE_POSITION_SCALING\n vec3 dir = normalize(localPos);\n float flip = dot(dir, normalize(In.normal)) < 0.0 ? -1.0 : 1.0;\n localPos += flip * dir * width * 2.0;\n #else\n localPos += normalize(In.normal) * width;\n #endif\n return localPos;\n }\n #define CC_SURFACES_VERTEX_MODIFY_CLIP_POS\n vec4 SurfacesVertexModifyClipPos(in SurfacesStandardVertexIntermediate In)\n {\n vec4 clipPos = In.clipPos;\n float scaleZ = cc_nearFar.z == 0.0 ? 0.5 : 1.0;\n clipPos.z -= outlineParams.y * 0.002 * scaleZ;\n return clipPos;\n }\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_POS\nvec3 SurfacesVertexModifyLocalPos(in SurfacesStandardVertexIntermediate In)\n{\n return vec3(In.position.xyz);\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_NORMAL\nvec3 SurfacesVertexModifyLocalNormal(in SurfacesStandardVertexIntermediate In)\n{\n return In.normal.xyz;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_TANGENT\n #if CC_SURFACES_USE_TANGENT_SPACE\n vec4 SurfacesVertexModifyLocalTangent(in SurfacesStandardVertexIntermediate In)\n {\n return In.tangent;\n }\n #endif\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_SHARED_DATA\nvoid SurfacesVertexModifyLocalSharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_POS\nvec3 SurfacesVertexModifyWorldPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.worldPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_CLIP_POS\nvec4 SurfacesVertexModifyClipPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.clipPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_UV\nvoid SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_NORMAL\nvec3 SurfacesVertexModifyWorldNormal(in SurfacesStandardVertexIntermediate In)\n{\n vec3 worldNormal = In.worldNormal.xyz;\n #if CC_SURFACES_USE_TWO_SIDED\n worldNormal.xyz *= In.worldNormal.w;\n #endif\n return worldNormal;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHADOW_BIAS\nvec2 SurfacesVertexModifyShadowBias(in SurfacesStandardVertexIntermediate In, vec2 originShadowBias)\n{\n return originShadowBias;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHARED_DATA\nvoid SurfacesVertexModifySharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\nvoid CCSurfacesVertexInput(out SurfacesStandardVertexIntermediate In)\n{\n In.position = vec4(a_position, 1.0);\n In.normal = a_normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n In.tangent = a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n In.color = a_color;\n#endif\n In.texCoord = a_texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = a_texCoord1;\n#endif\n}\nvoid CCSurfacesVertexOutput(in SurfacesStandardVertexIntermediate In)\n{\n gl_Position = In.clipPos;\n VSOutput_worldNormal = In.worldNormal.xyz;\n VSOutput_faceSideSign = In.worldNormal.w;\n VSOutput_worldPos = In.worldPos;\n#if CC_SURFACES_USE_TANGENT_SPACE\n VSOutput_worldTangent = In.worldTangent.xyz;\n VSOutput_mirrorNormal = In.tangent.w > 0.0 ? 1.0 : -1.0;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n VSOutput_vertexColor = In.color;\n#endif\n VSOutput_texcoord = In.texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n VSOutput_texcoord1 = In.texCoord1;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n VSOutput_fogFactor = In.fogFactor;\n#endif\n#if CC_RECEIVE_SHADOW\n VSOutput_shadowBias = In.shadowBiasAndProbeId.xy;\n#endif\n#if CC_USE_REFLECTION_PROBE\n VSOutput_reflectionProbeId = In.shadowBiasAndProbeId.z;\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n VSOutput_reflectionProbeBlendId = In.shadowBiasAndProbeId.w;\n #endif\n #if USE_INSTANCING\n v_reflectionProbeData = a_reflectionProbeData;\n #endif\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n VSOutput_lightMapUV = In.lightmapUV;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n VSOutput_localPos = In.position;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n VSOutput_clipPos = In.clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n v_sh_linear_const_r = a_sh_linear_const_r;\n v_sh_linear_const_g = a_sh_linear_const_g;\n v_sh_linear_const_b = a_sh_linear_const_b;\n #endif\n#endif\n}\nvoid CCSurfacesVertexAnimation(inout SurfacesStandardVertexIntermediate In)\n{\nvec4 temp = vec4(0.0);\n#if CC_USE_MORPH\n #if CC_SURFACES_USE_TANGENT_SPACE\n applyMorph(In.position, In.normal, In.tangent);\n #else\n applyMorph(In.position, In.normal, temp);\n #endif\n#endif\n#if CC_USE_SKINNING\n #if CC_SURFACES_USE_TANGENT_SPACE\n CCSkin(In.position, In.normal, In.tangent);\n #else\n CCSkin(In.position, In.normal, temp);\n #endif\n#endif\n}\nvoid CCSurfacesVertexWorldTransform(inout SurfacesStandardVertexIntermediate In)\n{\n mat4 matWorld, matWorldIT;\n CCGetWorldMatrixFull(matWorld, matWorldIT);\n In.worldPos = (matWorld * In.position).xyz;\n In.worldNormal.xyz = normalize((matWorldIT * vec4(In.normal.xyz, 0.0)).xyz);\n #if CC_SURFACES_USE_TANGENT_SPACE\n In.worldTangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\n In.worldBinormal = cross(In.worldNormal.xyz, In.worldTangent) * In.tangent.w;\n #endif\n}\nvoid CCSurfacesVertexTransformUV(inout SurfacesStandardVertexIntermediate In)\n{\n #if CC_SURFACES_FLIP_UV\n In.texCoord = cc_cameraPos.w > 1.0 ? vec2(In.texCoord.x, 1.0 - In.texCoord.y) : In.texCoord;\n #if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = cc_cameraPos.w > 1.0 ? vec2(In.texCoord1.x, 1.0 - In.texCoord1.y) : In.texCoord1;\n #endif\n #endif\n}\nvoid CCSurfacesVertexTransferFog(inout SurfacesStandardVertexIntermediate In)\n{\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n CC_TRANSFER_FOG_BASE(vec4(In.worldPos, 1.0), In.fogFactor);\n#endif\n}\nvoid CCSurfacesVertexTransferShadow(inout SurfacesStandardVertexIntermediate In)\n{\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n In.shadowBiasAndProbeId = vec4(0.0);\n #endif\n #if CC_RECEIVE_SHADOW\n In.shadowBiasAndProbeId.xy = vec2(cc_shadowWHPBInfo.w, cc_shadowLPNNInfo.z);\n #if USE_INSTANCING\n In.shadowBiasAndProbeId.xy += a_localShadowBiasAndProbeId.xy;\n #else\n In.shadowBiasAndProbeId.xy += cc_localShadowBias.xy;\n #endif\n #endif\n #if CC_USE_REFLECTION_PROBE\n #if USE_INSTANCING\n In.shadowBiasAndProbeId.zw = a_localShadowBiasAndProbeId.zw;\n #else\n In.shadowBiasAndProbeId.zw = cc_localShadowBias.zw;\n #endif\n #endif\n}\nvoid CCSurfacesVertexTransferLightMapUV(inout SurfacesStandardVertexIntermediate In)\n{\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #if USE_INSTANCING\n In.lightmapUV.xy = a_lightingMapUVParam.xy + a_texCoord1 * a_lightingMapUVParam.z;\n In.lightmapUV.z = a_lightingMapUVParam.w;\n #else\n In.lightmapUV.xy = cc_lightingMapUVParam.xy + a_texCoord1 * cc_lightingMapUVParam.z;\n In.lightmapUV.z = cc_lightingMapUVParam.w;\n #endif\n#endif\n}\nvoid main()\n{\n SurfacesStandardVertexIntermediate In;\n CCSurfacesVertexInput(In);\n CCSurfacesVertexAnimation(In);\n In.position.xyz = SurfacesVertexModifyLocalPos(In);\n In.normal.xyz = SurfacesVertexModifyLocalNormal(In);\n #if CC_SURFACES_USE_TANGENT_SPACE\n In.tangent = SurfacesVertexModifyLocalTangent(In);\n #endif\n SurfacesVertexModifyLocalSharedData(In);\n CCSurfacesVertexWorldTransform(In);\n In.worldPos = SurfacesVertexModifyWorldPos(In);\n In.clipPos = cc_matProj * cc_matView * vec4(In.worldPos, 1.0);\n In.clipPos = SurfacesVertexModifyClipPos(In);\n vec3 viewDirect = normalize(cc_cameraPos.xyz - In.worldPos);\n In.worldNormal.w = dot(In.worldNormal.xyz, viewDirect) < 0.0 ? -1.0 : 1.0;\n In.worldNormal.xyz = SurfacesVertexModifyWorldNormal(In);\n SurfacesVertexModifyUV(In);\n SurfacesVertexModifySharedData(In);\n CCSurfacesVertexTransformUV(In);\n CCSurfacesVertexTransferFog(In);\n CCSurfacesVertexTransferLightMapUV(In);\n CCSurfacesVertexTransferShadow(In);\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n In.shadowBiasAndProbeId.xy = SurfacesVertexModifyShadowBias(In, In.shadowBiasAndProbeId.xy);\n #endif\n CCSurfacesVertexOutput(In);\n}",
- "frag": "\n#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives: enable\n#endif\n#ifdef GL_EXT_shader_texture_lod\n#extension GL_EXT_shader_texture_lod: enable\n#endif\nprecision highp float;\n#define CC_SURFACES_USE_TANGENT_SPACE 0\n#define CC_SURFACES_USE_VERTEX_COLOR 0\n#define CC_SURFACES_USE_SECOND_UV 0\n#define CC_SURFACES_USE_LIGHT_MAP 0\n#define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nvarying highp vec3 v_worldPos;\nvarying vec4 v_normal;\nvarying vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n varying lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n varying mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n varying mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n varying mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n varying mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n varying mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n varying mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n varying highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n varying highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n varying mediump vec4 v_sh_linear_const_r;\n varying mediump vec4 v_sh_linear_const_g;\n varying mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define FSInput_worldPos v_worldPos\n#define FSInput_worldNormal v_normal.xyz\n#define FSInput_faceSideSign v_normal.w\n#define FSInput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define FSInput_vertexColor v_color\n#else\n #define FSInput_vertexColor vec4(1.0)\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define FSInput_worldTangent v_tangent.xyz\n #define FSInput_mirrorNormal v_tangent.w\n#else\n #define FSInput_worldTangent vec3(1.0, 1.0, 1.0)\n #define FSInput_mirrorNormal 1.0\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define FSInput_texcoord1 v_uv1\n#else\n #define FSInput_texcoord1 vec2(0.0, 0.0)\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define FSInput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define FSInput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define FSInput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define FSInput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define FSInput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define FSInput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define FSInput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define FSInput_clipPos v_clipPos\n#endif\nuniform mediump vec4 cc_debug_view_mode;\nuniform mediump vec4 cc_surfaceTransform;\n uniform mediump vec4 cc_mainLitColor;\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_WORLD_POS CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR CC_SURFACES_DEBUG_VIEW_WORLD_POS + 1\n#define CC_SURFACES_DEBUG_VIEW_FACE_SIDE CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR + 1\n#define CC_SURFACES_DEBUG_VIEW_UV0 CC_SURFACES_DEBUG_VIEW_FACE_SIDE + 1\n#define CC_SURFACES_DEBUG_VIEW_UV1 CC_SURFACES_DEBUG_VIEW_UV0 + 1\n#define CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP CC_SURFACES_DEBUG_VIEW_UV1 + 1\n#define CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP + 1\n#define CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_BASE_COLOR CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR CC_SURFACES_DEBUG_VIEW_BASE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSPARENCY CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_METALLIC CC_SURFACES_DEBUG_VIEW_TRANSPARENCY + 1\n#define CC_SURFACES_DEBUG_VIEW_ROUGHNESS CC_SURFACES_DEBUG_VIEW_METALLIC + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY CC_SURFACES_DEBUG_VIEW_ROUGHNESS + 1\n#define CC_SURFACES_DEBUG_VIEW_IOR CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_IOR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_ALL CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_DIRECT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_ALL CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_EMISSIVE CC_SURFACES_DEBUG_VIEW_ENV_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_LIGHT_MAP CC_SURFACES_DEBUG_VIEW_EMISSIVE + 1\n#define CC_SURFACES_DEBUG_VIEW_SHADOW CC_SURFACES_DEBUG_VIEW_LIGHT_MAP + 1\n#define CC_SURFACES_DEBUG_VIEW_AO CC_SURFACES_DEBUG_VIEW_SHADOW + 1\n#define CC_SURFACES_DEBUG_VIEW_FRESNEL CC_SURFACES_DEBUG_VIEW_AO + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_FRESNEL + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_FOG CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL + 1\n#define IS_DEBUG_VIEW_ENABLE_WITH_CAMERA (cc_surfaceTransform.y != 3.0)\n#define IS_DEBUG_VIEW_LIGHTING_ENABLE_WITH_ALBEDO (UnpackBitFromFloat(cc_debug_view_mode.w, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_MISC_ENABLE_CSM_LAYER_COLORATION (UnpackBitFromFloat(cc_debug_view_mode.w, 7) && IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_EMISSIVE (UnpackBitFromFloat(cc_debug_view_mode.y, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_LIGHT_MAP (UnpackBitFromFloat(cc_debug_view_mode.y, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_SHADOW (UnpackBitFromFloat(cc_debug_view_mode.y, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_AO (UnpackBitFromFloat(cc_debug_view_mode.y, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_NORMAL_MAP (UnpackBitFromFloat(cc_debug_view_mode.z, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FOG (UnpackBitFromFloat(cc_debug_view_mode.z, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TONE_MAPPING (UnpackBitFromFloat(cc_debug_view_mode.z, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION (UnpackBitFromFloat(cc_debug_view_mode.z, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FRESNEL (UnpackBitFromFloat(cc_debug_view_mode.z, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.z, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_2ND_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TT (UnpackBitFromFloat(cc_debug_view_mode.w, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#if (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\n #if CC_FORWARD_ADD\n #if CC_PIPELINE_TYPE == 0\n #define LIGHTS_PER_PASS 1\n #else\n #define LIGHTS_PER_PASS 10\n #endif\n #if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\n #endif\n #endif\n#endif\n#if CC_USE_LIGHT_PROBE\n #if !USE_INSTANCING\n #endif\n#endif\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n #endif\nuniform samplerCube cc_environment;\n#if CC_USE_IBL\n #if CC_USE_DIFFUSEMAP\n uniform samplerCube cc_diffuseMap;\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n uniform samplerCube cc_reflectionProbeCubemap;\n uniform sampler2D cc_reflectionProbePlanarMap;\n uniform sampler2D cc_reflectionProbeDataMap;\n uniform samplerCube cc_reflectionProbeBlendCubemap;\n#endif\n#define UnpackBitFromFloat(value, bit) (mod(floor(value / pow(10.0, float(bit))), 10.0) > 0.0)\nvec4 packRGBE (vec3 rgb) {\n highp float maxComp = max(max(rgb.r, rgb.g), rgb.b);\n highp float e = 128.0;\n if (maxComp > 0.0001) {\n e = log(maxComp) / log(1.1);\n e = ceil(e);\n e = clamp(e + 128.0, 0.0, 255.0);\n }\n highp float sc = 1.0 / pow(1.1, e - 128.0);\n vec3 encode = clamp(rgb * sc, vec3(0.0), vec3(1.0)) * 255.0;\n vec3 encode_rounded = floor(encode) + step(encode - floor(encode), vec3(0.5));\n return vec4(encode_rounded, e) / 255.0;\n}\nvec3 SRGBToLinear (vec3 gamma) {\n#ifdef CC_USE_SURFACE_SHADER\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION) {\n return gamma;\n }\n #endif\n#endif\n return gamma * gamma;\n}\nvec3 LinearToSRGB(vec3 linear) {\n#ifdef CC_USE_SURFACE_SHADER\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION) {\n return linear;\n }\n #endif\n#endif\n return sqrt(linear);\n}\n#if defined(CC_USE_METAL) || defined(CC_USE_WGPU)\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y) y = -y\n#else\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y)\n#endif\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n#endif\n#if CC_RECEIVE_SHADOW\n uniform highp sampler2D cc_shadowMap;\n uniform highp sampler2D cc_spotShadowMap;\n #if CC_SUPPORT_CASCADED_SHADOW_MAP\n #else\n #endif\n#endif\n#if CC_USE_FOG != 4\n#endif\n#if CC_USE_LIGHT_PROBE\n #if CC_USE_LIGHT_PROBE\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n #endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n uniform sampler2D cc_lightingMap;\n#endif\n uniform vec4 baseColor;\n#if USE_BASE_COLOR_MAP\n uniform sampler2D baseColorMap;\n#endif\n#define CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TRANSPARENCY\nvec4 SurfacesFragmentModifyBaseColorAndTransparency()\n{\n vec4 color = vec4(cc_mainLitColor.rgb, 1.0);\n color.rgb = SRGBToLinear(baseColor.rgb);\n #if USE_BASE_COLOR_MAP\n vec4 texColor = texture2D(baseColorMap, FSInput_texcoord);\n texColor.rgb = SRGBToLinear(texColor.rgb);\n color *= texColor;\n #endif\n return color;\n}\nvoid main () {\n vec4 color = SurfacesFragmentModifyBaseColorAndTransparency();\n #if CC_USE_RGBE_OUTPUT\n color = packRGBE(color.rgb);\n #elif !CC_USE_FLOAT_OUTPUT\n color.rgb = LinearToSRGB(color.rgb);\n #endif\n gl_FragColor = color;\n}"
- },
- "builtins": {
- "globals": {
- "blocks": [
- {
- "name": "CCGlobal",
- "defines": []
- },
- {
- "name": "CCCamera",
- "defines": []
- },
- {
- "name": "CCShadow",
- "defines": []
- },
- {
- "name": "CCCSM",
- "defines": [
- "CC_SUPPORT_CASCADED_SHADOW_MAP"
- ]
- }
- ],
- "samplerTextures": [
- {
- "name": "cc_environment",
- "defines": []
- },
- {
- "name": "cc_diffuseMap",
- "defines": [
- "CC_USE_IBL",
- "CC_USE_DIFFUSEMAP"
- ]
- },
- {
- "name": "cc_shadowMap",
- "defines": [
- "CC_RECEIVE_SHADOW"
- ]
- },
- {
- "name": "cc_spotShadowMap",
- "defines": [
- "CC_RECEIVE_SHADOW"
- ]
- }
- ],
- "buffers": [],
- "images": []
- },
- "locals": {
- "blocks": [
- {
- "name": "CCLocal",
- "defines": [
- "!USE_INSTANCING"
- ]
- },
- {
- "name": "CCMorph",
- "defines": [
- "CC_USE_MORPH"
- ]
- },
- {
- "name": "CCSkinningTexture",
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ]
- },
- {
- "name": "CCSkinningAnimation",
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ]
- },
- {
- "name": "CCSkinning",
- "defines": [
- "CC_USE_SKINNING",
- "!CC_USE_BAKED_ANIMATION",
- "!CC_USE_REAL_TIME_JOINT_TEXTURE"
- ]
- },
- {
- "name": "CCForwardLight",
- "defines": [
- "CC_FORWARD_ADD",
- "CC_ENABLE_CLUSTERED_LIGHT_CULLING"
- ]
- },
- {
- "name": "CCSH",
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "!USE_INSTANCING"
- ]
- }
- ],
- "samplerTextures": [
- {
- "name": "cc_PositionDisplacements",
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_POSITION"
- ]
- },
- {
- "name": "cc_NormalDisplacements",
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_NORMAL"
- ]
- },
- {
- "name": "cc_TangentDisplacements",
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_TANGENT"
- ]
- },
- {
- "name": "cc_jointTexture",
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ]
- },
- {
- "name": "cc_realtimeJoint",
- "defines": [
- "CC_USE_SKINNING",
- "!CC_USE_BAKED_ANIMATION",
- "CC_USE_REAL_TIME_JOINT_TEXTURE"
- ]
- },
- {
- "name": "cc_reflectionProbeCubemap",
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ]
- },
- {
- "name": "cc_reflectionProbePlanarMap",
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ]
- },
- {
- "name": "cc_reflectionProbeDataMap",
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ]
- },
- {
- "name": "cc_reflectionProbeBlendCubemap",
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ]
- },
- {
- "name": "cc_lightingMap",
- "defines": [
- "CC_USE_LIGHTMAP",
- "!CC_FORWARD_ADD"
- ]
- }
- ],
- "buffers": [],
- "images": []
- },
- "statistics": {
- "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 91,
- "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 121
- }
- },
- "defines": [
- {
- "name": "USE_INSTANCING",
- "type": "boolean",
- "defines": [],
- "editor": {
- "elevated": true
- }
- },
- {
- "name": "CC_USE_LIGHTMAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_SKINNING",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_BAKED_ANIMATION",
- "type": "boolean",
- "defines": [
- "USE_INSTANCING"
- ]
- },
- {
- "name": "CC_RECEIVE_SHADOW",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_REFLECTION_PROBE",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 3
- ]
- },
- {
- "name": "CC_USE_LIGHT_PROBE",
- "type": "boolean",
- "defines": [],
- "default": 0
- },
- {
- "name": "CC_USE_MORPH",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_FORWARD_ADD",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_FOG",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 4
- ]
- },
- {
- "name": "CC_USE_ACCURATE_FOG",
- "type": "boolean",
- "defines": [
- "CC_USE_FOG"
- ]
- },
- {
- "name": "CC_MORPH_TARGET_COUNT",
- "type": "number",
- "defines": [
- "CC_USE_MORPH"
- ],
- "range": [
- 2,
- 8
- ]
- },
- {
- "name": "CC_MORPH_TARGET_HAS_POSITION",
- "type": "boolean",
- "defines": [
- "CC_USE_MORPH"
- ]
- },
- {
- "name": "CC_MORPH_TARGET_HAS_NORMAL",
- "type": "boolean",
- "defines": [
- "CC_USE_MORPH"
- ]
- },
- {
- "name": "CC_MORPH_TARGET_HAS_TANGENT",
- "type": "boolean",
- "defines": [
- "CC_USE_MORPH"
- ]
- },
- {
- "name": "CC_MORPH_PRECOMPUTED",
- "type": "boolean",
- "defines": [
- "CC_USE_MORPH"
- ]
- },
- {
- "name": "CC_USE_REAL_TIME_JOINT_TEXTURE",
- "type": "boolean",
- "defines": [
- "CC_USE_SKINNING",
- "!CC_USE_BAKED_ANIMATION"
- ]
- },
- {
- "name": "USE_POSITION_SCALING",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_DISABLE_STRUCTURE_IN_FRAGMENT_SHADER",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 1
- ]
- },
- {
- "name": "CC_PIPELINE_TYPE",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 1
- ]
- },
- {
- "name": "CC_FORCE_FORWARD_SHADING",
- "type": "boolean",
- "defines": [
- "CC_PIPELINE_TYPE"
- ]
- },
- {
- "name": "CC_ENABLE_CLUSTERED_LIGHT_CULLING",
- "type": "number",
- "defines": [
- "CC_FORWARD_ADD"
- ],
- "range": [
- 0,
- 3
- ]
- },
- {
- "name": "CC_SUPPORT_CASCADED_SHADOW_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_IBL",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 2
- ]
- },
- {
- "name": "CC_USE_DIFFUSEMAP",
- "type": "number",
- "defines": [
- "CC_USE_IBL"
- ],
- "range": [
- 0,
- 2
- ]
- },
- {
- "name": "CC_USE_DEBUG_VIEW",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 3
- ]
- },
- {
- "name": "USE_BASE_COLOR_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_RGBE_OUTPUT",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_FLOAT_OUTPUT",
- "type": "boolean",
- "defines": [
- "!CC_USE_RGBE_OUTPUT"
- ]
- }
- ],
- "name": "builtin-toon|silhouette-edge-vs|silhouette-edge-fs"
- },
- {
- "blocks": [
- {
- "name": "Constants",
- "members": [
- {
- "name": "tilingOffset",
- "type": 16,
- "count": 1
- },
- {
- "name": "baseColor",
- "type": 16,
- "count": 1
- },
- {
- "name": "colorScaleAndCutoff",
- "type": 16,
- "count": 1
- },
- {
- "name": "shadeColor1",
- "type": 16,
- "count": 1
- },
- {
- "name": "shadeColor2",
- "type": 16,
- "count": 1
- },
- {
- "name": "specular",
- "type": 16,
- "count": 1
- },
- {
- "name": "shadeParams",
- "type": 16,
- "count": 1
- },
- {
- "name": "miscParams",
- "type": 16,
- "count": 1
- },
- {
- "name": "emissive",
- "type": 16,
- "count": 1
- },
- {
- "name": "emissiveScaleAndStrenth",
- "type": 16,
- "count": 1
- }
- ],
- "defines": [],
- "stageFlags": 17,
- "binding": 0
- }
- ],
- "samplerTextures": [
- {
- "name": "baseColorMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_BASE_COLOR_MAP"
- ],
- "stageFlags": 16,
- "binding": 1
- },
- {
- "name": "normalMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_NORMAL_MAP"
- ],
- "stageFlags": 16,
- "binding": 2
- },
- {
- "name": "shadeMap1",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_1ST_SHADE_MAP"
- ],
- "stageFlags": 16,
- "binding": 3
- },
- {
- "name": "shadeMap2",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_2ND_SHADE_MAP"
- ],
- "stageFlags": 16,
- "binding": 4
- },
- {
- "name": "specularMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_SPECULAR_MAP"
- ],
- "stageFlags": 16,
- "binding": 5
- },
- {
- "name": "emissiveMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_EMISSIVE_MAP"
- ],
- "stageFlags": 16,
- "binding": 6
- }
- ],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": [],
- "attributes": [
- {
- "name": "a_position",
- "defines": [],
- "format": 32,
- "location": 0
- },
- {
- "name": "a_normal",
- "defines": [],
- "format": 32,
- "location": 1
- },
- {
- "name": "a_texCoord",
- "defines": [],
- "format": 21,
- "location": 2
- },
- {
- "name": "a_tangent",
- "defines": [
- "USE_NORMAL_MAP"
- ],
- "format": 44,
- "location": 3
- },
- {
- "name": "a_color",
- "defines": [],
- "format": 44,
- "location": 6
- },
- {
- "name": "a_texCoord1",
- "defines": [],
- "format": 21,
- "location": 7
- },
- {
- "name": "a_joints",
- "defines": [
- "CC_USE_SKINNING"
- ],
- "location": 4
- },
- {
- "name": "a_weights",
- "defines": [
- "CC_USE_SKINNING"
- ],
- "format": 44,
- "location": 5
- },
- {
- "name": "a_jointAnimInfo",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_BAKED_ANIMATION"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 8
- },
- {
- "name": "a_matWorld0",
- "defines": [
- "USE_INSTANCING"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 9
- },
- {
- "name": "a_matWorld1",
- "defines": [
- "USE_INSTANCING"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 10
- },
- {
- "name": "a_matWorld2",
- "defines": [
- "USE_INSTANCING"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 11
- },
- {
- "name": "a_lightingMapUVParam",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_LIGHTMAP"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 12
- },
- {
- "name": "a_localShadowBiasAndProbeId",
- "defines": [
- "USE_INSTANCING"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 13
- },
- {
- "name": "a_reflectionProbeData",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_REFLECTION_PROBE"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 14
- },
- {
- "name": "a_sh_linear_const_r",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_LIGHT_PROBE"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 15
- },
- {
- "name": "a_sh_linear_const_g",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_LIGHT_PROBE"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 16
- },
- {
- "name": "a_sh_linear_const_b",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_LIGHT_PROBE"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 17
- },
- {
- "name": "a_vertexId",
- "defines": [
- "CC_USE_MORPH"
- ],
- "format": 11,
- "location": 18
- }
- ],
- "varyings": [
- {
- "name": "v_worldPos",
- "type": 15,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 0
- },
- {
- "name": "v_normal",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 1
- },
- {
- "name": "v_uv",
- "type": 14,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 2
- },
- {
- "name": "v_color",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 3
- },
- {
- "name": "v_tangent",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 4
- },
- {
- "name": "v_uv1",
- "type": 14,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 5
- },
- {
- "name": "v_luv",
- "type": 15,
- "count": 1,
- "defines": [
- "CC_USE_LIGHTMAP",
- "!CC_FORWARD_ADD"
- ],
- "stageFlags": 17,
- "location": 6
- },
- {
- "name": "v_shadowBiasAndProbeId",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 7
- },
- {
- "name": "v_reflectionProbeData",
- "type": 16,
- "count": 1,
- "defines": [
- "CC_USE_REFLECTION_PROBE",
- "USE_INSTANCING"
- ],
- "stageFlags": 17,
- "location": 8
- },
- {
- "name": "v_fogFactor",
- "type": 13,
- "count": 1,
- "defines": [
- "CC_USE_FOG",
- "!CC_USE_ACCURATE_FOG"
- ],
- "stageFlags": 17,
- "location": 9
- },
- {
- "name": "v_localPos",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 10
- },
- {
- "name": "v_clipPos",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 11
- },
- {
- "name": "v_sh_linear_const_r",
- "type": 16,
- "count": 1,
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "USE_INSTANCING"
- ],
- "stageFlags": 17,
- "location": 12
- },
- {
- "name": "v_sh_linear_const_g",
- "type": 16,
- "count": 1,
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "USE_INSTANCING"
- ],
- "stageFlags": 17,
- "location": 13
- },
- {
- "name": "v_sh_linear_const_b",
- "type": 16,
- "count": 1,
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "USE_INSTANCING"
- ],
- "stageFlags": 17,
- "location": 14
- }
- ],
- "fragColors": [
- {
- "tags": [],
- "name": "fragColorX",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 16,
- "location": 0
- },
- {
- "tags": [
- "CC_PIPELINE_TYPE"
- ],
- "name": "albedoOut",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "defines": [
- "CC_PIPELINE_TYPE"
- ],
- "stageFlags": 16,
- "location": 1
- },
- {
- "name": "emissiveOut",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "defines": [
- "CC_PIPELINE_TYPE"
- ],
- "stageFlags": 16,
- "location": 2
- },
- {
- "name": "normalOut",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "defines": [
- "CC_PIPELINE_TYPE"
- ],
- "stageFlags": 16,
- "location": 3
- }
- ],
- "descriptors": [
- {
- "rate": 0,
- "blocks": [
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCLocal",
- "members": [
- {
- "name": "cc_matWorld",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matWorldIT",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_lightingMapUVParam",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_localShadowBias",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeData1",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeData2",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeBlendData1",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeBlendData2",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- }
- ],
- "defines": [
- "!USE_INSTANCING"
- ],
- "stageFlags": 17
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCMorph",
- "members": [
- {
- "name": "cc_displacementWeights",
- "typename": "vec4",
- "type": 16,
- "count": 15,
- "isArray": true
- },
- {
- "name": "cc_displacementTextureInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1
- }
- ],
- "defines": [
- "CC_USE_MORPH"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCSkinningTexture",
- "members": [
- {
- "name": "cc_jointTextureInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- }
- ],
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCSkinningAnimation",
- "members": [
- {
- "name": "cc_jointAnimInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- }
- ],
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCSkinning",
- "members": [
- {
- "name": "cc_joints",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "precision": "highp ",
- "isArray": true
- }
- ],
- "defines": [
- "CC_USE_SKINNING",
- "!CC_USE_BAKED_ANIMATION",
- "!CC_USE_REAL_TIME_JOINT_TEXTURE"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCForwardLight",
- "members": [
- {
- "name": "cc_lightPos",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_lightColor",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "isArray": true
- },
- {
- "name": "cc_lightSizeRangeAngle",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "isArray": true
- },
- {
- "name": "cc_lightDir",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "isArray": true
- },
- {
- "name": "cc_lightBoundingSizeVS",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "isArray": true
- }
- ],
- "defines": [
- "CC_FORWARD_ADD",
- "CC_ENABLE_CLUSTERED_LIGHT_CULLING"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCSH",
- "members": [
- {
- "name": "cc_sh_linear_const_r",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_linear_const_g",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_linear_const_b",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_r",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_g",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_b",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_a",
- "typename": "vec4",
- "type": 16,
- "count": 1
- }
- ],
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "!USE_INSTANCING"
- ],
- "stageFlags": 16
- }
- ],
- "samplerTextures": [
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_PositionDisplacements",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_POSITION"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_NormalDisplacements",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_NORMAL"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_TangentDisplacements",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_TANGENT"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_jointTexture",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "precision": "highp ",
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_realtimeJoint",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "precision": "highp ",
- "defines": [
- "CC_USE_SKINNING",
- "!CC_USE_BAKED_ANIMATION",
- "CC_USE_REAL_TIME_JOINT_TEXTURE"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_reflectionProbeCubemap",
- "typename": "samplerCube",
- "type": 31,
- "count": 1,
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_reflectionProbePlanarMap",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_reflectionProbeDataMap",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_reflectionProbeBlendCubemap",
- "typename": "samplerCube",
- "type": 31,
- "count": 1,
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_lightingMap",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_LIGHTMAP",
- "!CC_FORWARD_ADD"
- ],
- "stageFlags": 16
- }
- ],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- },
- {
- "rate": 1,
- "blocks": [
- {
- "name": "Constants",
- "members": [
- {
- "name": "tilingOffset",
- "type": 16,
- "count": 1
- },
- {
- "name": "baseColor",
- "type": 16,
- "count": 1
- },
- {
- "name": "colorScaleAndCutoff",
- "type": 16,
- "count": 1
- },
- {
- "name": "shadeColor1",
- "type": 16,
- "count": 1
- },
- {
- "name": "shadeColor2",
- "type": 16,
- "count": 1
- },
- {
- "name": "specular",
- "type": 16,
- "count": 1
- },
- {
- "name": "shadeParams",
- "type": 16,
- "count": 1
- },
- {
- "name": "miscParams",
- "type": 16,
- "count": 1
- },
- {
- "name": "emissive",
- "type": 16,
- "count": 1
- },
- {
- "name": "emissiveScaleAndStrenth",
- "type": 16,
- "count": 1
- }
- ],
- "defines": [],
- "stageFlags": 17,
- "binding": 0
- }
- ],
- "samplerTextures": [
- {
- "name": "baseColorMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_BASE_COLOR_MAP"
- ],
- "stageFlags": 16,
- "binding": 1
- },
- {
- "name": "normalMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_NORMAL_MAP"
- ],
- "stageFlags": 16,
- "binding": 2
- },
- {
- "name": "shadeMap1",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_1ST_SHADE_MAP"
- ],
- "stageFlags": 16,
- "binding": 3
- },
- {
- "name": "shadeMap2",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_2ND_SHADE_MAP"
- ],
- "stageFlags": 16,
- "binding": 4
- },
- {
- "name": "specularMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_SPECULAR_MAP"
- ],
- "stageFlags": 16,
- "binding": 5
- },
- {
- "name": "emissiveMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_EMISSIVE_MAP"
- ],
- "stageFlags": 16,
- "binding": 6
- }
- ],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- },
- {
- "rate": 2,
- "blocks": [],
- "samplerTextures": [],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- },
- {
- "rate": 3,
- "blocks": [
- {
- "tags": {
- "builtin": "global"
- },
- "name": "CCGlobal",
- "members": [
- {
- "name": "cc_time",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_screenSize",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_nativeSize",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_probeInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_debug_view_mode",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- }
- ],
- "defines": [],
- "stageFlags": 17
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "CCCamera",
- "members": [
- {
- "name": "cc_matView",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matViewInv",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matProj",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matProjInv",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matViewProj",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matViewProjInv",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_cameraPos",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_surfaceTransform",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_screenScale",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_exposure",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_mainLitDir",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_mainLitColor",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_ambientSky",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_ambientGround",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_fogColor",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_fogBase",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_fogAdd",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_nearFar",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_viewPort",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- }
- ],
- "defines": [],
- "stageFlags": 17
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "CCShadow",
- "members": [
- {
- "name": "cc_matLightView",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matLightViewProj",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_shadowInvProjDepthInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_shadowProjDepthInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_shadowProjInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_shadowNFLSInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_shadowWHPBInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_shadowLPNNInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_shadowColor",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "lowp "
- },
- {
- "name": "cc_planarNDInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- }
- ],
- "defines": [],
- "stageFlags": 17
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "CCCSM",
- "members": [
- {
- "name": "cc_csmViewDir0",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmViewDir1",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmViewDir2",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmAtlas",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_matCSMViewProj",
- "typename": "mat4",
- "type": 25,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmProjDepthInfo",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmProjInfo",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmSplitsInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- }
- ],
- "defines": [
- "CC_SUPPORT_CASCADED_SHADOW_MAP"
- ],
- "stageFlags": 16
- }
- ],
- "samplerTextures": [
- {
- "tags": {
- "builtin": "global"
- },
- "name": "cc_environment",
- "typename": "samplerCube",
- "type": 31,
- "count": 1,
- "defines": [],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "cc_diffuseMap",
- "typename": "samplerCube",
- "type": 31,
- "count": 1,
- "defines": [
- "CC_USE_IBL",
- "CC_USE_DIFFUSEMAP"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "cc_shadowMap",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "precision": "highp ",
- "defines": [
- "CC_RECEIVE_SHADOW"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "cc_spotShadowMap",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "precision": "highp ",
- "defines": [
- "CC_RECEIVE_SHADOW"
- ],
- "stageFlags": 16
- }
- ],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- }
- ],
- "hash": 1072892874,
- "glsl4": {
- "vert": "#extension GL_EXT_shader_explicit_arithmetic_types_int32: require\nprecision highp float;\n#define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING USE_COMPATIBLE_LIGHTING\n#define CC_SURFACES_USE_TANGENT_SPACE USE_NORMAL_MAP\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec3 a_normal;\nlayout(location = 2) in vec2 a_texCoord;\n#if CC_SURFACES_USE_TANGENT_SPACE\n layout(location = 3) in vec4 a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n layout(location = 6) in vec4 a_color;\n#endif\n#if CC_SURFACES_USE_SECOND_UV || CC_USE_LIGHTMAP\n layout(location = 7) in vec2 a_texCoord1;\n#endif\n#if CC_USE_SKINNING\n layout(location = 4) in u32vec4 a_joints;\n layout(location = 5) in vec4 a_weights;\n#endif\n#if USE_INSTANCING\n #if CC_USE_BAKED_ANIMATION\n layout(location = 8) in highp vec4 a_jointAnimInfo;\n #endif\n layout(location = 9) in vec4 a_matWorld0;\n layout(location = 10) in vec4 a_matWorld1;\n layout(location = 11) in vec4 a_matWorld2;\n #if CC_USE_LIGHTMAP\n layout(location = 12) in vec4 a_lightingMapUVParam;\n #endif\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n layout(location = 13) in vec4 a_localShadowBiasAndProbeId;\n #endif\n #if CC_USE_REFLECTION_PROBE\n layout(location = 14) in vec4 a_reflectionProbeData;\n #endif\n #if CC_USE_LIGHT_PROBE\n layout(location = 15) in vec4 a_sh_linear_const_r;\n layout(location = 16) in vec4 a_sh_linear_const_g;\n layout(location = 17) in vec4 a_sh_linear_const_b;\n #endif\n#endif\n#if CC_USE_MORPH\n#endif\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nlayout(location = 0) out highp vec3 v_worldPos;\nlayout(location = 1) out vec4 v_normal;\nlayout(location = 2) out vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n layout(location = 3) out lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n layout(location = 4) out mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n layout(location = 5) out mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n layout(location = 6) out mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n layout(location = 7) out mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n layout(location = 8) out mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n layout(location = 9) out mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n layout(location = 10) out highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n layout(location = 11) out highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n layout(location = 12) out mediump vec4 v_sh_linear_const_r;\n layout(location = 13) out mediump vec4 v_sh_linear_const_g;\n layout(location = 14) out mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define VSOutput_worldPos v_worldPos\n#define VSOutput_worldNormal v_normal.xyz\n#define VSOutput_faceSideSign v_normal.w\n#define VSOutput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define VSOutput_vertexColor v_color\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define VSOutput_worldTangent v_tangent.xyz\n #define VSOutput_mirrorNormal v_tangent.w\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define VSOutput_texcoord1 v_uv1\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define VSOutput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define VSOutput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define VSOutput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define VSOutput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define VSOutput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define VSOutput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define VSOutput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define VSOutput_clipPos v_clipPos\n#endif\nstruct SurfacesStandardVertexIntermediate\n{\n highp vec4 position;\n vec3 normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n vec4 tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n vec4 color;\n#endif\n vec2 texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n vec2 texCoord1;\n#endif\n highp vec4 clipPos;\n highp vec3 worldPos;\n vec4 worldNormal;\n #if CC_SURFACES_USE_TANGENT_SPACE\n vec3 worldTangent, worldBinormal;\n #endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n vec4 shadowBiasAndProbeId;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n float fogFactor;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n vec3 lightmapUV;\n#endif\n};\n#if CC_USE_MORPH\n int getVertexId() {\n return gl_VertexIndex;\n }\n#endif\nlayout(set = 0, binding = 0) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\nlayout(set = 0, binding = 2) uniform CCShadow {\n highp mat4 cc_matLightView;\n highp mat4 cc_matLightViewProj;\n highp vec4 cc_shadowInvProjDepthInfo;\n highp vec4 cc_shadowProjDepthInfo;\n highp vec4 cc_shadowProjInfo;\n mediump vec4 cc_shadowNFLSInfo;\n mediump vec4 cc_shadowWHPBInfo;\n mediump vec4 cc_shadowLPNNInfo;\n lowp vec4 cc_shadowColor;\n mediump vec4 cc_planarNDInfo;\n};\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\n#if !USE_INSTANCING\n layout(set = 2, binding = 0) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n highp vec4 cc_localShadowBias;\n highp vec4 cc_reflectionProbeData1;\n highp vec4 cc_reflectionProbeData2;\n highp vec4 cc_reflectionProbeBlendData1;\n highp vec4 cc_reflectionProbeBlendData2;\n };\n#endif\nvoid CCGetWorldMatrixFull(out mat4 matWorld, out mat4 matWorldIT)\n{\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n vec3 scale = 1.0 / vec3(length(a_matWorld0.xyz), length(a_matWorld1.xyz), length(a_matWorld2.xyz));\n vec3 scale2 = scale * scale;\n matWorldIT = mat4(\n vec4(a_matWorld0.xyz * scale2.x, 0.0),\n vec4(a_matWorld1.xyz * scale2.y, 0.0),\n vec4(a_matWorld2.xyz * scale2.z, 0.0),\n vec4(0.0, 0.0, 0.0, 1.0)\n );\n #else\n matWorld = cc_matWorld;\n matWorldIT = cc_matWorldIT;\n #endif\n}\n#if CC_USE_MORPH\n layout(set = 2, binding = 4) uniform CCMorph {\n vec4 cc_displacementWeights[15];\n vec4 cc_displacementTextureInfo;\n };\n #if CC_MORPH_TARGET_HAS_POSITION\n layout(set = 2, binding = 8) uniform sampler2D cc_PositionDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n layout(set = 2, binding = 9) uniform sampler2D cc_NormalDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n layout(set = 2, binding = 10) uniform sampler2D cc_TangentDisplacements;\n #endif\n vec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n }\n vec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n }\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\n ivec2 texSize = textureSize(tex, 0);\n return texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n }\n #else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture(tex, x)),\n decode32(texture(tex, y)),\n decode32(texture(tex, z)),\n 1.0\n );\n }\n #endif\n float getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n }\n vec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n #if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n #else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n #endif\n }\n #if CC_MORPH_TARGET_HAS_POSITION\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n #endif\n void applyMorph (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n int vertexId = getVertexId();\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n normal.xyz = normal.xyz + getNormalDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n tangent.xyz = tangent.xyz + getTangentDisplacement(vertexId);\n #endif\n }\n void applyMorph (inout vec4 position) {\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n #endif\n }\n#endif\n#if CC_USE_SKINNING\n #if CC_USE_BAKED_ANIMATION\n layout(set = 2, binding = 3) uniform CCSkinningTexture {\n highp vec4 cc_jointTextureInfo;\n };\n layout(set = 2, binding = 2) uniform CCSkinningAnimation {\n highp vec4 cc_jointAnimInfo;\n };\n layout(set = 2, binding = 7) uniform highp sampler2D cc_jointTexture;\n void CCGetJointTextureCoords(float pixelsPerJoint, float jointIdx, out highp float x, out highp float y, out highp float invSize)\n {\n #if USE_INSTANCING\n highp float temp = pixelsPerJoint * (a_jointAnimInfo.x * a_jointAnimInfo.y + jointIdx) + a_jointAnimInfo.z;\n #else\n highp float temp = pixelsPerJoint * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + jointIdx) + cc_jointTextureInfo.z;\n #endif\n invSize = cc_jointTextureInfo.w;\n highp float tempY = floor(temp * invSize);\n x = floor(temp - tempY * cc_jointTextureInfo.x);\n y = (tempY + 0.5) * invSize;\n }\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n layout(set = 2, binding = 7) uniform highp sampler2D cc_realtimeJoint;\n #else\n layout(set = 2, binding = 3) uniform CCSkinning {\n highp vec4 cc_joints[CC_JOINT_UNIFORM_CAPACITY * 3];\n };\n #endif\n #endif\n #if CC_USE_BAKED_ANIMATION\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(3.0, i, x, y, invSize);\n vec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(12.0, i, x, y, invSize);\n vec4 v1 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n float x = i;\n vec4 v1 = texture(cc_realtimeJoint, vec2( x / 256.0, 0.5 / 3.0));\n vec4 v2 = texture(cc_realtimeJoint, vec2( x / 256.0, 1.5 / 3.0));\n vec4 v3 = texture(cc_realtimeJoint, vec2( x / 256.0, 2.5 / 3.0));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n float x = 4.0 * i;\n vec4 v1 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 0.5 / 3.0)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 1.5 / 3.0)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 2.5 / 3.0)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #endif\n mat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n }\n void CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n }\n void CCSkin (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n mat4 m = skinMatrix();\n position = m * position;\n normal = (m * vec4(normal, 0.0)).xyz;\n tangent.xyz = (m * vec4(tangent.xyz, 0.0)).xyz;\n }\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #if CC_USE_FOG != 4\n float LinearFog(vec4 pos, vec3 cameraPos, float fogStart, float fogEnd) {\n vec4 wPos = pos;\n float cam_dis = distance(cameraPos, wPos.xyz);\n return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n }\n float ExpFog(vec4 pos, vec3 cameraPos, float fogStart, float fogDensity, float fogAtten) {\n vec4 wPos = pos;\n float cam_dis = max(distance(cameraPos, wPos.xyz) - fogStart, 0.0) / fogAtten * 4.;\n float f = exp(-cam_dis * fogDensity);\n return f;\n }\n float ExpSquaredFog(vec4 pos, vec3 cameraPos, float fogStart, float fogDensity, float fogAtten) {\n vec4 wPos = pos;\n float cam_dis = max(distance(cameraPos, wPos.xyz) - fogStart, 0.0) / fogAtten * 4.;\n float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\n return f;\n }\n float LayeredFog(vec4 pos, vec3 cameraPos, float fogTop, float fogRange, float fogAtten) {\n vec4 wPos = pos;\n vec3 camWorldProj = cameraPos.xyz;\n camWorldProj.y = 0.;\n vec3 worldPosProj = wPos.xyz;\n worldPosProj.y = 0.;\n float fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\n float fDeltaY, fDensityIntegral;\n if (cameraPos.y > fogTop) {\n if (wPos.y < fogTop) {\n fDeltaY = (fogTop - wPos.y) / fogRange * 2.0;\n fDensityIntegral = fDeltaY * fDeltaY * 0.5;\n }\n else {\n fDeltaY = 0.;\n fDensityIntegral = 0.;\n }\n }\n else {\n if (wPos.y < fogTop) {\n float fDeltaA = (fogTop - cameraPos.y) / fogRange * 2.;\n float fDeltaB = (fogTop - wPos.y) / fogRange * 2.;\n fDeltaY = abs(fDeltaA - fDeltaB);\n fDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n }\n else {\n fDeltaY = abs(fogTop - cameraPos.y) / fogRange * 2.;\n fDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n }\n }\n float fDensity;\n if (fDeltaY != 0.) {\n fDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n }\n else {\n fDensity = 0.;\n }\n float f = exp(-fDensity);\n return f;\n }\n #endif\n void CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n {\n #if CC_USE_FOG == 0\n \tfactor = LinearFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.y);\n #elif CC_USE_FOG == 1\n \tfactor = ExpFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z);\n #elif CC_USE_FOG == 2\n \tfactor = ExpSquaredFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z);\n #elif CC_USE_FOG == 3\n \tfactor = LayeredFog(pos, cc_cameraPos.xyz, cc_fogAdd.x, cc_fogAdd.y, cc_fogAdd.z);\n #else\n \tfactor = 1.0;\n #endif\n }\n#endif\nlayout(set = 1, binding = 0) uniform Constants {\n vec4 tilingOffset;\n vec4 baseColor;\n vec4 colorScaleAndCutoff;\n vec4 shadeColor1;\n vec4 shadeColor2;\n vec4 specular;\n vec4 shadeParams;\n vec4 miscParams;\n vec4 emissive;\n vec4 emissiveScaleAndStrenth;\n};\n#define CC_SURFACES_VERTEX_MODIFY_UV\nvoid SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)\n{\n In.texCoord = In.texCoord * tilingOffset.xy + tilingOffset.zw;\n}\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_POS\nvec3 SurfacesVertexModifyLocalPos(in SurfacesStandardVertexIntermediate In)\n{\n return vec3(In.position.xyz);\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_NORMAL\nvec3 SurfacesVertexModifyLocalNormal(in SurfacesStandardVertexIntermediate In)\n{\n return In.normal.xyz;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_TANGENT\n #if CC_SURFACES_USE_TANGENT_SPACE\n vec4 SurfacesVertexModifyLocalTangent(in SurfacesStandardVertexIntermediate In)\n {\n return In.tangent;\n }\n #endif\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_SHARED_DATA\nvoid SurfacesVertexModifyLocalSharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_POS\nvec3 SurfacesVertexModifyWorldPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.worldPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_CLIP_POS\nvec4 SurfacesVertexModifyClipPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.clipPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_UV\nvoid SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_NORMAL\nvec3 SurfacesVertexModifyWorldNormal(in SurfacesStandardVertexIntermediate In)\n{\n vec3 worldNormal = In.worldNormal.xyz;\n #if CC_SURFACES_USE_TWO_SIDED\n worldNormal.xyz *= In.worldNormal.w;\n #endif\n return worldNormal;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHADOW_BIAS\nvec2 SurfacesVertexModifyShadowBias(in SurfacesStandardVertexIntermediate In, vec2 originShadowBias)\n{\n return originShadowBias;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHARED_DATA\nvoid SurfacesVertexModifySharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\nvoid CCSurfacesVertexInput(out SurfacesStandardVertexIntermediate In)\n{\n In.position = vec4(a_position, 1.0);\n In.normal = a_normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n In.tangent = a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n In.color = a_color;\n#endif\n In.texCoord = a_texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = a_texCoord1;\n#endif\n}\nvoid CCSurfacesVertexOutput(in SurfacesStandardVertexIntermediate In)\n{\n gl_Position = In.clipPos;\n VSOutput_worldNormal = In.worldNormal.xyz;\n VSOutput_faceSideSign = In.worldNormal.w;\n VSOutput_worldPos = In.worldPos;\n#if CC_SURFACES_USE_TANGENT_SPACE\n VSOutput_worldTangent = In.worldTangent.xyz;\n VSOutput_mirrorNormal = In.tangent.w > 0.0 ? 1.0 : -1.0;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n VSOutput_vertexColor = In.color;\n#endif\n VSOutput_texcoord = In.texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n VSOutput_texcoord1 = In.texCoord1;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n VSOutput_fogFactor = In.fogFactor;\n#endif\n#if CC_RECEIVE_SHADOW\n VSOutput_shadowBias = In.shadowBiasAndProbeId.xy;\n#endif\n#if CC_USE_REFLECTION_PROBE\n VSOutput_reflectionProbeId = In.shadowBiasAndProbeId.z;\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n VSOutput_reflectionProbeBlendId = In.shadowBiasAndProbeId.w;\n #endif\n #if USE_INSTANCING\n v_reflectionProbeData = a_reflectionProbeData;\n #endif\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n VSOutput_lightMapUV = In.lightmapUV;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n VSOutput_localPos = In.position;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n VSOutput_clipPos = In.clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n v_sh_linear_const_r = a_sh_linear_const_r;\n v_sh_linear_const_g = a_sh_linear_const_g;\n v_sh_linear_const_b = a_sh_linear_const_b;\n #endif\n#endif\n}\nvoid CCSurfacesVertexAnimation(inout SurfacesStandardVertexIntermediate In)\n{\nvec4 temp = vec4(0.0);\n#if CC_USE_MORPH\n #if CC_SURFACES_USE_TANGENT_SPACE\n applyMorph(In.position, In.normal, In.tangent);\n #else\n applyMorph(In.position, In.normal, temp);\n #endif\n#endif\n#if CC_USE_SKINNING\n #if CC_SURFACES_USE_TANGENT_SPACE\n CCSkin(In.position, In.normal, In.tangent);\n #else\n CCSkin(In.position, In.normal, temp);\n #endif\n#endif\n}\nvoid CCSurfacesVertexWorldTransform(inout SurfacesStandardVertexIntermediate In)\n{\n mat4 matWorld, matWorldIT;\n CCGetWorldMatrixFull(matWorld, matWorldIT);\n In.worldPos = (matWorld * In.position).xyz;\n In.worldNormal.xyz = normalize((matWorldIT * vec4(In.normal.xyz, 0.0)).xyz);\n #if CC_SURFACES_USE_TANGENT_SPACE\n In.worldTangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\n In.worldBinormal = cross(In.worldNormal.xyz, In.worldTangent) * In.tangent.w;\n #endif\n}\nvoid CCSurfacesVertexTransformUV(inout SurfacesStandardVertexIntermediate In)\n{\n #if CC_SURFACES_FLIP_UV\n In.texCoord = cc_cameraPos.w > 1.0 ? vec2(In.texCoord.x, 1.0 - In.texCoord.y) : In.texCoord;\n #if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = cc_cameraPos.w > 1.0 ? vec2(In.texCoord1.x, 1.0 - In.texCoord1.y) : In.texCoord1;\n #endif\n #endif\n}\nvoid CCSurfacesVertexTransferFog(inout SurfacesStandardVertexIntermediate In)\n{\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n CC_TRANSFER_FOG_BASE(vec4(In.worldPos, 1.0), In.fogFactor);\n#endif\n}\nvoid CCSurfacesVertexTransferShadow(inout SurfacesStandardVertexIntermediate In)\n{\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n In.shadowBiasAndProbeId = vec4(0.0);\n #endif\n #if CC_RECEIVE_SHADOW\n In.shadowBiasAndProbeId.xy = vec2(cc_shadowWHPBInfo.w, cc_shadowLPNNInfo.z);\n #if USE_INSTANCING\n In.shadowBiasAndProbeId.xy += a_localShadowBiasAndProbeId.xy;\n #else\n In.shadowBiasAndProbeId.xy += cc_localShadowBias.xy;\n #endif\n #endif\n #if CC_USE_REFLECTION_PROBE\n #if USE_INSTANCING\n In.shadowBiasAndProbeId.zw = a_localShadowBiasAndProbeId.zw;\n #else\n In.shadowBiasAndProbeId.zw = cc_localShadowBias.zw;\n #endif\n #endif\n}\nvoid CCSurfacesVertexTransferLightMapUV(inout SurfacesStandardVertexIntermediate In)\n{\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #if USE_INSTANCING\n In.lightmapUV.xy = a_lightingMapUVParam.xy + a_texCoord1 * a_lightingMapUVParam.z;\n In.lightmapUV.z = a_lightingMapUVParam.w;\n #else\n In.lightmapUV.xy = cc_lightingMapUVParam.xy + a_texCoord1 * cc_lightingMapUVParam.z;\n In.lightmapUV.z = cc_lightingMapUVParam.w;\n #endif\n#endif\n}\nvoid main()\n{\n SurfacesStandardVertexIntermediate In;\n CCSurfacesVertexInput(In);\n CCSurfacesVertexAnimation(In);\n In.position.xyz = SurfacesVertexModifyLocalPos(In);\n In.normal.xyz = SurfacesVertexModifyLocalNormal(In);\n #if CC_SURFACES_USE_TANGENT_SPACE\n In.tangent = SurfacesVertexModifyLocalTangent(In);\n #endif\n SurfacesVertexModifyLocalSharedData(In);\n CCSurfacesVertexWorldTransform(In);\n In.worldPos = SurfacesVertexModifyWorldPos(In);\n In.clipPos = cc_matProj * cc_matView * vec4(In.worldPos, 1.0);\n In.clipPos = SurfacesVertexModifyClipPos(In);\n vec3 viewDirect = normalize(cc_cameraPos.xyz - In.worldPos);\n In.worldNormal.w = dot(In.worldNormal.xyz, viewDirect) < 0.0 ? -1.0 : 1.0;\n In.worldNormal.xyz = SurfacesVertexModifyWorldNormal(In);\n SurfacesVertexModifyUV(In);\n SurfacesVertexModifySharedData(In);\n CCSurfacesVertexTransformUV(In);\n CCSurfacesVertexTransferFog(In);\n CCSurfacesVertexTransferLightMapUV(In);\n CCSurfacesVertexTransferShadow(In);\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n In.shadowBiasAndProbeId.xy = SurfacesVertexModifyShadowBias(In, In.shadowBiasAndProbeId.xy);\n #endif\n CCSurfacesVertexOutput(In);\n}",
- "frag": "\nprecision highp float;\n#define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING USE_COMPATIBLE_LIGHTING\n#define CC_SURFACES_USE_TANGENT_SPACE USE_NORMAL_MAP\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nlayout(location = 0) in highp vec3 v_worldPos;\nlayout(location = 1) in vec4 v_normal;\nlayout(location = 2) in vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n layout(location = 3) in lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n layout(location = 4) in mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n layout(location = 5) in mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n layout(location = 6) in mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n layout(location = 7) in mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n layout(location = 8) in mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n layout(location = 9) in mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n layout(location = 10) in highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n layout(location = 11) in highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n layout(location = 12) in mediump vec4 v_sh_linear_const_r;\n layout(location = 13) in mediump vec4 v_sh_linear_const_g;\n layout(location = 14) in mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define FSInput_worldPos v_worldPos\n#define FSInput_worldNormal v_normal.xyz\n#define FSInput_faceSideSign v_normal.w\n#define FSInput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define FSInput_vertexColor v_color\n#else\n #define FSInput_vertexColor vec4(1.0)\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define FSInput_worldTangent v_tangent.xyz\n #define FSInput_mirrorNormal v_tangent.w\n#else\n #define FSInput_worldTangent vec3(1.0, 1.0, 1.0)\n #define FSInput_mirrorNormal 1.0\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define FSInput_texcoord1 v_uv1\n#else\n #define FSInput_texcoord1 vec2(0.0, 0.0)\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define FSInput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define FSInput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define FSInput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define FSInput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define FSInput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define FSInput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define FSInput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define FSInput_clipPos v_clipPos\n#endif\nlayout(set = 0, binding = 0) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_WORLD_POS CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR CC_SURFACES_DEBUG_VIEW_WORLD_POS + 1\n#define CC_SURFACES_DEBUG_VIEW_FACE_SIDE CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR + 1\n#define CC_SURFACES_DEBUG_VIEW_UV0 CC_SURFACES_DEBUG_VIEW_FACE_SIDE + 1\n#define CC_SURFACES_DEBUG_VIEW_UV1 CC_SURFACES_DEBUG_VIEW_UV0 + 1\n#define CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP CC_SURFACES_DEBUG_VIEW_UV1 + 1\n#define CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP + 1\n#define CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_BASE_COLOR CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR CC_SURFACES_DEBUG_VIEW_BASE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSPARENCY CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_METALLIC CC_SURFACES_DEBUG_VIEW_TRANSPARENCY + 1\n#define CC_SURFACES_DEBUG_VIEW_ROUGHNESS CC_SURFACES_DEBUG_VIEW_METALLIC + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY CC_SURFACES_DEBUG_VIEW_ROUGHNESS + 1\n#define CC_SURFACES_DEBUG_VIEW_IOR CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_IOR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_ALL CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_DIRECT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_ALL CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_EMISSIVE CC_SURFACES_DEBUG_VIEW_ENV_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_LIGHT_MAP CC_SURFACES_DEBUG_VIEW_EMISSIVE + 1\n#define CC_SURFACES_DEBUG_VIEW_SHADOW CC_SURFACES_DEBUG_VIEW_LIGHT_MAP + 1\n#define CC_SURFACES_DEBUG_VIEW_AO CC_SURFACES_DEBUG_VIEW_SHADOW + 1\n#define CC_SURFACES_DEBUG_VIEW_FRESNEL CC_SURFACES_DEBUG_VIEW_AO + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_FRESNEL + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_FOG CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL + 1\n#define IS_DEBUG_VIEW_ENABLE_WITH_CAMERA (cc_surfaceTransform.y != 3.0)\nbool equalf_mode(float data1, float data2) { return abs(float(data1) - float(data2)) < 0.001; }\n#define IS_DEBUG_VIEW_LIGHTING_ENABLE_WITH_ALBEDO (UnpackBitFromFloat(cc_debug_view_mode.w, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_MISC_ENABLE_CSM_LAYER_COLORATION (UnpackBitFromFloat(cc_debug_view_mode.w, 7) && IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_EMISSIVE (UnpackBitFromFloat(cc_debug_view_mode.y, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_LIGHT_MAP (UnpackBitFromFloat(cc_debug_view_mode.y, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_SHADOW (UnpackBitFromFloat(cc_debug_view_mode.y, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_AO (UnpackBitFromFloat(cc_debug_view_mode.y, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_NORMAL_MAP (UnpackBitFromFloat(cc_debug_view_mode.z, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FOG (UnpackBitFromFloat(cc_debug_view_mode.z, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TONE_MAPPING (UnpackBitFromFloat(cc_debug_view_mode.z, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION (UnpackBitFromFloat(cc_debug_view_mode.z, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FRESNEL (UnpackBitFromFloat(cc_debug_view_mode.z, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.z, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_2ND_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TT (UnpackBitFromFloat(cc_debug_view_mode.w, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#if (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\n #if CC_FORWARD_ADD\n #if CC_PIPELINE_TYPE == 0\n #define LIGHTS_PER_PASS 1\n #else\n #define LIGHTS_PER_PASS 10\n #endif\n #if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\n layout(set = 2, binding = 1) uniform CCForwardLight {\n highp vec4 cc_lightPos[LIGHTS_PER_PASS];\n vec4 cc_lightColor[LIGHTS_PER_PASS];\n vec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\n vec4 cc_lightDir[LIGHTS_PER_PASS];\n vec4 cc_lightBoundingSizeVS[LIGHTS_PER_PASS];\n };\n #endif\n #endif\n#endif\n#if CC_USE_LIGHT_PROBE\n #if !USE_INSTANCING\n layout(set = 2, binding = 6) uniform CCSH {\n vec4 cc_sh_linear_const_r;\n vec4 cc_sh_linear_const_g;\n vec4 cc_sh_linear_const_b;\n vec4 cc_sh_quadratic_r;\n vec4 cc_sh_quadratic_g;\n vec4 cc_sh_quadratic_b;\n vec4 cc_sh_quadratic_a;\n };\n #endif\n#endif\nlayout(set = 0, binding = 2) uniform CCShadow {\n highp mat4 cc_matLightView;\n highp mat4 cc_matLightViewProj;\n highp vec4 cc_shadowInvProjDepthInfo;\n highp vec4 cc_shadowProjDepthInfo;\n highp vec4 cc_shadowProjInfo;\n mediump vec4 cc_shadowNFLSInfo;\n mediump vec4 cc_shadowWHPBInfo;\n mediump vec4 cc_shadowLPNNInfo;\n lowp vec4 cc_shadowColor;\n mediump vec4 cc_planarNDInfo;\n};\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n layout(set = 0, binding = 3) uniform CCCSM {\n highp vec4 cc_csmViewDir0[4];\n highp vec4 cc_csmViewDir1[4];\n highp vec4 cc_csmViewDir2[4];\n highp vec4 cc_csmAtlas[4];\n highp mat4 cc_matCSMViewProj[4];\n highp vec4 cc_csmProjDepthInfo[4];\n highp vec4 cc_csmProjInfo[4];\n highp vec4 cc_csmSplitsInfo;\n };\n#endif\nlayout(set = 0, binding = 5) uniform samplerCube cc_environment;\n#if CC_USE_IBL\n #if CC_USE_DIFFUSEMAP\n layout(set = 0, binding = 7) uniform samplerCube cc_diffuseMap;\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n layout(set = 2, binding = 15) uniform samplerCube cc_reflectionProbeCubemap;\n layout(set = 2, binding = 16) uniform sampler2D cc_reflectionProbePlanarMap;\n layout(set = 2, binding = 17) uniform sampler2D cc_reflectionProbeDataMap;\n layout(set = 2, binding = 18) uniform samplerCube cc_reflectionProbeBlendCubemap;\n#endif\n#define UnpackBitFromFloat(value, bit) (mod(floor(value / pow(10.0, float(bit))), 10.0) > 0.0)\nhighp float unpackHighpData (float mainPart, float modPart) {\n highp float data = mainPart;\n return data + modPart;\n}\nvoid packHighpData (out float mainPart, out float modPart, highp float data) {\n mainPart = fract(data);\n modPart = data - mainPart;\n}\nhighp float unpackHighpData (float mainPart, float modPart, const float modValue) {\n highp float data = mainPart * modValue;\n return data + modPart * modValue;\n}\nvoid packHighpData (out float mainPart, out float modPart, highp float data, const float modValue) {\n highp float divide = data / modValue;\n mainPart = floor(divide);\n modPart = (data - mainPart * modValue) / modValue;\n}\nhighp vec2 unpackHighpData (vec2 mainPart, vec2 modPart) {\n highp vec2 data = mainPart;\n return data + modPart;\n}\nvoid packHighpData (out vec2 mainPart, out vec2 modPart, highp vec2 data) {\n mainPart = fract(data);\n modPart = data - mainPart;\n}\nhighp vec2 unpackHighpData (vec2 mainPart, vec2 modPart, const float modValue) {\n highp vec2 data = mainPart * modValue;\n return data + modPart * modValue;\n}\nvoid packHighpData (out vec2 mainPart, out vec2 modPart, highp vec2 data, const float modValue) {\n highp vec2 divide = data / modValue;\n mainPart = floor(divide);\n modPart = (data - mainPart * modValue) / modValue;\n}\nhighp vec3 unpackHighpData (vec3 mainPart, vec3 modPart) {\n highp vec3 data = mainPart;\n return data + modPart;\n}\nvoid packHighpData (out vec3 mainPart, out vec3 modPart, highp vec3 data) {\n mainPart = fract(data);\n modPart = data - mainPart;\n}\nhighp vec3 unpackHighpData (vec3 mainPart, vec3 modPart, const float modValue) {\n highp vec3 data = mainPart * modValue;\n return data + modPart * modValue;\n}\nvoid packHighpData (out vec3 mainPart, out vec3 modPart, highp vec3 data, const float modValue) {\n highp vec3 divide = data / modValue;\n mainPart = floor(divide);\n modPart = (data - mainPart * modValue) / modValue;\n}\nhighp vec4 unpackHighpData (vec4 mainPart, vec4 modPart) {\n highp vec4 data = mainPart;\n return data + modPart;\n}\nvoid packHighpData (out vec4 mainPart, out vec4 modPart, highp vec4 data) {\n mainPart = fract(data);\n modPart = data - mainPart;\n}\nhighp vec4 unpackHighpData (vec4 mainPart, vec4 modPart, const float modValue) {\n highp vec4 data = mainPart * modValue;\n return data + modPart * modValue;\n}\nvoid packHighpData (out vec4 mainPart, out vec4 modPart, highp vec4 data, const float modValue) {\n highp vec4 divide = data / modValue;\n mainPart = floor(divide);\n modPart = (data - mainPart * modValue) / modValue;\n}\nvec4 packRGBE (vec3 rgb) {\n highp float maxComp = max(max(rgb.r, rgb.g), rgb.b);\n highp float e = 128.0;\n if (maxComp > 0.0001) {\n e = log(maxComp) / log(1.1);\n e = ceil(e);\n e = clamp(e + 128.0, 0.0, 255.0);\n }\n highp float sc = 1.0 / pow(1.1, e - 128.0);\n vec3 encode = clamp(rgb * sc, vec3(0.0), vec3(1.0)) * 255.0;\n vec3 encode_rounded = floor(encode) + step(encode - floor(encode), vec3(0.5));\n return vec4(encode_rounded, e) / 255.0;\n}\nvec3 ACESToneMap (vec3 color) {\n color = min(color, vec3(8.0));\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec3 HDRToLDR(vec3 color)\n{\n #if CC_USE_HDR\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (IS_DEBUG_VIEW_COMPOSITE_ENABLE_TONE_MAPPING)\n #endif\n {\n #if CC_TONE_MAPPING_TYPE == HDR_TONE_MAPPING_ACES\n color.rgb = ACESToneMap(color.rgb);\n #endif\n }\n #endif\n return color;\n}\nvec3 SRGBToLinear (vec3 gamma) {\n#ifdef CC_USE_SURFACE_SHADER\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION) {\n return gamma;\n }\n #endif\n#endif\n return gamma * gamma;\n}\nvec3 LinearToSRGB(vec3 linear) {\n#ifdef CC_USE_SURFACE_SHADER\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION) {\n return linear;\n }\n #endif\n#endif\n return sqrt(linear);\n}\nbool isnans(vec2 val) {\n return isnan(val.x) || isnan(val.y);\n}\nbool isnans(vec3 val) {\n return isnan(val.x) || isnan(val.y) || isnan(val.z);\n}\nbool isnans(vec4 val) {\n return isnan(val.x) || isnan(val.y) || isnan(val.z) || isnan(val.w);\n}\nbool isinfs(vec2 val) {\n return isinf(val.x) || isinf(val.y);\n}\nbool isinfs(vec3 val) {\n return isinf(val.x) || isinf(val.y) || isinf(val.z);\n}\nbool isinfs(vec4 val) {\n return isinf(val.x) || isinf(val.y) || isinf(val.z) || isinf(val.w);\n}\n#if defined(CC_USE_METAL) || defined(CC_USE_WGPU)\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y) y = -y\n#else\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y)\n#endif\nfloat GetLinearDepthFromViewSpace(vec3 viewPos, float near, float far) {\n float dist = length(viewPos);\n return (dist - near) / (far - near);\n}\nvec3 CalculateBinormal(vec3 normal, vec3 tangent, float mirrorNormal)\n{\n return cross(normal, tangent) * mirrorNormal;\n}\nvec3 CalculateNormalFromTangentSpace(vec3 normalFromTangentSpace, float normalStrength, vec3 normal, vec3 tangent, float mirrorNormal)\n{\n vec3 binormal = CalculateBinormal(normal, tangent, mirrorNormal);\n return (normalFromTangentSpace.x * normalStrength) * normalize(tangent) +\n (normalFromTangentSpace.y * normalStrength) * normalize(binormal) +\n normalFromTangentSpace.z * normalize(normal);\n}\nvec2 signNotZero(vec2 v) {\n return vec2((v.x >= 0.0) ? +1.0 : -1.0, (v.y >= 0.0) ? +1.0 : -1.0);\n}\nvec2 float32x3_to_oct(in vec3 v) {\n vec2 p = v.xy * (1.0 / (abs(v.x) + abs(v.y) + abs(v.z)));\n return (v.z <= 0.0) ? ((1.0 - abs(p.yx)) * signNotZero(p)) : p;\n}\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n#endif\nfloat CCGetLinearDepth(vec3 worldPos, float viewSpaceBias) {\n\tvec4 viewPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\n viewPos.z += viewSpaceBias;\n\treturn GetLinearDepthFromViewSpace(viewPos.xyz, cc_shadowNFLSInfo.x, cc_shadowNFLSInfo.y);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\n\treturn CCGetLinearDepth(worldPos, 0.0);\n}\n#if CC_RECEIVE_SHADOW\n layout(set = 0, binding = 4) uniform highp sampler2D cc_shadowMap;\n layout(set = 0, binding = 6) uniform highp sampler2D cc_spotShadowMap;\n float SampleShadowMap (vec3 shadowNDCPos, highp sampler2D shadowMap)\n {\n #if CC_SHADOWMAP_FORMAT == 1\n return dot(texture(shadowMap, shadowNDCPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n #else\n return texture(shadowMap, shadowNDCPos.xy).x;\n #endif\n }\n float SampleShadowMapSoft (vec3 shadowNDCPos, highp sampler2D shadowMap, vec2 shadowMapResolution)\n {\n vec2 oneTap = 1.0 / shadowMapResolution;\n vec2 shadowNDCPos_offset = shadowNDCPos.xy + oneTap;\n float block0 = SampleShadowMap(vec3(shadowNDCPos.x, shadowNDCPos.y, shadowNDCPos.z), shadowMap);\n float block1 = SampleShadowMap(vec3(shadowNDCPos_offset.x, shadowNDCPos.y, shadowNDCPos.z), shadowMap);\n float block2 = SampleShadowMap(vec3(shadowNDCPos.x, shadowNDCPos_offset.y, shadowNDCPos.z), shadowMap);\n float block3 = SampleShadowMap(vec3(shadowNDCPos_offset.x, shadowNDCPos_offset.y, shadowNDCPos.z), shadowMap);\n float coefX = mod(shadowNDCPos.x, oneTap.x) * shadowMapResolution.x;\n float resultX = mix(block0, block1, coefX);\n float resultY = mix(block2, block3, coefX);\n float coefY = mod(shadowNDCPos.y, oneTap.y) * shadowMapResolution.y;\n return mix(resultX, resultY, coefY);\n }\n float NativePCFShadowFactorHard (vec3 shadowNDCPos, highp sampler2D shadowMap, vec2 shadowMapResolution)\n {\n #if CC_SHADOWMAP_FORMAT == 1\n return step(shadowNDCPos.z, dot(texture(shadowMap, shadowNDCPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n #else\n return step(shadowNDCPos.z, texture(shadowMap, shadowNDCPos.xy).x);\n #endif\n }\n float NativePCFShadowFactorSoft (vec3 shadowNDCPos, highp sampler2D shadowMap, vec2 shadowMapResolution)\n {\n vec2 oneTap = 1.0 / shadowMapResolution;\n vec2 shadowNDCPos_offset = shadowNDCPos.xy + oneTap;\n float block0, block1, block2, block3;\n #if CC_SHADOWMAP_FORMAT == 1\n block0 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block1 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos_offset.x, shadowNDCPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block2 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block3 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos_offset.x, shadowNDCPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n #else\n block0 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos.y)).x);\n block1 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos_offset.x, shadowNDCPos.y)).x);\n block2 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos_offset.y)).x);\n block3 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos_offset.x, shadowNDCPos_offset.y)).x);\n #endif\n float coefX = mod(shadowNDCPos.x, oneTap.x) * shadowMapResolution.x;\n float resultX = mix(block0, block1, coefX);\n float resultY = mix(block2, block3, coefX);\n float coefY = mod(shadowNDCPos.y, oneTap.y) * shadowMapResolution.y;\n return mix(resultX, resultY, coefY);\n }\n float NativePCFShadowFactorSoft3X (vec3 shadowNDCPos, highp sampler2D shadowMap, vec2 shadowMapResolution)\n {\n vec2 oneTap = 1.0 / shadowMapResolution;\n float shadowNDCPos_offset_L = shadowNDCPos.x - oneTap.x;\n float shadowNDCPos_offset_R = shadowNDCPos.x + oneTap.x;\n float shadowNDCPos_offset_U = shadowNDCPos.y - oneTap.y;\n float shadowNDCPos_offset_D = shadowNDCPos.y + oneTap.y;\n float block0, block1, block2, block3, block4, block5, block6, block7, block8;\n #if CC_SHADOWMAP_FORMAT == 1\n block0 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos_offset_L, shadowNDCPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block1 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block2 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos_offset_R, shadowNDCPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block3 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos_offset_L, shadowNDCPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block4 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block5 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos_offset_R, shadowNDCPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block6 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos_offset_L, shadowNDCPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block7 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block8 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos_offset_R, shadowNDCPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n #else\n block0 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos_offset_L, shadowNDCPos_offset_U)).x);\n block1 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos_offset_U)).x);\n block2 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos_offset_R, shadowNDCPos_offset_U)).x);\n block3 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos_offset_L, shadowNDCPos.y)).x);\n block4 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos.y)).x);\n block5 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos_offset_R, shadowNDCPos.y)).x);\n block6 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos_offset_L, shadowNDCPos_offset_D)).x);\n block7 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos_offset_D)).x);\n block8 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos_offset_R, shadowNDCPos_offset_D)).x);\n #endif\n float coefX = mod(shadowNDCPos.x, oneTap.x) * shadowMapResolution.x;\n float coefY = mod(shadowNDCPos.y, oneTap.y) * shadowMapResolution.y;\n float shadow = 0.0;\n float resultX = mix(block0, block1, coefX);\n float resultY = mix(block3, block4, coefX);\n shadow += mix(resultX , resultY, coefY);\n resultX = mix(block1, block2, coefX);\n resultY = mix(block4, block5, coefX);\n shadow += mix(resultX , resultY, coefY);\n resultX = mix(block3, block4, coefX);\n resultY = mix(block6, block7, coefX);\n shadow += mix(resultX, resultY, coefY);\n resultX = mix(block4, block5, coefX);\n resultY = mix(block7, block8, coefX);\n shadow += mix(resultX, resultY, coefY);\n return shadow * 0.25;\n }\n float NativePCFShadowFactorSoft5X (vec3 shadowNDCPos, highp sampler2D shadowMap, vec2 shadowMapResolution)\n {\n vec2 oneTap = 1.0 / shadowMapResolution;\n vec2 twoTap = oneTap * 2.0;\n vec2 offset1 = shadowNDCPos.xy + vec2(-twoTap.x, -twoTap.y);\n vec2 offset2 = shadowNDCPos.xy + vec2(-oneTap.x, -twoTap.y);\n vec2 offset3 = shadowNDCPos.xy + vec2(0.0, -twoTap.y);\n vec2 offset4 = shadowNDCPos.xy + vec2(oneTap.x, -twoTap.y);\n vec2 offset5 = shadowNDCPos.xy + vec2(twoTap.x, -twoTap.y);\n vec2 offset6 = shadowNDCPos.xy + vec2(-twoTap.x, -oneTap.y);\n vec2 offset7 = shadowNDCPos.xy + vec2(-oneTap.x, -oneTap.y);\n vec2 offset8 = shadowNDCPos.xy + vec2(0.0, -oneTap.y);\n vec2 offset9 = shadowNDCPos.xy + vec2(oneTap.x, -oneTap.y);\n vec2 offset10 = shadowNDCPos.xy + vec2(twoTap.x, -oneTap.y);\n vec2 offset11 = shadowNDCPos.xy + vec2(-twoTap.x, 0.0);\n vec2 offset12 = shadowNDCPos.xy + vec2(-oneTap.x, 0.0);\n vec2 offset13 = shadowNDCPos.xy + vec2(0.0, 0.0);\n vec2 offset14 = shadowNDCPos.xy + vec2(oneTap.x, 0.0);\n vec2 offset15 = shadowNDCPos.xy + vec2(twoTap.x, 0.0);\n vec2 offset16 = shadowNDCPos.xy + vec2(-twoTap.x, oneTap.y);\n vec2 offset17 = shadowNDCPos.xy + vec2(-oneTap.x, oneTap.y);\n vec2 offset18 = shadowNDCPos.xy + vec2(0.0, oneTap.y);\n vec2 offset19 = shadowNDCPos.xy + vec2(oneTap.x, oneTap.y);\n vec2 offset20 = shadowNDCPos.xy + vec2(twoTap.x, oneTap.y);\n vec2 offset21 = shadowNDCPos.xy + vec2(-twoTap.x, twoTap.y);\n vec2 offset22 = shadowNDCPos.xy + vec2(-oneTap.x, twoTap.y);\n vec2 offset23 = shadowNDCPos.xy + vec2(0.0, twoTap.y);\n vec2 offset24 = shadowNDCPos.xy + vec2(oneTap.x, twoTap.y);\n vec2 offset25 = shadowNDCPos.xy + vec2(twoTap.x, twoTap.y);\n float block1, block2, block3, block4, block5, block6, block7, block8, block9, block10, block11, block12, block13, block14, block15, block16, block17, block18, block19, block20, block21, block22, block23, block24, block25;\n #if CC_SHADOWMAP_FORMAT == 1\n block1 = step(shadowNDCPos.z, dot(texture(shadowMap, offset1), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block2 = step(shadowNDCPos.z, dot(texture(shadowMap, offset2), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block3 = step(shadowNDCPos.z, dot(texture(shadowMap, offset3), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block4 = step(shadowNDCPos.z, dot(texture(shadowMap, offset4), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block5 = step(shadowNDCPos.z, dot(texture(shadowMap, offset5), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block6 = step(shadowNDCPos.z, dot(texture(shadowMap, offset6), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block7 = step(shadowNDCPos.z, dot(texture(shadowMap, offset7), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block8 = step(shadowNDCPos.z, dot(texture(shadowMap, offset8), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block9 = step(shadowNDCPos.z, dot(texture(shadowMap, offset9), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block10 = step(shadowNDCPos.z, dot(texture(shadowMap, offset10), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block11 = step(shadowNDCPos.z, dot(texture(shadowMap, offset11), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block12 = step(shadowNDCPos.z, dot(texture(shadowMap, offset12), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block13 = step(shadowNDCPos.z, dot(texture(shadowMap, offset13), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block14 = step(shadowNDCPos.z, dot(texture(shadowMap, offset14), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block15 = step(shadowNDCPos.z, dot(texture(shadowMap, offset15), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block16 = step(shadowNDCPos.z, dot(texture(shadowMap, offset16), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block17 = step(shadowNDCPos.z, dot(texture(shadowMap, offset17), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block18 = step(shadowNDCPos.z, dot(texture(shadowMap, offset18), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block19 = step(shadowNDCPos.z, dot(texture(shadowMap, offset19), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block20 = step(shadowNDCPos.z, dot(texture(shadowMap, offset20), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block21 = step(shadowNDCPos.z, dot(texture(shadowMap, offset21), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block22 = step(shadowNDCPos.z, dot(texture(shadowMap, offset22), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block23 = step(shadowNDCPos.z, dot(texture(shadowMap, offset23), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block24 = step(shadowNDCPos.z, dot(texture(shadowMap, offset24), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block25 = step(shadowNDCPos.z, dot(texture(shadowMap, offset25), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n #else\n block1 = step(shadowNDCPos.z, texture(shadowMap, offset1).x);\n block2 = step(shadowNDCPos.z, texture(shadowMap, offset2).x);\n block3 = step(shadowNDCPos.z, texture(shadowMap, offset3).x);\n block4 = step(shadowNDCPos.z, texture(shadowMap, offset4).x);\n block5 = step(shadowNDCPos.z, texture(shadowMap, offset5).x);\n block6 = step(shadowNDCPos.z, texture(shadowMap, offset6).x);\n block7 = step(shadowNDCPos.z, texture(shadowMap, offset7).x);\n block8 = step(shadowNDCPos.z, texture(shadowMap, offset8).x);\n block9 = step(shadowNDCPos.z, texture(shadowMap, offset9).x);\n block10 = step(shadowNDCPos.z, texture(shadowMap, offset10).x);\n block11 = step(shadowNDCPos.z, texture(shadowMap, offset11).x);\n block12 = step(shadowNDCPos.z, texture(shadowMap, offset12).x);\n block13 = step(shadowNDCPos.z, texture(shadowMap, offset13).x);\n block14 = step(shadowNDCPos.z, texture(shadowMap, offset14).x);\n block15 = step(shadowNDCPos.z, texture(shadowMap, offset15).x);\n block16 = step(shadowNDCPos.z, texture(shadowMap, offset16).x);\n block17 = step(shadowNDCPos.z, texture(shadowMap, offset17).x);\n block18 = step(shadowNDCPos.z, texture(shadowMap, offset18).x);\n block19 = step(shadowNDCPos.z, texture(shadowMap, offset19).x);\n block20 = step(shadowNDCPos.z, texture(shadowMap, offset20).x);\n block21 = step(shadowNDCPos.z, texture(shadowMap, offset21).x);\n block22 = step(shadowNDCPos.z, texture(shadowMap, offset22).x);\n block23 = step(shadowNDCPos.z, texture(shadowMap, offset23).x);\n block24 = step(shadowNDCPos.z, texture(shadowMap, offset24).x);\n block25 = step(shadowNDCPos.z, texture(shadowMap, offset25).x);\n #endif\n vec2 coef = fract(shadowNDCPos.xy * shadowMapResolution);\n vec2 v1X1 = mix(vec2(block1, block6), vec2(block2, block7), coef.xx);\n vec2 v1X2 = mix(vec2(block2, block7), vec2(block3, block8), coef.xx);\n vec2 v1X3 = mix(vec2(block3, block8), vec2(block4, block9), coef.xx);\n vec2 v1X4 = mix(vec2(block4, block9), vec2(block5, block10), coef.xx);\n float v1 = mix(v1X1.x, v1X1.y, coef.y) + mix(v1X2.x, v1X2.y, coef.y) + mix(v1X3.x, v1X3.y, coef.y) + mix(v1X4.x, v1X4.y, coef.y);\n vec2 v2X1 = mix(vec2(block6, block11), vec2(block7, block12), coef.xx);\n vec2 v2X2 = mix(vec2(block7, block12), vec2(block8, block13), coef.xx);\n vec2 v2X3 = mix(vec2(block8, block13), vec2(block9, block14), coef.xx);\n vec2 v2X4 = mix(vec2(block9, block14), vec2(block10, block15), coef.xx);\n float v2 = mix(v2X1.x, v2X1.y, coef.y) + mix(v2X2.x, v2X2.y, coef.y) + mix(v2X3.x, v2X3.y, coef.y) + mix(v2X4.x, v2X4.y, coef.y);\n vec2 v3X1 = mix(vec2(block11, block16), vec2(block12, block17), coef.xx);\n vec2 v3X2 = mix(vec2(block12, block17), vec2(block13, block18), coef.xx);\n vec2 v3X3 = mix(vec2(block13, block18), vec2(block14, block19), coef.xx);\n vec2 v3X4 = mix(vec2(block14, block19), vec2(block15, block20), coef.xx);\n float v3 = mix(v3X1.x, v3X1.y, coef.y) + mix(v3X2.x, v3X2.y, coef.y) + mix(v3X3.x, v3X3.y, coef.y) + mix(v3X4.x, v3X4.y, coef.y);\n vec2 v4X1 = mix(vec2(block16, block21), vec2(block17, block22), coef.xx);\n vec2 v4X2 = mix(vec2(block17, block22), vec2(block18, block23), coef.xx);\n vec2 v4X3 = mix(vec2(block18, block23), vec2(block19, block24), coef.xx);\n vec2 v4X4 = mix(vec2(block19, block24), vec2(block20, block25), coef.xx);\n float v4 = mix(v4X1.x, v4X1.y, coef.y) + mix(v4X2.x, v4X2.y, coef.y) + mix(v4X3.x, v4X3.y, coef.y) + mix(v4X4.x, v4X4.y, coef.y);\n float fAvg = (v1 + v2 + v3 + v4) * 0.0625;\n return fAvg;\n }\n bool GetShadowNDCPos(out vec3 shadowNDCPos, vec4 shadowPosWithDepthBias)\n {\n \tshadowNDCPos = shadowPosWithDepthBias.xyz / shadowPosWithDepthBias.w * 0.5 + 0.5;\n \tif (shadowNDCPos.x < 0.0 || shadowNDCPos.x > 1.0 ||\n \t\tshadowNDCPos.y < 0.0 || shadowNDCPos.y > 1.0 ||\n \t\tshadowNDCPos.z < 0.0 || shadowNDCPos.z > 1.0) {\n \t\treturn false;\n \t}\n \tshadowNDCPos.xy = cc_cameraPos.w == 1.0 ? vec2(shadowNDCPos.xy.x, 1.0 - shadowNDCPos.xy.y) : shadowNDCPos.xy;\n \treturn true;\n }\n vec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal, float normalBias, vec3 matViewDir0, vec3 matViewDir1, vec3 matViewDir2, vec2 projScaleXY)\n {\n vec4 newShadowPos = shadowPos;\n if (normalBias > EPSILON_LOWP)\n {\n vec3 viewNormal = vec3(dot(matViewDir0, worldNormal), dot(matViewDir1, worldNormal), dot(matViewDir2, worldNormal));\n if (viewNormal.z < 0.1)\n newShadowPos.xy += viewNormal.xy * projScaleXY * normalBias * clamp(viewNormal.z, 0.001, 0.1);\n }\n return newShadowPos;\n }\n vec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal, float normalBias, mat4 matLightView, vec2 projScaleXY)\n {\n \tvec4 newShadowPos = shadowPos;\n \tif (normalBias > EPSILON_LOWP)\n \t{\n \t\tvec4 viewNormal = matLightView * vec4(worldNormal, 0.0);\n \t\tif (viewNormal.z < 0.1)\n \t\t\tnewShadowPos.xy += viewNormal.xy * projScaleXY * normalBias * clamp(viewNormal.z, 0.001, 0.1);\n \t}\n \treturn newShadowPos;\n }\n float GetViewSpaceDepthFromNDCDepth_Orthgraphic(float NDCDepth, float projScaleZ, float projBiasZ)\n {\n \treturn (NDCDepth - projBiasZ) / projScaleZ;\n }\n float GetViewSpaceDepthFromNDCDepth_Perspective(float NDCDepth, float homogenousDividW, float invProjScaleZ, float invProjBiasZ)\n {\n \treturn NDCDepth * invProjScaleZ + homogenousDividW * invProjBiasZ;\n }\n vec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n {\n \tvec3 viewSpacePos;\n \tviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\n \tviewSpacePos.z = GetViewSpaceDepthFromNDCDepth_Perspective(shadowPos.z, shadowPos.w, cc_shadowInvProjDepthInfo.x, cc_shadowInvProjDepthInfo.y);\n \tviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\n \tvec4 clipSpacePos;\n \tclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\n \tclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\n \t#if CC_SHADOWMAP_USE_LINEAR_DEPTH\n \t\tclipSpacePos.z = GetLinearDepthFromViewSpace(viewSpacePos.xyz, cc_shadowNFLSInfo.x, cc_shadowNFLSInfo.y);\n \t\tclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n \t#endif\n \treturn clipSpacePos;\n }\n vec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias, float projScaleZ, float projBiasZ)\n {\n \tfloat coeffA = projScaleZ;\n \tfloat coeffB = projBiasZ;\n \tfloat viewSpacePos_z = GetViewSpaceDepthFromNDCDepth_Orthgraphic(shadowPos.z, projScaleZ, projBiasZ);\n \tviewSpacePos_z += viewspaceDepthBias;\n \tvec4 result = shadowPos;\n \tresult.z = viewSpacePos_z * coeffA + coeffB;\n \treturn result;\n }\n vec4 ApplyShadowDepthBias_PerspectiveLinearDepth(vec4 shadowPos, float viewspaceDepthBias, vec3 worldPos)\n {\n shadowPos.z = CCGetLinearDepth(worldPos, viewspaceDepthBias) * 2.0 - 1.0;\n shadowPos.z *= shadowPos.w;\n return shadowPos;\n }\n float CCGetDirLightShadowFactorHard (vec4 shadowPosWithDepthBias) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorHard(shadowNDCPos, cc_shadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCGetDirLightShadowFactorSoft (vec4 shadowPosWithDepthBias) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorSoft(shadowNDCPos, cc_shadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCGetDirLightShadowFactorSoft3X (vec4 shadowPosWithDepthBias) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorSoft3X(shadowNDCPos, cc_shadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCGetDirLightShadowFactorSoft5X (vec4 shadowPosWithDepthBias) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorSoft5X(shadowNDCPos, cc_shadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCGetSpotLightShadowFactorHard (vec4 shadowPosWithDepthBias, vec3 worldPos) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorHard(shadowNDCPos, cc_spotShadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCGetSpotLightShadowFactorSoft (vec4 shadowPosWithDepthBias, vec3 worldPos) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorSoft(shadowNDCPos, cc_spotShadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCGetSpotLightShadowFactorSoft3X (vec4 shadowPosWithDepthBias, vec3 worldPos) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorSoft3X(shadowNDCPos, cc_spotShadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCGetSpotLightShadowFactorSoft5X (vec4 shadowPosWithDepthBias, vec3 worldPos) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorSoft5X(shadowNDCPos, cc_spotShadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCSpotShadowFactorBase(out vec4 shadowPosWithDepthBias, vec4 shadowPos, vec3 worldPos, vec2 shadowBias)\n {\n float pcf = cc_shadowWHPBInfo.z;\n vec4 pos = vec4(1.0);\n #if CC_SHADOWMAP_USE_LINEAR_DEPTH\n pos = ApplyShadowDepthBias_PerspectiveLinearDepth(shadowPos, shadowBias.x, worldPos);\n #else\n pos = ApplyShadowDepthBias_Perspective(shadowPos, shadowBias.x);\n #endif\n float realtimeShadow = 1.0;\n if (pcf > 2.9) {\n realtimeShadow = CCGetSpotLightShadowFactorSoft5X(pos, worldPos);\n }else if (pcf > 1.9) {\n realtimeShadow = CCGetSpotLightShadowFactorSoft3X(pos, worldPos);\n }else if (pcf > 0.9) {\n realtimeShadow = CCGetSpotLightShadowFactorSoft(pos, worldPos);\n }else {\n realtimeShadow = CCGetSpotLightShadowFactorHard(pos, worldPos);\n }\n shadowPosWithDepthBias = pos;\n return mix(realtimeShadow, 1.0, cc_shadowNFLSInfo.w);\n }\n float CCShadowFactorBase(out vec4 shadowPosWithDepthBias, vec4 shadowPos, vec3 N, vec2 shadowBias)\n {\n vec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N, shadowBias.y, cc_matLightView, cc_shadowProjInfo.xy);\n pos = ApplyShadowDepthBias_Orthographic(pos, shadowBias.x, cc_shadowProjDepthInfo.x, cc_shadowProjDepthInfo.y);\n float realtimeShadow = 1.0;\n #if CC_DIR_SHADOW_PCF_TYPE == 3\n realtimeShadow = CCGetDirLightShadowFactorSoft5X(pos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 2\n realtimeShadow = CCGetDirLightShadowFactorSoft3X(pos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 1\n realtimeShadow = CCGetDirLightShadowFactorSoft(pos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 0\n realtimeShadow = CCGetDirLightShadowFactorHard(pos);\n #endif\n shadowPosWithDepthBias = pos;\n return mix(realtimeShadow, 1.0, cc_shadowNFLSInfo.w);\n }\n #if CC_SUPPORT_CASCADED_SHADOW_MAP\n bool CCGetCSMLevelWithTransition(out highp float ratio, vec3 clipPos) {\n highp float maxRange = 1.0 - cc_csmSplitsInfo.x;\n highp float minRange = cc_csmSplitsInfo.x;\n highp float thresholdInvert = 1.0 / cc_csmSplitsInfo.x;\n ratio = 0.0;\n if (clipPos.x <= minRange) {\n ratio = clipPos.x * thresholdInvert;\n return true;\n }\n if (clipPos.x >= maxRange) {\n ratio = 1.0 - (clipPos.x - maxRange) * thresholdInvert;\n return true;\n }\n if (clipPos.y <= minRange) {\n ratio = clipPos.y * thresholdInvert;\n return true;\n }\n if (clipPos.y >= maxRange) {\n ratio = 1.0 - (clipPos.y - maxRange) * thresholdInvert;\n return true;\n }\n return false;\n }\n bool CCHasCSMLevel(int level, vec3 worldPos) {\n highp float layerThreshold = cc_csmViewDir0[0].w;\n bool hasLevel = false;\n for (int i = 0; i < 4; i++) {\n if (i == level) {\n vec4 shadowPos = cc_matCSMViewProj[i] * vec4(worldPos.xyz, 1.0);\n vec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\n if (clipPos.x >= layerThreshold && clipPos.x <= (1.0 - layerThreshold) &&\n clipPos.y >= layerThreshold && clipPos.y <= (1.0 - layerThreshold) &&\n clipPos.z >= 0.0 && clipPos.z <= 1.0) {\n hasLevel = true;\n }\n }\n }\n return hasLevel;\n }\n void CCGetCSMLevel(out vec4 csmPos, out vec4 shadowProjDepthInfo, out vec4 shadowProjInfo, out vec3 shadowViewDir0, out vec3 shadowViewDir1, out vec3 shadowViewDir2, vec3 worldPos, int level) {\n highp float layerThreshold = cc_csmViewDir0[0].w;\n for (int i = 0; i < 4; i++) {\n vec4 shadowPos = cc_matCSMViewProj[i] * vec4(worldPos.xyz, 1.0);\n vec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\n if (clipPos.x >= layerThreshold && clipPos.x <= (1.0 - layerThreshold) &&\n clipPos.y >= layerThreshold && clipPos.y <= (1.0 - layerThreshold) &&\n clipPos.z >= 0.0 && clipPos.z <= 1.0 && i == level) {\n csmPos = cc_matCSMViewProj[i] * vec4(worldPos.xyz, 1.0);\n csmPos.xy = csmPos.xy * cc_csmAtlas[i].xy + cc_csmAtlas[i].zw;\n shadowProjDepthInfo = cc_csmProjDepthInfo[i];\n shadowProjInfo = cc_csmProjInfo[i];\n shadowViewDir0 = cc_csmViewDir0[i].xyz;\n shadowViewDir1 = cc_csmViewDir1[i].xyz;\n shadowViewDir2 = cc_csmViewDir2[i].xyz;\n }\n }\n }\n int CCGetCSMLevel(out bool isTransitionArea, out highp float transitionRatio, out vec4 csmPos, out vec4 shadowProjDepthInfo, out vec4 shadowProjInfo, out vec3 shadowViewDir0, out vec3 shadowViewDir1, out vec3 shadowViewDir2, vec3 worldPos)\n {\n int level = -1;\n highp float layerThreshold = cc_csmViewDir0[0].w;\n for (int i = 0; i < 4; i++) {\n vec4 shadowPos = cc_matCSMViewProj[i] * vec4(worldPos.xyz, 1.0);\n vec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\n if (clipPos.x >= layerThreshold && clipPos.x <= (1.0 - layerThreshold) &&\n clipPos.y >= layerThreshold && clipPos.y <= (1.0 - layerThreshold) &&\n clipPos.z >= 0.0 && clipPos.z <= 1.0 && level < 0) {\n #if CC_CASCADED_LAYERS_TRANSITION\n isTransitionArea = CCGetCSMLevelWithTransition(transitionRatio, clipPos);\n #endif\n csmPos = cc_matCSMViewProj[i] * vec4(worldPos.xyz, 1.0);\n csmPos.xy = csmPos.xy * cc_csmAtlas[i].xy + cc_csmAtlas[i].zw;\n shadowProjDepthInfo = cc_csmProjDepthInfo[i];\n shadowProjInfo = cc_csmProjInfo[i];\n shadowViewDir0 = cc_csmViewDir0[i].xyz;\n shadowViewDir1 = cc_csmViewDir1[i].xyz;\n shadowViewDir2 = cc_csmViewDir2[i].xyz;\n level = i;\n }\n }\n return level;\n }\n int CCGetCSMLevel(out vec4 csmPos, out vec4 shadowProjDepthInfo, out vec4 shadowProjInfo, out vec3 shadowViewDir0, out vec3 shadowViewDir1, out vec3 shadowViewDir2, vec3 worldPos)\n {\n bool isTransitionArea = false;\n highp float transitionRatio = 0.0;\n return CCGetCSMLevel(isTransitionArea, transitionRatio, csmPos, shadowProjDepthInfo, shadowProjInfo, shadowViewDir0, shadowViewDir1, shadowViewDir2, worldPos);\n }\n float CCCSMFactorBase(out vec4 csmPos, out vec4 csmPosWithBias, vec3 worldPos, vec3 N, vec2 shadowBias)\n {\n bool isTransitionArea = false;\n highp float ratio = 0.0;\n csmPos = vec4(1.0);\n vec4 shadowProjDepthInfo, shadowProjInfo;\n vec3 shadowViewDir0, shadowViewDir1, shadowViewDir2;\n int level = -1;\n #if CC_CASCADED_LAYERS_TRANSITION\n level = CCGetCSMLevel(isTransitionArea, ratio, csmPos, shadowProjDepthInfo, shadowProjInfo, shadowViewDir0, shadowViewDir1, shadowViewDir2, worldPos);\n #else\n level = CCGetCSMLevel(csmPos, shadowProjDepthInfo, shadowProjInfo, shadowViewDir0, shadowViewDir1, shadowViewDir2, worldPos);\n #endif\n if (level < 0) { return 1.0; }\n vec4 pos = ApplyShadowDepthBias_FaceNormal(csmPos, N, shadowBias.y, shadowViewDir0, shadowViewDir1, shadowViewDir2, shadowProjInfo.xy);\n pos = ApplyShadowDepthBias_Orthographic(pos, shadowBias.x, shadowProjDepthInfo.x, shadowProjDepthInfo.y);\n csmPosWithBias = pos;\n float realtimeShadow = 1.0;\n #if CC_DIR_SHADOW_PCF_TYPE == 3\n realtimeShadow = CCGetDirLightShadowFactorSoft5X(pos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 2\n realtimeShadow = CCGetDirLightShadowFactorSoft3X(pos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 1\n realtimeShadow = CCGetDirLightShadowFactorSoft(pos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 0\n realtimeShadow = CCGetDirLightShadowFactorHard(pos);\n #endif\n #if CC_CASCADED_LAYERS_TRANSITION\n vec4 nextCSMPos = vec4(1.0);\n vec4 nextShadowProjDepthInfo, nextShadowProjInfo;\n vec3 nextShadowViewDir0, nextShadowViewDir1, nextShadowViewDir2;\n float nextRealtimeShadow = 1.0;\n CCGetCSMLevel(nextCSMPos, nextShadowProjDepthInfo, nextShadowProjInfo, nextShadowViewDir0, nextShadowViewDir1, nextShadowViewDir2, worldPos, level + 1);\n bool hasNextLevel = CCHasCSMLevel(level + 1, worldPos);\n if (hasNextLevel && isTransitionArea) {\n vec4 nexPos = ApplyShadowDepthBias_FaceNormal(nextCSMPos, N, shadowBias.y, nextShadowViewDir0, nextShadowViewDir1, nextShadowViewDir2, nextShadowProjInfo.xy);\n nexPos = ApplyShadowDepthBias_Orthographic(nexPos, shadowBias.x, nextShadowProjDepthInfo.x, nextShadowProjDepthInfo.y);\n #if CC_DIR_SHADOW_PCF_TYPE == 3\n nextRealtimeShadow = CCGetDirLightShadowFactorSoft5X(nexPos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 2\n nextRealtimeShadow = CCGetDirLightShadowFactorSoft3X(nexPos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 1\n nextRealtimeShadow = CCGetDirLightShadowFactorSoft(nexPos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 0\n nextRealtimeShadow = CCGetDirLightShadowFactorHard(nexPos);\n #endif\n return mix(mix(nextRealtimeShadow, realtimeShadow, ratio), 1.0, cc_shadowNFLSInfo.w);\n }\n return mix(realtimeShadow, 1.0, cc_shadowNFLSInfo.w);\n #else\n return mix(realtimeShadow, 1.0, cc_shadowNFLSInfo.w);\n #endif\n }\n #else\n int CCGetCSMLevel(out vec4 csmPos, out vec4 shadowProjDepthInfo, out vec4 shadowProjInfo, out vec3 shadowViewDir0, out vec3 shadowViewDir1, out vec3 shadowViewDir2, vec3 worldPos) {\n return -1;\n }\n float CCCSMFactorBase(out vec4 csmPos, out vec4 csmPosWithBias, vec3 worldPos, vec3 N, vec2 shadowBias) {\n csmPos = cc_matLightViewProj * vec4(worldPos, 1.0);\n return CCShadowFactorBase(csmPosWithBias, csmPos, N, shadowBias);\n }\n #endif\n float CCShadowFactorBase(vec4 shadowPos, vec3 N, vec2 shadowBias) {\n vec4 shadowPosWithDepthBias;\n return CCShadowFactorBase(shadowPosWithDepthBias, shadowPos, N, shadowBias);\n }\n float CCCSMFactorBase(vec3 worldPos, vec3 N, vec2 shadowBias) {\n vec4 csmPos, csmPosWithBias;\n return CCCSMFactorBase(csmPos, csmPosWithBias, worldPos, N, shadowBias);\n }\n float CCSpotShadowFactorBase(vec4 shadowPos, vec3 worldPos, vec2 shadowBias)\n {\n vec4 shadowPosWithDepthBias;\n return CCSpotShadowFactorBase(shadowPosWithDepthBias, shadowPos, worldPos, shadowBias);\n }\n#endif\n#if CC_USE_FOG != 4\n float LinearFog(vec4 pos, vec3 cameraPos, float fogStart, float fogEnd) {\n vec4 wPos = pos;\n float cam_dis = distance(cameraPos, wPos.xyz);\n return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n }\n float ExpFog(vec4 pos, vec3 cameraPos, float fogStart, float fogDensity, float fogAtten) {\n vec4 wPos = pos;\n float cam_dis = max(distance(cameraPos, wPos.xyz) - fogStart, 0.0) / fogAtten * 4.;\n float f = exp(-cam_dis * fogDensity);\n return f;\n }\n float ExpSquaredFog(vec4 pos, vec3 cameraPos, float fogStart, float fogDensity, float fogAtten) {\n vec4 wPos = pos;\n float cam_dis = max(distance(cameraPos, wPos.xyz) - fogStart, 0.0) / fogAtten * 4.;\n float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\n return f;\n }\n float LayeredFog(vec4 pos, vec3 cameraPos, float fogTop, float fogRange, float fogAtten) {\n vec4 wPos = pos;\n vec3 camWorldProj = cameraPos.xyz;\n camWorldProj.y = 0.;\n vec3 worldPosProj = wPos.xyz;\n worldPosProj.y = 0.;\n float fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\n float fDeltaY, fDensityIntegral;\n if (cameraPos.y > fogTop) {\n if (wPos.y < fogTop) {\n fDeltaY = (fogTop - wPos.y) / fogRange * 2.0;\n fDensityIntegral = fDeltaY * fDeltaY * 0.5;\n }\n else {\n fDeltaY = 0.;\n fDensityIntegral = 0.;\n }\n }\n else {\n if (wPos.y < fogTop) {\n float fDeltaA = (fogTop - cameraPos.y) / fogRange * 2.;\n float fDeltaB = (fogTop - wPos.y) / fogRange * 2.;\n fDeltaY = abs(fDeltaA - fDeltaB);\n fDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n }\n else {\n fDeltaY = abs(fogTop - cameraPos.y) / fogRange * 2.;\n fDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n }\n }\n float fDensity;\n if (fDeltaY != 0.) {\n fDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n }\n else {\n fDensity = 0.;\n }\n float f = exp(-fDensity);\n return f;\n }\n#endif\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\n\tfactor = LinearFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.y);\n#elif CC_USE_FOG == 1\n\tfactor = ExpFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z);\n#elif CC_USE_FOG == 2\n\tfactor = ExpSquaredFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z);\n#elif CC_USE_FOG == 3\n\tfactor = LayeredFog(pos, cc_cameraPos.xyz, cc_fogAdd.x, cc_fogAdd.y, cc_fogAdd.z);\n#else\n\tfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\n\tcolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\n#if CC_USE_LIGHT_PROBE\n #if CC_USE_LIGHT_PROBE\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n layout(set = 2, binding = 0) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n highp vec4 cc_localShadowBias;\n highp vec4 cc_reflectionProbeData1;\n highp vec4 cc_reflectionProbeData2;\n highp vec4 cc_reflectionProbeBlendData1;\n highp vec4 cc_reflectionProbeBlendData2;\n };\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n layout(set = 2, binding = 11) uniform sampler2D cc_lightingMap;\n void SampleAndDecodeLightMapColor(out vec3 lightmapColor, out float dirShadow, out float ao, sampler2D lightingMap, vec2 luv, float lum, vec3 worldNormal)\n {\n #if CC_LIGHT_MAP_VERSION > 2\n #elif CC_LIGHT_MAP_VERSION > 1\n \tvec4 dataLow = texture(lightingMap, luv);\n \tvec4 dataHigh = texture(lightingMap, luv + vec2(0.5, 0.0));\n \tlightmapColor.xyz = dataLow.xyz + dataHigh.xyz * 0.00392156862745098;\n lightmapColor.rgb *= lum;\n \tdirShadow = dataLow.a;\n \tao = dataHigh.a;\n #else\n vec4 lightmap = texture(lightingMap, luv);\n lightmapColor = lightmap.rgb * lum;\n \tdirShadow = lightmap.a;\n \tao = 1.0;\n #endif\n }\n void GetLightMapColor(out vec3 lightmapColor, out float dirShadow, out float ao, sampler2D lightingMap, vec2 luv, float lum, vec3 worldNormal)\n {\n \tvec4 lightmap;\n \tvec2 occlusion;\n \tSampleAndDecodeLightMapColor(lightmapColor, dirShadow, ao, lightingMap, luv, lum, worldNormal);\n #if CC_USE_HDR\n lightmapColor.rgb *= cc_exposure.w * cc_exposure.x;\n #endif\n }\n#endif\nlayout(set = 1, binding = 0) uniform Constants {\n vec4 tilingOffset;\n vec4 baseColor;\n vec4 colorScaleAndCutoff;\n vec4 shadeColor1;\n vec4 shadeColor2;\n vec4 specular;\n vec4 shadeParams;\n vec4 miscParams;\n vec4 emissive;\n vec4 emissiveScaleAndStrenth;\n};\n#if USE_BASE_COLOR_MAP\n layout(set = 1, binding = 1) uniform sampler2D baseColorMap;\n#endif\n#if USE_NORMAL_MAP\n layout(set = 1, binding = 2) uniform sampler2D normalMap;\n#endif\n#if USE_1ST_SHADE_MAP\n layout(set = 1, binding = 3) uniform sampler2D shadeMap1;\n#endif\n#if USE_2ND_SHADE_MAP\n layout(set = 1, binding = 4) uniform sampler2D shadeMap2;\n#endif\n#if USE_SPECULAR_MAP\n layout(set = 1, binding = 5) uniform sampler2D specularMap;\n#endif\n#if USE_EMISSIVE_MAP\n layout(set = 1, binding = 6) uniform sampler2D emissiveMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\n#define CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TOONSHADE\nvoid SurfacesFragmentModifyBaseColorAndToonShade(out vec4 baseColorAndTransparency, out vec3 shade1, out vec3 shade2)\n{\n shade2 = shadeColor2.rgb * colorScaleAndCutoff.rgb;\n #if USE_2ND_SHADE_MAP\n shade2 *= SRGBToLinear(texture(shadeMap2, FSInput_texcoord).rgb);\n #endif\n shade1 = shadeColor1.rgb * colorScaleAndCutoff.rgb;\n #if USE_1ST_SHADE_MAP\n shade1 *= SRGBToLinear(texture(shadeMap1, FSInput_texcoord).rgb);\n #if SHADE_MAP_1_AS_SHADE_MAP_2\n shade2 *= shade1.rgb;\n #endif\n #endif\n vec4 color = baseColor;\n #if USE_BASE_COLOR_MAP\n vec4 texColor = texture(baseColorMap, FSInput_texcoord);\n texColor.rgb = SRGBToLinear(texColor.rgb);\n color *= texColor;\n #if BASE_COLOR_MAP_AS_SHADE_MAP_1\n shade1 *= texColor.rgb;\n #endif\n #if BASE_COLOR_MAP_AS_SHADE_MAP_2\n shade2 *= texColor.rgb;\n #endif\n #endif\n baseColorAndTransparency = color;\n baseColorAndTransparency.rgb *= colorScaleAndCutoff.xyz;\n #if USE_ALPHA_TEST\n if (baseColorAndTransparency.ALPHA_TEST_CHANNEL < colorScaleAndCutoff.w) discard;\n #endif\n}\n#define CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY\n#define CC_SURFACES_FRAGMENT_MODIFY_WORLD_NORMAL\nvec3 SurfacesFragmentModifyWorldNormal()\n{\n vec3 normal = FSInput_worldNormal;\n #if USE_NORMAL_MAP\n vec3 nmmp = texture(normalMap, FSInput_texcoord).xyz - vec3(0.5);\n normal = CalculateNormalFromTangentSpace(nmmp, emissiveScaleAndStrenth.w, normalize(normal.xyz), normalize(FSInput_worldTangent), FSInput_mirrorNormal);\n #endif\n return normalize(normal);\n}\n#define CC_SURFACES_FRAGMENT_MODIFY_EMISSIVE\nvec3 SurfacesFragmentModifyEmissive()\n{\n vec3 emissive = emissive.rgb * emissiveScaleAndStrenth.xyz;\n #if USE_EMISSIVE_MAP\n emissive *= SRGBToLinear(texture(emissiveMap, FSInput_texcoord).rgb);\n #endif\n return emissive;\n}\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_STEP_AND_FEATHER\nvec4 SurfacesFragmentModifyToonStepAndFeather()\n{\n return shadeParams;\n}\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_SHADOW_COVER\nfloat SurfacesFragmentModifyToonShadowCover()\n{\n return miscParams.x;\n}\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_SPECULAR\nvec4 SurfacesFragmentModifyToonSpecular()\n{\n vec4 specularParam = specular;\n #if USE_SPECULAR_MAP\n specularParam.rgb *= SRGBToLinear(texture(specularMap, FSInput_texcoord).rgb);\n #endif\n return specularParam;\n}\nstruct LightingIntermediateData\n{\n vec3 N, H, L, V;\n float distToLight, distToLightSqr;\n float distToCamera, distToCameraSqr;\n float angleAttenuation, distAttenuation;\n float NoL, NoV, NoH, VoH;\n float NoLSat, NoVSat, NoHSat;\n float NoVAbsSat, VoHAbsSat;\n #if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\n vec3 worldPosition, worldPosition_fract_part;\n #else\n vec3 worldPosition;\n #endif\n vec3 T, B;\n float specularParam;\n float ior, layerOpacity;\n#if CC_SURFACES_LIGHTING_ANISOTROPIC\n float anisotropyShape;\n#endif\n#if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n vec4 shadowPosAndDepth;\n vec4 transmitDiffuseParams;\n#endif\n#if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR || CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n vec4 transmitScatteringParams;\n vec3 outScatteringColor, inScatteringColor;\n#endif\n#if CC_SURFACES_LIGHTING_TT\n vec3 baseColorTT;\n float ttIntensity, ttScatterCoef;\n#endif\n};\nvoid CCSurfacesLightingGetIntermediateData_PerPixel(inout LightingIntermediateData data, vec3 worldNormal, vec3 worldPos, vec3 worldTangent, vec3 worldBinormal\n#if CC_SURFACES_LIGHTING_ANISOTROPIC\n , float anisotropyShape\n#endif\n)\n{\n data.N = worldNormal;\n data.V = cc_cameraPos.xyz - worldPos;\n data.distToCameraSqr = dot(data.V, data.V);\n data.distToCamera = sqrt(data.distToCameraSqr);\n data.V /= data.distToCamera;\n data.angleAttenuation = data.distAttenuation = 1.0;\n data.NoV = dot(data.N, data.V);\n data.NoVSat = max(data.NoV, 0.0);\n data.NoVAbsSat = max(abs(data.NoV), 0.0);\n #if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\n packHighpData(data.worldPosition, data.worldPosition_fract_part, worldPos);\n #else\n data.worldPosition = worldPos;\n #endif\n data.T = worldTangent;\n data.B = worldBinormal;\n#if CC_SURFACES_LIGHTING_ANISOTROPIC\n data.anisotropyShape = anisotropyShape;\n#endif\n#if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR || CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n data.outScatteringColor = vec3(1.0);\n data.inScatteringColor = vec3(0.0);\n data.transmitScatteringParams = vec4(0.0);\n#endif\n#if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n data.shadowPosAndDepth = vec4(0.0, 0.0, SURFACES_MAX_TRANSMIT_DEPTH_VALUE, SURFACES_MAX_TRANSMIT_DEPTH_VALUE);\n#endif\n#if CC_SURFACES_LIGHTING_TT\n data.baseColorTT = vec3(0.0);\n data.ttIntensity = data.ttScatterCoef = 0.0;\n#endif\n}\nvoid CCSurfacesLightingGetIntermediateData_PerLight(inout LightingIntermediateData data, vec3 lightDirWithDist)\n{\n data.L = lightDirWithDist;\n data.distToLightSqr = dot(data.L, data.L);\n data.distToLight = sqrt(data.distToLightSqr);\n data.L /= data.distToLight;\n data.H = normalize(data.L + data.V);\n data.NoL = dot(data.N, data.L);\n data.NoH = dot(data.N, data.H);\n data.VoH = dot(data.V, data.H);\n data.NoLSat = max(data.NoL, 0.0);\n data.NoHSat = max(data.NoH, 0.0);\n data.VoHAbsSat = max(abs(data.VoH), 0.0);\n}\nstruct LightingResult\n{\n vec3 diffuseColorWithLighting, specularColorWithLighting;\n vec3 directDiffuse, directSpecular, directGF;\n vec3 environmentDiffuse, environmentSpecular, environmentGF;\n float shadow, ao;\n vec3 lightmapColor;\n vec3 emissive;\n vec3 fresnel;\n#if CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n vec3 directDiffuseSubLayers, directSpecularSubLayers;\n vec3 environmentDiffuseSubLayers, environmentSpecularSubLayers;\n#endif\n#if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n vec3 directTransmitSpecular, environmentTransmitSpecular;\n#endif\n#if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n vec3 directTransmitDiffuse, environmentTransmitDiffuse;\n#endif\n#if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n vec3 direct2ndSpecular, environment2ndSpecular;\n vec3 specularColorWithLighting2ndSpecular;\n vec3 directGF2ndSpecular, environmentGF2ndSpecular;\n vec3 directSubLayerF, environmentSubLayerF;\n#endif\n#if CC_SURFACES_LIGHTING_TT\n vec3 directTT;\n vec3 diffuseColorWithLightingTT;\n#endif\n};\nstruct LightingMiscData\n{\n float lightType;\n vec3 lightPos, lightDir;\n vec4 lightColorAndIntensity;\n vec4 lightSizeRangeAngle;\n};\n#define DiffuseCoefficient_EnergyConservation INV_PI\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\n float factor = distSqr * invSqrAttRadius;\n float smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\n return smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\n float attenuation = 1.0 / max(distSqr, 0.01*0.01);\n attenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\n return attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\n float cd = dot(litDir, L);\n float attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\n return (attenuation * attenuation);\n}\nfloat GetOutOfRange (vec3 worldPos, vec3 lightPos, vec3 lookAt, vec3 right, vec3 BoundingHalfSizeVS) {\n vec3 v = vec3(0.0);\n vec3 up = cross(right, lookAt);\n worldPos -= lightPos;\n v.x = dot(worldPos, right);\n v.y = dot(worldPos, up);\n v.z = dot(worldPos, lookAt);\n vec3 result = step(abs(v), BoundingHalfSizeVS);\n return result.x * result.y * result.z;\n}\nfloat CalculateDistanceAttenuation(float distToLightSqr, float lightRadius, float lightRange, float lightType)\n{\n float attRadiusSqrInv = 1.0 / max(lightRange, 0.01);\n attRadiusSqrInv *= attRadiusSqrInv;\n float litRadiusSqr = lightRadius * lightRadius;\n float edgeAttenuation = (IS_POINT_LIGHT(lightType) || IS_RANGED_DIRECTIONAL_LIGHT(lightType)) ? 1.0 : litRadiusSqr / max(litRadiusSqr, distToLightSqr);\n return GetDistAtt(distToLightSqr, attRadiusSqrInv) * edgeAttenuation;\n}\nfloat CalculateAngleAttenuation(vec3 spotLightDir, vec3 L, float cosAngleOuter)\n{\n float cosInner = max(dot(spotLightDir, L), 0.01);\n float litAngleScale = 1.0 / max(0.001, cosInner - cosAngleOuter);\n float litAngleOffset = -cosAngleOuter * litAngleScale;\n return GetAngleAtt(L, spotLightDir, litAngleScale, litAngleOffset);\n}\nbool CCSurfacesLightingEnableShadow(in float NoL)\n{\n return NoL > 0.0;\n}\nfloat CCSurfacesLightingCalculateDistanceAttenuation(in LightingIntermediateData lightingData, in vec4 lightSizeRangeAngle, in float lightType)\n{\n return CalculateDistanceAttenuation(lightingData.distToLightSqr, lightSizeRangeAngle.x, lightSizeRangeAngle.y, lightType);\n}\nfloat CCSurfacesLightingCalculateAngleAttenuation(in LightingIntermediateData lightingData, in vec4 lightSizeRangeAngle, in vec3 spotLightDir)\n{\n return CalculateAngleAttenuation(spotLightDir, lightingData.L, lightSizeRangeAngle.z);\n}\nvoid CCSurfacesLightingCalculateDirect(out vec3 lightingDiffuse, out vec3 lightingSpecular, in LightingIntermediateData lightingData, in vec4 lightSourceColorAndIntensity)\n{\n vec3 irradiance = lightSourceColorAndIntensity.rgb * lightSourceColorAndIntensity.w;\n lightingDiffuse = irradiance;\n#if CC_FORWARD_ADD\n float NL = 0.5 * lightingData.NoL + 0.5;\n lightingDiffuse *= NL;\n#endif\n float NH = 0.5 * lightingData.NoH + 0.5;\n float specularWeight = 1.0 - pow(lightingData.specularParam, 5.0);\n float specularMask = step(specularWeight + EPSILON_LOWP, NH);\n lightingSpecular = irradiance * specularMask;\n}\nvoid CCSurfacesLightingCalculateEnvironment(out vec3 lightingDiffuse, out vec3 lightingSpecular, in LightingIntermediateData lightingData, float lightIntensity)\n{\n lightingDiffuse = vec3(0.0);\n lightingSpecular = vec3(0.0);\n}\n#if CC_SURFACES_LIGHTING_USE_FRESNEL\nvec3 CCSurfaceLightingCalculateExtraFresnel(in LightingIntermediateData lightingData)\n{\n return vec3(1.0);\n}\n#endif\nvoid CCSurfaceLightingCalculateDirectFresnel(out vec3 fresnel, in LightingIntermediateData lightingData, vec3 specularColor, in vec3 environmentGF)\n{\n fresnel = vec3(1.0);\n}\nvoid CCSurfaceLightingCalculateEnvironmentFresnel(out vec3 integratedGF, out vec3 integratedF, in LightingIntermediateData lightingData, vec3 specularColor)\n{\n integratedF = integratedGF = vec3(1.0);\n}\nstruct SurfacesMaterialData\n{\n #if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\n vec3 worldPos, worldPos_fract_part;\n #else\n vec3 worldPos;\n #endif\n vec4 baseColor;\n vec4 specular;\n vec3 worldNormal;\n vec3 emissive;\n vec3 shade1;\n vec3 shade2;\n float baseStep;\n float baseFeather;\n float shadeStep;\n float shadeFeather;\n float shadowCover;\n};\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TRANSPARENCY\nvec4 SurfacesFragmentModifyBaseColorAndTransparency()\n{\n return FSInput_vertexColor;\n}\n#endif\n#ifndef CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_WORLD_NORMAL\nvec3 SurfacesFragmentModifyWorldNormal()\n{\n return normalize(FSInput_worldNormal);\n}\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_WORLD_TANGENT_AND_BINORMAL\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_IOR\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_ANISOTROPY_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_EMISSIVE\nvec3 SurfacesFragmentModifyEmissive()\n{\n return vec3(0.0, 0.0, 0.0);\n}\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_PBRPARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_SCATTERING_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_IN_SCATTERING_COLOR\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_OUT_SCATTERING_COLOR\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_DIFFUSE_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRT_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRT_COLOR\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TT_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TT_COLOR\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_SSS_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_DUAL_LOBE_SPECULAR_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_CLEAR_COAT_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_CLEAR_COAT_COLOR\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_CLEAR_COAT_WORLD_NORMAL\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_SHEEN_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_SHEEN_COLOR\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_SHARED_DATA\nvoid SurfacesFragmentModifySharedData(inout SurfacesMaterialData surfaceData)\n{\n}\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TOONSHADE\nvoid SurfacesFragmentModifyBaseColorAndToonShade(out vec4 baseColorAndTransparency, out vec3 shade1, out vec3 shade2, in vec3 baseColor)\n{\n baseColorAndTransparency = FSInput_vertexColor;\n shade1 = shade2 = vec3(0.0);\n}\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TOON_STEP_AND_FEATHER\nvec4 SurfacesFragmentModifyToonStepAndFeather()\n{\n return vec3(0.8, 0.001, 0.5, 0.001);\n}\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TOON_SHADOW_COVER\nfloat SurfacesFragmentModifyToonShadowCover()\n{\n return 0.5;\n}\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TOON_SPECULAR\nvec4 SurfacesFragmentModifyToonSpecular()\n{\n return vec4(1.0, 1.0, 1.0, 0.3);\n}\n#endif\nvoid CCSurfacesFragmentGetMaterialData(inout SurfacesMaterialData surfaceData)\n{\n #if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\n packHighpData(surfaceData.worldPos, surfaceData.worldPos_fract_part, FSInput_worldPos);\n #else\n surfaceData.worldPos = FSInput_worldPos;\n #endif\n surfaceData.worldNormal = SurfacesFragmentModifyWorldNormal();\n surfaceData.emissive = SurfacesFragmentModifyEmissive();\n SurfacesFragmentModifyBaseColorAndToonShade(surfaceData.baseColor, surfaceData.shade1, surfaceData.shade2);\n surfaceData.specular = SurfacesFragmentModifyToonSpecular();\n surfaceData.shadowCover = SurfacesFragmentModifyToonShadowCover();\n vec4 shaderParams = SurfacesFragmentModifyToonStepAndFeather();\n surfaceData.baseStep = shadeParams.x;\n surfaceData.baseFeather = shadeParams.y;\n surfaceData.shadeStep = shadeParams.z;\n surfaceData.shadeFeather = shadeParams.w;\n SurfacesFragmentModifySharedData(surfaceData);\n#if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_NORMAL_MAP)\n surfaceData.worldNormal = normalize(FSInput_worldNormal);\n#endif\n#if CC_USE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_LIGHTING_ENABLE_WITH_ALBEDO) {\n float brightBase = dot(GRAY_VECTOR, surfaceData.baseColor.rgb);\n float brightShade1 = dot(GRAY_VECTOR, surfaceData.shade1.rgb);\n float brightShade2 = dot(GRAY_VECTOR, surfaceData.shade2.rgb);\n surfaceData.baseColor.rgb = vec3(1.0);\n surfaceData.shade1.rgb = vec3(brightShade1 / brightBase);\n surfaceData.shade2.rgb = vec3(brightShade2 / brightBase);\n surfaceData.specular.rgb = vec3(1.0);\n }\n#endif\n}\nvec3 CCSurfacesGetDiffuseColor(in SurfacesMaterialData surfaceData)\n{\n return surfaceData.shade1;\n}\nvec3 CCSurfacesGetSpecularColor(in SurfacesMaterialData surfaceData)\n{\n return surfaceData.specular.xyz;\n}\nvoid CCSurfacesLightingInitializeColorWithLighting(inout vec3 diffuseColorWithLighting, inout vec3 specularColorWithLighting, in SurfacesMaterialData surfaceData, in LightingIntermediateData lightingData)\n{\n diffuseColorWithLighting = vec3(0.0);\n specularColorWithLighting = surfaceData.specular.xyz * surfaceData.baseStep;\n}\nvoid CCSurfacesLightingCalculateColorWithLighting(inout vec3 diffuseColorWithLighting, inout vec3 specularColorWithLighting, in SurfacesMaterialData surfaceData, in LightingIntermediateData lightingData)\n{\n float NL = 0.5 * lightingData.NoL + 0.5;\n vec3 diffuse = mix(surfaceData.shade1, surfaceData.shade2,\n clamp(1.0 + (surfaceData.shadeStep - surfaceData.shadeFeather - NL) / surfaceData.shadeFeather, 0.0, 1.0));\n diffuse = mix(surfaceData.baseColor.rgb, diffuse,\n clamp(1.0 + (surfaceData.baseStep - surfaceData.baseFeather - NL) / surfaceData.baseFeather, 0.0, 1.0));\n diffuseColorWithLighting = diffuse * surfaceData.baseStep;\n}\nvoid CCSurfacesInitializeLightingIntermediateData(inout LightingIntermediateData lightingData, in SurfacesMaterialData surfaceData)\n{\n vec3 worldPos;\n #if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\n worldPos = unpackHighpData(surfaceData.worldPos, surfaceData.worldPos_fract_part);\n #else\n worldPos = surfaceData.worldPos;\n #endif\n CCSurfacesLightingGetIntermediateData_PerPixel(lightingData, surfaceData.worldNormal, worldPos, vec3(0.0), vec3(0.0));\n lightingData.specularParam = surfaceData.specular.a;\n lightingData.ior = 1.0;\n}\nvoid CCSurfacesLightingCalculateIntermediateData_PerLight(inout LightingIntermediateData lightingData, in SurfacesMaterialData surfaceData, vec3 lightDirWithDist)\n{\n CCSurfacesLightingGetIntermediateData_PerLight(lightingData, lightDirWithDist);\n}\nvoid CCSurfacesInitializeLightingResult(inout LightingResult lightingResult, in SurfacesMaterialData surfaceData)\n{\n lightingResult.emissive = surfaceData.emissive;\n}\nvoid CCSurfacesInitializeLightingResult(inout LightingResult lightingResult)\n{\n lightingResult.directDiffuse = lightingResult.directSpecular = vec3(0.0);\n}\nvoid CCSurfacesAccumulateLightingResult(inout LightingResult lightingResultAccumulated, in LightingResult lightingResult)\n{\n lightingResultAccumulated.directDiffuse += lightingResult.directDiffuse * lightingResult.shadow;\n lightingResultAccumulated.directSpecular += lightingResult.directSpecular * lightingResult.shadow;\n}\n#if CC_PIPELINE_TYPE == 1\n vec4 CCSurfacesDeferredOutputBaseColor(in SurfacesMaterialData surfaceData)\n {\n return surfaceData.baseColor;\n }\n vec4 CCSurfacesDeferredOutputNormalMR(in SurfacesMaterialData surfaceData)\n {\n return vec4(float32x3_to_oct(surfaceData.worldNormal), 0.5, 0.0);\n }\n vec4 CCSurfacesDeferredOutputEmissiveAO(in SurfacesMaterialData surfaceData)\n {\n return vec4(surfaceData.emissive, 1.0);\n }\n#endif\nvec4 CCSurfacesShading(in SurfacesMaterialData surfaceData, in LightingResult lightingResult)\n{\n vec4 color = vec4(0.0, 0.0, 0.0, surfaceData.baseColor.a);\n#if CC_FORWARD_ADD\n color.xyz += lightingResult.directDiffuse * lightingResult.diffuseColorWithLighting;\n color.xyz += lightingResult.directSpecular * lightingResult.specularColorWithLighting;\n#else\n float lightmapCoef = 0.0;\n#if CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n color.xyz += (\n mix(lightingResult.directDiffuse, lightingResult.lightmapColor, lightmapCoef) * lightingResult.diffuseColorWithLighting\n + lightingResult.directSpecular * lightingResult.specularColorWithLighting)\n * lightingResult.shadow\n ;\n#else\n LightingIntermediateData lightingData;\n lightingData.NoL = -1.0;\n vec3 backLightingDiffuse, backLightingSpecular;\n CCSurfacesLightingInitializeColorWithLighting(backLightingDiffuse, backLightingSpecular, surfaceData, lightingData);\n CCSurfacesLightingCalculateColorWithLighting(backLightingDiffuse, backLightingSpecular, surfaceData, lightingData);\n color.xyz +=\n mix(lightingResult.directDiffuse, lightingResult.lightmapColor, lightmapCoef) * mix(backLightingDiffuse, lightingResult.diffuseColorWithLighting, lightingResult.shadow)\n + lightingResult.directSpecular * lightingResult.specularColorWithLighting * lightingResult.shadow\n ;\n#endif\n color.xyz += lightingResult.emissive;\n#endif\n return color;\n}\n#if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_SINGLE\nbool CCSurfacesDebugViewSurfaceData(inout vec4 color, in SurfacesMaterialData surfaceData)\n{\n bool enableMaterialAlpha = true;\n float scalar;\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(surfaceData.worldNormal * 0.5 + vec3(0.5), 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(0.0, 0.0, 0.0, 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(0.0, 0.0, 0.0, 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSPARENCY)) && (cc_surfaceTransform.y != 3.0)))\n {\n scalar = surfaceData.baseColor.a;\n color = vec4(scalar, scalar, scalar, 1.0);\n enableMaterialAlpha = false;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_BASE_COLOR)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(LinearToSRGB(surfaceData.baseColor.rgb), 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(LinearToSRGB(CCSurfacesGetDiffuseColor(surfaceData)), 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(LinearToSRGB(CCSurfacesGetSpecularColor(surfaceData)), 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY)) && (cc_surfaceTransform.y != 3.0)))\n {\n scalar = surfaceData.specular.a;\n color = vec4(scalar, scalar, scalar, 1.0);\n }\n return enableMaterialAlpha;\n}\n#endif\n#if (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\n #if CC_FORWARD_ADD\n void CCSurfacesLighting(inout LightingResult lightingResultAccumulated, in SurfacesMaterialData surfaceData, in vec2 shadowBias)\n {\n vec3 worldPos;\n #if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\n worldPos = unpackHighpData(surfaceData.worldPos, surfaceData.worldPos_fract_part);\n #else\n worldPos = surfaceData.worldPos;\n #endif\n CCSurfacesInitializeLightingResult(lightingResultAccumulated);\n LightingIntermediateData lightingData;\n CCSurfacesInitializeLightingIntermediateData(lightingData, surfaceData);\n LightingResult lightingResult;\n CCSurfacesLightingInitializeColorWithLighting(lightingResult.diffuseColorWithLighting, lightingResult.specularColorWithLighting, surfaceData, lightingData);\n lightingResultAccumulated.diffuseColorWithLighting = lightingResult.diffuseColorWithLighting;\n lightingResultAccumulated.specularColorWithLighting = lightingResult.specularColorWithLighting;\n #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n vec3 diff;\n SurfacesMaterialData surfaceData2ndSpecular;\n CCSurfacesGetSurfacesMaterialData2ndSpecular(surfaceData2ndSpecular, surfaceData);\n CCSurfacesLightingInitializeColorWithLighting(diff, lightingResult.specularColorWithLighting2ndSpecular, surfaceData2ndSpecular, lightingData);\n lightingResultAccumulated.specularColorWithLighting2ndSpecular = lightingResult.specularColorWithLighting2ndSpecular;\n #endif\n int numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\n for (int i = 0; i < LIGHTS_PER_PASS; i++) {\n if (i >= numLights) break;\n vec3 lightDirWithLength = IS_RANGED_DIRECTIONAL_LIGHT(cc_lightPos[i].w) ? -normalize(cc_lightDir[i].xyz) : cc_lightPos[i].xyz - worldPos;\n CCSurfacesLightingCalculateIntermediateData_PerLight(lightingData, surfaceData, lightDirWithLength);\n CCSurfacesLightingCalculateColorWithLighting(lightingResult.diffuseColorWithLighting, lightingResult.specularColorWithLighting, surfaceData, lightingData);\n vec3 diffuseLighting, specularLighting;\n CCSurfacesLightingCalculateDirect(diffuseLighting, specularLighting, lightingData, cc_lightColor[i]);\n #if CC_SURFACES_LIGHTING_USE_FRESNEL\n vec3 fresnel = CCSurfaceLightingCalculateExtraFresnel(lightingData);\n #else\n vec3 fresnel = vec3(1.0);\n #endif\n lightingResult.fresnel = fresnel;\n float shadow = 1.0;\n #if CC_RECEIVE_SHADOW && CC_SHADOW_TYPE == 2\n if (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) {\n vec4 shadowPos = vec4(0.0), shadowPosWithDepthBias = vec4(0.0);\n if (CCSurfacesLightingEnableShadow(lightingData.NoL)) {\n shadowPos = cc_matLightViewProj * vec4(worldPos, 1.0);\n shadow = CCSpotShadowFactorBase(shadowPosWithDepthBias, shadowPos, worldPos, shadowBias);\n }\n #if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE && CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n vec3 shadowNDCPos;\n bool isExceedShadowMap = !GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias);\n lightingData.shadowPosAndDepth.xy = shadowNDCPos.xy;\n lightingData.shadowPosAndDepth.z = isExceedShadowMap ? 0.0 : GetViewSpaceDepthFromNDCDepth_Perspective(shadowNDCPos.z, shadowPosWithDepthBias.w, cc_shadowInvProjDepthInfo.x, cc_shadowInvProjDepthInfo.y);\n lightingData.shadowPosAndDepth.w = isExceedShadowMap ? lightingData.shadowPosAndDepth.w : GetViewSpaceDepthFromNDCDepth_Perspective(SampleShadowMapSoft(shadowNDCPos, cc_spotShadowMap, cc_shadowWHPBInfo.xy), shadowPosWithDepthBias.w, cc_shadowInvProjDepthInfo.x, cc_shadowInvProjDepthInfo.y);\n #endif\n }\n #endif\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_SHADOW)\n shadow = 1.0;\n #endif\n lightingResult.shadow = shadow;\n float distAtt = 1.0;\n if(IS_RANGED_DIRECTIONAL_LIGHT(cc_lightPos[i].w)) {\n distAtt = GetOutOfRange(worldPos, cc_lightPos[i].xyz, cc_lightDir[i].xyz, cc_lightSizeRangeAngle[i].xyz, cc_lightBoundingSizeVS[i].xyz);\n } else {\n distAtt = CCSurfacesLightingCalculateDistanceAttenuation(lightingData, cc_lightSizeRangeAngle[i], cc_lightPos[i].w);\n }\n float angleAtt = 1.0;\n if (IS_SPOT_LIGHT(cc_lightPos[i].w)) {\n angleAtt = CCSurfacesLightingCalculateAngleAttenuation(lightingData, cc_lightSizeRangeAngle[i], -cc_lightDir[i].xyz);\n }\n float multiplier = distAtt * angleAtt;\n lightingData.angleAttenuation = angleAtt;\n lightingData.distAttenuation = distAtt;\n lightingResult.directDiffuse = diffuseLighting * multiplier;\n lightingResult.directSpecular = specularLighting * multiplier;\n CCSurfaceLightingCalculateDirectFresnel(lightingResult.directGF, lightingData, lightingResult.specularColorWithLighting, vec3(1.0));\n vec4 attenuatedLightColorAndIntensity = vec4(cc_lightColor[i].xyz, cc_lightColor[i].w * multiplier);\n #if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n vec3 transmitSpecularLighting;\n CCSurfacesLightingCalculateDirectTransmitSpecular(transmitSpecularLighting, lightingData, attenuatedLightColorAndIntensity);\n lightingResult.directTransmitSpecular = transmitSpecularLighting * multiplier * (1.0 - fresnel);\n #endif\n #if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n LightingIntermediateData lightingDataTD;\n CCSurfacesGetLightingIntermediateDataTransmitDiffuse(lightingDataTD, lightingData, surfaceData);\n CCSurfacesLightingCalculateIntermediateData_PerLight(lightingDataTD, surfaceData, lightDirWithLength);\n CCSurfacesLightingCalculateDirectTransmitDiffuse(lightingResult.directTransmitDiffuse, lightingDataTD, attenuatedLightColorAndIntensity, lightingResult.shadow);\n #endif\n #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n LightingIntermediateData lightingData2ndSpecular;\n CCSurfacesInitializeLightingIntermediateData(lightingData2ndSpecular, surfaceData2ndSpecular);\n CCSurfacesLightingCalculateIntermediateData_PerLight(lightingData2ndSpecular, surfaceData, lightDirWithLength);\n #if !CC_SURFACES_LIGHTING_SHEEN\n CCSurfacesLightingCalculateDirect2ndSpecular(lightingResult.direct2ndSpecular, lightingData2ndSpecular, attenuatedLightColorAndIntensity, surfaceData2ndSpecular.intensity2ndSpecular, lightingResult.directSpecular);\n CCSurfaceLightingCalculateDirectFresnel(lightingResult.directGF2ndSpecular, lightingData2ndSpecular, lightingResult.specularColorWithLighting2ndSpecular, vec3(1.0));\n #else\n CCSurfacesLightingCalculateDirectSheen(lightingResult.direct2ndSpecular, lightingResult.directGF2ndSpecular, lightingData2ndSpecular, attenuatedLightColorAndIntensity, surfaceData2ndSpecular.intensity2ndSpecular);\n #endif\n lightingResult.direct2ndSpecular *= multiplier;\n #endif\n #if CC_SURFACES_LIGHTING_TT\n CCSurfacesLightingCalculateDirectTT(lightingResult, lightingData, attenuatedLightColorAndIntensity);\n #endif\n #if CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n lightingResult.specularColorWithLighting2ndSpecular *= surfaceData.color2ndSpecular;\n CCSurfacesLightingCalculateDirectMultiLayerBlending(lightingResult, lightingData2ndSpecular);\n #endif\n #ifdef CC_SURFACES_LIGHTING_MODIFY_FINAL_RESULT\n LightingMiscData miscData;\n miscData.lightType = cc_lightPos[i].w;\n miscData.lightPos = cc_lightPos[i].xyz;\n miscData.lightDir = cc_lightDir[i].xyz;\n miscData.lightColorAndIntensity = cc_lightColor[i];\n miscData.lightSizeRangeAngle = cc_lightSizeRangeAngle[i];\n SurfacesLightingModifyFinalResult(lightingResult, lightingData, surfaceData, miscData);\n #endif\n CCSurfacesAccumulateLightingResult(lightingResultAccumulated, lightingResult);\n }\n }\n #else\n void CCSurfacesLighting(inout LightingResult lightingResult, in SurfacesMaterialData surfaceData, in vec2 shadowBias)\n {\n vec3 worldPos;\n #if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\n worldPos = unpackHighpData(surfaceData.worldPos, surfaceData.worldPos_fract_part);\n #else\n worldPos = surfaceData.worldPos;\n #endif\n LightingIntermediateData lightingData;\n CCSurfacesInitializeLightingIntermediateData(lightingData, surfaceData);\n CCSurfacesInitializeLightingResult(lightingResult, surfaceData);\n CCSurfacesLightingInitializeColorWithLighting(lightingResult.diffuseColorWithLighting, lightingResult.specularColorWithLighting, surfaceData, lightingData);\n CCSurfacesLightingCalculateIntermediateData_PerLight(lightingData, surfaceData, -cc_mainLitDir.xyz);\n lightingResult.shadow = 1.0;\n #if CC_RECEIVE_SHADOW && CC_SHADOW_TYPE == 2\n if (cc_mainLitDir.w > 0.0) {\n vec4 shadowPos = vec4(0.0), shadowPosWithDepthBias = vec4(0.0);\n vec4 shadowProjDepthInfo = vec4(0.0);\n vec3 shadowNDCPos;\n bool isExceedShadowMap = true;\n if (CCSurfacesLightingEnableShadow(lightingData.NoL)) {\n #if CC_DIR_LIGHT_SHADOW_TYPE == 2\n lightingResult.shadow = CCCSMFactorBase(worldPos, lightingData.N, shadowBias);\n #if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE && CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n vec4 shadowProjInfo;\n vec3 shadowViewDir0, shadowViewDir1, shadowViewDir2;\n isExceedShadowMap = 0 > CCGetCSMLevel(shadowPosWithDepthBias, shadowProjDepthInfo, shadowProjInfo, shadowViewDir0, shadowViewDir1, shadowViewDir2, worldPos);\n GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias);\n #endif\n #endif\n #if CC_DIR_LIGHT_SHADOW_TYPE == 1\n shadowPos = cc_matLightViewProj * vec4(worldPos, 1.0);\n lightingResult.shadow = CCShadowFactorBase(shadowPosWithDepthBias, shadowPos, lightingData.N, shadowBias);\n shadowProjDepthInfo = cc_shadowProjDepthInfo;\n isExceedShadowMap = !GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias);\n #endif\n }\n #if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE && CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n lightingData.shadowPosAndDepth.xy = shadowNDCPos.xy;\n lightingData.shadowPosAndDepth.z = isExceedShadowMap ? 0.0 : GetViewSpaceDepthFromNDCDepth_Orthgraphic(shadowNDCPos.z, shadowProjDepthInfo.x, shadowProjDepthInfo.y);\n lightingData.shadowPosAndDepth.w = isExceedShadowMap ? lightingData.shadowPosAndDepth.w : GetViewSpaceDepthFromNDCDepth_Orthgraphic(SampleShadowMapSoft(shadowNDCPos, cc_shadowMap, cc_shadowWHPBInfo.xy), shadowProjDepthInfo.x, shadowProjDepthInfo.y);\n #endif\n }\n #endif\n lightingResult.lightmapColor = vec3(0.0);\n #if CC_SURFACES_USE_LIGHT_MAP && !CC_FORWARD_ADD\n float lightmapShadow, lightmapAO;\n GetLightMapColor(lightingResult.lightmapColor, lightmapShadow, lightmapAO, cc_lightingMap, FSInput_lightMapUV.xy, FSInput_lightMapUV.z, surfaceData.worldNormal);\n #if CC_SURFACES_USE_LIGHT_MAP == LIGHT_MAP_TYPE_INDIRECT_OCCLUSION\n lightingResult.shadow *= lightmapShadow;\n #endif\n lightingResult.ao *= lightmapAO;\n #endif\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_SHADOW)\n lightingResult.shadow = 1.0;\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_AO)\n lightingResult.ao = 1.0;\n #endif\n vec3 unused;\n CCSurfacesLightingCalculateEnvironment(lightingResult.environmentDiffuse, lightingResult.environmentSpecular, lightingData, cc_ambientSky.w);\n CCSurfaceLightingCalculateEnvironmentFresnel(lightingResult.environmentGF, unused, lightingData, lightingResult.specularColorWithLighting);\n lightingResult.directDiffuse = lightingResult.directSpecular = vec3(0.0);\n #if !CC_DISABLE_DIRECTIONAL_LIGHT && !CC_FORWARD_ADD\n CCSurfacesLightingCalculateColorWithLighting(lightingResult.diffuseColorWithLighting, lightingResult.specularColorWithLighting, surfaceData, lightingData);\n CCSurfacesLightingCalculateDirect(lightingResult.directDiffuse, lightingResult.directSpecular, lightingData, cc_mainLitColor);\n CCSurfaceLightingCalculateDirectFresnel(lightingResult.directGF, lightingData, lightingResult.specularColorWithLighting, lightingResult.environmentGF);\n #endif\n #if CC_SURFACES_LIGHTING_USE_FRESNEL\n lightingResult.fresnel = CCSurfaceLightingCalculateExtraFresnel(lightingData);\n #else\n lightingResult.fresnel = vec3(1.0);\n #endif\n #if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n CCSurfacesLightingCalculateDirectTransmitSpecular(lightingResult.directTransmitSpecular, lightingData, cc_mainLitColor);\n CCSurfacesLightingCalculateEnvironmentTransmitSpecular(lightingResult.environmentTransmitSpecular, lightingData, cc_ambientSky.w);\n #endif\n #if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n LightingIntermediateData lightingDataTD;\n CCSurfacesGetLightingIntermediateDataTransmitDiffuse(lightingDataTD, lightingData, surfaceData);\n CCSurfacesLightingCalculateIntermediateData_PerLight(lightingDataTD, surfaceData, -cc_mainLitDir.xyz);\n CCSurfacesLightingCalculateDirectTransmitDiffuse(lightingResult.directTransmitDiffuse, lightingDataTD, cc_mainLitColor, lightingResult.shadow);\n CCSurfacesLightingCalculateEnvironmentTransmitDiffuse(lightingResult.environmentTransmitDiffuse, lightingDataTD, cc_ambientSky.w, lightingResult.ao, -cc_mainLitDir.xyz);\n #endif\n #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n SurfacesMaterialData surfaceData2ndSpecular;\n CCSurfacesGetSurfacesMaterialData2ndSpecular(surfaceData2ndSpecular, surfaceData);\n LightingIntermediateData lightingData2ndSpecular;\n CCSurfacesInitializeLightingIntermediateData(lightingData2ndSpecular, surfaceData2ndSpecular);\n CCSurfacesLightingCalculateIntermediateData_PerLight(lightingData2ndSpecular, surfaceData2ndSpecular, -cc_mainLitDir.xyz);\n vec3 diff;\n CCSurfacesLightingInitializeColorWithLighting(diff, lightingResult.specularColorWithLighting2ndSpecular, surfaceData2ndSpecular, lightingData2ndSpecular);\n #if !CC_SURFACES_LIGHTING_SHEEN\n CCSurfacesLightingCalculateEnvironment2ndSpecular(lightingResult.environment2ndSpecular, lightingData2ndSpecular, cc_ambientSky.w, surfaceData2ndSpecular.intensity2ndSpecular, lightingResult.environmentSpecular);\n CCSurfaceLightingCalculateEnvironmentFresnel(lightingResult.environmentGF2ndSpecular, lightingResult.environmentSubLayerF, lightingData2ndSpecular, lightingResult.specularColorWithLighting2ndSpecular);\n CCSurfacesLightingCalculateDirect2ndSpecular(lightingResult.direct2ndSpecular, lightingData2ndSpecular, cc_mainLitColor, surfaceData2ndSpecular.intensity2ndSpecular, lightingResult.directSpecular);\n CCSurfaceLightingCalculateDirectFresnel(lightingResult.directGF2ndSpecular, lightingData2ndSpecular, lightingResult.specularColorWithLighting2ndSpecular, lightingResult.environmentGF2ndSpecular);\n #else\n CCSurfacesLightingCalculateDirectSheen(lightingResult.direct2ndSpecular, lightingResult.directGF2ndSpecular, lightingData2ndSpecular, cc_mainLitColor, surfaceData2ndSpecular.intensity2ndSpecular);\n CCSurfacesLightingCalculateEnvironmentSheen(lightingResult.environment2ndSpecular, lightingResult.environmentGF2ndSpecular, lightingData2ndSpecular, cc_ambientSky.w, surfaceData2ndSpecular.intensity2ndSpecular);\n #endif\n #endif\n #if CC_SURFACES_LIGHTING_TT\n CCSurfacesLightingCalculateDirectTT(lightingResult, lightingData, cc_mainLitColor);\n #endif\n #if CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n lightingResult.specularColorWithLighting2ndSpecular *= surfaceData.color2ndSpecular;\n CCSurfacesLightingCalculateDirectMultiLayerBlending(lightingResult, lightingData2ndSpecular);\n CCSurfacesLightingCalculateEnvironmentMultiLayerBlending(lightingResult, lightingData2ndSpecular);\n #endif\n #ifdef CC_SURFACES_LIGHTING_MODIFY_FINAL_RESULT\n LightingMiscData miscData;\n miscData.lightType = LIGHT_TYPE_DIRECTIONAL;\n miscData.lightPos = vec3(0.0);\n miscData.lightDir = cc_mainLitDir.xyz;\n miscData.lightColorAndIntensity = cc_mainLitColor;\n miscData.lightSizeRangeAngle = vec4(0.0, 0.0, 0.0, 0.0);\n SurfacesLightingModifyFinalResult(lightingResult, lightingData, surfaceData, miscData);\n #endif\n }\n #if CC_ENABLE_CLUSTERED_LIGHT_CULLING\n #endif\n #endif\n#endif\nvec4 CCSurfacesDebugDisplayInvalidNumber(vec4 color)\n{\n float index = mod(cc_time.x * 10.0, 2.0);\n vec4 error = index < 1.0 ? vec4(1.0, 0.0, 0.2, 1.0) : vec4(0.0, 1.0, 0.2, 1.0);\n return (isnans(color.rgb) || isinfs(color.rgb)) ? error : color;\n}\nvec4 CCSurfacesDebugDisplayInvalidInputData(vec4 color, vec3 data)\n{\n float index = mod(cc_time.x * 10.0, 2.0);\n vec4 error = index < 1.0 ? vec4(1.0, 0.0, 0.2, 1.0) : vec4(0.0, 1.0, 0.2, 1.0);\n return (isnans(data) || isinfs(data)) ? error : color;\n}\n#if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_SINGLE && !CC_FORWARD_ADD\n void CCSurfacesDebugViewMeshData(inout vec4 color)\n {\n vec4 white = vec4(1.0, 1.0, 1.0, 1.0);\n vec4 black = vec4(0.0, 0.0, 0.0, 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR)) && (cc_surfaceTransform.y != 3.0)))\n {\n #if CC_SURFACES_USE_VERTEX_COLOR\n color = FSInput_vertexColor;\n #else\n color = white;\n #endif\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(FSInput_worldNormal * 0.5 + vec3(0.5), 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT)) && (cc_surfaceTransform.y != 3.0)))\n {\n #if CC_SURFACES_USE_TANGENT_SPACE\n color = vec4(FSInput_worldTangent * 0.5 + vec3(0.5), 1.0);\n #else\n color = black;\n #endif\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR)) && (cc_surfaceTransform.y != 3.0)))\n {\n #if CC_SURFACES_USE_TANGENT_SPACE\n float sign = FSInput_mirrorNormal * 0.5 + 0.5;\n color = vec4(sign, sign, sign, 1.0);\n #else\n color = black;\n #endif\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_FACE_SIDE)) && (cc_surfaceTransform.y != 3.0)))\n {\n float scalar = clamp(FSInput_faceSideSign, 0.0, 1.0);\n color = vec4(scalar, scalar, scalar, 1.0);\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_UV0)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(FSInput_texcoord.xy, 0.0, 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_UV1)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(FSInput_texcoord1.xy, 0.0, 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP)) && (cc_surfaceTransform.y != 3.0)))\n {\n #if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n color = vec4(FSInput_lightMapUV.xy, 0.0, 1.0);\n #else\n color = vec4(0.0, 0.0, 0.0, 1.0);\n #endif\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH)) && (cc_surfaceTransform.y != 3.0)))\n {\n vec4 clipPos = cc_matProj * cc_matView * vec4(FSInput_worldPos.xyz, 1.0);\n float depth = clipPos.z / clipPos.w;\n color = vec4(depth, depth, depth, 1.0);\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH)) && (cc_surfaceTransform.y != 3.0)))\n {\n vec4 viewPos = cc_matView * vec4(FSInput_worldPos.xyz, 1.0);\n float depth = (-viewPos.z - cc_nearFar.x) / cc_nearFar.y;\n color = vec4(depth, depth, depth, 1.0);\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_WORLD_POS)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(FSInput_worldPos.xyz, 1.0);\n }\n#endif\n#if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_SINGLE\n bool CCSurfacesDebugViewLightingResult(inout vec4 color, in LightingResult lightingResult)\n {\n bool isSRGBColor = false;\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.directDiffuse * lightingResult.diffuseColorWithLighting;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.directSpecular * lightingResult.specularColorWithLighting * lightingResult.directGF;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_ALL)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.directDiffuse * lightingResult.diffuseColorWithLighting + lightingResult.directSpecular * lightingResult.specularColorWithLighting * lightingResult.directGF;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.environmentDiffuse * lightingResult.diffuseColorWithLighting;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.environmentSpecular * lightingResult.specularColorWithLighting * lightingResult.environmentGF;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_ENV_ALL)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.environmentDiffuse * lightingResult.diffuseColorWithLighting + lightingResult.environmentSpecular * lightingResult.specularColorWithLighting * lightingResult.environmentGF;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_LIGHT_MAP)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.lightmapColor;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_EMISSIVE)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.emissive;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_AO)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = vec3(lightingResult.ao);\n isSRGBColor = false;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_SHADOW)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = vec3(lightingResult.shadow);\n isSRGBColor = false;\n }\n vec3 fresnel = lightingResult.fresnel;\n vec3 directTransmitSpecular = vec3(0.0), environmentTransmitSpecular = vec3(0.0);\n vec3 directTransmitDiffuse = vec3(0.0), environmentTransmitDiffuse = vec3(0.0);\n vec3 diffuseColorWithLightingTT = vec3(0.0), specularColorWithLighting2ndSpecular = vec3(0.0);\n vec3 direct2ndSpecular = vec3(0.0), environment2ndSpecular = vec3(0.0);\n #if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n directTransmitSpecular = lightingResult.directTransmitSpecular;\n environmentTransmitSpecular = lightingResult.environmentTransmitSpecular;\n #endif\n #if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n directTransmitDiffuse = lightingResult.directTransmitDiffuse;\n environmentTransmitDiffuse = lightingResult.environmentTransmitDiffuse;\n #endif\n #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n direct2ndSpecular = lightingResult.direct2ndSpecular * lightingResult.directGF2ndSpecular;\n environment2ndSpecular = lightingResult.environment2ndSpecular * lightingResult.environmentGF2ndSpecular;\n specularColorWithLighting2ndSpecular = lightingResult.specularColorWithLighting2ndSpecular;\n #if CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n fresnel = lightingResult.environmentSubLayerF;\n #endif\n #endif\n #if CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n direct2ndSpecular = lightingResult.directSpecularSubLayers;\n environment2ndSpecular = lightingResult.environmentSpecularSubLayers;\n #endif\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_FRESNEL)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = vec3(fresnel);\n isSRGBColor = false;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = directTransmitSpecular;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = environmentTransmitSpecular;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = directTransmitDiffuse;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = environmentTransmitDiffuse;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = directTransmitSpecular + environmentTransmitSpecular + directTransmitDiffuse + environmentTransmitDiffuse;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = direct2ndSpecular * specularColorWithLighting2ndSpecular;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = environment2ndSpecular * specularColorWithLighting2ndSpecular;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = (direct2ndSpecular + environment2ndSpecular) * specularColorWithLighting2ndSpecular;\n isSRGBColor = true;\n }\n return isSRGBColor;\n }\n#endif\n#if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n void CCSurfacesDebugViewCompositeLightingResult(inout LightingResult lightingResult)\n {\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_DIFFUSE)\n lightingResult.directDiffuse = vec3(0.0);\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_SPECULAR)\n lightingResult.directSpecular = vec3(0.0);\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_DIFFUSE)\n lightingResult.environmentDiffuse = vec3(0.0);\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_SPECULAR)\n lightingResult.environmentSpecular = vec3(0.0);\n #if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_DIFFUSE)\n lightingResult.directTransmitDiffuse = lightingResult.environmentTransmitDiffuse = vec3(0.0);\n #endif\n #if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_SPECULAR)\n lightingResult.directTransmitSpecular = lightingResult.environmentTransmitSpecular = vec3(0.0);\n #endif\n #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_2ND_SPECULAR)\n lightingResult.direct2ndSpecular = lightingResult.environment2ndSpecular = vec3(0.0);\n #endif\n #if CC_SURFACES_LIGHTING_TT\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_TT)\n lightingResult.directTT = vec3(0.0);\n #endif\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_EMISSIVE)\n lightingResult.emissive = vec3(0.0);\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_LIGHT_MAP)\n lightingResult.lightmapColor = vec3(0.0);\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_SHADOW)\n lightingResult.shadow = 1.0;\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_AO)\n lightingResult.ao = 1.0;\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_FRESNEL)\n lightingResult.fresnel = vec3(1.0);\n }\n#endif\n#if (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\n layout(location = 0) out vec4 fragColorX;\n void main() {\n #if CC_DISABLE_STRUCTURE_IN_FRAGMENT_SHADER\n float NoL = dot(-cc_mainLitDir.xyz, FSInput_worldNormal.xyz);\n vec4 color = SurfacesFragmentModifyBaseColorAndTransparency();\n float fogFactor = 1.0;\n #if CC_FORWARD_ADD\n color.rgb = vec3(0.0);\n #endif\n #else\n SurfacesMaterialData surfaceData;\n CCSurfacesFragmentGetMaterialData(surfaceData);\n vec2 shadowBias = vec2(0.0);\n vec3 colDebugCSMLayer = vec3(1.0);\n #if CC_RECEIVE_SHADOW\n shadowBias = FSInput_shadowBias;\n #if !CC_FORWARD_ADD\n #if CC_USE_DEBUG_VIEW && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (IS_DEBUG_VIEW_MISC_ENABLE_CSM_LAYER_COLORATION)\n {\n vec4 csmPos;\n vec4 shadowProjDepthInfo, shadowProjInfo;\n vec3 shadowViewDir0, shadowViewDir1, shadowViewDir2;\n int csmLayer = -1;\n csmLayer = CCGetCSMLevel(csmPos, shadowProjDepthInfo, shadowProjInfo, shadowViewDir0, shadowViewDir1, shadowViewDir2, surfaceData.worldPos);\n bool OutOfRange = csmLayer < 0;\n if (OutOfRange)\n colDebugCSMLayer = vec3(1.0);\n else if (csmLayer == 0)\n colDebugCSMLayer = vec3(1.0, 0.0, 0.0);\n else if (csmLayer == 1)\n colDebugCSMLayer = vec3(0.0, 1.0, 0.0);\n else if (csmLayer == 2)\n colDebugCSMLayer = vec3(0.0, 0.0, 1.0);\n else if (csmLayer == 3)\n colDebugCSMLayer = vec3(0.0, 1.0, 1.0);\n }\n #endif\n #endif\n #endif\n float fogFactor = 1.0;\n #if !CC_FORWARD_ADD\n #if CC_USE_FOG != 4\n #if !CC_USE_ACCURATE_FOG\n fogFactor = FSInput_fogFactor;\n #else\n CC_TRANSFER_FOG_BASE(vec4(FSInput_worldPos, 1.0), fogFactor);\n #endif\n #endif\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_FOG) {\n fogFactor = 1.0;\n }\n #endif\n #endif\n LightingResult lightingResult;\n CCSurfacesLighting(lightingResult, surfaceData, shadowBias);\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_SINGLE && CC_SURFACES_ENABLE_DEBUG_VIEW\n vec4 debugColor = vec4(0.0, 0.0, 0.0, 1.0);\n float materialTransparency = CCSurfacesShading(surfaceData, lightingResult).a;\n #if !CC_FORWARD_ADD && !CC_SURFACES_LIGHTING_DISABLE_DIFFUSE\n CCSurfacesDebugViewMeshData(debugColor);\n if (CCSurfacesDebugViewSurfaceData(debugColor, surfaceData))\n {\n debugColor.a = materialTransparency;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_FOG)) && (cc_surfaceTransform.y != 3.0)))\n {\n debugColor.rgb = vec3(1.0 - fogFactor);\n }\n #endif\n #if CC_FORWARD_ADD\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE)) && (cc_surfaceTransform.y != 3.0)) || (equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR)) && (cc_surfaceTransform.y != 3.0)) || (equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_ALL)) && (cc_surfaceTransform.y != 3.0)) ||\n (equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE)) && (cc_surfaceTransform.y != 3.0)) || (equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR)) && (cc_surfaceTransform.y != 3.0)) || (equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR)) && (cc_surfaceTransform.y != 3.0)))\n #endif\n {\n if (CCSurfacesDebugViewLightingResult(debugColor, lightingResult))\n {\n debugColor.a = materialTransparency;\n #if !CC_USE_FLOAT_OUTPUT\n debugColor.rgb = HDRToLDR(debugColor.rgb);\n debugColor.rgb = LinearToSRGB(debugColor.rgb);\n #endif\n }\n }\n if (IS_DEBUG_VIEW_ENABLE_WITH_CAMERA) {\n fragColorX = debugColor;\n return;\n }\n #elif CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n CCSurfacesDebugViewCompositeLightingResult(lightingResult);\n #endif\n vec4 color = CCSurfacesShading(surfaceData, lightingResult);\n #if CC_USE_DEBUG_VIEW && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (IS_DEBUG_VIEW_MISC_ENABLE_CSM_LAYER_COLORATION) {\n color.rgb *= colDebugCSMLayer.rgb;\n }\n #if CC_SURFACES_USE_TANGENT_SPACE\n color = CCSurfacesDebugDisplayInvalidInputData(color, FSInput_worldTangent);\n #endif\n #endif\n #endif\n #if CC_USE_FOG != 4 && (!CC_USE_FLOAT_OUTPUT || CC_IS_TRANSPARENCY_PASS)\n #if !CC_FORWARD_ADD\n #ifdef CC_SURFACES_LIGHTING_MODIFY_FOG\n color.rgb = CCSurfacesLightingModifyFog(fogFactor, color.rgb, surfaceData, lightingResult);\n #else\n CC_APPLY_FOG_BASE(color, fogFactor);\n #endif\n #endif\n #endif\n #if CC_USE_RGBE_OUTPUT\n color = packRGBE(color.rgb);\n #else\n color = CCSurfacesDebugDisplayInvalidNumber(color);\n #if !CC_USE_FLOAT_OUTPUT || CC_IS_TRANSPARENCY_PASS\n color.rgb = HDRToLDR(color.rgb);\n color.rgb = LinearToSRGB(color.rgb);\n #endif\n #endif\n fragColorX = color;\n }\n#elif CC_PIPELINE_TYPE == 1\n layout(location = 0) out vec4 albedoOut;\n layout(location = 1) out vec4 emissiveOut;\n layout(location = 2) out vec4 normalOut;\n void main () {\n SurfacesMaterialData surfaceData;\n CCSurfacesFragmentGetMaterialData(surfaceData);\n albedoOut = CCSurfacesDeferredOutputBaseColor(surfaceData);\n normalOut = CCSurfacesDeferredOutputNormalMR(surfaceData);\n emissiveOut = CCSurfacesDeferredOutputEmissiveAO(surfaceData);\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_SINGLE && CC_SURFACES_ENABLE_DEBUG_VIEW\n vec4 debugColor = vec4(0.0, 0.0, 0.0, 1.0);\n CCSurfacesDebugViewMeshData(debugColor);\n CCSurfacesDebugViewSurfaceData(debugColor, surfaceData);\n if (IS_DEBUG_VIEW_ENABLE_WITH_CAMERA) {\n albedoOut = debugColor;\n }\n #endif\n }\n#endif"
- },
- "glsl3": {
- "vert": "\nprecision highp float;\n#define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING USE_COMPATIBLE_LIGHTING\n#define CC_SURFACES_USE_TANGENT_SPACE USE_NORMAL_MAP\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\n#if CC_SURFACES_USE_TANGENT_SPACE\n in vec4 a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n in vec4 a_color;\n#endif\n#if CC_SURFACES_USE_SECOND_UV || CC_USE_LIGHTMAP\n in vec2 a_texCoord1;\n#endif\n#if CC_USE_SKINNING\n in vec4 a_joints;\n in vec4 a_weights;\n#endif\n#if USE_INSTANCING\n #if CC_USE_BAKED_ANIMATION\n in highp vec4 a_jointAnimInfo;\n #endif\n in vec4 a_matWorld0;\n in vec4 a_matWorld1;\n in vec4 a_matWorld2;\n #if CC_USE_LIGHTMAP\n in vec4 a_lightingMapUVParam;\n #endif\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n in vec4 a_localShadowBiasAndProbeId;\n #endif\n #if CC_USE_REFLECTION_PROBE\n in vec4 a_reflectionProbeData;\n #endif\n #if CC_USE_LIGHT_PROBE\n in vec4 a_sh_linear_const_r;\n in vec4 a_sh_linear_const_g;\n in vec4 a_sh_linear_const_b;\n #endif\n#endif\n#if CC_USE_MORPH\n in float a_vertexId;\n#endif\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nout highp vec3 v_worldPos;\nout vec4 v_normal;\nout vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n out lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n out mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n out mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n out mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n out mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n out mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n out mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n out highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n out highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n out mediump vec4 v_sh_linear_const_r;\n out mediump vec4 v_sh_linear_const_g;\n out mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define VSOutput_worldPos v_worldPos\n#define VSOutput_worldNormal v_normal.xyz\n#define VSOutput_faceSideSign v_normal.w\n#define VSOutput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define VSOutput_vertexColor v_color\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define VSOutput_worldTangent v_tangent.xyz\n #define VSOutput_mirrorNormal v_tangent.w\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define VSOutput_texcoord1 v_uv1\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define VSOutput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define VSOutput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define VSOutput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define VSOutput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define VSOutput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define VSOutput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define VSOutput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define VSOutput_clipPos v_clipPos\n#endif\nstruct SurfacesStandardVertexIntermediate\n{\n highp vec4 position;\n vec3 normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n vec4 tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n vec4 color;\n#endif\n vec2 texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n vec2 texCoord1;\n#endif\n highp vec4 clipPos;\n highp vec3 worldPos;\n vec4 worldNormal;\n #if CC_SURFACES_USE_TANGENT_SPACE\n vec3 worldTangent, worldBinormal;\n #endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n vec4 shadowBiasAndProbeId;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n float fogFactor;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n vec3 lightmapUV;\n#endif\n};\n#if CC_USE_MORPH\n int getVertexId() {\n return int(a_vertexId);\n }\n#endif\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightView;\n highp mat4 cc_matLightViewProj;\n highp vec4 cc_shadowInvProjDepthInfo;\n highp vec4 cc_shadowProjDepthInfo;\n highp vec4 cc_shadowProjInfo;\n mediump vec4 cc_shadowNFLSInfo;\n mediump vec4 cc_shadowWHPBInfo;\n mediump vec4 cc_shadowLPNNInfo;\n lowp vec4 cc_shadowColor;\n mediump vec4 cc_planarNDInfo;\n};\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\n#if !USE_INSTANCING\n layout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n highp vec4 cc_localShadowBias;\n highp vec4 cc_reflectionProbeData1;\n highp vec4 cc_reflectionProbeData2;\n highp vec4 cc_reflectionProbeBlendData1;\n highp vec4 cc_reflectionProbeBlendData2;\n };\n#endif\nvoid CCGetWorldMatrixFull(out mat4 matWorld, out mat4 matWorldIT)\n{\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n vec3 scale = 1.0 / vec3(length(a_matWorld0.xyz), length(a_matWorld1.xyz), length(a_matWorld2.xyz));\n vec3 scale2 = scale * scale;\n matWorldIT = mat4(\n vec4(a_matWorld0.xyz * scale2.x, 0.0),\n vec4(a_matWorld1.xyz * scale2.y, 0.0),\n vec4(a_matWorld2.xyz * scale2.z, 0.0),\n vec4(0.0, 0.0, 0.0, 1.0)\n );\n #else\n matWorld = cc_matWorld;\n matWorldIT = cc_matWorldIT;\n #endif\n}\n#if CC_USE_MORPH\n layout(std140) uniform CCMorph {\n vec4 cc_displacementWeights[15];\n vec4 cc_displacementTextureInfo;\n };\n #if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n #endif\n vec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n }\n vec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n }\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\n ivec2 texSize = textureSize(tex, 0);\n return texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n }\n #else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture(tex, x)),\n decode32(texture(tex, y)),\n decode32(texture(tex, z)),\n 1.0\n );\n }\n #endif\n float getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n }\n vec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n #if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n #else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n #endif\n }\n #if CC_MORPH_TARGET_HAS_POSITION\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n #endif\n void applyMorph (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n int vertexId = getVertexId();\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n normal.xyz = normal.xyz + getNormalDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n tangent.xyz = tangent.xyz + getTangentDisplacement(vertexId);\n #endif\n }\n void applyMorph (inout vec4 position) {\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n #endif\n }\n#endif\n#if CC_USE_SKINNING\n #if CC_USE_BAKED_ANIMATION\n layout(std140) uniform CCSkinningTexture {\n highp vec4 cc_jointTextureInfo;\n };\n layout(std140) uniform CCSkinningAnimation {\n highp vec4 cc_jointAnimInfo;\n };\n uniform highp sampler2D cc_jointTexture;\n void CCGetJointTextureCoords(float pixelsPerJoint, float jointIdx, out highp float x, out highp float y, out highp float invSize)\n {\n #if USE_INSTANCING\n highp float temp = pixelsPerJoint * (a_jointAnimInfo.x * a_jointAnimInfo.y + jointIdx) + a_jointAnimInfo.z;\n #else\n highp float temp = pixelsPerJoint * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + jointIdx) + cc_jointTextureInfo.z;\n #endif\n invSize = cc_jointTextureInfo.w;\n highp float tempY = floor(temp * invSize);\n x = floor(temp - tempY * cc_jointTextureInfo.x);\n y = (tempY + 0.5) * invSize;\n }\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n uniform highp sampler2D cc_realtimeJoint;\n #else\n layout(std140) uniform CCSkinning {\n highp vec4 cc_joints[CC_JOINT_UNIFORM_CAPACITY * 3];\n };\n #endif\n #endif\n #if CC_USE_BAKED_ANIMATION\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(3.0, i, x, y, invSize);\n vec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(12.0, i, x, y, invSize);\n vec4 v1 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n float x = i;\n vec4 v1 = texture(cc_realtimeJoint, vec2( x / 256.0, 0.5 / 3.0));\n vec4 v2 = texture(cc_realtimeJoint, vec2( x / 256.0, 1.5 / 3.0));\n vec4 v3 = texture(cc_realtimeJoint, vec2( x / 256.0, 2.5 / 3.0));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n float x = 4.0 * i;\n vec4 v1 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 0.5 / 3.0)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 1.5 / 3.0)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 2.5 / 3.0)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #endif\n mat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n }\n void CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n }\n void CCSkin (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n mat4 m = skinMatrix();\n position = m * position;\n normal = (m * vec4(normal, 0.0)).xyz;\n tangent.xyz = (m * vec4(tangent.xyz, 0.0)).xyz;\n }\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #if CC_USE_FOG != 4\n float LinearFog(vec4 pos, vec3 cameraPos, float fogStart, float fogEnd) {\n vec4 wPos = pos;\n float cam_dis = distance(cameraPos, wPos.xyz);\n return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n }\n float ExpFog(vec4 pos, vec3 cameraPos, float fogStart, float fogDensity, float fogAtten) {\n vec4 wPos = pos;\n float cam_dis = max(distance(cameraPos, wPos.xyz) - fogStart, 0.0) / fogAtten * 4.;\n float f = exp(-cam_dis * fogDensity);\n return f;\n }\n float ExpSquaredFog(vec4 pos, vec3 cameraPos, float fogStart, float fogDensity, float fogAtten) {\n vec4 wPos = pos;\n float cam_dis = max(distance(cameraPos, wPos.xyz) - fogStart, 0.0) / fogAtten * 4.;\n float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\n return f;\n }\n float LayeredFog(vec4 pos, vec3 cameraPos, float fogTop, float fogRange, float fogAtten) {\n vec4 wPos = pos;\n vec3 camWorldProj = cameraPos.xyz;\n camWorldProj.y = 0.;\n vec3 worldPosProj = wPos.xyz;\n worldPosProj.y = 0.;\n float fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\n float fDeltaY, fDensityIntegral;\n if (cameraPos.y > fogTop) {\n if (wPos.y < fogTop) {\n fDeltaY = (fogTop - wPos.y) / fogRange * 2.0;\n fDensityIntegral = fDeltaY * fDeltaY * 0.5;\n }\n else {\n fDeltaY = 0.;\n fDensityIntegral = 0.;\n }\n }\n else {\n if (wPos.y < fogTop) {\n float fDeltaA = (fogTop - cameraPos.y) / fogRange * 2.;\n float fDeltaB = (fogTop - wPos.y) / fogRange * 2.;\n fDeltaY = abs(fDeltaA - fDeltaB);\n fDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n }\n else {\n fDeltaY = abs(fogTop - cameraPos.y) / fogRange * 2.;\n fDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n }\n }\n float fDensity;\n if (fDeltaY != 0.) {\n fDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n }\n else {\n fDensity = 0.;\n }\n float f = exp(-fDensity);\n return f;\n }\n #endif\n void CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n {\n #if CC_USE_FOG == 0\n \tfactor = LinearFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.y);\n #elif CC_USE_FOG == 1\n \tfactor = ExpFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z);\n #elif CC_USE_FOG == 2\n \tfactor = ExpSquaredFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z);\n #elif CC_USE_FOG == 3\n \tfactor = LayeredFog(pos, cc_cameraPos.xyz, cc_fogAdd.x, cc_fogAdd.y, cc_fogAdd.z);\n #else\n \tfactor = 1.0;\n #endif\n }\n#endif\nlayout(std140) uniform Constants {\n vec4 tilingOffset;\n vec4 baseColor;\n vec4 colorScaleAndCutoff;\n vec4 shadeColor1;\n vec4 shadeColor2;\n vec4 specular;\n vec4 shadeParams;\n vec4 miscParams;\n vec4 emissive;\n vec4 emissiveScaleAndStrenth;\n};\n#define CC_SURFACES_VERTEX_MODIFY_UV\nvoid SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)\n{\n In.texCoord = In.texCoord * tilingOffset.xy + tilingOffset.zw;\n}\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_POS\nvec3 SurfacesVertexModifyLocalPos(in SurfacesStandardVertexIntermediate In)\n{\n return vec3(In.position.xyz);\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_NORMAL\nvec3 SurfacesVertexModifyLocalNormal(in SurfacesStandardVertexIntermediate In)\n{\n return In.normal.xyz;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_TANGENT\n #if CC_SURFACES_USE_TANGENT_SPACE\n vec4 SurfacesVertexModifyLocalTangent(in SurfacesStandardVertexIntermediate In)\n {\n return In.tangent;\n }\n #endif\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_SHARED_DATA\nvoid SurfacesVertexModifyLocalSharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_POS\nvec3 SurfacesVertexModifyWorldPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.worldPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_CLIP_POS\nvec4 SurfacesVertexModifyClipPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.clipPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_UV\nvoid SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_NORMAL\nvec3 SurfacesVertexModifyWorldNormal(in SurfacesStandardVertexIntermediate In)\n{\n vec3 worldNormal = In.worldNormal.xyz;\n #if CC_SURFACES_USE_TWO_SIDED\n worldNormal.xyz *= In.worldNormal.w;\n #endif\n return worldNormal;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHADOW_BIAS\nvec2 SurfacesVertexModifyShadowBias(in SurfacesStandardVertexIntermediate In, vec2 originShadowBias)\n{\n return originShadowBias;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHARED_DATA\nvoid SurfacesVertexModifySharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\nvoid CCSurfacesVertexInput(out SurfacesStandardVertexIntermediate In)\n{\n In.position = vec4(a_position, 1.0);\n In.normal = a_normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n In.tangent = a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n In.color = a_color;\n#endif\n In.texCoord = a_texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = a_texCoord1;\n#endif\n}\nvoid CCSurfacesVertexOutput(in SurfacesStandardVertexIntermediate In)\n{\n gl_Position = In.clipPos;\n VSOutput_worldNormal = In.worldNormal.xyz;\n VSOutput_faceSideSign = In.worldNormal.w;\n VSOutput_worldPos = In.worldPos;\n#if CC_SURFACES_USE_TANGENT_SPACE\n VSOutput_worldTangent = In.worldTangent.xyz;\n VSOutput_mirrorNormal = In.tangent.w > 0.0 ? 1.0 : -1.0;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n VSOutput_vertexColor = In.color;\n#endif\n VSOutput_texcoord = In.texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n VSOutput_texcoord1 = In.texCoord1;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n VSOutput_fogFactor = In.fogFactor;\n#endif\n#if CC_RECEIVE_SHADOW\n VSOutput_shadowBias = In.shadowBiasAndProbeId.xy;\n#endif\n#if CC_USE_REFLECTION_PROBE\n VSOutput_reflectionProbeId = In.shadowBiasAndProbeId.z;\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n VSOutput_reflectionProbeBlendId = In.shadowBiasAndProbeId.w;\n #endif\n #if USE_INSTANCING\n v_reflectionProbeData = a_reflectionProbeData;\n #endif\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n VSOutput_lightMapUV = In.lightmapUV;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n VSOutput_localPos = In.position;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n VSOutput_clipPos = In.clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n v_sh_linear_const_r = a_sh_linear_const_r;\n v_sh_linear_const_g = a_sh_linear_const_g;\n v_sh_linear_const_b = a_sh_linear_const_b;\n #endif\n#endif\n}\nvoid CCSurfacesVertexAnimation(inout SurfacesStandardVertexIntermediate In)\n{\nvec4 temp = vec4(0.0);\n#if CC_USE_MORPH\n #if CC_SURFACES_USE_TANGENT_SPACE\n applyMorph(In.position, In.normal, In.tangent);\n #else\n applyMorph(In.position, In.normal, temp);\n #endif\n#endif\n#if CC_USE_SKINNING\n #if CC_SURFACES_USE_TANGENT_SPACE\n CCSkin(In.position, In.normal, In.tangent);\n #else\n CCSkin(In.position, In.normal, temp);\n #endif\n#endif\n}\nvoid CCSurfacesVertexWorldTransform(inout SurfacesStandardVertexIntermediate In)\n{\n mat4 matWorld, matWorldIT;\n CCGetWorldMatrixFull(matWorld, matWorldIT);\n In.worldPos = (matWorld * In.position).xyz;\n In.worldNormal.xyz = normalize((matWorldIT * vec4(In.normal.xyz, 0.0)).xyz);\n #if CC_SURFACES_USE_TANGENT_SPACE\n In.worldTangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\n In.worldBinormal = cross(In.worldNormal.xyz, In.worldTangent) * In.tangent.w;\n #endif\n}\nvoid CCSurfacesVertexTransformUV(inout SurfacesStandardVertexIntermediate In)\n{\n #if CC_SURFACES_FLIP_UV\n In.texCoord = cc_cameraPos.w > 1.0 ? vec2(In.texCoord.x, 1.0 - In.texCoord.y) : In.texCoord;\n #if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = cc_cameraPos.w > 1.0 ? vec2(In.texCoord1.x, 1.0 - In.texCoord1.y) : In.texCoord1;\n #endif\n #endif\n}\nvoid CCSurfacesVertexTransferFog(inout SurfacesStandardVertexIntermediate In)\n{\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n CC_TRANSFER_FOG_BASE(vec4(In.worldPos, 1.0), In.fogFactor);\n#endif\n}\nvoid CCSurfacesVertexTransferShadow(inout SurfacesStandardVertexIntermediate In)\n{\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n In.shadowBiasAndProbeId = vec4(0.0);\n #endif\n #if CC_RECEIVE_SHADOW\n In.shadowBiasAndProbeId.xy = vec2(cc_shadowWHPBInfo.w, cc_shadowLPNNInfo.z);\n #if USE_INSTANCING\n In.shadowBiasAndProbeId.xy += a_localShadowBiasAndProbeId.xy;\n #else\n In.shadowBiasAndProbeId.xy += cc_localShadowBias.xy;\n #endif\n #endif\n #if CC_USE_REFLECTION_PROBE\n #if USE_INSTANCING\n In.shadowBiasAndProbeId.zw = a_localShadowBiasAndProbeId.zw;\n #else\n In.shadowBiasAndProbeId.zw = cc_localShadowBias.zw;\n #endif\n #endif\n}\nvoid CCSurfacesVertexTransferLightMapUV(inout SurfacesStandardVertexIntermediate In)\n{\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #if USE_INSTANCING\n In.lightmapUV.xy = a_lightingMapUVParam.xy + a_texCoord1 * a_lightingMapUVParam.z;\n In.lightmapUV.z = a_lightingMapUVParam.w;\n #else\n In.lightmapUV.xy = cc_lightingMapUVParam.xy + a_texCoord1 * cc_lightingMapUVParam.z;\n In.lightmapUV.z = cc_lightingMapUVParam.w;\n #endif\n#endif\n}\nvoid main()\n{\n SurfacesStandardVertexIntermediate In;\n CCSurfacesVertexInput(In);\n CCSurfacesVertexAnimation(In);\n In.position.xyz = SurfacesVertexModifyLocalPos(In);\n In.normal.xyz = SurfacesVertexModifyLocalNormal(In);\n #if CC_SURFACES_USE_TANGENT_SPACE\n In.tangent = SurfacesVertexModifyLocalTangent(In);\n #endif\n SurfacesVertexModifyLocalSharedData(In);\n CCSurfacesVertexWorldTransform(In);\n In.worldPos = SurfacesVertexModifyWorldPos(In);\n In.clipPos = cc_matProj * cc_matView * vec4(In.worldPos, 1.0);\n In.clipPos = SurfacesVertexModifyClipPos(In);\n vec3 viewDirect = normalize(cc_cameraPos.xyz - In.worldPos);\n In.worldNormal.w = dot(In.worldNormal.xyz, viewDirect) < 0.0 ? -1.0 : 1.0;\n In.worldNormal.xyz = SurfacesVertexModifyWorldNormal(In);\n SurfacesVertexModifyUV(In);\n SurfacesVertexModifySharedData(In);\n CCSurfacesVertexTransformUV(In);\n CCSurfacesVertexTransferFog(In);\n CCSurfacesVertexTransferLightMapUV(In);\n CCSurfacesVertexTransferShadow(In);\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n In.shadowBiasAndProbeId.xy = SurfacesVertexModifyShadowBias(In, In.shadowBiasAndProbeId.xy);\n #endif\n CCSurfacesVertexOutput(In);\n}",
- "frag": "\nprecision highp float;\n#define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING USE_COMPATIBLE_LIGHTING\n#define CC_SURFACES_USE_TANGENT_SPACE USE_NORMAL_MAP\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nin highp vec3 v_worldPos;\nin vec4 v_normal;\nin vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n in lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n in mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n in mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n in mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n in mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n in mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n in mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n in highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n in highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n in mediump vec4 v_sh_linear_const_r;\n in mediump vec4 v_sh_linear_const_g;\n in mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define FSInput_worldPos v_worldPos\n#define FSInput_worldNormal v_normal.xyz\n#define FSInput_faceSideSign v_normal.w\n#define FSInput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define FSInput_vertexColor v_color\n#else\n #define FSInput_vertexColor vec4(1.0)\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define FSInput_worldTangent v_tangent.xyz\n #define FSInput_mirrorNormal v_tangent.w\n#else\n #define FSInput_worldTangent vec3(1.0, 1.0, 1.0)\n #define FSInput_mirrorNormal 1.0\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define FSInput_texcoord1 v_uv1\n#else\n #define FSInput_texcoord1 vec2(0.0, 0.0)\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define FSInput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define FSInput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define FSInput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define FSInput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define FSInput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define FSInput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define FSInput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define FSInput_clipPos v_clipPos\n#endif\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_WORLD_POS CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR CC_SURFACES_DEBUG_VIEW_WORLD_POS + 1\n#define CC_SURFACES_DEBUG_VIEW_FACE_SIDE CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR + 1\n#define CC_SURFACES_DEBUG_VIEW_UV0 CC_SURFACES_DEBUG_VIEW_FACE_SIDE + 1\n#define CC_SURFACES_DEBUG_VIEW_UV1 CC_SURFACES_DEBUG_VIEW_UV0 + 1\n#define CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP CC_SURFACES_DEBUG_VIEW_UV1 + 1\n#define CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP + 1\n#define CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_BASE_COLOR CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR CC_SURFACES_DEBUG_VIEW_BASE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSPARENCY CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_METALLIC CC_SURFACES_DEBUG_VIEW_TRANSPARENCY + 1\n#define CC_SURFACES_DEBUG_VIEW_ROUGHNESS CC_SURFACES_DEBUG_VIEW_METALLIC + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY CC_SURFACES_DEBUG_VIEW_ROUGHNESS + 1\n#define CC_SURFACES_DEBUG_VIEW_IOR CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_IOR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_ALL CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_DIRECT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_ALL CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_EMISSIVE CC_SURFACES_DEBUG_VIEW_ENV_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_LIGHT_MAP CC_SURFACES_DEBUG_VIEW_EMISSIVE + 1\n#define CC_SURFACES_DEBUG_VIEW_SHADOW CC_SURFACES_DEBUG_VIEW_LIGHT_MAP + 1\n#define CC_SURFACES_DEBUG_VIEW_AO CC_SURFACES_DEBUG_VIEW_SHADOW + 1\n#define CC_SURFACES_DEBUG_VIEW_FRESNEL CC_SURFACES_DEBUG_VIEW_AO + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_FRESNEL + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_FOG CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL + 1\n#define IS_DEBUG_VIEW_ENABLE_WITH_CAMERA (cc_surfaceTransform.y != 3.0)\nbool equalf_mode(float data1, float data2) { return abs(float(data1) - float(data2)) < 0.001; }\n#define IS_DEBUG_VIEW_LIGHTING_ENABLE_WITH_ALBEDO (UnpackBitFromFloat(cc_debug_view_mode.w, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_MISC_ENABLE_CSM_LAYER_COLORATION (UnpackBitFromFloat(cc_debug_view_mode.w, 7) && IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_EMISSIVE (UnpackBitFromFloat(cc_debug_view_mode.y, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_LIGHT_MAP (UnpackBitFromFloat(cc_debug_view_mode.y, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_SHADOW (UnpackBitFromFloat(cc_debug_view_mode.y, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_AO (UnpackBitFromFloat(cc_debug_view_mode.y, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_NORMAL_MAP (UnpackBitFromFloat(cc_debug_view_mode.z, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FOG (UnpackBitFromFloat(cc_debug_view_mode.z, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TONE_MAPPING (UnpackBitFromFloat(cc_debug_view_mode.z, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION (UnpackBitFromFloat(cc_debug_view_mode.z, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FRESNEL (UnpackBitFromFloat(cc_debug_view_mode.z, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.z, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_2ND_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TT (UnpackBitFromFloat(cc_debug_view_mode.w, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#if (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\n #if CC_FORWARD_ADD\n #if CC_PIPELINE_TYPE == 0\n #define LIGHTS_PER_PASS 1\n #else\n #define LIGHTS_PER_PASS 10\n #endif\n #if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\n layout(std140) uniform CCForwardLight {\n highp vec4 cc_lightPos[LIGHTS_PER_PASS];\n vec4 cc_lightColor[LIGHTS_PER_PASS];\n vec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\n vec4 cc_lightDir[LIGHTS_PER_PASS];\n vec4 cc_lightBoundingSizeVS[LIGHTS_PER_PASS];\n };\n #endif\n #endif\n#endif\n#if CC_USE_LIGHT_PROBE\n #if !USE_INSTANCING\n layout(std140) uniform CCSH {\n vec4 cc_sh_linear_const_r;\n vec4 cc_sh_linear_const_g;\n vec4 cc_sh_linear_const_b;\n vec4 cc_sh_quadratic_r;\n vec4 cc_sh_quadratic_g;\n vec4 cc_sh_quadratic_b;\n vec4 cc_sh_quadratic_a;\n };\n #endif\n#endif\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightView;\n highp mat4 cc_matLightViewProj;\n highp vec4 cc_shadowInvProjDepthInfo;\n highp vec4 cc_shadowProjDepthInfo;\n highp vec4 cc_shadowProjInfo;\n mediump vec4 cc_shadowNFLSInfo;\n mediump vec4 cc_shadowWHPBInfo;\n mediump vec4 cc_shadowLPNNInfo;\n lowp vec4 cc_shadowColor;\n mediump vec4 cc_planarNDInfo;\n};\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n layout(std140) uniform CCCSM {\n highp vec4 cc_csmViewDir0[4];\n highp vec4 cc_csmViewDir1[4];\n highp vec4 cc_csmViewDir2[4];\n highp vec4 cc_csmAtlas[4];\n highp mat4 cc_matCSMViewProj[4];\n highp vec4 cc_csmProjDepthInfo[4];\n highp vec4 cc_csmProjInfo[4];\n highp vec4 cc_csmSplitsInfo;\n };\n#endif\nuniform samplerCube cc_environment;\n#if CC_USE_IBL\n #if CC_USE_DIFFUSEMAP\n uniform samplerCube cc_diffuseMap;\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n uniform samplerCube cc_reflectionProbeCubemap;\n uniform sampler2D cc_reflectionProbePlanarMap;\n uniform sampler2D cc_reflectionProbeDataMap;\n uniform samplerCube cc_reflectionProbeBlendCubemap;\n#endif\n#define UnpackBitFromFloat(value, bit) (mod(floor(value / pow(10.0, float(bit))), 10.0) > 0.0)\nhighp float unpackHighpData (float mainPart, float modPart) {\n highp float data = mainPart;\n return data + modPart;\n}\nvoid packHighpData (out float mainPart, out float modPart, highp float data) {\n mainPart = fract(data);\n modPart = data - mainPart;\n}\nhighp float unpackHighpData (float mainPart, float modPart, const float modValue) {\n highp float data = mainPart * modValue;\n return data + modPart * modValue;\n}\nvoid packHighpData (out float mainPart, out float modPart, highp float data, const float modValue) {\n highp float divide = data / modValue;\n mainPart = floor(divide);\n modPart = (data - mainPart * modValue) / modValue;\n}\nhighp vec2 unpackHighpData (vec2 mainPart, vec2 modPart) {\n highp vec2 data = mainPart;\n return data + modPart;\n}\nvoid packHighpData (out vec2 mainPart, out vec2 modPart, highp vec2 data) {\n mainPart = fract(data);\n modPart = data - mainPart;\n}\nhighp vec2 unpackHighpData (vec2 mainPart, vec2 modPart, const float modValue) {\n highp vec2 data = mainPart * modValue;\n return data + modPart * modValue;\n}\nvoid packHighpData (out vec2 mainPart, out vec2 modPart, highp vec2 data, const float modValue) {\n highp vec2 divide = data / modValue;\n mainPart = floor(divide);\n modPart = (data - mainPart * modValue) / modValue;\n}\nhighp vec3 unpackHighpData (vec3 mainPart, vec3 modPart) {\n highp vec3 data = mainPart;\n return data + modPart;\n}\nvoid packHighpData (out vec3 mainPart, out vec3 modPart, highp vec3 data) {\n mainPart = fract(data);\n modPart = data - mainPart;\n}\nhighp vec3 unpackHighpData (vec3 mainPart, vec3 modPart, const float modValue) {\n highp vec3 data = mainPart * modValue;\n return data + modPart * modValue;\n}\nvoid packHighpData (out vec3 mainPart, out vec3 modPart, highp vec3 data, const float modValue) {\n highp vec3 divide = data / modValue;\n mainPart = floor(divide);\n modPart = (data - mainPart * modValue) / modValue;\n}\nhighp vec4 unpackHighpData (vec4 mainPart, vec4 modPart) {\n highp vec4 data = mainPart;\n return data + modPart;\n}\nvoid packHighpData (out vec4 mainPart, out vec4 modPart, highp vec4 data) {\n mainPart = fract(data);\n modPart = data - mainPart;\n}\nhighp vec4 unpackHighpData (vec4 mainPart, vec4 modPart, const float modValue) {\n highp vec4 data = mainPart * modValue;\n return data + modPart * modValue;\n}\nvoid packHighpData (out vec4 mainPart, out vec4 modPart, highp vec4 data, const float modValue) {\n highp vec4 divide = data / modValue;\n mainPart = floor(divide);\n modPart = (data - mainPart * modValue) / modValue;\n}\nvec4 packRGBE (vec3 rgb) {\n highp float maxComp = max(max(rgb.r, rgb.g), rgb.b);\n highp float e = 128.0;\n if (maxComp > 0.0001) {\n e = log(maxComp) / log(1.1);\n e = ceil(e);\n e = clamp(e + 128.0, 0.0, 255.0);\n }\n highp float sc = 1.0 / pow(1.1, e - 128.0);\n vec3 encode = clamp(rgb * sc, vec3(0.0), vec3(1.0)) * 255.0;\n vec3 encode_rounded = floor(encode) + step(encode - floor(encode), vec3(0.5));\n return vec4(encode_rounded, e) / 255.0;\n}\nvec3 ACESToneMap (vec3 color) {\n color = min(color, vec3(8.0));\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec3 HDRToLDR(vec3 color)\n{\n #if CC_USE_HDR\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (IS_DEBUG_VIEW_COMPOSITE_ENABLE_TONE_MAPPING)\n #endif\n {\n #if CC_TONE_MAPPING_TYPE == HDR_TONE_MAPPING_ACES\n color.rgb = ACESToneMap(color.rgb);\n #endif\n }\n #endif\n return color;\n}\nvec3 SRGBToLinear (vec3 gamma) {\n#ifdef CC_USE_SURFACE_SHADER\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION) {\n return gamma;\n }\n #endif\n#endif\n return gamma * gamma;\n}\nvec3 LinearToSRGB(vec3 linear) {\n#ifdef CC_USE_SURFACE_SHADER\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION) {\n return linear;\n }\n #endif\n#endif\n return sqrt(linear);\n}\nbool isnans(vec2 val) {\n return isnan(val.x) || isnan(val.y);\n}\nbool isnans(vec3 val) {\n return isnan(val.x) || isnan(val.y) || isnan(val.z);\n}\nbool isnans(vec4 val) {\n return isnan(val.x) || isnan(val.y) || isnan(val.z) || isnan(val.w);\n}\nbool isinfs(vec2 val) {\n return isinf(val.x) || isinf(val.y);\n}\nbool isinfs(vec3 val) {\n return isinf(val.x) || isinf(val.y) || isinf(val.z);\n}\nbool isinfs(vec4 val) {\n return isinf(val.x) || isinf(val.y) || isinf(val.z) || isinf(val.w);\n}\n#if defined(CC_USE_METAL) || defined(CC_USE_WGPU)\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y) y = -y\n#else\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y)\n#endif\nfloat GetLinearDepthFromViewSpace(vec3 viewPos, float near, float far) {\n float dist = length(viewPos);\n return (dist - near) / (far - near);\n}\nvec3 CalculateBinormal(vec3 normal, vec3 tangent, float mirrorNormal)\n{\n return cross(normal, tangent) * mirrorNormal;\n}\nvec3 CalculateNormalFromTangentSpace(vec3 normalFromTangentSpace, float normalStrength, vec3 normal, vec3 tangent, float mirrorNormal)\n{\n vec3 binormal = CalculateBinormal(normal, tangent, mirrorNormal);\n return (normalFromTangentSpace.x * normalStrength) * normalize(tangent) +\n (normalFromTangentSpace.y * normalStrength) * normalize(binormal) +\n normalFromTangentSpace.z * normalize(normal);\n}\nvec2 signNotZero(vec2 v) {\n return vec2((v.x >= 0.0) ? +1.0 : -1.0, (v.y >= 0.0) ? +1.0 : -1.0);\n}\nvec2 float32x3_to_oct(in vec3 v) {\n vec2 p = v.xy * (1.0 / (abs(v.x) + abs(v.y) + abs(v.z)));\n return (v.z <= 0.0) ? ((1.0 - abs(p.yx)) * signNotZero(p)) : p;\n}\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n#endif\nfloat CCGetLinearDepth(vec3 worldPos, float viewSpaceBias) {\n\tvec4 viewPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\n viewPos.z += viewSpaceBias;\n\treturn GetLinearDepthFromViewSpace(viewPos.xyz, cc_shadowNFLSInfo.x, cc_shadowNFLSInfo.y);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\n\treturn CCGetLinearDepth(worldPos, 0.0);\n}\n#if CC_RECEIVE_SHADOW\n uniform highp sampler2D cc_shadowMap;\n uniform highp sampler2D cc_spotShadowMap;\n float SampleShadowMap (vec3 shadowNDCPos, highp sampler2D shadowMap)\n {\n #if CC_SHADOWMAP_FORMAT == 1\n return dot(texture(shadowMap, shadowNDCPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n #else\n return texture(shadowMap, shadowNDCPos.xy).x;\n #endif\n }\n float SampleShadowMapSoft (vec3 shadowNDCPos, highp sampler2D shadowMap, vec2 shadowMapResolution)\n {\n vec2 oneTap = 1.0 / shadowMapResolution;\n vec2 shadowNDCPos_offset = shadowNDCPos.xy + oneTap;\n float block0 = SampleShadowMap(vec3(shadowNDCPos.x, shadowNDCPos.y, shadowNDCPos.z), shadowMap);\n float block1 = SampleShadowMap(vec3(shadowNDCPos_offset.x, shadowNDCPos.y, shadowNDCPos.z), shadowMap);\n float block2 = SampleShadowMap(vec3(shadowNDCPos.x, shadowNDCPos_offset.y, shadowNDCPos.z), shadowMap);\n float block3 = SampleShadowMap(vec3(shadowNDCPos_offset.x, shadowNDCPos_offset.y, shadowNDCPos.z), shadowMap);\n float coefX = mod(shadowNDCPos.x, oneTap.x) * shadowMapResolution.x;\n float resultX = mix(block0, block1, coefX);\n float resultY = mix(block2, block3, coefX);\n float coefY = mod(shadowNDCPos.y, oneTap.y) * shadowMapResolution.y;\n return mix(resultX, resultY, coefY);\n }\n float NativePCFShadowFactorHard (vec3 shadowNDCPos, highp sampler2D shadowMap, vec2 shadowMapResolution)\n {\n #if CC_SHADOWMAP_FORMAT == 1\n return step(shadowNDCPos.z, dot(texture(shadowMap, shadowNDCPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n #else\n return step(shadowNDCPos.z, texture(shadowMap, shadowNDCPos.xy).x);\n #endif\n }\n float NativePCFShadowFactorSoft (vec3 shadowNDCPos, highp sampler2D shadowMap, vec2 shadowMapResolution)\n {\n vec2 oneTap = 1.0 / shadowMapResolution;\n vec2 shadowNDCPos_offset = shadowNDCPos.xy + oneTap;\n float block0, block1, block2, block3;\n #if CC_SHADOWMAP_FORMAT == 1\n block0 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block1 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos_offset.x, shadowNDCPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block2 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block3 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos_offset.x, shadowNDCPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n #else\n block0 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos.y)).x);\n block1 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos_offset.x, shadowNDCPos.y)).x);\n block2 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos_offset.y)).x);\n block3 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos_offset.x, shadowNDCPos_offset.y)).x);\n #endif\n float coefX = mod(shadowNDCPos.x, oneTap.x) * shadowMapResolution.x;\n float resultX = mix(block0, block1, coefX);\n float resultY = mix(block2, block3, coefX);\n float coefY = mod(shadowNDCPos.y, oneTap.y) * shadowMapResolution.y;\n return mix(resultX, resultY, coefY);\n }\n float NativePCFShadowFactorSoft3X (vec3 shadowNDCPos, highp sampler2D shadowMap, vec2 shadowMapResolution)\n {\n vec2 oneTap = 1.0 / shadowMapResolution;\n float shadowNDCPos_offset_L = shadowNDCPos.x - oneTap.x;\n float shadowNDCPos_offset_R = shadowNDCPos.x + oneTap.x;\n float shadowNDCPos_offset_U = shadowNDCPos.y - oneTap.y;\n float shadowNDCPos_offset_D = shadowNDCPos.y + oneTap.y;\n float block0, block1, block2, block3, block4, block5, block6, block7, block8;\n #if CC_SHADOWMAP_FORMAT == 1\n block0 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos_offset_L, shadowNDCPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block1 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block2 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos_offset_R, shadowNDCPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block3 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos_offset_L, shadowNDCPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block4 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block5 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos_offset_R, shadowNDCPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block6 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos_offset_L, shadowNDCPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block7 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block8 = step(shadowNDCPos.z, dot(texture(shadowMap, vec2(shadowNDCPos_offset_R, shadowNDCPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n #else\n block0 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos_offset_L, shadowNDCPos_offset_U)).x);\n block1 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos_offset_U)).x);\n block2 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos_offset_R, shadowNDCPos_offset_U)).x);\n block3 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos_offset_L, shadowNDCPos.y)).x);\n block4 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos.y)).x);\n block5 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos_offset_R, shadowNDCPos.y)).x);\n block6 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos_offset_L, shadowNDCPos_offset_D)).x);\n block7 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos_offset_D)).x);\n block8 = step(shadowNDCPos.z, texture(shadowMap, vec2(shadowNDCPos_offset_R, shadowNDCPos_offset_D)).x);\n #endif\n float coefX = mod(shadowNDCPos.x, oneTap.x) * shadowMapResolution.x;\n float coefY = mod(shadowNDCPos.y, oneTap.y) * shadowMapResolution.y;\n float shadow = 0.0;\n float resultX = mix(block0, block1, coefX);\n float resultY = mix(block3, block4, coefX);\n shadow += mix(resultX , resultY, coefY);\n resultX = mix(block1, block2, coefX);\n resultY = mix(block4, block5, coefX);\n shadow += mix(resultX , resultY, coefY);\n resultX = mix(block3, block4, coefX);\n resultY = mix(block6, block7, coefX);\n shadow += mix(resultX, resultY, coefY);\n resultX = mix(block4, block5, coefX);\n resultY = mix(block7, block8, coefX);\n shadow += mix(resultX, resultY, coefY);\n return shadow * 0.25;\n }\n float NativePCFShadowFactorSoft5X (vec3 shadowNDCPos, highp sampler2D shadowMap, vec2 shadowMapResolution)\n {\n vec2 oneTap = 1.0 / shadowMapResolution;\n vec2 twoTap = oneTap * 2.0;\n vec2 offset1 = shadowNDCPos.xy + vec2(-twoTap.x, -twoTap.y);\n vec2 offset2 = shadowNDCPos.xy + vec2(-oneTap.x, -twoTap.y);\n vec2 offset3 = shadowNDCPos.xy + vec2(0.0, -twoTap.y);\n vec2 offset4 = shadowNDCPos.xy + vec2(oneTap.x, -twoTap.y);\n vec2 offset5 = shadowNDCPos.xy + vec2(twoTap.x, -twoTap.y);\n vec2 offset6 = shadowNDCPos.xy + vec2(-twoTap.x, -oneTap.y);\n vec2 offset7 = shadowNDCPos.xy + vec2(-oneTap.x, -oneTap.y);\n vec2 offset8 = shadowNDCPos.xy + vec2(0.0, -oneTap.y);\n vec2 offset9 = shadowNDCPos.xy + vec2(oneTap.x, -oneTap.y);\n vec2 offset10 = shadowNDCPos.xy + vec2(twoTap.x, -oneTap.y);\n vec2 offset11 = shadowNDCPos.xy + vec2(-twoTap.x, 0.0);\n vec2 offset12 = shadowNDCPos.xy + vec2(-oneTap.x, 0.0);\n vec2 offset13 = shadowNDCPos.xy + vec2(0.0, 0.0);\n vec2 offset14 = shadowNDCPos.xy + vec2(oneTap.x, 0.0);\n vec2 offset15 = shadowNDCPos.xy + vec2(twoTap.x, 0.0);\n vec2 offset16 = shadowNDCPos.xy + vec2(-twoTap.x, oneTap.y);\n vec2 offset17 = shadowNDCPos.xy + vec2(-oneTap.x, oneTap.y);\n vec2 offset18 = shadowNDCPos.xy + vec2(0.0, oneTap.y);\n vec2 offset19 = shadowNDCPos.xy + vec2(oneTap.x, oneTap.y);\n vec2 offset20 = shadowNDCPos.xy + vec2(twoTap.x, oneTap.y);\n vec2 offset21 = shadowNDCPos.xy + vec2(-twoTap.x, twoTap.y);\n vec2 offset22 = shadowNDCPos.xy + vec2(-oneTap.x, twoTap.y);\n vec2 offset23 = shadowNDCPos.xy + vec2(0.0, twoTap.y);\n vec2 offset24 = shadowNDCPos.xy + vec2(oneTap.x, twoTap.y);\n vec2 offset25 = shadowNDCPos.xy + vec2(twoTap.x, twoTap.y);\n float block1, block2, block3, block4, block5, block6, block7, block8, block9, block10, block11, block12, block13, block14, block15, block16, block17, block18, block19, block20, block21, block22, block23, block24, block25;\n #if CC_SHADOWMAP_FORMAT == 1\n block1 = step(shadowNDCPos.z, dot(texture(shadowMap, offset1), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block2 = step(shadowNDCPos.z, dot(texture(shadowMap, offset2), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block3 = step(shadowNDCPos.z, dot(texture(shadowMap, offset3), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block4 = step(shadowNDCPos.z, dot(texture(shadowMap, offset4), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block5 = step(shadowNDCPos.z, dot(texture(shadowMap, offset5), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block6 = step(shadowNDCPos.z, dot(texture(shadowMap, offset6), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block7 = step(shadowNDCPos.z, dot(texture(shadowMap, offset7), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block8 = step(shadowNDCPos.z, dot(texture(shadowMap, offset8), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block9 = step(shadowNDCPos.z, dot(texture(shadowMap, offset9), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block10 = step(shadowNDCPos.z, dot(texture(shadowMap, offset10), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block11 = step(shadowNDCPos.z, dot(texture(shadowMap, offset11), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block12 = step(shadowNDCPos.z, dot(texture(shadowMap, offset12), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block13 = step(shadowNDCPos.z, dot(texture(shadowMap, offset13), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block14 = step(shadowNDCPos.z, dot(texture(shadowMap, offset14), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block15 = step(shadowNDCPos.z, dot(texture(shadowMap, offset15), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block16 = step(shadowNDCPos.z, dot(texture(shadowMap, offset16), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block17 = step(shadowNDCPos.z, dot(texture(shadowMap, offset17), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block18 = step(shadowNDCPos.z, dot(texture(shadowMap, offset18), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block19 = step(shadowNDCPos.z, dot(texture(shadowMap, offset19), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block20 = step(shadowNDCPos.z, dot(texture(shadowMap, offset20), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block21 = step(shadowNDCPos.z, dot(texture(shadowMap, offset21), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block22 = step(shadowNDCPos.z, dot(texture(shadowMap, offset22), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block23 = step(shadowNDCPos.z, dot(texture(shadowMap, offset23), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block24 = step(shadowNDCPos.z, dot(texture(shadowMap, offset24), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block25 = step(shadowNDCPos.z, dot(texture(shadowMap, offset25), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n #else\n block1 = step(shadowNDCPos.z, texture(shadowMap, offset1).x);\n block2 = step(shadowNDCPos.z, texture(shadowMap, offset2).x);\n block3 = step(shadowNDCPos.z, texture(shadowMap, offset3).x);\n block4 = step(shadowNDCPos.z, texture(shadowMap, offset4).x);\n block5 = step(shadowNDCPos.z, texture(shadowMap, offset5).x);\n block6 = step(shadowNDCPos.z, texture(shadowMap, offset6).x);\n block7 = step(shadowNDCPos.z, texture(shadowMap, offset7).x);\n block8 = step(shadowNDCPos.z, texture(shadowMap, offset8).x);\n block9 = step(shadowNDCPos.z, texture(shadowMap, offset9).x);\n block10 = step(shadowNDCPos.z, texture(shadowMap, offset10).x);\n block11 = step(shadowNDCPos.z, texture(shadowMap, offset11).x);\n block12 = step(shadowNDCPos.z, texture(shadowMap, offset12).x);\n block13 = step(shadowNDCPos.z, texture(shadowMap, offset13).x);\n block14 = step(shadowNDCPos.z, texture(shadowMap, offset14).x);\n block15 = step(shadowNDCPos.z, texture(shadowMap, offset15).x);\n block16 = step(shadowNDCPos.z, texture(shadowMap, offset16).x);\n block17 = step(shadowNDCPos.z, texture(shadowMap, offset17).x);\n block18 = step(shadowNDCPos.z, texture(shadowMap, offset18).x);\n block19 = step(shadowNDCPos.z, texture(shadowMap, offset19).x);\n block20 = step(shadowNDCPos.z, texture(shadowMap, offset20).x);\n block21 = step(shadowNDCPos.z, texture(shadowMap, offset21).x);\n block22 = step(shadowNDCPos.z, texture(shadowMap, offset22).x);\n block23 = step(shadowNDCPos.z, texture(shadowMap, offset23).x);\n block24 = step(shadowNDCPos.z, texture(shadowMap, offset24).x);\n block25 = step(shadowNDCPos.z, texture(shadowMap, offset25).x);\n #endif\n vec2 coef = fract(shadowNDCPos.xy * shadowMapResolution);\n vec2 v1X1 = mix(vec2(block1, block6), vec2(block2, block7), coef.xx);\n vec2 v1X2 = mix(vec2(block2, block7), vec2(block3, block8), coef.xx);\n vec2 v1X3 = mix(vec2(block3, block8), vec2(block4, block9), coef.xx);\n vec2 v1X4 = mix(vec2(block4, block9), vec2(block5, block10), coef.xx);\n float v1 = mix(v1X1.x, v1X1.y, coef.y) + mix(v1X2.x, v1X2.y, coef.y) + mix(v1X3.x, v1X3.y, coef.y) + mix(v1X4.x, v1X4.y, coef.y);\n vec2 v2X1 = mix(vec2(block6, block11), vec2(block7, block12), coef.xx);\n vec2 v2X2 = mix(vec2(block7, block12), vec2(block8, block13), coef.xx);\n vec2 v2X3 = mix(vec2(block8, block13), vec2(block9, block14), coef.xx);\n vec2 v2X4 = mix(vec2(block9, block14), vec2(block10, block15), coef.xx);\n float v2 = mix(v2X1.x, v2X1.y, coef.y) + mix(v2X2.x, v2X2.y, coef.y) + mix(v2X3.x, v2X3.y, coef.y) + mix(v2X4.x, v2X4.y, coef.y);\n vec2 v3X1 = mix(vec2(block11, block16), vec2(block12, block17), coef.xx);\n vec2 v3X2 = mix(vec2(block12, block17), vec2(block13, block18), coef.xx);\n vec2 v3X3 = mix(vec2(block13, block18), vec2(block14, block19), coef.xx);\n vec2 v3X4 = mix(vec2(block14, block19), vec2(block15, block20), coef.xx);\n float v3 = mix(v3X1.x, v3X1.y, coef.y) + mix(v3X2.x, v3X2.y, coef.y) + mix(v3X3.x, v3X3.y, coef.y) + mix(v3X4.x, v3X4.y, coef.y);\n vec2 v4X1 = mix(vec2(block16, block21), vec2(block17, block22), coef.xx);\n vec2 v4X2 = mix(vec2(block17, block22), vec2(block18, block23), coef.xx);\n vec2 v4X3 = mix(vec2(block18, block23), vec2(block19, block24), coef.xx);\n vec2 v4X4 = mix(vec2(block19, block24), vec2(block20, block25), coef.xx);\n float v4 = mix(v4X1.x, v4X1.y, coef.y) + mix(v4X2.x, v4X2.y, coef.y) + mix(v4X3.x, v4X3.y, coef.y) + mix(v4X4.x, v4X4.y, coef.y);\n float fAvg = (v1 + v2 + v3 + v4) * 0.0625;\n return fAvg;\n }\n bool GetShadowNDCPos(out vec3 shadowNDCPos, vec4 shadowPosWithDepthBias)\n {\n \tshadowNDCPos = shadowPosWithDepthBias.xyz / shadowPosWithDepthBias.w * 0.5 + 0.5;\n \tif (shadowNDCPos.x < 0.0 || shadowNDCPos.x > 1.0 ||\n \t\tshadowNDCPos.y < 0.0 || shadowNDCPos.y > 1.0 ||\n \t\tshadowNDCPos.z < 0.0 || shadowNDCPos.z > 1.0) {\n \t\treturn false;\n \t}\n \tshadowNDCPos.xy = cc_cameraPos.w == 1.0 ? vec2(shadowNDCPos.xy.x, 1.0 - shadowNDCPos.xy.y) : shadowNDCPos.xy;\n \treturn true;\n }\n vec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal, float normalBias, vec3 matViewDir0, vec3 matViewDir1, vec3 matViewDir2, vec2 projScaleXY)\n {\n vec4 newShadowPos = shadowPos;\n if (normalBias > EPSILON_LOWP)\n {\n vec3 viewNormal = vec3(dot(matViewDir0, worldNormal), dot(matViewDir1, worldNormal), dot(matViewDir2, worldNormal));\n if (viewNormal.z < 0.1)\n newShadowPos.xy += viewNormal.xy * projScaleXY * normalBias * clamp(viewNormal.z, 0.001, 0.1);\n }\n return newShadowPos;\n }\n vec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal, float normalBias, mat4 matLightView, vec2 projScaleXY)\n {\n \tvec4 newShadowPos = shadowPos;\n \tif (normalBias > EPSILON_LOWP)\n \t{\n \t\tvec4 viewNormal = matLightView * vec4(worldNormal, 0.0);\n \t\tif (viewNormal.z < 0.1)\n \t\t\tnewShadowPos.xy += viewNormal.xy * projScaleXY * normalBias * clamp(viewNormal.z, 0.001, 0.1);\n \t}\n \treturn newShadowPos;\n }\n float GetViewSpaceDepthFromNDCDepth_Orthgraphic(float NDCDepth, float projScaleZ, float projBiasZ)\n {\n \treturn (NDCDepth - projBiasZ) / projScaleZ;\n }\n float GetViewSpaceDepthFromNDCDepth_Perspective(float NDCDepth, float homogenousDividW, float invProjScaleZ, float invProjBiasZ)\n {\n \treturn NDCDepth * invProjScaleZ + homogenousDividW * invProjBiasZ;\n }\n vec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n {\n \tvec3 viewSpacePos;\n \tviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\n \tviewSpacePos.z = GetViewSpaceDepthFromNDCDepth_Perspective(shadowPos.z, shadowPos.w, cc_shadowInvProjDepthInfo.x, cc_shadowInvProjDepthInfo.y);\n \tviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\n \tvec4 clipSpacePos;\n \tclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\n \tclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\n \t#if CC_SHADOWMAP_USE_LINEAR_DEPTH\n \t\tclipSpacePos.z = GetLinearDepthFromViewSpace(viewSpacePos.xyz, cc_shadowNFLSInfo.x, cc_shadowNFLSInfo.y);\n \t\tclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n \t#endif\n \treturn clipSpacePos;\n }\n vec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias, float projScaleZ, float projBiasZ)\n {\n \tfloat coeffA = projScaleZ;\n \tfloat coeffB = projBiasZ;\n \tfloat viewSpacePos_z = GetViewSpaceDepthFromNDCDepth_Orthgraphic(shadowPos.z, projScaleZ, projBiasZ);\n \tviewSpacePos_z += viewspaceDepthBias;\n \tvec4 result = shadowPos;\n \tresult.z = viewSpacePos_z * coeffA + coeffB;\n \treturn result;\n }\n vec4 ApplyShadowDepthBias_PerspectiveLinearDepth(vec4 shadowPos, float viewspaceDepthBias, vec3 worldPos)\n {\n shadowPos.z = CCGetLinearDepth(worldPos, viewspaceDepthBias) * 2.0 - 1.0;\n shadowPos.z *= shadowPos.w;\n return shadowPos;\n }\n float CCGetDirLightShadowFactorHard (vec4 shadowPosWithDepthBias) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorHard(shadowNDCPos, cc_shadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCGetDirLightShadowFactorSoft (vec4 shadowPosWithDepthBias) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorSoft(shadowNDCPos, cc_shadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCGetDirLightShadowFactorSoft3X (vec4 shadowPosWithDepthBias) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorSoft3X(shadowNDCPos, cc_shadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCGetDirLightShadowFactorSoft5X (vec4 shadowPosWithDepthBias) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorSoft5X(shadowNDCPos, cc_shadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCGetSpotLightShadowFactorHard (vec4 shadowPosWithDepthBias, vec3 worldPos) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorHard(shadowNDCPos, cc_spotShadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCGetSpotLightShadowFactorSoft (vec4 shadowPosWithDepthBias, vec3 worldPos) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorSoft(shadowNDCPos, cc_spotShadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCGetSpotLightShadowFactorSoft3X (vec4 shadowPosWithDepthBias, vec3 worldPos) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorSoft3X(shadowNDCPos, cc_spotShadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCGetSpotLightShadowFactorSoft5X (vec4 shadowPosWithDepthBias, vec3 worldPos) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorSoft5X(shadowNDCPos, cc_spotShadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCSpotShadowFactorBase(out vec4 shadowPosWithDepthBias, vec4 shadowPos, vec3 worldPos, vec2 shadowBias)\n {\n float pcf = cc_shadowWHPBInfo.z;\n vec4 pos = vec4(1.0);\n #if CC_SHADOWMAP_USE_LINEAR_DEPTH\n pos = ApplyShadowDepthBias_PerspectiveLinearDepth(shadowPos, shadowBias.x, worldPos);\n #else\n pos = ApplyShadowDepthBias_Perspective(shadowPos, shadowBias.x);\n #endif\n float realtimeShadow = 1.0;\n if (pcf > 2.9) {\n realtimeShadow = CCGetSpotLightShadowFactorSoft5X(pos, worldPos);\n }else if (pcf > 1.9) {\n realtimeShadow = CCGetSpotLightShadowFactorSoft3X(pos, worldPos);\n }else if (pcf > 0.9) {\n realtimeShadow = CCGetSpotLightShadowFactorSoft(pos, worldPos);\n }else {\n realtimeShadow = CCGetSpotLightShadowFactorHard(pos, worldPos);\n }\n shadowPosWithDepthBias = pos;\n return mix(realtimeShadow, 1.0, cc_shadowNFLSInfo.w);\n }\n float CCShadowFactorBase(out vec4 shadowPosWithDepthBias, vec4 shadowPos, vec3 N, vec2 shadowBias)\n {\n vec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N, shadowBias.y, cc_matLightView, cc_shadowProjInfo.xy);\n pos = ApplyShadowDepthBias_Orthographic(pos, shadowBias.x, cc_shadowProjDepthInfo.x, cc_shadowProjDepthInfo.y);\n float realtimeShadow = 1.0;\n #if CC_DIR_SHADOW_PCF_TYPE == 3\n realtimeShadow = CCGetDirLightShadowFactorSoft5X(pos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 2\n realtimeShadow = CCGetDirLightShadowFactorSoft3X(pos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 1\n realtimeShadow = CCGetDirLightShadowFactorSoft(pos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 0\n realtimeShadow = CCGetDirLightShadowFactorHard(pos);\n #endif\n shadowPosWithDepthBias = pos;\n return mix(realtimeShadow, 1.0, cc_shadowNFLSInfo.w);\n }\n #if CC_SUPPORT_CASCADED_SHADOW_MAP\n bool CCGetCSMLevelWithTransition(out highp float ratio, vec3 clipPos) {\n highp float maxRange = 1.0 - cc_csmSplitsInfo.x;\n highp float minRange = cc_csmSplitsInfo.x;\n highp float thresholdInvert = 1.0 / cc_csmSplitsInfo.x;\n ratio = 0.0;\n if (clipPos.x <= minRange) {\n ratio = clipPos.x * thresholdInvert;\n return true;\n }\n if (clipPos.x >= maxRange) {\n ratio = 1.0 - (clipPos.x - maxRange) * thresholdInvert;\n return true;\n }\n if (clipPos.y <= minRange) {\n ratio = clipPos.y * thresholdInvert;\n return true;\n }\n if (clipPos.y >= maxRange) {\n ratio = 1.0 - (clipPos.y - maxRange) * thresholdInvert;\n return true;\n }\n return false;\n }\n bool CCHasCSMLevel(int level, vec3 worldPos) {\n highp float layerThreshold = cc_csmViewDir0[0].w;\n bool hasLevel = false;\n for (int i = 0; i < 4; i++) {\n if (i == level) {\n vec4 shadowPos = cc_matCSMViewProj[i] * vec4(worldPos.xyz, 1.0);\n vec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\n if (clipPos.x >= layerThreshold && clipPos.x <= (1.0 - layerThreshold) &&\n clipPos.y >= layerThreshold && clipPos.y <= (1.0 - layerThreshold) &&\n clipPos.z >= 0.0 && clipPos.z <= 1.0) {\n hasLevel = true;\n }\n }\n }\n return hasLevel;\n }\n void CCGetCSMLevel(out vec4 csmPos, out vec4 shadowProjDepthInfo, out vec4 shadowProjInfo, out vec3 shadowViewDir0, out vec3 shadowViewDir1, out vec3 shadowViewDir2, vec3 worldPos, int level) {\n highp float layerThreshold = cc_csmViewDir0[0].w;\n for (int i = 0; i < 4; i++) {\n vec4 shadowPos = cc_matCSMViewProj[i] * vec4(worldPos.xyz, 1.0);\n vec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\n if (clipPos.x >= layerThreshold && clipPos.x <= (1.0 - layerThreshold) &&\n clipPos.y >= layerThreshold && clipPos.y <= (1.0 - layerThreshold) &&\n clipPos.z >= 0.0 && clipPos.z <= 1.0 && i == level) {\n csmPos = cc_matCSMViewProj[i] * vec4(worldPos.xyz, 1.0);\n csmPos.xy = csmPos.xy * cc_csmAtlas[i].xy + cc_csmAtlas[i].zw;\n shadowProjDepthInfo = cc_csmProjDepthInfo[i];\n shadowProjInfo = cc_csmProjInfo[i];\n shadowViewDir0 = cc_csmViewDir0[i].xyz;\n shadowViewDir1 = cc_csmViewDir1[i].xyz;\n shadowViewDir2 = cc_csmViewDir2[i].xyz;\n }\n }\n }\n int CCGetCSMLevel(out bool isTransitionArea, out highp float transitionRatio, out vec4 csmPos, out vec4 shadowProjDepthInfo, out vec4 shadowProjInfo, out vec3 shadowViewDir0, out vec3 shadowViewDir1, out vec3 shadowViewDir2, vec3 worldPos)\n {\n int level = -1;\n highp float layerThreshold = cc_csmViewDir0[0].w;\n for (int i = 0; i < 4; i++) {\n vec4 shadowPos = cc_matCSMViewProj[i] * vec4(worldPos.xyz, 1.0);\n vec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\n if (clipPos.x >= layerThreshold && clipPos.x <= (1.0 - layerThreshold) &&\n clipPos.y >= layerThreshold && clipPos.y <= (1.0 - layerThreshold) &&\n clipPos.z >= 0.0 && clipPos.z <= 1.0 && level < 0) {\n #if CC_CASCADED_LAYERS_TRANSITION\n isTransitionArea = CCGetCSMLevelWithTransition(transitionRatio, clipPos);\n #endif\n csmPos = cc_matCSMViewProj[i] * vec4(worldPos.xyz, 1.0);\n csmPos.xy = csmPos.xy * cc_csmAtlas[i].xy + cc_csmAtlas[i].zw;\n shadowProjDepthInfo = cc_csmProjDepthInfo[i];\n shadowProjInfo = cc_csmProjInfo[i];\n shadowViewDir0 = cc_csmViewDir0[i].xyz;\n shadowViewDir1 = cc_csmViewDir1[i].xyz;\n shadowViewDir2 = cc_csmViewDir2[i].xyz;\n level = i;\n }\n }\n return level;\n }\n int CCGetCSMLevel(out vec4 csmPos, out vec4 shadowProjDepthInfo, out vec4 shadowProjInfo, out vec3 shadowViewDir0, out vec3 shadowViewDir1, out vec3 shadowViewDir2, vec3 worldPos)\n {\n bool isTransitionArea = false;\n highp float transitionRatio = 0.0;\n return CCGetCSMLevel(isTransitionArea, transitionRatio, csmPos, shadowProjDepthInfo, shadowProjInfo, shadowViewDir0, shadowViewDir1, shadowViewDir2, worldPos);\n }\n float CCCSMFactorBase(out vec4 csmPos, out vec4 csmPosWithBias, vec3 worldPos, vec3 N, vec2 shadowBias)\n {\n bool isTransitionArea = false;\n highp float ratio = 0.0;\n csmPos = vec4(1.0);\n vec4 shadowProjDepthInfo, shadowProjInfo;\n vec3 shadowViewDir0, shadowViewDir1, shadowViewDir2;\n int level = -1;\n #if CC_CASCADED_LAYERS_TRANSITION\n level = CCGetCSMLevel(isTransitionArea, ratio, csmPos, shadowProjDepthInfo, shadowProjInfo, shadowViewDir0, shadowViewDir1, shadowViewDir2, worldPos);\n #else\n level = CCGetCSMLevel(csmPos, shadowProjDepthInfo, shadowProjInfo, shadowViewDir0, shadowViewDir1, shadowViewDir2, worldPos);\n #endif\n if (level < 0) { return 1.0; }\n vec4 pos = ApplyShadowDepthBias_FaceNormal(csmPos, N, shadowBias.y, shadowViewDir0, shadowViewDir1, shadowViewDir2, shadowProjInfo.xy);\n pos = ApplyShadowDepthBias_Orthographic(pos, shadowBias.x, shadowProjDepthInfo.x, shadowProjDepthInfo.y);\n csmPosWithBias = pos;\n float realtimeShadow = 1.0;\n #if CC_DIR_SHADOW_PCF_TYPE == 3\n realtimeShadow = CCGetDirLightShadowFactorSoft5X(pos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 2\n realtimeShadow = CCGetDirLightShadowFactorSoft3X(pos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 1\n realtimeShadow = CCGetDirLightShadowFactorSoft(pos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 0\n realtimeShadow = CCGetDirLightShadowFactorHard(pos);\n #endif\n #if CC_CASCADED_LAYERS_TRANSITION\n vec4 nextCSMPos = vec4(1.0);\n vec4 nextShadowProjDepthInfo, nextShadowProjInfo;\n vec3 nextShadowViewDir0, nextShadowViewDir1, nextShadowViewDir2;\n float nextRealtimeShadow = 1.0;\n CCGetCSMLevel(nextCSMPos, nextShadowProjDepthInfo, nextShadowProjInfo, nextShadowViewDir0, nextShadowViewDir1, nextShadowViewDir2, worldPos, level + 1);\n bool hasNextLevel = CCHasCSMLevel(level + 1, worldPos);\n if (hasNextLevel && isTransitionArea) {\n vec4 nexPos = ApplyShadowDepthBias_FaceNormal(nextCSMPos, N, shadowBias.y, nextShadowViewDir0, nextShadowViewDir1, nextShadowViewDir2, nextShadowProjInfo.xy);\n nexPos = ApplyShadowDepthBias_Orthographic(nexPos, shadowBias.x, nextShadowProjDepthInfo.x, nextShadowProjDepthInfo.y);\n #if CC_DIR_SHADOW_PCF_TYPE == 3\n nextRealtimeShadow = CCGetDirLightShadowFactorSoft5X(nexPos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 2\n nextRealtimeShadow = CCGetDirLightShadowFactorSoft3X(nexPos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 1\n nextRealtimeShadow = CCGetDirLightShadowFactorSoft(nexPos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 0\n nextRealtimeShadow = CCGetDirLightShadowFactorHard(nexPos);\n #endif\n return mix(mix(nextRealtimeShadow, realtimeShadow, ratio), 1.0, cc_shadowNFLSInfo.w);\n }\n return mix(realtimeShadow, 1.0, cc_shadowNFLSInfo.w);\n #else\n return mix(realtimeShadow, 1.0, cc_shadowNFLSInfo.w);\n #endif\n }\n #else\n int CCGetCSMLevel(out vec4 csmPos, out vec4 shadowProjDepthInfo, out vec4 shadowProjInfo, out vec3 shadowViewDir0, out vec3 shadowViewDir1, out vec3 shadowViewDir2, vec3 worldPos) {\n return -1;\n }\n float CCCSMFactorBase(out vec4 csmPos, out vec4 csmPosWithBias, vec3 worldPos, vec3 N, vec2 shadowBias) {\n csmPos = cc_matLightViewProj * vec4(worldPos, 1.0);\n return CCShadowFactorBase(csmPosWithBias, csmPos, N, shadowBias);\n }\n #endif\n float CCShadowFactorBase(vec4 shadowPos, vec3 N, vec2 shadowBias) {\n vec4 shadowPosWithDepthBias;\n return CCShadowFactorBase(shadowPosWithDepthBias, shadowPos, N, shadowBias);\n }\n float CCCSMFactorBase(vec3 worldPos, vec3 N, vec2 shadowBias) {\n vec4 csmPos, csmPosWithBias;\n return CCCSMFactorBase(csmPos, csmPosWithBias, worldPos, N, shadowBias);\n }\n float CCSpotShadowFactorBase(vec4 shadowPos, vec3 worldPos, vec2 shadowBias)\n {\n vec4 shadowPosWithDepthBias;\n return CCSpotShadowFactorBase(shadowPosWithDepthBias, shadowPos, worldPos, shadowBias);\n }\n#endif\n#if CC_USE_FOG != 4\n float LinearFog(vec4 pos, vec3 cameraPos, float fogStart, float fogEnd) {\n vec4 wPos = pos;\n float cam_dis = distance(cameraPos, wPos.xyz);\n return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n }\n float ExpFog(vec4 pos, vec3 cameraPos, float fogStart, float fogDensity, float fogAtten) {\n vec4 wPos = pos;\n float cam_dis = max(distance(cameraPos, wPos.xyz) - fogStart, 0.0) / fogAtten * 4.;\n float f = exp(-cam_dis * fogDensity);\n return f;\n }\n float ExpSquaredFog(vec4 pos, vec3 cameraPos, float fogStart, float fogDensity, float fogAtten) {\n vec4 wPos = pos;\n float cam_dis = max(distance(cameraPos, wPos.xyz) - fogStart, 0.0) / fogAtten * 4.;\n float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\n return f;\n }\n float LayeredFog(vec4 pos, vec3 cameraPos, float fogTop, float fogRange, float fogAtten) {\n vec4 wPos = pos;\n vec3 camWorldProj = cameraPos.xyz;\n camWorldProj.y = 0.;\n vec3 worldPosProj = wPos.xyz;\n worldPosProj.y = 0.;\n float fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\n float fDeltaY, fDensityIntegral;\n if (cameraPos.y > fogTop) {\n if (wPos.y < fogTop) {\n fDeltaY = (fogTop - wPos.y) / fogRange * 2.0;\n fDensityIntegral = fDeltaY * fDeltaY * 0.5;\n }\n else {\n fDeltaY = 0.;\n fDensityIntegral = 0.;\n }\n }\n else {\n if (wPos.y < fogTop) {\n float fDeltaA = (fogTop - cameraPos.y) / fogRange * 2.;\n float fDeltaB = (fogTop - wPos.y) / fogRange * 2.;\n fDeltaY = abs(fDeltaA - fDeltaB);\n fDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n }\n else {\n fDeltaY = abs(fogTop - cameraPos.y) / fogRange * 2.;\n fDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n }\n }\n float fDensity;\n if (fDeltaY != 0.) {\n fDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n }\n else {\n fDensity = 0.;\n }\n float f = exp(-fDensity);\n return f;\n }\n#endif\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\n\tfactor = LinearFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.y);\n#elif CC_USE_FOG == 1\n\tfactor = ExpFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z);\n#elif CC_USE_FOG == 2\n\tfactor = ExpSquaredFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z);\n#elif CC_USE_FOG == 3\n\tfactor = LayeredFog(pos, cc_cameraPos.xyz, cc_fogAdd.x, cc_fogAdd.y, cc_fogAdd.z);\n#else\n\tfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\n\tcolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\n#if CC_USE_LIGHT_PROBE\n #if CC_USE_LIGHT_PROBE\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n layout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n highp vec4 cc_localShadowBias;\n highp vec4 cc_reflectionProbeData1;\n highp vec4 cc_reflectionProbeData2;\n highp vec4 cc_reflectionProbeBlendData1;\n highp vec4 cc_reflectionProbeBlendData2;\n };\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n uniform sampler2D cc_lightingMap;\n void SampleAndDecodeLightMapColor(out vec3 lightmapColor, out float dirShadow, out float ao, sampler2D lightingMap, vec2 luv, float lum, vec3 worldNormal)\n {\n #if CC_LIGHT_MAP_VERSION > 2\n #elif CC_LIGHT_MAP_VERSION > 1\n \tvec4 dataLow = texture(lightingMap, luv);\n \tvec4 dataHigh = texture(lightingMap, luv + vec2(0.5, 0.0));\n \tlightmapColor.xyz = dataLow.xyz + dataHigh.xyz * 0.00392156862745098;\n lightmapColor.rgb *= lum;\n \tdirShadow = dataLow.a;\n \tao = dataHigh.a;\n #else\n vec4 lightmap = texture(lightingMap, luv);\n lightmapColor = lightmap.rgb * lum;\n \tdirShadow = lightmap.a;\n \tao = 1.0;\n #endif\n }\n void GetLightMapColor(out vec3 lightmapColor, out float dirShadow, out float ao, sampler2D lightingMap, vec2 luv, float lum, vec3 worldNormal)\n {\n \tvec4 lightmap;\n \tvec2 occlusion;\n \tSampleAndDecodeLightMapColor(lightmapColor, dirShadow, ao, lightingMap, luv, lum, worldNormal);\n #if CC_USE_HDR\n lightmapColor.rgb *= cc_exposure.w * cc_exposure.x;\n #endif\n }\n#endif\nlayout(std140) uniform Constants {\n vec4 tilingOffset;\n vec4 baseColor;\n vec4 colorScaleAndCutoff;\n vec4 shadeColor1;\n vec4 shadeColor2;\n vec4 specular;\n vec4 shadeParams;\n vec4 miscParams;\n vec4 emissive;\n vec4 emissiveScaleAndStrenth;\n};\n#if USE_BASE_COLOR_MAP\n uniform sampler2D baseColorMap;\n#endif\n#if USE_NORMAL_MAP\n uniform sampler2D normalMap;\n#endif\n#if USE_1ST_SHADE_MAP\n uniform sampler2D shadeMap1;\n#endif\n#if USE_2ND_SHADE_MAP\n uniform sampler2D shadeMap2;\n#endif\n#if USE_SPECULAR_MAP\n uniform sampler2D specularMap;\n#endif\n#if USE_EMISSIVE_MAP\n uniform sampler2D emissiveMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\n#define CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TOONSHADE\nvoid SurfacesFragmentModifyBaseColorAndToonShade(out vec4 baseColorAndTransparency, out vec3 shade1, out vec3 shade2)\n{\n shade2 = shadeColor2.rgb * colorScaleAndCutoff.rgb;\n #if USE_2ND_SHADE_MAP\n shade2 *= SRGBToLinear(texture(shadeMap2, FSInput_texcoord).rgb);\n #endif\n shade1 = shadeColor1.rgb * colorScaleAndCutoff.rgb;\n #if USE_1ST_SHADE_MAP\n shade1 *= SRGBToLinear(texture(shadeMap1, FSInput_texcoord).rgb);\n #if SHADE_MAP_1_AS_SHADE_MAP_2\n shade2 *= shade1.rgb;\n #endif\n #endif\n vec4 color = baseColor;\n #if USE_BASE_COLOR_MAP\n vec4 texColor = texture(baseColorMap, FSInput_texcoord);\n texColor.rgb = SRGBToLinear(texColor.rgb);\n color *= texColor;\n #if BASE_COLOR_MAP_AS_SHADE_MAP_1\n shade1 *= texColor.rgb;\n #endif\n #if BASE_COLOR_MAP_AS_SHADE_MAP_2\n shade2 *= texColor.rgb;\n #endif\n #endif\n baseColorAndTransparency = color;\n baseColorAndTransparency.rgb *= colorScaleAndCutoff.xyz;\n #if USE_ALPHA_TEST\n if (baseColorAndTransparency.ALPHA_TEST_CHANNEL < colorScaleAndCutoff.w) discard;\n #endif\n}\n#define CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY\n#define CC_SURFACES_FRAGMENT_MODIFY_WORLD_NORMAL\nvec3 SurfacesFragmentModifyWorldNormal()\n{\n vec3 normal = FSInput_worldNormal;\n #if USE_NORMAL_MAP\n vec3 nmmp = texture(normalMap, FSInput_texcoord).xyz - vec3(0.5);\n normal = CalculateNormalFromTangentSpace(nmmp, emissiveScaleAndStrenth.w, normalize(normal.xyz), normalize(FSInput_worldTangent), FSInput_mirrorNormal);\n #endif\n return normalize(normal);\n}\n#define CC_SURFACES_FRAGMENT_MODIFY_EMISSIVE\nvec3 SurfacesFragmentModifyEmissive()\n{\n vec3 emissive = emissive.rgb * emissiveScaleAndStrenth.xyz;\n #if USE_EMISSIVE_MAP\n emissive *= SRGBToLinear(texture(emissiveMap, FSInput_texcoord).rgb);\n #endif\n return emissive;\n}\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_STEP_AND_FEATHER\nvec4 SurfacesFragmentModifyToonStepAndFeather()\n{\n return shadeParams;\n}\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_SHADOW_COVER\nfloat SurfacesFragmentModifyToonShadowCover()\n{\n return miscParams.x;\n}\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_SPECULAR\nvec4 SurfacesFragmentModifyToonSpecular()\n{\n vec4 specularParam = specular;\n #if USE_SPECULAR_MAP\n specularParam.rgb *= SRGBToLinear(texture(specularMap, FSInput_texcoord).rgb);\n #endif\n return specularParam;\n}\nstruct LightingIntermediateData\n{\n vec3 N, H, L, V;\n float distToLight, distToLightSqr;\n float distToCamera, distToCameraSqr;\n float angleAttenuation, distAttenuation;\n float NoL, NoV, NoH, VoH;\n float NoLSat, NoVSat, NoHSat;\n float NoVAbsSat, VoHAbsSat;\n #if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\n vec3 worldPosition, worldPosition_fract_part;\n #else\n vec3 worldPosition;\n #endif\n vec3 T, B;\n float specularParam;\n float ior, layerOpacity;\n#if CC_SURFACES_LIGHTING_ANISOTROPIC\n float anisotropyShape;\n#endif\n#if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n vec4 shadowPosAndDepth;\n vec4 transmitDiffuseParams;\n#endif\n#if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR || CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n vec4 transmitScatteringParams;\n vec3 outScatteringColor, inScatteringColor;\n#endif\n#if CC_SURFACES_LIGHTING_TT\n vec3 baseColorTT;\n float ttIntensity, ttScatterCoef;\n#endif\n};\nvoid CCSurfacesLightingGetIntermediateData_PerPixel(inout LightingIntermediateData data, vec3 worldNormal, vec3 worldPos, vec3 worldTangent, vec3 worldBinormal\n#if CC_SURFACES_LIGHTING_ANISOTROPIC\n , float anisotropyShape\n#endif\n)\n{\n data.N = worldNormal;\n data.V = cc_cameraPos.xyz - worldPos;\n data.distToCameraSqr = dot(data.V, data.V);\n data.distToCamera = sqrt(data.distToCameraSqr);\n data.V /= data.distToCamera;\n data.angleAttenuation = data.distAttenuation = 1.0;\n data.NoV = dot(data.N, data.V);\n data.NoVSat = max(data.NoV, 0.0);\n data.NoVAbsSat = max(abs(data.NoV), 0.0);\n #if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\n packHighpData(data.worldPosition, data.worldPosition_fract_part, worldPos);\n #else\n data.worldPosition = worldPos;\n #endif\n data.T = worldTangent;\n data.B = worldBinormal;\n#if CC_SURFACES_LIGHTING_ANISOTROPIC\n data.anisotropyShape = anisotropyShape;\n#endif\n#if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR || CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n data.outScatteringColor = vec3(1.0);\n data.inScatteringColor = vec3(0.0);\n data.transmitScatteringParams = vec4(0.0);\n#endif\n#if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n data.shadowPosAndDepth = vec4(0.0, 0.0, SURFACES_MAX_TRANSMIT_DEPTH_VALUE, SURFACES_MAX_TRANSMIT_DEPTH_VALUE);\n#endif\n#if CC_SURFACES_LIGHTING_TT\n data.baseColorTT = vec3(0.0);\n data.ttIntensity = data.ttScatterCoef = 0.0;\n#endif\n}\nvoid CCSurfacesLightingGetIntermediateData_PerLight(inout LightingIntermediateData data, vec3 lightDirWithDist)\n{\n data.L = lightDirWithDist;\n data.distToLightSqr = dot(data.L, data.L);\n data.distToLight = sqrt(data.distToLightSqr);\n data.L /= data.distToLight;\n data.H = normalize(data.L + data.V);\n data.NoL = dot(data.N, data.L);\n data.NoH = dot(data.N, data.H);\n data.VoH = dot(data.V, data.H);\n data.NoLSat = max(data.NoL, 0.0);\n data.NoHSat = max(data.NoH, 0.0);\n data.VoHAbsSat = max(abs(data.VoH), 0.0);\n}\nstruct LightingResult\n{\n vec3 diffuseColorWithLighting, specularColorWithLighting;\n vec3 directDiffuse, directSpecular, directGF;\n vec3 environmentDiffuse, environmentSpecular, environmentGF;\n float shadow, ao;\n vec3 lightmapColor;\n vec3 emissive;\n vec3 fresnel;\n#if CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n vec3 directDiffuseSubLayers, directSpecularSubLayers;\n vec3 environmentDiffuseSubLayers, environmentSpecularSubLayers;\n#endif\n#if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n vec3 directTransmitSpecular, environmentTransmitSpecular;\n#endif\n#if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n vec3 directTransmitDiffuse, environmentTransmitDiffuse;\n#endif\n#if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n vec3 direct2ndSpecular, environment2ndSpecular;\n vec3 specularColorWithLighting2ndSpecular;\n vec3 directGF2ndSpecular, environmentGF2ndSpecular;\n vec3 directSubLayerF, environmentSubLayerF;\n#endif\n#if CC_SURFACES_LIGHTING_TT\n vec3 directTT;\n vec3 diffuseColorWithLightingTT;\n#endif\n};\nstruct LightingMiscData\n{\n float lightType;\n vec3 lightPos, lightDir;\n vec4 lightColorAndIntensity;\n vec4 lightSizeRangeAngle;\n};\n#define DiffuseCoefficient_EnergyConservation INV_PI\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\n float factor = distSqr * invSqrAttRadius;\n float smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\n return smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\n float attenuation = 1.0 / max(distSqr, 0.01*0.01);\n attenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\n return attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\n float cd = dot(litDir, L);\n float attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\n return (attenuation * attenuation);\n}\nfloat GetOutOfRange (vec3 worldPos, vec3 lightPos, vec3 lookAt, vec3 right, vec3 BoundingHalfSizeVS) {\n vec3 v = vec3(0.0);\n vec3 up = cross(right, lookAt);\n worldPos -= lightPos;\n v.x = dot(worldPos, right);\n v.y = dot(worldPos, up);\n v.z = dot(worldPos, lookAt);\n vec3 result = step(abs(v), BoundingHalfSizeVS);\n return result.x * result.y * result.z;\n}\nfloat CalculateDistanceAttenuation(float distToLightSqr, float lightRadius, float lightRange, float lightType)\n{\n float attRadiusSqrInv = 1.0 / max(lightRange, 0.01);\n attRadiusSqrInv *= attRadiusSqrInv;\n float litRadiusSqr = lightRadius * lightRadius;\n float edgeAttenuation = (IS_POINT_LIGHT(lightType) || IS_RANGED_DIRECTIONAL_LIGHT(lightType)) ? 1.0 : litRadiusSqr / max(litRadiusSqr, distToLightSqr);\n return GetDistAtt(distToLightSqr, attRadiusSqrInv) * edgeAttenuation;\n}\nfloat CalculateAngleAttenuation(vec3 spotLightDir, vec3 L, float cosAngleOuter)\n{\n float cosInner = max(dot(spotLightDir, L), 0.01);\n float litAngleScale = 1.0 / max(0.001, cosInner - cosAngleOuter);\n float litAngleOffset = -cosAngleOuter * litAngleScale;\n return GetAngleAtt(L, spotLightDir, litAngleScale, litAngleOffset);\n}\nbool CCSurfacesLightingEnableShadow(in float NoL)\n{\n return NoL > 0.0;\n}\nfloat CCSurfacesLightingCalculateDistanceAttenuation(in LightingIntermediateData lightingData, in vec4 lightSizeRangeAngle, in float lightType)\n{\n return CalculateDistanceAttenuation(lightingData.distToLightSqr, lightSizeRangeAngle.x, lightSizeRangeAngle.y, lightType);\n}\nfloat CCSurfacesLightingCalculateAngleAttenuation(in LightingIntermediateData lightingData, in vec4 lightSizeRangeAngle, in vec3 spotLightDir)\n{\n return CalculateAngleAttenuation(spotLightDir, lightingData.L, lightSizeRangeAngle.z);\n}\nvoid CCSurfacesLightingCalculateDirect(out vec3 lightingDiffuse, out vec3 lightingSpecular, in LightingIntermediateData lightingData, in vec4 lightSourceColorAndIntensity)\n{\n vec3 irradiance = lightSourceColorAndIntensity.rgb * lightSourceColorAndIntensity.w;\n lightingDiffuse = irradiance;\n#if CC_FORWARD_ADD\n float NL = 0.5 * lightingData.NoL + 0.5;\n lightingDiffuse *= NL;\n#endif\n float NH = 0.5 * lightingData.NoH + 0.5;\n float specularWeight = 1.0 - pow(lightingData.specularParam, 5.0);\n float specularMask = step(specularWeight + EPSILON_LOWP, NH);\n lightingSpecular = irradiance * specularMask;\n}\nvoid CCSurfacesLightingCalculateEnvironment(out vec3 lightingDiffuse, out vec3 lightingSpecular, in LightingIntermediateData lightingData, float lightIntensity)\n{\n lightingDiffuse = vec3(0.0);\n lightingSpecular = vec3(0.0);\n}\n#if CC_SURFACES_LIGHTING_USE_FRESNEL\nvec3 CCSurfaceLightingCalculateExtraFresnel(in LightingIntermediateData lightingData)\n{\n return vec3(1.0);\n}\n#endif\nvoid CCSurfaceLightingCalculateDirectFresnel(out vec3 fresnel, in LightingIntermediateData lightingData, vec3 specularColor, in vec3 environmentGF)\n{\n fresnel = vec3(1.0);\n}\nvoid CCSurfaceLightingCalculateEnvironmentFresnel(out vec3 integratedGF, out vec3 integratedF, in LightingIntermediateData lightingData, vec3 specularColor)\n{\n integratedF = integratedGF = vec3(1.0);\n}\nstruct SurfacesMaterialData\n{\n #if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\n vec3 worldPos, worldPos_fract_part;\n #else\n vec3 worldPos;\n #endif\n vec4 baseColor;\n vec4 specular;\n vec3 worldNormal;\n vec3 emissive;\n vec3 shade1;\n vec3 shade2;\n float baseStep;\n float baseFeather;\n float shadeStep;\n float shadeFeather;\n float shadowCover;\n};\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TRANSPARENCY\nvec4 SurfacesFragmentModifyBaseColorAndTransparency()\n{\n return FSInput_vertexColor;\n}\n#endif\n#ifndef CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_WORLD_NORMAL\nvec3 SurfacesFragmentModifyWorldNormal()\n{\n return normalize(FSInput_worldNormal);\n}\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_WORLD_TANGENT_AND_BINORMAL\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_IOR\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_ANISOTROPY_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_EMISSIVE\nvec3 SurfacesFragmentModifyEmissive()\n{\n return vec3(0.0, 0.0, 0.0);\n}\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_PBRPARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_SCATTERING_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_IN_SCATTERING_COLOR\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_OUT_SCATTERING_COLOR\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_DIFFUSE_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRT_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRT_COLOR\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TT_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TT_COLOR\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_SSS_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_DUAL_LOBE_SPECULAR_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_CLEAR_COAT_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_CLEAR_COAT_COLOR\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_CLEAR_COAT_WORLD_NORMAL\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_SHEEN_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_SHEEN_COLOR\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_SHARED_DATA\nvoid SurfacesFragmentModifySharedData(inout SurfacesMaterialData surfaceData)\n{\n}\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TOONSHADE\nvoid SurfacesFragmentModifyBaseColorAndToonShade(out vec4 baseColorAndTransparency, out vec3 shade1, out vec3 shade2, in vec3 baseColor)\n{\n baseColorAndTransparency = FSInput_vertexColor;\n shade1 = shade2 = vec3(0.0);\n}\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TOON_STEP_AND_FEATHER\nvec4 SurfacesFragmentModifyToonStepAndFeather()\n{\n return vec3(0.8, 0.001, 0.5, 0.001);\n}\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TOON_SHADOW_COVER\nfloat SurfacesFragmentModifyToonShadowCover()\n{\n return 0.5;\n}\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TOON_SPECULAR\nvec4 SurfacesFragmentModifyToonSpecular()\n{\n return vec4(1.0, 1.0, 1.0, 0.3);\n}\n#endif\nvoid CCSurfacesFragmentGetMaterialData(inout SurfacesMaterialData surfaceData)\n{\n #if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\n packHighpData(surfaceData.worldPos, surfaceData.worldPos_fract_part, FSInput_worldPos);\n #else\n surfaceData.worldPos = FSInput_worldPos;\n #endif\n surfaceData.worldNormal = SurfacesFragmentModifyWorldNormal();\n surfaceData.emissive = SurfacesFragmentModifyEmissive();\n SurfacesFragmentModifyBaseColorAndToonShade(surfaceData.baseColor, surfaceData.shade1, surfaceData.shade2);\n surfaceData.specular = SurfacesFragmentModifyToonSpecular();\n surfaceData.shadowCover = SurfacesFragmentModifyToonShadowCover();\n vec4 shaderParams = SurfacesFragmentModifyToonStepAndFeather();\n surfaceData.baseStep = shadeParams.x;\n surfaceData.baseFeather = shadeParams.y;\n surfaceData.shadeStep = shadeParams.z;\n surfaceData.shadeFeather = shadeParams.w;\n SurfacesFragmentModifySharedData(surfaceData);\n#if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_NORMAL_MAP)\n surfaceData.worldNormal = normalize(FSInput_worldNormal);\n#endif\n#if CC_USE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_LIGHTING_ENABLE_WITH_ALBEDO) {\n float brightBase = dot(GRAY_VECTOR, surfaceData.baseColor.rgb);\n float brightShade1 = dot(GRAY_VECTOR, surfaceData.shade1.rgb);\n float brightShade2 = dot(GRAY_VECTOR, surfaceData.shade2.rgb);\n surfaceData.baseColor.rgb = vec3(1.0);\n surfaceData.shade1.rgb = vec3(brightShade1 / brightBase);\n surfaceData.shade2.rgb = vec3(brightShade2 / brightBase);\n surfaceData.specular.rgb = vec3(1.0);\n }\n#endif\n}\nvec3 CCSurfacesGetDiffuseColor(in SurfacesMaterialData surfaceData)\n{\n return surfaceData.shade1;\n}\nvec3 CCSurfacesGetSpecularColor(in SurfacesMaterialData surfaceData)\n{\n return surfaceData.specular.xyz;\n}\nvoid CCSurfacesLightingInitializeColorWithLighting(inout vec3 diffuseColorWithLighting, inout vec3 specularColorWithLighting, in SurfacesMaterialData surfaceData, in LightingIntermediateData lightingData)\n{\n diffuseColorWithLighting = vec3(0.0);\n specularColorWithLighting = surfaceData.specular.xyz * surfaceData.baseStep;\n}\nvoid CCSurfacesLightingCalculateColorWithLighting(inout vec3 diffuseColorWithLighting, inout vec3 specularColorWithLighting, in SurfacesMaterialData surfaceData, in LightingIntermediateData lightingData)\n{\n float NL = 0.5 * lightingData.NoL + 0.5;\n vec3 diffuse = mix(surfaceData.shade1, surfaceData.shade2,\n clamp(1.0 + (surfaceData.shadeStep - surfaceData.shadeFeather - NL) / surfaceData.shadeFeather, 0.0, 1.0));\n diffuse = mix(surfaceData.baseColor.rgb, diffuse,\n clamp(1.0 + (surfaceData.baseStep - surfaceData.baseFeather - NL) / surfaceData.baseFeather, 0.0, 1.0));\n diffuseColorWithLighting = diffuse * surfaceData.baseStep;\n}\nvoid CCSurfacesInitializeLightingIntermediateData(inout LightingIntermediateData lightingData, in SurfacesMaterialData surfaceData)\n{\n vec3 worldPos;\n #if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\n worldPos = unpackHighpData(surfaceData.worldPos, surfaceData.worldPos_fract_part);\n #else\n worldPos = surfaceData.worldPos;\n #endif\n CCSurfacesLightingGetIntermediateData_PerPixel(lightingData, surfaceData.worldNormal, worldPos, vec3(0.0), vec3(0.0));\n lightingData.specularParam = surfaceData.specular.a;\n lightingData.ior = 1.0;\n}\nvoid CCSurfacesLightingCalculateIntermediateData_PerLight(inout LightingIntermediateData lightingData, in SurfacesMaterialData surfaceData, vec3 lightDirWithDist)\n{\n CCSurfacesLightingGetIntermediateData_PerLight(lightingData, lightDirWithDist);\n}\nvoid CCSurfacesInitializeLightingResult(inout LightingResult lightingResult, in SurfacesMaterialData surfaceData)\n{\n lightingResult.emissive = surfaceData.emissive;\n}\nvoid CCSurfacesInitializeLightingResult(inout LightingResult lightingResult)\n{\n lightingResult.directDiffuse = lightingResult.directSpecular = vec3(0.0);\n}\nvoid CCSurfacesAccumulateLightingResult(inout LightingResult lightingResultAccumulated, in LightingResult lightingResult)\n{\n lightingResultAccumulated.directDiffuse += lightingResult.directDiffuse * lightingResult.shadow;\n lightingResultAccumulated.directSpecular += lightingResult.directSpecular * lightingResult.shadow;\n}\n#if CC_PIPELINE_TYPE == 1\n vec4 CCSurfacesDeferredOutputBaseColor(in SurfacesMaterialData surfaceData)\n {\n return surfaceData.baseColor;\n }\n vec4 CCSurfacesDeferredOutputNormalMR(in SurfacesMaterialData surfaceData)\n {\n return vec4(float32x3_to_oct(surfaceData.worldNormal), 0.5, 0.0);\n }\n vec4 CCSurfacesDeferredOutputEmissiveAO(in SurfacesMaterialData surfaceData)\n {\n return vec4(surfaceData.emissive, 1.0);\n }\n#endif\nvec4 CCSurfacesShading(in SurfacesMaterialData surfaceData, in LightingResult lightingResult)\n{\n vec4 color = vec4(0.0, 0.0, 0.0, surfaceData.baseColor.a);\n#if CC_FORWARD_ADD\n color.xyz += lightingResult.directDiffuse * lightingResult.diffuseColorWithLighting;\n color.xyz += lightingResult.directSpecular * lightingResult.specularColorWithLighting;\n#else\n float lightmapCoef = 0.0;\n#if CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n color.xyz += (\n mix(lightingResult.directDiffuse, lightingResult.lightmapColor, lightmapCoef) * lightingResult.diffuseColorWithLighting\n + lightingResult.directSpecular * lightingResult.specularColorWithLighting)\n * lightingResult.shadow\n ;\n#else\n LightingIntermediateData lightingData;\n lightingData.NoL = -1.0;\n vec3 backLightingDiffuse, backLightingSpecular;\n CCSurfacesLightingInitializeColorWithLighting(backLightingDiffuse, backLightingSpecular, surfaceData, lightingData);\n CCSurfacesLightingCalculateColorWithLighting(backLightingDiffuse, backLightingSpecular, surfaceData, lightingData);\n color.xyz +=\n mix(lightingResult.directDiffuse, lightingResult.lightmapColor, lightmapCoef) * mix(backLightingDiffuse, lightingResult.diffuseColorWithLighting, lightingResult.shadow)\n + lightingResult.directSpecular * lightingResult.specularColorWithLighting * lightingResult.shadow\n ;\n#endif\n color.xyz += lightingResult.emissive;\n#endif\n return color;\n}\n#if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_SINGLE\nbool CCSurfacesDebugViewSurfaceData(inout vec4 color, in SurfacesMaterialData surfaceData)\n{\n bool enableMaterialAlpha = true;\n float scalar;\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(surfaceData.worldNormal * 0.5 + vec3(0.5), 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(0.0, 0.0, 0.0, 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(0.0, 0.0, 0.0, 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSPARENCY)) && (cc_surfaceTransform.y != 3.0)))\n {\n scalar = surfaceData.baseColor.a;\n color = vec4(scalar, scalar, scalar, 1.0);\n enableMaterialAlpha = false;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_BASE_COLOR)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(LinearToSRGB(surfaceData.baseColor.rgb), 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(LinearToSRGB(CCSurfacesGetDiffuseColor(surfaceData)), 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(LinearToSRGB(CCSurfacesGetSpecularColor(surfaceData)), 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY)) && (cc_surfaceTransform.y != 3.0)))\n {\n scalar = surfaceData.specular.a;\n color = vec4(scalar, scalar, scalar, 1.0);\n }\n return enableMaterialAlpha;\n}\n#endif\n#if (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\n #if CC_FORWARD_ADD\n void CCSurfacesLighting(inout LightingResult lightingResultAccumulated, in SurfacesMaterialData surfaceData, in vec2 shadowBias)\n {\n vec3 worldPos;\n #if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\n worldPos = unpackHighpData(surfaceData.worldPos, surfaceData.worldPos_fract_part);\n #else\n worldPos = surfaceData.worldPos;\n #endif\n CCSurfacesInitializeLightingResult(lightingResultAccumulated);\n LightingIntermediateData lightingData;\n CCSurfacesInitializeLightingIntermediateData(lightingData, surfaceData);\n LightingResult lightingResult;\n CCSurfacesLightingInitializeColorWithLighting(lightingResult.diffuseColorWithLighting, lightingResult.specularColorWithLighting, surfaceData, lightingData);\n lightingResultAccumulated.diffuseColorWithLighting = lightingResult.diffuseColorWithLighting;\n lightingResultAccumulated.specularColorWithLighting = lightingResult.specularColorWithLighting;\n #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n vec3 diff;\n SurfacesMaterialData surfaceData2ndSpecular;\n CCSurfacesGetSurfacesMaterialData2ndSpecular(surfaceData2ndSpecular, surfaceData);\n CCSurfacesLightingInitializeColorWithLighting(diff, lightingResult.specularColorWithLighting2ndSpecular, surfaceData2ndSpecular, lightingData);\n lightingResultAccumulated.specularColorWithLighting2ndSpecular = lightingResult.specularColorWithLighting2ndSpecular;\n #endif\n int numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\n for (int i = 0; i < LIGHTS_PER_PASS; i++) {\n if (i >= numLights) break;\n vec3 lightDirWithLength = IS_RANGED_DIRECTIONAL_LIGHT(cc_lightPos[i].w) ? -normalize(cc_lightDir[i].xyz) : cc_lightPos[i].xyz - worldPos;\n CCSurfacesLightingCalculateIntermediateData_PerLight(lightingData, surfaceData, lightDirWithLength);\n CCSurfacesLightingCalculateColorWithLighting(lightingResult.diffuseColorWithLighting, lightingResult.specularColorWithLighting, surfaceData, lightingData);\n vec3 diffuseLighting, specularLighting;\n CCSurfacesLightingCalculateDirect(diffuseLighting, specularLighting, lightingData, cc_lightColor[i]);\n #if CC_SURFACES_LIGHTING_USE_FRESNEL\n vec3 fresnel = CCSurfaceLightingCalculateExtraFresnel(lightingData);\n #else\n vec3 fresnel = vec3(1.0);\n #endif\n lightingResult.fresnel = fresnel;\n float shadow = 1.0;\n #if CC_RECEIVE_SHADOW && CC_SHADOW_TYPE == 2\n if (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) {\n vec4 shadowPos = vec4(0.0), shadowPosWithDepthBias = vec4(0.0);\n if (CCSurfacesLightingEnableShadow(lightingData.NoL)) {\n shadowPos = cc_matLightViewProj * vec4(worldPos, 1.0);\n shadow = CCSpotShadowFactorBase(shadowPosWithDepthBias, shadowPos, worldPos, shadowBias);\n }\n #if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE && CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n vec3 shadowNDCPos;\n bool isExceedShadowMap = !GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias);\n lightingData.shadowPosAndDepth.xy = shadowNDCPos.xy;\n lightingData.shadowPosAndDepth.z = isExceedShadowMap ? 0.0 : GetViewSpaceDepthFromNDCDepth_Perspective(shadowNDCPos.z, shadowPosWithDepthBias.w, cc_shadowInvProjDepthInfo.x, cc_shadowInvProjDepthInfo.y);\n lightingData.shadowPosAndDepth.w = isExceedShadowMap ? lightingData.shadowPosAndDepth.w : GetViewSpaceDepthFromNDCDepth_Perspective(SampleShadowMapSoft(shadowNDCPos, cc_spotShadowMap, cc_shadowWHPBInfo.xy), shadowPosWithDepthBias.w, cc_shadowInvProjDepthInfo.x, cc_shadowInvProjDepthInfo.y);\n #endif\n }\n #endif\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_SHADOW)\n shadow = 1.0;\n #endif\n lightingResult.shadow = shadow;\n float distAtt = 1.0;\n if(IS_RANGED_DIRECTIONAL_LIGHT(cc_lightPos[i].w)) {\n distAtt = GetOutOfRange(worldPos, cc_lightPos[i].xyz, cc_lightDir[i].xyz, cc_lightSizeRangeAngle[i].xyz, cc_lightBoundingSizeVS[i].xyz);\n } else {\n distAtt = CCSurfacesLightingCalculateDistanceAttenuation(lightingData, cc_lightSizeRangeAngle[i], cc_lightPos[i].w);\n }\n float angleAtt = 1.0;\n if (IS_SPOT_LIGHT(cc_lightPos[i].w)) {\n angleAtt = CCSurfacesLightingCalculateAngleAttenuation(lightingData, cc_lightSizeRangeAngle[i], -cc_lightDir[i].xyz);\n }\n float multiplier = distAtt * angleAtt;\n lightingData.angleAttenuation = angleAtt;\n lightingData.distAttenuation = distAtt;\n lightingResult.directDiffuse = diffuseLighting * multiplier;\n lightingResult.directSpecular = specularLighting * multiplier;\n CCSurfaceLightingCalculateDirectFresnel(lightingResult.directGF, lightingData, lightingResult.specularColorWithLighting, vec3(1.0));\n vec4 attenuatedLightColorAndIntensity = vec4(cc_lightColor[i].xyz, cc_lightColor[i].w * multiplier);\n #if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n vec3 transmitSpecularLighting;\n CCSurfacesLightingCalculateDirectTransmitSpecular(transmitSpecularLighting, lightingData, attenuatedLightColorAndIntensity);\n lightingResult.directTransmitSpecular = transmitSpecularLighting * multiplier * (1.0 - fresnel);\n #endif\n #if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n LightingIntermediateData lightingDataTD;\n CCSurfacesGetLightingIntermediateDataTransmitDiffuse(lightingDataTD, lightingData, surfaceData);\n CCSurfacesLightingCalculateIntermediateData_PerLight(lightingDataTD, surfaceData, lightDirWithLength);\n CCSurfacesLightingCalculateDirectTransmitDiffuse(lightingResult.directTransmitDiffuse, lightingDataTD, attenuatedLightColorAndIntensity, lightingResult.shadow);\n #endif\n #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n LightingIntermediateData lightingData2ndSpecular;\n CCSurfacesInitializeLightingIntermediateData(lightingData2ndSpecular, surfaceData2ndSpecular);\n CCSurfacesLightingCalculateIntermediateData_PerLight(lightingData2ndSpecular, surfaceData, lightDirWithLength);\n #if !CC_SURFACES_LIGHTING_SHEEN\n CCSurfacesLightingCalculateDirect2ndSpecular(lightingResult.direct2ndSpecular, lightingData2ndSpecular, attenuatedLightColorAndIntensity, surfaceData2ndSpecular.intensity2ndSpecular, lightingResult.directSpecular);\n CCSurfaceLightingCalculateDirectFresnel(lightingResult.directGF2ndSpecular, lightingData2ndSpecular, lightingResult.specularColorWithLighting2ndSpecular, vec3(1.0));\n #else\n CCSurfacesLightingCalculateDirectSheen(lightingResult.direct2ndSpecular, lightingResult.directGF2ndSpecular, lightingData2ndSpecular, attenuatedLightColorAndIntensity, surfaceData2ndSpecular.intensity2ndSpecular);\n #endif\n lightingResult.direct2ndSpecular *= multiplier;\n #endif\n #if CC_SURFACES_LIGHTING_TT\n CCSurfacesLightingCalculateDirectTT(lightingResult, lightingData, attenuatedLightColorAndIntensity);\n #endif\n #if CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n lightingResult.specularColorWithLighting2ndSpecular *= surfaceData.color2ndSpecular;\n CCSurfacesLightingCalculateDirectMultiLayerBlending(lightingResult, lightingData2ndSpecular);\n #endif\n #ifdef CC_SURFACES_LIGHTING_MODIFY_FINAL_RESULT\n LightingMiscData miscData;\n miscData.lightType = cc_lightPos[i].w;\n miscData.lightPos = cc_lightPos[i].xyz;\n miscData.lightDir = cc_lightDir[i].xyz;\n miscData.lightColorAndIntensity = cc_lightColor[i];\n miscData.lightSizeRangeAngle = cc_lightSizeRangeAngle[i];\n SurfacesLightingModifyFinalResult(lightingResult, lightingData, surfaceData, miscData);\n #endif\n CCSurfacesAccumulateLightingResult(lightingResultAccumulated, lightingResult);\n }\n }\n #else\n void CCSurfacesLighting(inout LightingResult lightingResult, in SurfacesMaterialData surfaceData, in vec2 shadowBias)\n {\n vec3 worldPos;\n #if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\n worldPos = unpackHighpData(surfaceData.worldPos, surfaceData.worldPos_fract_part);\n #else\n worldPos = surfaceData.worldPos;\n #endif\n LightingIntermediateData lightingData;\n CCSurfacesInitializeLightingIntermediateData(lightingData, surfaceData);\n CCSurfacesInitializeLightingResult(lightingResult, surfaceData);\n CCSurfacesLightingInitializeColorWithLighting(lightingResult.diffuseColorWithLighting, lightingResult.specularColorWithLighting, surfaceData, lightingData);\n CCSurfacesLightingCalculateIntermediateData_PerLight(lightingData, surfaceData, -cc_mainLitDir.xyz);\n lightingResult.shadow = 1.0;\n #if CC_RECEIVE_SHADOW && CC_SHADOW_TYPE == 2\n if (cc_mainLitDir.w > 0.0) {\n vec4 shadowPos = vec4(0.0), shadowPosWithDepthBias = vec4(0.0);\n vec4 shadowProjDepthInfo = vec4(0.0);\n vec3 shadowNDCPos;\n bool isExceedShadowMap = true;\n if (CCSurfacesLightingEnableShadow(lightingData.NoL)) {\n #if CC_DIR_LIGHT_SHADOW_TYPE == 2\n lightingResult.shadow = CCCSMFactorBase(worldPos, lightingData.N, shadowBias);\n #if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE && CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n vec4 shadowProjInfo;\n vec3 shadowViewDir0, shadowViewDir1, shadowViewDir2;\n isExceedShadowMap = 0 > CCGetCSMLevel(shadowPosWithDepthBias, shadowProjDepthInfo, shadowProjInfo, shadowViewDir0, shadowViewDir1, shadowViewDir2, worldPos);\n GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias);\n #endif\n #endif\n #if CC_DIR_LIGHT_SHADOW_TYPE == 1\n shadowPos = cc_matLightViewProj * vec4(worldPos, 1.0);\n lightingResult.shadow = CCShadowFactorBase(shadowPosWithDepthBias, shadowPos, lightingData.N, shadowBias);\n shadowProjDepthInfo = cc_shadowProjDepthInfo;\n isExceedShadowMap = !GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias);\n #endif\n }\n #if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE && CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n lightingData.shadowPosAndDepth.xy = shadowNDCPos.xy;\n lightingData.shadowPosAndDepth.z = isExceedShadowMap ? 0.0 : GetViewSpaceDepthFromNDCDepth_Orthgraphic(shadowNDCPos.z, shadowProjDepthInfo.x, shadowProjDepthInfo.y);\n lightingData.shadowPosAndDepth.w = isExceedShadowMap ? lightingData.shadowPosAndDepth.w : GetViewSpaceDepthFromNDCDepth_Orthgraphic(SampleShadowMapSoft(shadowNDCPos, cc_shadowMap, cc_shadowWHPBInfo.xy), shadowProjDepthInfo.x, shadowProjDepthInfo.y);\n #endif\n }\n #endif\n lightingResult.lightmapColor = vec3(0.0);\n #if CC_SURFACES_USE_LIGHT_MAP && !CC_FORWARD_ADD\n float lightmapShadow, lightmapAO;\n GetLightMapColor(lightingResult.lightmapColor, lightmapShadow, lightmapAO, cc_lightingMap, FSInput_lightMapUV.xy, FSInput_lightMapUV.z, surfaceData.worldNormal);\n #if CC_SURFACES_USE_LIGHT_MAP == LIGHT_MAP_TYPE_INDIRECT_OCCLUSION\n lightingResult.shadow *= lightmapShadow;\n #endif\n lightingResult.ao *= lightmapAO;\n #endif\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_SHADOW)\n lightingResult.shadow = 1.0;\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_AO)\n lightingResult.ao = 1.0;\n #endif\n vec3 unused;\n CCSurfacesLightingCalculateEnvironment(lightingResult.environmentDiffuse, lightingResult.environmentSpecular, lightingData, cc_ambientSky.w);\n CCSurfaceLightingCalculateEnvironmentFresnel(lightingResult.environmentGF, unused, lightingData, lightingResult.specularColorWithLighting);\n lightingResult.directDiffuse = lightingResult.directSpecular = vec3(0.0);\n #if !CC_DISABLE_DIRECTIONAL_LIGHT && !CC_FORWARD_ADD\n CCSurfacesLightingCalculateColorWithLighting(lightingResult.diffuseColorWithLighting, lightingResult.specularColorWithLighting, surfaceData, lightingData);\n CCSurfacesLightingCalculateDirect(lightingResult.directDiffuse, lightingResult.directSpecular, lightingData, cc_mainLitColor);\n CCSurfaceLightingCalculateDirectFresnel(lightingResult.directGF, lightingData, lightingResult.specularColorWithLighting, lightingResult.environmentGF);\n #endif\n #if CC_SURFACES_LIGHTING_USE_FRESNEL\n lightingResult.fresnel = CCSurfaceLightingCalculateExtraFresnel(lightingData);\n #else\n lightingResult.fresnel = vec3(1.0);\n #endif\n #if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n CCSurfacesLightingCalculateDirectTransmitSpecular(lightingResult.directTransmitSpecular, lightingData, cc_mainLitColor);\n CCSurfacesLightingCalculateEnvironmentTransmitSpecular(lightingResult.environmentTransmitSpecular, lightingData, cc_ambientSky.w);\n #endif\n #if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n LightingIntermediateData lightingDataTD;\n CCSurfacesGetLightingIntermediateDataTransmitDiffuse(lightingDataTD, lightingData, surfaceData);\n CCSurfacesLightingCalculateIntermediateData_PerLight(lightingDataTD, surfaceData, -cc_mainLitDir.xyz);\n CCSurfacesLightingCalculateDirectTransmitDiffuse(lightingResult.directTransmitDiffuse, lightingDataTD, cc_mainLitColor, lightingResult.shadow);\n CCSurfacesLightingCalculateEnvironmentTransmitDiffuse(lightingResult.environmentTransmitDiffuse, lightingDataTD, cc_ambientSky.w, lightingResult.ao, -cc_mainLitDir.xyz);\n #endif\n #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n SurfacesMaterialData surfaceData2ndSpecular;\n CCSurfacesGetSurfacesMaterialData2ndSpecular(surfaceData2ndSpecular, surfaceData);\n LightingIntermediateData lightingData2ndSpecular;\n CCSurfacesInitializeLightingIntermediateData(lightingData2ndSpecular, surfaceData2ndSpecular);\n CCSurfacesLightingCalculateIntermediateData_PerLight(lightingData2ndSpecular, surfaceData2ndSpecular, -cc_mainLitDir.xyz);\n vec3 diff;\n CCSurfacesLightingInitializeColorWithLighting(diff, lightingResult.specularColorWithLighting2ndSpecular, surfaceData2ndSpecular, lightingData2ndSpecular);\n #if !CC_SURFACES_LIGHTING_SHEEN\n CCSurfacesLightingCalculateEnvironment2ndSpecular(lightingResult.environment2ndSpecular, lightingData2ndSpecular, cc_ambientSky.w, surfaceData2ndSpecular.intensity2ndSpecular, lightingResult.environmentSpecular);\n CCSurfaceLightingCalculateEnvironmentFresnel(lightingResult.environmentGF2ndSpecular, lightingResult.environmentSubLayerF, lightingData2ndSpecular, lightingResult.specularColorWithLighting2ndSpecular);\n CCSurfacesLightingCalculateDirect2ndSpecular(lightingResult.direct2ndSpecular, lightingData2ndSpecular, cc_mainLitColor, surfaceData2ndSpecular.intensity2ndSpecular, lightingResult.directSpecular);\n CCSurfaceLightingCalculateDirectFresnel(lightingResult.directGF2ndSpecular, lightingData2ndSpecular, lightingResult.specularColorWithLighting2ndSpecular, lightingResult.environmentGF2ndSpecular);\n #else\n CCSurfacesLightingCalculateDirectSheen(lightingResult.direct2ndSpecular, lightingResult.directGF2ndSpecular, lightingData2ndSpecular, cc_mainLitColor, surfaceData2ndSpecular.intensity2ndSpecular);\n CCSurfacesLightingCalculateEnvironmentSheen(lightingResult.environment2ndSpecular, lightingResult.environmentGF2ndSpecular, lightingData2ndSpecular, cc_ambientSky.w, surfaceData2ndSpecular.intensity2ndSpecular);\n #endif\n #endif\n #if CC_SURFACES_LIGHTING_TT\n CCSurfacesLightingCalculateDirectTT(lightingResult, lightingData, cc_mainLitColor);\n #endif\n #if CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n lightingResult.specularColorWithLighting2ndSpecular *= surfaceData.color2ndSpecular;\n CCSurfacesLightingCalculateDirectMultiLayerBlending(lightingResult, lightingData2ndSpecular);\n CCSurfacesLightingCalculateEnvironmentMultiLayerBlending(lightingResult, lightingData2ndSpecular);\n #endif\n #ifdef CC_SURFACES_LIGHTING_MODIFY_FINAL_RESULT\n LightingMiscData miscData;\n miscData.lightType = LIGHT_TYPE_DIRECTIONAL;\n miscData.lightPos = vec3(0.0);\n miscData.lightDir = cc_mainLitDir.xyz;\n miscData.lightColorAndIntensity = cc_mainLitColor;\n miscData.lightSizeRangeAngle = vec4(0.0, 0.0, 0.0, 0.0);\n SurfacesLightingModifyFinalResult(lightingResult, lightingData, surfaceData, miscData);\n #endif\n }\n #if CC_ENABLE_CLUSTERED_LIGHT_CULLING\n #endif\n #endif\n#endif\nvec4 CCSurfacesDebugDisplayInvalidNumber(vec4 color)\n{\n float index = mod(cc_time.x * 10.0, 2.0);\n vec4 error = index < 1.0 ? vec4(1.0, 0.0, 0.2, 1.0) : vec4(0.0, 1.0, 0.2, 1.0);\n return (isnans(color.rgb) || isinfs(color.rgb)) ? error : color;\n}\nvec4 CCSurfacesDebugDisplayInvalidInputData(vec4 color, vec3 data)\n{\n float index = mod(cc_time.x * 10.0, 2.0);\n vec4 error = index < 1.0 ? vec4(1.0, 0.0, 0.2, 1.0) : vec4(0.0, 1.0, 0.2, 1.0);\n return (isnans(data) || isinfs(data)) ? error : color;\n}\n#if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_SINGLE && !CC_FORWARD_ADD\n void CCSurfacesDebugViewMeshData(inout vec4 color)\n {\n vec4 white = vec4(1.0, 1.0, 1.0, 1.0);\n vec4 black = vec4(0.0, 0.0, 0.0, 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR)) && (cc_surfaceTransform.y != 3.0)))\n {\n #if CC_SURFACES_USE_VERTEX_COLOR\n color = FSInput_vertexColor;\n #else\n color = white;\n #endif\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(FSInput_worldNormal * 0.5 + vec3(0.5), 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT)) && (cc_surfaceTransform.y != 3.0)))\n {\n #if CC_SURFACES_USE_TANGENT_SPACE\n color = vec4(FSInput_worldTangent * 0.5 + vec3(0.5), 1.0);\n #else\n color = black;\n #endif\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR)) && (cc_surfaceTransform.y != 3.0)))\n {\n #if CC_SURFACES_USE_TANGENT_SPACE\n float sign = FSInput_mirrorNormal * 0.5 + 0.5;\n color = vec4(sign, sign, sign, 1.0);\n #else\n color = black;\n #endif\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_FACE_SIDE)) && (cc_surfaceTransform.y != 3.0)))\n {\n float scalar = clamp(FSInput_faceSideSign, 0.0, 1.0);\n color = vec4(scalar, scalar, scalar, 1.0);\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_UV0)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(FSInput_texcoord.xy, 0.0, 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_UV1)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(FSInput_texcoord1.xy, 0.0, 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP)) && (cc_surfaceTransform.y != 3.0)))\n {\n #if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n color = vec4(FSInput_lightMapUV.xy, 0.0, 1.0);\n #else\n color = vec4(0.0, 0.0, 0.0, 1.0);\n #endif\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH)) && (cc_surfaceTransform.y != 3.0)))\n {\n vec4 clipPos = cc_matProj * cc_matView * vec4(FSInput_worldPos.xyz, 1.0);\n float depth = clipPos.z / clipPos.w;\n color = vec4(depth, depth, depth, 1.0);\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH)) && (cc_surfaceTransform.y != 3.0)))\n {\n vec4 viewPos = cc_matView * vec4(FSInput_worldPos.xyz, 1.0);\n float depth = (-viewPos.z - cc_nearFar.x) / cc_nearFar.y;\n color = vec4(depth, depth, depth, 1.0);\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_WORLD_POS)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(FSInput_worldPos.xyz, 1.0);\n }\n#endif\n#if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_SINGLE\n bool CCSurfacesDebugViewLightingResult(inout vec4 color, in LightingResult lightingResult)\n {\n bool isSRGBColor = false;\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.directDiffuse * lightingResult.diffuseColorWithLighting;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.directSpecular * lightingResult.specularColorWithLighting * lightingResult.directGF;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_ALL)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.directDiffuse * lightingResult.diffuseColorWithLighting + lightingResult.directSpecular * lightingResult.specularColorWithLighting * lightingResult.directGF;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.environmentDiffuse * lightingResult.diffuseColorWithLighting;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.environmentSpecular * lightingResult.specularColorWithLighting * lightingResult.environmentGF;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_ENV_ALL)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.environmentDiffuse * lightingResult.diffuseColorWithLighting + lightingResult.environmentSpecular * lightingResult.specularColorWithLighting * lightingResult.environmentGF;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_LIGHT_MAP)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.lightmapColor;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_EMISSIVE)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.emissive;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_AO)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = vec3(lightingResult.ao);\n isSRGBColor = false;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_SHADOW)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = vec3(lightingResult.shadow);\n isSRGBColor = false;\n }\n vec3 fresnel = lightingResult.fresnel;\n vec3 directTransmitSpecular = vec3(0.0), environmentTransmitSpecular = vec3(0.0);\n vec3 directTransmitDiffuse = vec3(0.0), environmentTransmitDiffuse = vec3(0.0);\n vec3 diffuseColorWithLightingTT = vec3(0.0), specularColorWithLighting2ndSpecular = vec3(0.0);\n vec3 direct2ndSpecular = vec3(0.0), environment2ndSpecular = vec3(0.0);\n #if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n directTransmitSpecular = lightingResult.directTransmitSpecular;\n environmentTransmitSpecular = lightingResult.environmentTransmitSpecular;\n #endif\n #if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n directTransmitDiffuse = lightingResult.directTransmitDiffuse;\n environmentTransmitDiffuse = lightingResult.environmentTransmitDiffuse;\n #endif\n #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n direct2ndSpecular = lightingResult.direct2ndSpecular * lightingResult.directGF2ndSpecular;\n environment2ndSpecular = lightingResult.environment2ndSpecular * lightingResult.environmentGF2ndSpecular;\n specularColorWithLighting2ndSpecular = lightingResult.specularColorWithLighting2ndSpecular;\n #if CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n fresnel = lightingResult.environmentSubLayerF;\n #endif\n #endif\n #if CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n direct2ndSpecular = lightingResult.directSpecularSubLayers;\n environment2ndSpecular = lightingResult.environmentSpecularSubLayers;\n #endif\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_FRESNEL)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = vec3(fresnel);\n isSRGBColor = false;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = directTransmitSpecular;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = environmentTransmitSpecular;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = directTransmitDiffuse;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = environmentTransmitDiffuse;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = directTransmitSpecular + environmentTransmitSpecular + directTransmitDiffuse + environmentTransmitDiffuse;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = direct2ndSpecular * specularColorWithLighting2ndSpecular;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = environment2ndSpecular * specularColorWithLighting2ndSpecular;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = (direct2ndSpecular + environment2ndSpecular) * specularColorWithLighting2ndSpecular;\n isSRGBColor = true;\n }\n return isSRGBColor;\n }\n#endif\n#if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n void CCSurfacesDebugViewCompositeLightingResult(inout LightingResult lightingResult)\n {\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_DIFFUSE)\n lightingResult.directDiffuse = vec3(0.0);\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_SPECULAR)\n lightingResult.directSpecular = vec3(0.0);\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_DIFFUSE)\n lightingResult.environmentDiffuse = vec3(0.0);\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_SPECULAR)\n lightingResult.environmentSpecular = vec3(0.0);\n #if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_DIFFUSE)\n lightingResult.directTransmitDiffuse = lightingResult.environmentTransmitDiffuse = vec3(0.0);\n #endif\n #if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_SPECULAR)\n lightingResult.directTransmitSpecular = lightingResult.environmentTransmitSpecular = vec3(0.0);\n #endif\n #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_2ND_SPECULAR)\n lightingResult.direct2ndSpecular = lightingResult.environment2ndSpecular = vec3(0.0);\n #endif\n #if CC_SURFACES_LIGHTING_TT\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_TT)\n lightingResult.directTT = vec3(0.0);\n #endif\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_EMISSIVE)\n lightingResult.emissive = vec3(0.0);\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_LIGHT_MAP)\n lightingResult.lightmapColor = vec3(0.0);\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_SHADOW)\n lightingResult.shadow = 1.0;\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_AO)\n lightingResult.ao = 1.0;\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_FRESNEL)\n lightingResult.fresnel = vec3(1.0);\n }\n#endif\n#if (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\n layout(location = 0) out vec4 fragColorX;\n void main() {\n #if CC_DISABLE_STRUCTURE_IN_FRAGMENT_SHADER\n float NoL = dot(-cc_mainLitDir.xyz, FSInput_worldNormal.xyz);\n vec4 color = SurfacesFragmentModifyBaseColorAndTransparency();\n float fogFactor = 1.0;\n #if CC_FORWARD_ADD\n color.rgb = vec3(0.0);\n #endif\n #else\n SurfacesMaterialData surfaceData;\n CCSurfacesFragmentGetMaterialData(surfaceData);\n vec2 shadowBias = vec2(0.0);\n vec3 colDebugCSMLayer = vec3(1.0);\n #if CC_RECEIVE_SHADOW\n shadowBias = FSInput_shadowBias;\n #if !CC_FORWARD_ADD\n #if CC_USE_DEBUG_VIEW && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (IS_DEBUG_VIEW_MISC_ENABLE_CSM_LAYER_COLORATION)\n {\n vec4 csmPos;\n vec4 shadowProjDepthInfo, shadowProjInfo;\n vec3 shadowViewDir0, shadowViewDir1, shadowViewDir2;\n int csmLayer = -1;\n csmLayer = CCGetCSMLevel(csmPos, shadowProjDepthInfo, shadowProjInfo, shadowViewDir0, shadowViewDir1, shadowViewDir2, surfaceData.worldPos);\n bool OutOfRange = csmLayer < 0;\n if (OutOfRange)\n colDebugCSMLayer = vec3(1.0);\n else if (csmLayer == 0)\n colDebugCSMLayer = vec3(1.0, 0.0, 0.0);\n else if (csmLayer == 1)\n colDebugCSMLayer = vec3(0.0, 1.0, 0.0);\n else if (csmLayer == 2)\n colDebugCSMLayer = vec3(0.0, 0.0, 1.0);\n else if (csmLayer == 3)\n colDebugCSMLayer = vec3(0.0, 1.0, 1.0);\n }\n #endif\n #endif\n #endif\n float fogFactor = 1.0;\n #if !CC_FORWARD_ADD\n #if CC_USE_FOG != 4\n #if !CC_USE_ACCURATE_FOG\n fogFactor = FSInput_fogFactor;\n #else\n CC_TRANSFER_FOG_BASE(vec4(FSInput_worldPos, 1.0), fogFactor);\n #endif\n #endif\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_FOG) {\n fogFactor = 1.0;\n }\n #endif\n #endif\n LightingResult lightingResult;\n CCSurfacesLighting(lightingResult, surfaceData, shadowBias);\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_SINGLE && CC_SURFACES_ENABLE_DEBUG_VIEW\n vec4 debugColor = vec4(0.0, 0.0, 0.0, 1.0);\n float materialTransparency = CCSurfacesShading(surfaceData, lightingResult).a;\n #if !CC_FORWARD_ADD && !CC_SURFACES_LIGHTING_DISABLE_DIFFUSE\n CCSurfacesDebugViewMeshData(debugColor);\n if (CCSurfacesDebugViewSurfaceData(debugColor, surfaceData))\n {\n debugColor.a = materialTransparency;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_FOG)) && (cc_surfaceTransform.y != 3.0)))\n {\n debugColor.rgb = vec3(1.0 - fogFactor);\n }\n #endif\n #if CC_FORWARD_ADD\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE)) && (cc_surfaceTransform.y != 3.0)) || (equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR)) && (cc_surfaceTransform.y != 3.0)) || (equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_ALL)) && (cc_surfaceTransform.y != 3.0)) ||\n (equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE)) && (cc_surfaceTransform.y != 3.0)) || (equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR)) && (cc_surfaceTransform.y != 3.0)) || (equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR)) && (cc_surfaceTransform.y != 3.0)))\n #endif\n {\n if (CCSurfacesDebugViewLightingResult(debugColor, lightingResult))\n {\n debugColor.a = materialTransparency;\n #if !CC_USE_FLOAT_OUTPUT\n debugColor.rgb = HDRToLDR(debugColor.rgb);\n debugColor.rgb = LinearToSRGB(debugColor.rgb);\n #endif\n }\n }\n if (IS_DEBUG_VIEW_ENABLE_WITH_CAMERA) {\n fragColorX = debugColor;\n return;\n }\n #elif CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n CCSurfacesDebugViewCompositeLightingResult(lightingResult);\n #endif\n vec4 color = CCSurfacesShading(surfaceData, lightingResult);\n #if CC_USE_DEBUG_VIEW && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (IS_DEBUG_VIEW_MISC_ENABLE_CSM_LAYER_COLORATION) {\n color.rgb *= colDebugCSMLayer.rgb;\n }\n #if CC_SURFACES_USE_TANGENT_SPACE\n color = CCSurfacesDebugDisplayInvalidInputData(color, FSInput_worldTangent);\n #endif\n #endif\n #endif\n #if CC_USE_FOG != 4 && (!CC_USE_FLOAT_OUTPUT || CC_IS_TRANSPARENCY_PASS)\n #if !CC_FORWARD_ADD\n #ifdef CC_SURFACES_LIGHTING_MODIFY_FOG\n color.rgb = CCSurfacesLightingModifyFog(fogFactor, color.rgb, surfaceData, lightingResult);\n #else\n CC_APPLY_FOG_BASE(color, fogFactor);\n #endif\n #endif\n #endif\n #if CC_USE_RGBE_OUTPUT\n color = packRGBE(color.rgb);\n #else\n color = CCSurfacesDebugDisplayInvalidNumber(color);\n #if !CC_USE_FLOAT_OUTPUT || CC_IS_TRANSPARENCY_PASS\n color.rgb = HDRToLDR(color.rgb);\n color.rgb = LinearToSRGB(color.rgb);\n #endif\n #endif\n fragColorX = color;\n }\n#elif CC_PIPELINE_TYPE == 1\n layout(location = 0) out vec4 albedoOut;\n layout(location = 1) out vec4 emissiveOut;\n layout(location = 2) out vec4 normalOut;\n void main () {\n SurfacesMaterialData surfaceData;\n CCSurfacesFragmentGetMaterialData(surfaceData);\n albedoOut = CCSurfacesDeferredOutputBaseColor(surfaceData);\n normalOut = CCSurfacesDeferredOutputNormalMR(surfaceData);\n emissiveOut = CCSurfacesDeferredOutputEmissiveAO(surfaceData);\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_SINGLE && CC_SURFACES_ENABLE_DEBUG_VIEW\n vec4 debugColor = vec4(0.0, 0.0, 0.0, 1.0);\n CCSurfacesDebugViewMeshData(debugColor);\n CCSurfacesDebugViewSurfaceData(debugColor, surfaceData);\n if (IS_DEBUG_VIEW_ENABLE_WITH_CAMERA) {\n albedoOut = debugColor;\n }\n #endif\n }\n#endif"
- },
- "glsl1": {
- "vert": "\nprecision highp float;\n#define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING USE_COMPATIBLE_LIGHTING\n#define CC_SURFACES_USE_TANGENT_SPACE USE_NORMAL_MAP\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\n#if CC_SURFACES_USE_TANGENT_SPACE\n attribute vec4 a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n attribute vec4 a_color;\n#endif\n#if CC_SURFACES_USE_SECOND_UV || CC_USE_LIGHTMAP\n attribute vec2 a_texCoord1;\n#endif\n#if CC_USE_SKINNING\n attribute vec4 a_joints;\n attribute vec4 a_weights;\n#endif\n#if USE_INSTANCING\n #if CC_USE_BAKED_ANIMATION\n attribute highp vec4 a_jointAnimInfo;\n #endif\n attribute vec4 a_matWorld0;\n attribute vec4 a_matWorld1;\n attribute vec4 a_matWorld2;\n #if CC_USE_LIGHTMAP\n attribute vec4 a_lightingMapUVParam;\n #endif\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n attribute vec4 a_localShadowBiasAndProbeId;\n #endif\n #if CC_USE_REFLECTION_PROBE\n attribute vec4 a_reflectionProbeData;\n #endif\n #if CC_USE_LIGHT_PROBE\n attribute vec4 a_sh_linear_const_r;\n attribute vec4 a_sh_linear_const_g;\n attribute vec4 a_sh_linear_const_b;\n #endif\n#endif\n#if CC_USE_MORPH\n attribute float a_vertexId;\n#endif\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nvarying highp vec3 v_worldPos;\nvarying vec4 v_normal;\nvarying vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n varying lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n varying mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n varying mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n varying mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n varying mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n varying mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n varying mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n varying highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n varying highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n varying mediump vec4 v_sh_linear_const_r;\n varying mediump vec4 v_sh_linear_const_g;\n varying mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define VSOutput_worldPos v_worldPos\n#define VSOutput_worldNormal v_normal.xyz\n#define VSOutput_faceSideSign v_normal.w\n#define VSOutput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define VSOutput_vertexColor v_color\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define VSOutput_worldTangent v_tangent.xyz\n #define VSOutput_mirrorNormal v_tangent.w\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define VSOutput_texcoord1 v_uv1\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define VSOutput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define VSOutput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define VSOutput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define VSOutput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define VSOutput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define VSOutput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define VSOutput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define VSOutput_clipPos v_clipPos\n#endif\nstruct SurfacesStandardVertexIntermediate\n{\n highp vec4 position;\n vec3 normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n vec4 tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n vec4 color;\n#endif\n vec2 texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n vec2 texCoord1;\n#endif\n highp vec4 clipPos;\n highp vec3 worldPos;\n vec4 worldNormal;\n #if CC_SURFACES_USE_TANGENT_SPACE\n vec3 worldTangent, worldBinormal;\n #endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n vec4 shadowBiasAndProbeId;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n float fogFactor;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n vec3 lightmapUV;\n#endif\n};\n#if CC_USE_MORPH\n int getVertexId() {\n return int(a_vertexId);\n }\n#endif\nuniform highp mat4 cc_matView;\n uniform highp mat4 cc_matProj;\n uniform highp vec4 cc_cameraPos;\n uniform mediump vec4 cc_fogBase;\n uniform mediump vec4 cc_fogAdd;\nuniform mediump vec4 cc_shadowWHPBInfo;\n uniform mediump vec4 cc_shadowLPNNInfo;\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\n#if !USE_INSTANCING\n uniform highp mat4 cc_matWorld;\n uniform highp mat4 cc_matWorldIT;\n uniform highp vec4 cc_lightingMapUVParam;\n uniform highp vec4 cc_localShadowBias;\n#endif\nvoid CCGetWorldMatrixFull(out mat4 matWorld, out mat4 matWorldIT)\n{\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n vec3 scale = 1.0 / vec3(length(a_matWorld0.xyz), length(a_matWorld1.xyz), length(a_matWorld2.xyz));\n vec3 scale2 = scale * scale;\n matWorldIT = mat4(\n vec4(a_matWorld0.xyz * scale2.x, 0.0),\n vec4(a_matWorld1.xyz * scale2.y, 0.0),\n vec4(a_matWorld2.xyz * scale2.z, 0.0),\n vec4(0.0, 0.0, 0.0, 1.0)\n );\n #else\n matWorld = cc_matWorld;\n matWorldIT = cc_matWorldIT;\n #endif\n}\n#if CC_USE_MORPH\n uniform vec4 cc_displacementWeights[15];\n uniform vec4 cc_displacementTextureInfo;\n #if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n #endif\n vec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n }\n vec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n }\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\n return texture2D(tex, uv);\n }\n #else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture2D(tex, x)),\n decode32(texture2D(tex, y)),\n decode32(texture2D(tex, z)),\n 1.0\n );\n }\n #endif\n float getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n }\n vec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n #if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n #else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n #endif\n }\n #if CC_MORPH_TARGET_HAS_POSITION\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n #endif\n void applyMorph (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n int vertexId = getVertexId();\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n normal.xyz = normal.xyz + getNormalDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n tangent.xyz = tangent.xyz + getTangentDisplacement(vertexId);\n #endif\n }\n void applyMorph (inout vec4 position) {\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n #endif\n }\n#endif\n#if CC_USE_SKINNING\n #if CC_USE_BAKED_ANIMATION\n uniform highp vec4 cc_jointTextureInfo;\n uniform highp vec4 cc_jointAnimInfo;\n uniform highp sampler2D cc_jointTexture;\n void CCGetJointTextureCoords(float pixelsPerJoint, float jointIdx, out highp float x, out highp float y, out highp float invSize)\n {\n #if USE_INSTANCING\n highp float temp = pixelsPerJoint * (a_jointAnimInfo.x * a_jointAnimInfo.y + jointIdx) + a_jointAnimInfo.z;\n #else\n highp float temp = pixelsPerJoint * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + jointIdx) + cc_jointTextureInfo.z;\n #endif\n invSize = cc_jointTextureInfo.w;\n highp float tempY = floor(temp * invSize);\n x = floor(temp - tempY * cc_jointTextureInfo.x);\n y = (tempY + 0.5) * invSize;\n }\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n uniform highp sampler2D cc_realtimeJoint;\n #else\n uniform highp vec4 cc_joints[CC_JOINT_UNIFORM_CAPACITY * 3];\n #endif\n #endif\n #if CC_USE_BAKED_ANIMATION\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(3.0, i, x, y, invSize);\n vec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(12.0, i, x, y, invSize);\n vec4 v1 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n float x = i;\n vec4 v1 = texture2D(cc_realtimeJoint, vec2( x / 256.0, 0.5 / 3.0));\n vec4 v2 = texture2D(cc_realtimeJoint, vec2( x / 256.0, 1.5 / 3.0));\n vec4 v3 = texture2D(cc_realtimeJoint, vec2( x / 256.0, 2.5 / 3.0));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n float x = 4.0 * i;\n vec4 v1 = vec4(\n decode32(texture2D(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 0.5 / 3.0)))\n );\n vec4 v2 = vec4(\n decode32(texture2D(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 1.5 / 3.0)))\n );\n vec4 v3 = vec4(\n decode32(texture2D(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 2.5 / 3.0)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #endif\n mat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n }\n void CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n }\n void CCSkin (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n mat4 m = skinMatrix();\n position = m * position;\n normal = (m * vec4(normal, 0.0)).xyz;\n tangent.xyz = (m * vec4(tangent.xyz, 0.0)).xyz;\n }\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #if CC_USE_FOG != 4\n float LinearFog(vec4 pos, vec3 cameraPos, float fogStart, float fogEnd) {\n vec4 wPos = pos;\n float cam_dis = distance(cameraPos, wPos.xyz);\n return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n }\n float ExpFog(vec4 pos, vec3 cameraPos, float fogStart, float fogDensity, float fogAtten) {\n vec4 wPos = pos;\n float cam_dis = max(distance(cameraPos, wPos.xyz) - fogStart, 0.0) / fogAtten * 4.;\n float f = exp(-cam_dis * fogDensity);\n return f;\n }\n float ExpSquaredFog(vec4 pos, vec3 cameraPos, float fogStart, float fogDensity, float fogAtten) {\n vec4 wPos = pos;\n float cam_dis = max(distance(cameraPos, wPos.xyz) - fogStart, 0.0) / fogAtten * 4.;\n float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\n return f;\n }\n float LayeredFog(vec4 pos, vec3 cameraPos, float fogTop, float fogRange, float fogAtten) {\n vec4 wPos = pos;\n vec3 camWorldProj = cameraPos.xyz;\n camWorldProj.y = 0.;\n vec3 worldPosProj = wPos.xyz;\n worldPosProj.y = 0.;\n float fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\n float fDeltaY, fDensityIntegral;\n if (cameraPos.y > fogTop) {\n if (wPos.y < fogTop) {\n fDeltaY = (fogTop - wPos.y) / fogRange * 2.0;\n fDensityIntegral = fDeltaY * fDeltaY * 0.5;\n }\n else {\n fDeltaY = 0.;\n fDensityIntegral = 0.;\n }\n }\n else {\n if (wPos.y < fogTop) {\n float fDeltaA = (fogTop - cameraPos.y) / fogRange * 2.;\n float fDeltaB = (fogTop - wPos.y) / fogRange * 2.;\n fDeltaY = abs(fDeltaA - fDeltaB);\n fDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n }\n else {\n fDeltaY = abs(fogTop - cameraPos.y) / fogRange * 2.;\n fDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n }\n }\n float fDensity;\n if (fDeltaY != 0.) {\n fDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n }\n else {\n fDensity = 0.;\n }\n float f = exp(-fDensity);\n return f;\n }\n #endif\n void CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n {\n #if CC_USE_FOG == 0\n \tfactor = LinearFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.y);\n #elif CC_USE_FOG == 1\n \tfactor = ExpFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z);\n #elif CC_USE_FOG == 2\n \tfactor = ExpSquaredFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z);\n #elif CC_USE_FOG == 3\n \tfactor = LayeredFog(pos, cc_cameraPos.xyz, cc_fogAdd.x, cc_fogAdd.y, cc_fogAdd.z);\n #else\n \tfactor = 1.0;\n #endif\n }\n#endif\n uniform vec4 tilingOffset;\n#define CC_SURFACES_VERTEX_MODIFY_UV\nvoid SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)\n{\n In.texCoord = In.texCoord * tilingOffset.xy + tilingOffset.zw;\n}\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_POS\nvec3 SurfacesVertexModifyLocalPos(in SurfacesStandardVertexIntermediate In)\n{\n return vec3(In.position.xyz);\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_NORMAL\nvec3 SurfacesVertexModifyLocalNormal(in SurfacesStandardVertexIntermediate In)\n{\n return In.normal.xyz;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_TANGENT\n #if CC_SURFACES_USE_TANGENT_SPACE\n vec4 SurfacesVertexModifyLocalTangent(in SurfacesStandardVertexIntermediate In)\n {\n return In.tangent;\n }\n #endif\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_SHARED_DATA\nvoid SurfacesVertexModifyLocalSharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_POS\nvec3 SurfacesVertexModifyWorldPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.worldPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_CLIP_POS\nvec4 SurfacesVertexModifyClipPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.clipPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_UV\nvoid SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_NORMAL\nvec3 SurfacesVertexModifyWorldNormal(in SurfacesStandardVertexIntermediate In)\n{\n vec3 worldNormal = In.worldNormal.xyz;\n #if CC_SURFACES_USE_TWO_SIDED\n worldNormal.xyz *= In.worldNormal.w;\n #endif\n return worldNormal;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHADOW_BIAS\nvec2 SurfacesVertexModifyShadowBias(in SurfacesStandardVertexIntermediate In, vec2 originShadowBias)\n{\n return originShadowBias;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHARED_DATA\nvoid SurfacesVertexModifySharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\nvoid CCSurfacesVertexInput(out SurfacesStandardVertexIntermediate In)\n{\n In.position = vec4(a_position, 1.0);\n In.normal = a_normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n In.tangent = a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n In.color = a_color;\n#endif\n In.texCoord = a_texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = a_texCoord1;\n#endif\n}\nvoid CCSurfacesVertexOutput(in SurfacesStandardVertexIntermediate In)\n{\n gl_Position = In.clipPos;\n VSOutput_worldNormal = In.worldNormal.xyz;\n VSOutput_faceSideSign = In.worldNormal.w;\n VSOutput_worldPos = In.worldPos;\n#if CC_SURFACES_USE_TANGENT_SPACE\n VSOutput_worldTangent = In.worldTangent.xyz;\n VSOutput_mirrorNormal = In.tangent.w > 0.0 ? 1.0 : -1.0;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n VSOutput_vertexColor = In.color;\n#endif\n VSOutput_texcoord = In.texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n VSOutput_texcoord1 = In.texCoord1;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n VSOutput_fogFactor = In.fogFactor;\n#endif\n#if CC_RECEIVE_SHADOW\n VSOutput_shadowBias = In.shadowBiasAndProbeId.xy;\n#endif\n#if CC_USE_REFLECTION_PROBE\n VSOutput_reflectionProbeId = In.shadowBiasAndProbeId.z;\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n VSOutput_reflectionProbeBlendId = In.shadowBiasAndProbeId.w;\n #endif\n #if USE_INSTANCING\n v_reflectionProbeData = a_reflectionProbeData;\n #endif\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n VSOutput_lightMapUV = In.lightmapUV;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n VSOutput_localPos = In.position;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n VSOutput_clipPos = In.clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n v_sh_linear_const_r = a_sh_linear_const_r;\n v_sh_linear_const_g = a_sh_linear_const_g;\n v_sh_linear_const_b = a_sh_linear_const_b;\n #endif\n#endif\n}\nvoid CCSurfacesVertexAnimation(inout SurfacesStandardVertexIntermediate In)\n{\nvec4 temp = vec4(0.0);\n#if CC_USE_MORPH\n #if CC_SURFACES_USE_TANGENT_SPACE\n applyMorph(In.position, In.normal, In.tangent);\n #else\n applyMorph(In.position, In.normal, temp);\n #endif\n#endif\n#if CC_USE_SKINNING\n #if CC_SURFACES_USE_TANGENT_SPACE\n CCSkin(In.position, In.normal, In.tangent);\n #else\n CCSkin(In.position, In.normal, temp);\n #endif\n#endif\n}\nvoid CCSurfacesVertexWorldTransform(inout SurfacesStandardVertexIntermediate In)\n{\n mat4 matWorld, matWorldIT;\n CCGetWorldMatrixFull(matWorld, matWorldIT);\n In.worldPos = (matWorld * In.position).xyz;\n In.worldNormal.xyz = normalize((matWorldIT * vec4(In.normal.xyz, 0.0)).xyz);\n #if CC_SURFACES_USE_TANGENT_SPACE\n In.worldTangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\n In.worldBinormal = cross(In.worldNormal.xyz, In.worldTangent) * In.tangent.w;\n #endif\n}\nvoid CCSurfacesVertexTransformUV(inout SurfacesStandardVertexIntermediate In)\n{\n #if CC_SURFACES_FLIP_UV\n In.texCoord = cc_cameraPos.w > 1.0 ? vec2(In.texCoord.x, 1.0 - In.texCoord.y) : In.texCoord;\n #if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = cc_cameraPos.w > 1.0 ? vec2(In.texCoord1.x, 1.0 - In.texCoord1.y) : In.texCoord1;\n #endif\n #endif\n}\nvoid CCSurfacesVertexTransferFog(inout SurfacesStandardVertexIntermediate In)\n{\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n CC_TRANSFER_FOG_BASE(vec4(In.worldPos, 1.0), In.fogFactor);\n#endif\n}\nvoid CCSurfacesVertexTransferShadow(inout SurfacesStandardVertexIntermediate In)\n{\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n In.shadowBiasAndProbeId = vec4(0.0);\n #endif\n #if CC_RECEIVE_SHADOW\n In.shadowBiasAndProbeId.xy = vec2(cc_shadowWHPBInfo.w, cc_shadowLPNNInfo.z);\n #if USE_INSTANCING\n In.shadowBiasAndProbeId.xy += a_localShadowBiasAndProbeId.xy;\n #else\n In.shadowBiasAndProbeId.xy += cc_localShadowBias.xy;\n #endif\n #endif\n #if CC_USE_REFLECTION_PROBE\n #if USE_INSTANCING\n In.shadowBiasAndProbeId.zw = a_localShadowBiasAndProbeId.zw;\n #else\n In.shadowBiasAndProbeId.zw = cc_localShadowBias.zw;\n #endif\n #endif\n}\nvoid CCSurfacesVertexTransferLightMapUV(inout SurfacesStandardVertexIntermediate In)\n{\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #if USE_INSTANCING\n In.lightmapUV.xy = a_lightingMapUVParam.xy + a_texCoord1 * a_lightingMapUVParam.z;\n In.lightmapUV.z = a_lightingMapUVParam.w;\n #else\n In.lightmapUV.xy = cc_lightingMapUVParam.xy + a_texCoord1 * cc_lightingMapUVParam.z;\n In.lightmapUV.z = cc_lightingMapUVParam.w;\n #endif\n#endif\n}\nvoid main()\n{\n SurfacesStandardVertexIntermediate In;\n CCSurfacesVertexInput(In);\n CCSurfacesVertexAnimation(In);\n In.position.xyz = SurfacesVertexModifyLocalPos(In);\n In.normal.xyz = SurfacesVertexModifyLocalNormal(In);\n #if CC_SURFACES_USE_TANGENT_SPACE\n In.tangent = SurfacesVertexModifyLocalTangent(In);\n #endif\n SurfacesVertexModifyLocalSharedData(In);\n CCSurfacesVertexWorldTransform(In);\n In.worldPos = SurfacesVertexModifyWorldPos(In);\n In.clipPos = cc_matProj * cc_matView * vec4(In.worldPos, 1.0);\n In.clipPos = SurfacesVertexModifyClipPos(In);\n vec3 viewDirect = normalize(cc_cameraPos.xyz - In.worldPos);\n In.worldNormal.w = dot(In.worldNormal.xyz, viewDirect) < 0.0 ? -1.0 : 1.0;\n In.worldNormal.xyz = SurfacesVertexModifyWorldNormal(In);\n SurfacesVertexModifyUV(In);\n SurfacesVertexModifySharedData(In);\n CCSurfacesVertexTransformUV(In);\n CCSurfacesVertexTransferFog(In);\n CCSurfacesVertexTransferLightMapUV(In);\n CCSurfacesVertexTransferShadow(In);\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n In.shadowBiasAndProbeId.xy = SurfacesVertexModifyShadowBias(In, In.shadowBiasAndProbeId.xy);\n #endif\n CCSurfacesVertexOutput(In);\n}",
- "frag": "\n#ifdef GL_EXT_draw_buffers\n#extension GL_EXT_draw_buffers: enable\n#endif\n#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives: enable\n#endif\n#ifdef GL_EXT_shader_texture_lod\n#extension GL_EXT_shader_texture_lod: enable\n#endif\nprecision highp float;\n#define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING USE_COMPATIBLE_LIGHTING\n#define CC_SURFACES_USE_TANGENT_SPACE USE_NORMAL_MAP\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nvarying highp vec3 v_worldPos;\nvarying vec4 v_normal;\nvarying vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n varying lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n varying mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n varying mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n varying mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n varying mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n varying mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n varying mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n varying highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n varying highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n varying mediump vec4 v_sh_linear_const_r;\n varying mediump vec4 v_sh_linear_const_g;\n varying mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define FSInput_worldPos v_worldPos\n#define FSInput_worldNormal v_normal.xyz\n#define FSInput_faceSideSign v_normal.w\n#define FSInput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define FSInput_vertexColor v_color\n#else\n #define FSInput_vertexColor vec4(1.0)\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define FSInput_worldTangent v_tangent.xyz\n #define FSInput_mirrorNormal v_tangent.w\n#else\n #define FSInput_worldTangent vec3(1.0, 1.0, 1.0)\n #define FSInput_mirrorNormal 1.0\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define FSInput_texcoord1 v_uv1\n#else\n #define FSInput_texcoord1 vec2(0.0, 0.0)\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define FSInput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define FSInput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define FSInput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define FSInput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define FSInput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define FSInput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define FSInput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define FSInput_clipPos v_clipPos\n#endif\nuniform highp vec4 cc_time;\n uniform mediump vec4 cc_debug_view_mode;\nuniform highp mat4 cc_matView;\n uniform highp mat4 cc_matProj;\n uniform highp vec4 cc_cameraPos;\n uniform mediump vec4 cc_surfaceTransform;\n uniform mediump vec4 cc_exposure;\n uniform mediump vec4 cc_mainLitDir;\n uniform mediump vec4 cc_mainLitColor;\n uniform mediump vec4 cc_ambientSky;\n uniform mediump vec4 cc_fogColor;\n uniform mediump vec4 cc_fogBase;\n uniform mediump vec4 cc_fogAdd;\n uniform mediump vec4 cc_nearFar;\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_WORLD_POS CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR CC_SURFACES_DEBUG_VIEW_WORLD_POS + 1\n#define CC_SURFACES_DEBUG_VIEW_FACE_SIDE CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR + 1\n#define CC_SURFACES_DEBUG_VIEW_UV0 CC_SURFACES_DEBUG_VIEW_FACE_SIDE + 1\n#define CC_SURFACES_DEBUG_VIEW_UV1 CC_SURFACES_DEBUG_VIEW_UV0 + 1\n#define CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP CC_SURFACES_DEBUG_VIEW_UV1 + 1\n#define CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP + 1\n#define CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_BASE_COLOR CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR CC_SURFACES_DEBUG_VIEW_BASE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSPARENCY CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_METALLIC CC_SURFACES_DEBUG_VIEW_TRANSPARENCY + 1\n#define CC_SURFACES_DEBUG_VIEW_ROUGHNESS CC_SURFACES_DEBUG_VIEW_METALLIC + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY CC_SURFACES_DEBUG_VIEW_ROUGHNESS + 1\n#define CC_SURFACES_DEBUG_VIEW_IOR CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_IOR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_ALL CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_DIRECT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_ALL CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_EMISSIVE CC_SURFACES_DEBUG_VIEW_ENV_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_LIGHT_MAP CC_SURFACES_DEBUG_VIEW_EMISSIVE + 1\n#define CC_SURFACES_DEBUG_VIEW_SHADOW CC_SURFACES_DEBUG_VIEW_LIGHT_MAP + 1\n#define CC_SURFACES_DEBUG_VIEW_AO CC_SURFACES_DEBUG_VIEW_SHADOW + 1\n#define CC_SURFACES_DEBUG_VIEW_FRESNEL CC_SURFACES_DEBUG_VIEW_AO + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_FRESNEL + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_FOG CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL + 1\n#define IS_DEBUG_VIEW_ENABLE_WITH_CAMERA (cc_surfaceTransform.y != 3.0)\nbool equalf_mode(float data1, float data2) { return abs(float(data1) - float(data2)) < 0.001; }\n#define IS_DEBUG_VIEW_LIGHTING_ENABLE_WITH_ALBEDO (UnpackBitFromFloat(cc_debug_view_mode.w, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_MISC_ENABLE_CSM_LAYER_COLORATION (UnpackBitFromFloat(cc_debug_view_mode.w, 7) && IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_EMISSIVE (UnpackBitFromFloat(cc_debug_view_mode.y, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_LIGHT_MAP (UnpackBitFromFloat(cc_debug_view_mode.y, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_SHADOW (UnpackBitFromFloat(cc_debug_view_mode.y, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_AO (UnpackBitFromFloat(cc_debug_view_mode.y, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_NORMAL_MAP (UnpackBitFromFloat(cc_debug_view_mode.z, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FOG (UnpackBitFromFloat(cc_debug_view_mode.z, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TONE_MAPPING (UnpackBitFromFloat(cc_debug_view_mode.z, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION (UnpackBitFromFloat(cc_debug_view_mode.z, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FRESNEL (UnpackBitFromFloat(cc_debug_view_mode.z, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.z, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_2ND_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TT (UnpackBitFromFloat(cc_debug_view_mode.w, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#if (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\n #if CC_FORWARD_ADD\n #if CC_PIPELINE_TYPE == 0\n #define LIGHTS_PER_PASS 1\n #else\n #define LIGHTS_PER_PASS 10\n #endif\n #if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\n uniform highp vec4 cc_lightPos[LIGHTS_PER_PASS];\n uniform vec4 cc_lightColor[LIGHTS_PER_PASS];\n uniform vec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\n uniform vec4 cc_lightDir[LIGHTS_PER_PASS];\n uniform vec4 cc_lightBoundingSizeVS[LIGHTS_PER_PASS];\n #endif\n #endif\n#endif\n#if CC_USE_LIGHT_PROBE\n #if !USE_INSTANCING\n #endif\n#endif\nuniform highp mat4 cc_matLightView;\n uniform highp mat4 cc_matLightViewProj;\n uniform highp vec4 cc_shadowInvProjDepthInfo;\n uniform highp vec4 cc_shadowProjDepthInfo;\n uniform highp vec4 cc_shadowProjInfo;\n uniform mediump vec4 cc_shadowNFLSInfo;\n uniform mediump vec4 cc_shadowWHPBInfo;\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n uniform highp vec4 cc_csmViewDir0[4];\n uniform highp vec4 cc_csmViewDir1[4];\n uniform highp vec4 cc_csmViewDir2[4];\n uniform highp vec4 cc_csmAtlas[4];\n uniform highp mat4 cc_matCSMViewProj[4];\n uniform highp vec4 cc_csmProjDepthInfo[4];\n uniform highp vec4 cc_csmProjInfo[4];\n uniform highp vec4 cc_csmSplitsInfo;\n#endif\nuniform samplerCube cc_environment;\n#if CC_USE_IBL\n #if CC_USE_DIFFUSEMAP\n uniform samplerCube cc_diffuseMap;\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n uniform samplerCube cc_reflectionProbeCubemap;\n uniform sampler2D cc_reflectionProbePlanarMap;\n uniform sampler2D cc_reflectionProbeDataMap;\n uniform samplerCube cc_reflectionProbeBlendCubemap;\n#endif\n#define UnpackBitFromFloat(value, bit) (mod(floor(value / pow(10.0, float(bit))), 10.0) > 0.0)\nhighp float unpackHighpData (float mainPart, float modPart) {\n highp float data = mainPart;\n return data + modPart;\n}\nvoid packHighpData (out float mainPart, out float modPart, highp float data) {\n mainPart = fract(data);\n modPart = data - mainPart;\n}\nhighp float unpackHighpData (float mainPart, float modPart, const float modValue) {\n highp float data = mainPart * modValue;\n return data + modPart * modValue;\n}\nvoid packHighpData (out float mainPart, out float modPart, highp float data, const float modValue) {\n highp float divide = data / modValue;\n mainPart = floor(divide);\n modPart = (data - mainPart * modValue) / modValue;\n}\nhighp vec2 unpackHighpData (vec2 mainPart, vec2 modPart) {\n highp vec2 data = mainPart;\n return data + modPart;\n}\nvoid packHighpData (out vec2 mainPart, out vec2 modPart, highp vec2 data) {\n mainPart = fract(data);\n modPart = data - mainPart;\n}\nhighp vec2 unpackHighpData (vec2 mainPart, vec2 modPart, const float modValue) {\n highp vec2 data = mainPart * modValue;\n return data + modPart * modValue;\n}\nvoid packHighpData (out vec2 mainPart, out vec2 modPart, highp vec2 data, const float modValue) {\n highp vec2 divide = data / modValue;\n mainPart = floor(divide);\n modPart = (data - mainPart * modValue) / modValue;\n}\nhighp vec3 unpackHighpData (vec3 mainPart, vec3 modPart) {\n highp vec3 data = mainPart;\n return data + modPart;\n}\nvoid packHighpData (out vec3 mainPart, out vec3 modPart, highp vec3 data) {\n mainPart = fract(data);\n modPart = data - mainPart;\n}\nhighp vec3 unpackHighpData (vec3 mainPart, vec3 modPart, const float modValue) {\n highp vec3 data = mainPart * modValue;\n return data + modPart * modValue;\n}\nvoid packHighpData (out vec3 mainPart, out vec3 modPart, highp vec3 data, const float modValue) {\n highp vec3 divide = data / modValue;\n mainPart = floor(divide);\n modPart = (data - mainPart * modValue) / modValue;\n}\nhighp vec4 unpackHighpData (vec4 mainPart, vec4 modPart) {\n highp vec4 data = mainPart;\n return data + modPart;\n}\nvoid packHighpData (out vec4 mainPart, out vec4 modPart, highp vec4 data) {\n mainPart = fract(data);\n modPart = data - mainPart;\n}\nhighp vec4 unpackHighpData (vec4 mainPart, vec4 modPart, const float modValue) {\n highp vec4 data = mainPart * modValue;\n return data + modPart * modValue;\n}\nvoid packHighpData (out vec4 mainPart, out vec4 modPart, highp vec4 data, const float modValue) {\n highp vec4 divide = data / modValue;\n mainPart = floor(divide);\n modPart = (data - mainPart * modValue) / modValue;\n}\nvec4 packRGBE (vec3 rgb) {\n highp float maxComp = max(max(rgb.r, rgb.g), rgb.b);\n highp float e = 128.0;\n if (maxComp > 0.0001) {\n e = log(maxComp) / log(1.1);\n e = ceil(e);\n e = clamp(e + 128.0, 0.0, 255.0);\n }\n highp float sc = 1.0 / pow(1.1, e - 128.0);\n vec3 encode = clamp(rgb * sc, vec3(0.0), vec3(1.0)) * 255.0;\n vec3 encode_rounded = floor(encode) + step(encode - floor(encode), vec3(0.5));\n return vec4(encode_rounded, e) / 255.0;\n}\nvec3 ACESToneMap (vec3 color) {\n color = min(color, vec3(8.0));\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec3 HDRToLDR(vec3 color)\n{\n #if CC_USE_HDR\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (IS_DEBUG_VIEW_COMPOSITE_ENABLE_TONE_MAPPING)\n #endif\n {\n #if CC_TONE_MAPPING_TYPE == HDR_TONE_MAPPING_ACES\n color.rgb = ACESToneMap(color.rgb);\n #endif\n }\n #endif\n return color;\n}\nvec3 SRGBToLinear (vec3 gamma) {\n#ifdef CC_USE_SURFACE_SHADER\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION) {\n return gamma;\n }\n #endif\n#endif\n return gamma * gamma;\n}\nvec3 LinearToSRGB(vec3 linear) {\n#ifdef CC_USE_SURFACE_SHADER\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION) {\n return linear;\n }\n #endif\n#endif\n return sqrt(linear);\n}\nbool isnan(float val) {\n return (val < 0.0 || 0.0 < val || val == 0.0) ? false : true;\n}\nbool isinf(float x) {\n return x == x * 2.0 && x != 0.0;\n}\nbool isnans(vec2 val) {\n return isnan(val.x) || isnan(val.y);\n}\nbool isnans(vec3 val) {\n return isnan(val.x) || isnan(val.y) || isnan(val.z);\n}\nbool isnans(vec4 val) {\n return isnan(val.x) || isnan(val.y) || isnan(val.z) || isnan(val.w);\n}\nbool isinfs(vec2 val) {\n return isinf(val.x) || isinf(val.y);\n}\nbool isinfs(vec3 val) {\n return isinf(val.x) || isinf(val.y) || isinf(val.z);\n}\nbool isinfs(vec4 val) {\n return isinf(val.x) || isinf(val.y) || isinf(val.z) || isinf(val.w);\n}\n#if defined(CC_USE_METAL) || defined(CC_USE_WGPU)\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y) y = -y\n#else\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y)\n#endif\nfloat GetLinearDepthFromViewSpace(vec3 viewPos, float near, float far) {\n float dist = length(viewPos);\n return (dist - near) / (far - near);\n}\nvec3 CalculateBinormal(vec3 normal, vec3 tangent, float mirrorNormal)\n{\n return cross(normal, tangent) * mirrorNormal;\n}\nvec3 CalculateNormalFromTangentSpace(vec3 normalFromTangentSpace, float normalStrength, vec3 normal, vec3 tangent, float mirrorNormal)\n{\n vec3 binormal = CalculateBinormal(normal, tangent, mirrorNormal);\n return (normalFromTangentSpace.x * normalStrength) * normalize(tangent) +\n (normalFromTangentSpace.y * normalStrength) * normalize(binormal) +\n normalFromTangentSpace.z * normalize(normal);\n}\nvec2 signNotZero(vec2 v) {\n return vec2((v.x >= 0.0) ? +1.0 : -1.0, (v.y >= 0.0) ? +1.0 : -1.0);\n}\nvec2 float32x3_to_oct(in vec3 v) {\n vec2 p = v.xy * (1.0 / (abs(v.x) + abs(v.y) + abs(v.z)));\n return (v.z <= 0.0) ? ((1.0 - abs(p.yx)) * signNotZero(p)) : p;\n}\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n#endif\nfloat CCGetLinearDepth(vec3 worldPos, float viewSpaceBias) {\n\tvec4 viewPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\n viewPos.z += viewSpaceBias;\n\treturn GetLinearDepthFromViewSpace(viewPos.xyz, cc_shadowNFLSInfo.x, cc_shadowNFLSInfo.y);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\n\treturn CCGetLinearDepth(worldPos, 0.0);\n}\n#if CC_RECEIVE_SHADOW\n uniform highp sampler2D cc_shadowMap;\n uniform highp sampler2D cc_spotShadowMap;\n float SampleShadowMap (vec3 shadowNDCPos, highp sampler2D shadowMap)\n {\n #if CC_SHADOWMAP_FORMAT == 1\n return dot(texture2D(shadowMap, shadowNDCPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n #else\n return texture2D(shadowMap, shadowNDCPos.xy).x;\n #endif\n }\n float SampleShadowMapSoft (vec3 shadowNDCPos, highp sampler2D shadowMap, vec2 shadowMapResolution)\n {\n vec2 oneTap = 1.0 / shadowMapResolution;\n vec2 shadowNDCPos_offset = shadowNDCPos.xy + oneTap;\n float block0 = SampleShadowMap(vec3(shadowNDCPos.x, shadowNDCPos.y, shadowNDCPos.z), shadowMap);\n float block1 = SampleShadowMap(vec3(shadowNDCPos_offset.x, shadowNDCPos.y, shadowNDCPos.z), shadowMap);\n float block2 = SampleShadowMap(vec3(shadowNDCPos.x, shadowNDCPos_offset.y, shadowNDCPos.z), shadowMap);\n float block3 = SampleShadowMap(vec3(shadowNDCPos_offset.x, shadowNDCPos_offset.y, shadowNDCPos.z), shadowMap);\n float coefX = mod(shadowNDCPos.x, oneTap.x) * shadowMapResolution.x;\n float resultX = mix(block0, block1, coefX);\n float resultY = mix(block2, block3, coefX);\n float coefY = mod(shadowNDCPos.y, oneTap.y) * shadowMapResolution.y;\n return mix(resultX, resultY, coefY);\n }\n float NativePCFShadowFactorHard (vec3 shadowNDCPos, highp sampler2D shadowMap, vec2 shadowMapResolution)\n {\n #if CC_SHADOWMAP_FORMAT == 1\n return step(shadowNDCPos.z, dot(texture2D(shadowMap, shadowNDCPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n #else\n return step(shadowNDCPos.z, texture2D(shadowMap, shadowNDCPos.xy).x);\n #endif\n }\n float NativePCFShadowFactorSoft (vec3 shadowNDCPos, highp sampler2D shadowMap, vec2 shadowMapResolution)\n {\n vec2 oneTap = 1.0 / shadowMapResolution;\n vec2 shadowNDCPos_offset = shadowNDCPos.xy + oneTap;\n float block0, block1, block2, block3;\n #if CC_SHADOWMAP_FORMAT == 1\n block0 = step(shadowNDCPos.z, dot(texture2D(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block1 = step(shadowNDCPos.z, dot(texture2D(shadowMap, vec2(shadowNDCPos_offset.x, shadowNDCPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block2 = step(shadowNDCPos.z, dot(texture2D(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block3 = step(shadowNDCPos.z, dot(texture2D(shadowMap, vec2(shadowNDCPos_offset.x, shadowNDCPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n #else\n block0 = step(shadowNDCPos.z, texture2D(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos.y)).x);\n block1 = step(shadowNDCPos.z, texture2D(shadowMap, vec2(shadowNDCPos_offset.x, shadowNDCPos.y)).x);\n block2 = step(shadowNDCPos.z, texture2D(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos_offset.y)).x);\n block3 = step(shadowNDCPos.z, texture2D(shadowMap, vec2(shadowNDCPos_offset.x, shadowNDCPos_offset.y)).x);\n #endif\n float coefX = mod(shadowNDCPos.x, oneTap.x) * shadowMapResolution.x;\n float resultX = mix(block0, block1, coefX);\n float resultY = mix(block2, block3, coefX);\n float coefY = mod(shadowNDCPos.y, oneTap.y) * shadowMapResolution.y;\n return mix(resultX, resultY, coefY);\n }\n float NativePCFShadowFactorSoft3X (vec3 shadowNDCPos, highp sampler2D shadowMap, vec2 shadowMapResolution)\n {\n vec2 oneTap = 1.0 / shadowMapResolution;\n float shadowNDCPos_offset_L = shadowNDCPos.x - oneTap.x;\n float shadowNDCPos_offset_R = shadowNDCPos.x + oneTap.x;\n float shadowNDCPos_offset_U = shadowNDCPos.y - oneTap.y;\n float shadowNDCPos_offset_D = shadowNDCPos.y + oneTap.y;\n float block0, block1, block2, block3, block4, block5, block6, block7, block8;\n #if CC_SHADOWMAP_FORMAT == 1\n block0 = step(shadowNDCPos.z, dot(texture2D(shadowMap, vec2(shadowNDCPos_offset_L, shadowNDCPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block1 = step(shadowNDCPos.z, dot(texture2D(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block2 = step(shadowNDCPos.z, dot(texture2D(shadowMap, vec2(shadowNDCPos_offset_R, shadowNDCPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block3 = step(shadowNDCPos.z, dot(texture2D(shadowMap, vec2(shadowNDCPos_offset_L, shadowNDCPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block4 = step(shadowNDCPos.z, dot(texture2D(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block5 = step(shadowNDCPos.z, dot(texture2D(shadowMap, vec2(shadowNDCPos_offset_R, shadowNDCPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block6 = step(shadowNDCPos.z, dot(texture2D(shadowMap, vec2(shadowNDCPos_offset_L, shadowNDCPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block7 = step(shadowNDCPos.z, dot(texture2D(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block8 = step(shadowNDCPos.z, dot(texture2D(shadowMap, vec2(shadowNDCPos_offset_R, shadowNDCPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n #else\n block0 = step(shadowNDCPos.z, texture2D(shadowMap, vec2(shadowNDCPos_offset_L, shadowNDCPos_offset_U)).x);\n block1 = step(shadowNDCPos.z, texture2D(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos_offset_U)).x);\n block2 = step(shadowNDCPos.z, texture2D(shadowMap, vec2(shadowNDCPos_offset_R, shadowNDCPos_offset_U)).x);\n block3 = step(shadowNDCPos.z, texture2D(shadowMap, vec2(shadowNDCPos_offset_L, shadowNDCPos.y)).x);\n block4 = step(shadowNDCPos.z, texture2D(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos.y)).x);\n block5 = step(shadowNDCPos.z, texture2D(shadowMap, vec2(shadowNDCPos_offset_R, shadowNDCPos.y)).x);\n block6 = step(shadowNDCPos.z, texture2D(shadowMap, vec2(shadowNDCPos_offset_L, shadowNDCPos_offset_D)).x);\n block7 = step(shadowNDCPos.z, texture2D(shadowMap, vec2(shadowNDCPos.x, shadowNDCPos_offset_D)).x);\n block8 = step(shadowNDCPos.z, texture2D(shadowMap, vec2(shadowNDCPos_offset_R, shadowNDCPos_offset_D)).x);\n #endif\n float coefX = mod(shadowNDCPos.x, oneTap.x) * shadowMapResolution.x;\n float coefY = mod(shadowNDCPos.y, oneTap.y) * shadowMapResolution.y;\n float shadow = 0.0;\n float resultX = mix(block0, block1, coefX);\n float resultY = mix(block3, block4, coefX);\n shadow += mix(resultX , resultY, coefY);\n resultX = mix(block1, block2, coefX);\n resultY = mix(block4, block5, coefX);\n shadow += mix(resultX , resultY, coefY);\n resultX = mix(block3, block4, coefX);\n resultY = mix(block6, block7, coefX);\n shadow += mix(resultX, resultY, coefY);\n resultX = mix(block4, block5, coefX);\n resultY = mix(block7, block8, coefX);\n shadow += mix(resultX, resultY, coefY);\n return shadow * 0.25;\n }\n float NativePCFShadowFactorSoft5X (vec3 shadowNDCPos, highp sampler2D shadowMap, vec2 shadowMapResolution)\n {\n vec2 oneTap = 1.0 / shadowMapResolution;\n vec2 twoTap = oneTap * 2.0;\n vec2 offset1 = shadowNDCPos.xy + vec2(-twoTap.x, -twoTap.y);\n vec2 offset2 = shadowNDCPos.xy + vec2(-oneTap.x, -twoTap.y);\n vec2 offset3 = shadowNDCPos.xy + vec2(0.0, -twoTap.y);\n vec2 offset4 = shadowNDCPos.xy + vec2(oneTap.x, -twoTap.y);\n vec2 offset5 = shadowNDCPos.xy + vec2(twoTap.x, -twoTap.y);\n vec2 offset6 = shadowNDCPos.xy + vec2(-twoTap.x, -oneTap.y);\n vec2 offset7 = shadowNDCPos.xy + vec2(-oneTap.x, -oneTap.y);\n vec2 offset8 = shadowNDCPos.xy + vec2(0.0, -oneTap.y);\n vec2 offset9 = shadowNDCPos.xy + vec2(oneTap.x, -oneTap.y);\n vec2 offset10 = shadowNDCPos.xy + vec2(twoTap.x, -oneTap.y);\n vec2 offset11 = shadowNDCPos.xy + vec2(-twoTap.x, 0.0);\n vec2 offset12 = shadowNDCPos.xy + vec2(-oneTap.x, 0.0);\n vec2 offset13 = shadowNDCPos.xy + vec2(0.0, 0.0);\n vec2 offset14 = shadowNDCPos.xy + vec2(oneTap.x, 0.0);\n vec2 offset15 = shadowNDCPos.xy + vec2(twoTap.x, 0.0);\n vec2 offset16 = shadowNDCPos.xy + vec2(-twoTap.x, oneTap.y);\n vec2 offset17 = shadowNDCPos.xy + vec2(-oneTap.x, oneTap.y);\n vec2 offset18 = shadowNDCPos.xy + vec2(0.0, oneTap.y);\n vec2 offset19 = shadowNDCPos.xy + vec2(oneTap.x, oneTap.y);\n vec2 offset20 = shadowNDCPos.xy + vec2(twoTap.x, oneTap.y);\n vec2 offset21 = shadowNDCPos.xy + vec2(-twoTap.x, twoTap.y);\n vec2 offset22 = shadowNDCPos.xy + vec2(-oneTap.x, twoTap.y);\n vec2 offset23 = shadowNDCPos.xy + vec2(0.0, twoTap.y);\n vec2 offset24 = shadowNDCPos.xy + vec2(oneTap.x, twoTap.y);\n vec2 offset25 = shadowNDCPos.xy + vec2(twoTap.x, twoTap.y);\n float block1, block2, block3, block4, block5, block6, block7, block8, block9, block10, block11, block12, block13, block14, block15, block16, block17, block18, block19, block20, block21, block22, block23, block24, block25;\n #if CC_SHADOWMAP_FORMAT == 1\n block1 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset1), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block2 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset2), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block3 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset3), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block4 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset4), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block5 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset5), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block6 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset6), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block7 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset7), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block8 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset8), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block9 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset9), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block10 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset10), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block11 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset11), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block12 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset12), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block13 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset13), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block14 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset14), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block15 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset15), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block16 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset16), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block17 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset17), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block18 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset18), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block19 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset19), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block20 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset20), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block21 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset21), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block22 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset22), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block23 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset23), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block24 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset24), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n block25 = step(shadowNDCPos.z, dot(texture2D(shadowMap, offset25), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n #else\n block1 = step(shadowNDCPos.z, texture2D(shadowMap, offset1).x);\n block2 = step(shadowNDCPos.z, texture2D(shadowMap, offset2).x);\n block3 = step(shadowNDCPos.z, texture2D(shadowMap, offset3).x);\n block4 = step(shadowNDCPos.z, texture2D(shadowMap, offset4).x);\n block5 = step(shadowNDCPos.z, texture2D(shadowMap, offset5).x);\n block6 = step(shadowNDCPos.z, texture2D(shadowMap, offset6).x);\n block7 = step(shadowNDCPos.z, texture2D(shadowMap, offset7).x);\n block8 = step(shadowNDCPos.z, texture2D(shadowMap, offset8).x);\n block9 = step(shadowNDCPos.z, texture2D(shadowMap, offset9).x);\n block10 = step(shadowNDCPos.z, texture2D(shadowMap, offset10).x);\n block11 = step(shadowNDCPos.z, texture2D(shadowMap, offset11).x);\n block12 = step(shadowNDCPos.z, texture2D(shadowMap, offset12).x);\n block13 = step(shadowNDCPos.z, texture2D(shadowMap, offset13).x);\n block14 = step(shadowNDCPos.z, texture2D(shadowMap, offset14).x);\n block15 = step(shadowNDCPos.z, texture2D(shadowMap, offset15).x);\n block16 = step(shadowNDCPos.z, texture2D(shadowMap, offset16).x);\n block17 = step(shadowNDCPos.z, texture2D(shadowMap, offset17).x);\n block18 = step(shadowNDCPos.z, texture2D(shadowMap, offset18).x);\n block19 = step(shadowNDCPos.z, texture2D(shadowMap, offset19).x);\n block20 = step(shadowNDCPos.z, texture2D(shadowMap, offset20).x);\n block21 = step(shadowNDCPos.z, texture2D(shadowMap, offset21).x);\n block22 = step(shadowNDCPos.z, texture2D(shadowMap, offset22).x);\n block23 = step(shadowNDCPos.z, texture2D(shadowMap, offset23).x);\n block24 = step(shadowNDCPos.z, texture2D(shadowMap, offset24).x);\n block25 = step(shadowNDCPos.z, texture2D(shadowMap, offset25).x);\n #endif\n vec2 coef = fract(shadowNDCPos.xy * shadowMapResolution);\n vec2 v1X1 = mix(vec2(block1, block6), vec2(block2, block7), coef.xx);\n vec2 v1X2 = mix(vec2(block2, block7), vec2(block3, block8), coef.xx);\n vec2 v1X3 = mix(vec2(block3, block8), vec2(block4, block9), coef.xx);\n vec2 v1X4 = mix(vec2(block4, block9), vec2(block5, block10), coef.xx);\n float v1 = mix(v1X1.x, v1X1.y, coef.y) + mix(v1X2.x, v1X2.y, coef.y) + mix(v1X3.x, v1X3.y, coef.y) + mix(v1X4.x, v1X4.y, coef.y);\n vec2 v2X1 = mix(vec2(block6, block11), vec2(block7, block12), coef.xx);\n vec2 v2X2 = mix(vec2(block7, block12), vec2(block8, block13), coef.xx);\n vec2 v2X3 = mix(vec2(block8, block13), vec2(block9, block14), coef.xx);\n vec2 v2X4 = mix(vec2(block9, block14), vec2(block10, block15), coef.xx);\n float v2 = mix(v2X1.x, v2X1.y, coef.y) + mix(v2X2.x, v2X2.y, coef.y) + mix(v2X3.x, v2X3.y, coef.y) + mix(v2X4.x, v2X4.y, coef.y);\n vec2 v3X1 = mix(vec2(block11, block16), vec2(block12, block17), coef.xx);\n vec2 v3X2 = mix(vec2(block12, block17), vec2(block13, block18), coef.xx);\n vec2 v3X3 = mix(vec2(block13, block18), vec2(block14, block19), coef.xx);\n vec2 v3X4 = mix(vec2(block14, block19), vec2(block15, block20), coef.xx);\n float v3 = mix(v3X1.x, v3X1.y, coef.y) + mix(v3X2.x, v3X2.y, coef.y) + mix(v3X3.x, v3X3.y, coef.y) + mix(v3X4.x, v3X4.y, coef.y);\n vec2 v4X1 = mix(vec2(block16, block21), vec2(block17, block22), coef.xx);\n vec2 v4X2 = mix(vec2(block17, block22), vec2(block18, block23), coef.xx);\n vec2 v4X3 = mix(vec2(block18, block23), vec2(block19, block24), coef.xx);\n vec2 v4X4 = mix(vec2(block19, block24), vec2(block20, block25), coef.xx);\n float v4 = mix(v4X1.x, v4X1.y, coef.y) + mix(v4X2.x, v4X2.y, coef.y) + mix(v4X3.x, v4X3.y, coef.y) + mix(v4X4.x, v4X4.y, coef.y);\n float fAvg = (v1 + v2 + v3 + v4) * 0.0625;\n return fAvg;\n }\n bool GetShadowNDCPos(out vec3 shadowNDCPos, vec4 shadowPosWithDepthBias)\n {\n \tshadowNDCPos = shadowPosWithDepthBias.xyz / shadowPosWithDepthBias.w * 0.5 + 0.5;\n \tif (shadowNDCPos.x < 0.0 || shadowNDCPos.x > 1.0 ||\n \t\tshadowNDCPos.y < 0.0 || shadowNDCPos.y > 1.0 ||\n \t\tshadowNDCPos.z < 0.0 || shadowNDCPos.z > 1.0) {\n \t\treturn false;\n \t}\n \tshadowNDCPos.xy = cc_cameraPos.w == 1.0 ? vec2(shadowNDCPos.xy.x, 1.0 - shadowNDCPos.xy.y) : shadowNDCPos.xy;\n \treturn true;\n }\n vec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal, float normalBias, vec3 matViewDir0, vec3 matViewDir1, vec3 matViewDir2, vec2 projScaleXY)\n {\n vec4 newShadowPos = shadowPos;\n if (normalBias > EPSILON_LOWP)\n {\n vec3 viewNormal = vec3(dot(matViewDir0, worldNormal), dot(matViewDir1, worldNormal), dot(matViewDir2, worldNormal));\n if (viewNormal.z < 0.1)\n newShadowPos.xy += viewNormal.xy * projScaleXY * normalBias * clamp(viewNormal.z, 0.001, 0.1);\n }\n return newShadowPos;\n }\n vec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal, float normalBias, mat4 matLightView, vec2 projScaleXY)\n {\n \tvec4 newShadowPos = shadowPos;\n \tif (normalBias > EPSILON_LOWP)\n \t{\n \t\tvec4 viewNormal = matLightView * vec4(worldNormal, 0.0);\n \t\tif (viewNormal.z < 0.1)\n \t\t\tnewShadowPos.xy += viewNormal.xy * projScaleXY * normalBias * clamp(viewNormal.z, 0.001, 0.1);\n \t}\n \treturn newShadowPos;\n }\n float GetViewSpaceDepthFromNDCDepth_Orthgraphic(float NDCDepth, float projScaleZ, float projBiasZ)\n {\n \treturn (NDCDepth - projBiasZ) / projScaleZ;\n }\n float GetViewSpaceDepthFromNDCDepth_Perspective(float NDCDepth, float homogenousDividW, float invProjScaleZ, float invProjBiasZ)\n {\n \treturn NDCDepth * invProjScaleZ + homogenousDividW * invProjBiasZ;\n }\n vec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n {\n \tvec3 viewSpacePos;\n \tviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\n \tviewSpacePos.z = GetViewSpaceDepthFromNDCDepth_Perspective(shadowPos.z, shadowPos.w, cc_shadowInvProjDepthInfo.x, cc_shadowInvProjDepthInfo.y);\n \tviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\n \tvec4 clipSpacePos;\n \tclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\n \tclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\n \t#if CC_SHADOWMAP_USE_LINEAR_DEPTH\n \t\tclipSpacePos.z = GetLinearDepthFromViewSpace(viewSpacePos.xyz, cc_shadowNFLSInfo.x, cc_shadowNFLSInfo.y);\n \t\tclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n \t#endif\n \treturn clipSpacePos;\n }\n vec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias, float projScaleZ, float projBiasZ)\n {\n \tfloat coeffA = projScaleZ;\n \tfloat coeffB = projBiasZ;\n \tfloat viewSpacePos_z = GetViewSpaceDepthFromNDCDepth_Orthgraphic(shadowPos.z, projScaleZ, projBiasZ);\n \tviewSpacePos_z += viewspaceDepthBias;\n \tvec4 result = shadowPos;\n \tresult.z = viewSpacePos_z * coeffA + coeffB;\n \treturn result;\n }\n vec4 ApplyShadowDepthBias_PerspectiveLinearDepth(vec4 shadowPos, float viewspaceDepthBias, vec3 worldPos)\n {\n shadowPos.z = CCGetLinearDepth(worldPos, viewspaceDepthBias) * 2.0 - 1.0;\n shadowPos.z *= shadowPos.w;\n return shadowPos;\n }\n float CCGetDirLightShadowFactorHard (vec4 shadowPosWithDepthBias) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorHard(shadowNDCPos, cc_shadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCGetDirLightShadowFactorSoft (vec4 shadowPosWithDepthBias) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorSoft(shadowNDCPos, cc_shadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCGetDirLightShadowFactorSoft3X (vec4 shadowPosWithDepthBias) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorSoft3X(shadowNDCPos, cc_shadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCGetDirLightShadowFactorSoft5X (vec4 shadowPosWithDepthBias) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorSoft5X(shadowNDCPos, cc_shadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCGetSpotLightShadowFactorHard (vec4 shadowPosWithDepthBias, vec3 worldPos) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorHard(shadowNDCPos, cc_spotShadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCGetSpotLightShadowFactorSoft (vec4 shadowPosWithDepthBias, vec3 worldPos) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorSoft(shadowNDCPos, cc_spotShadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCGetSpotLightShadowFactorSoft3X (vec4 shadowPosWithDepthBias, vec3 worldPos) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorSoft3X(shadowNDCPos, cc_spotShadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCGetSpotLightShadowFactorSoft5X (vec4 shadowPosWithDepthBias, vec3 worldPos) {\n\t vec3 shadowNDCPos;\n\t if (!GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias)) {\n\t\t return 1.0;\n\t }\n return NativePCFShadowFactorSoft5X(shadowNDCPos, cc_spotShadowMap, cc_shadowWHPBInfo.xy);\n }\n float CCSpotShadowFactorBase(out vec4 shadowPosWithDepthBias, vec4 shadowPos, vec3 worldPos, vec2 shadowBias)\n {\n float pcf = cc_shadowWHPBInfo.z;\n vec4 pos = vec4(1.0);\n #if CC_SHADOWMAP_USE_LINEAR_DEPTH\n pos = ApplyShadowDepthBias_PerspectiveLinearDepth(shadowPos, shadowBias.x, worldPos);\n #else\n pos = ApplyShadowDepthBias_Perspective(shadowPos, shadowBias.x);\n #endif\n float realtimeShadow = 1.0;\n if (pcf > 2.9) {\n realtimeShadow = CCGetSpotLightShadowFactorSoft5X(pos, worldPos);\n }else if (pcf > 1.9) {\n realtimeShadow = CCGetSpotLightShadowFactorSoft3X(pos, worldPos);\n }else if (pcf > 0.9) {\n realtimeShadow = CCGetSpotLightShadowFactorSoft(pos, worldPos);\n }else {\n realtimeShadow = CCGetSpotLightShadowFactorHard(pos, worldPos);\n }\n shadowPosWithDepthBias = pos;\n return mix(realtimeShadow, 1.0, cc_shadowNFLSInfo.w);\n }\n float CCShadowFactorBase(out vec4 shadowPosWithDepthBias, vec4 shadowPos, vec3 N, vec2 shadowBias)\n {\n vec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N, shadowBias.y, cc_matLightView, cc_shadowProjInfo.xy);\n pos = ApplyShadowDepthBias_Orthographic(pos, shadowBias.x, cc_shadowProjDepthInfo.x, cc_shadowProjDepthInfo.y);\n float realtimeShadow = 1.0;\n #if CC_DIR_SHADOW_PCF_TYPE == 3\n realtimeShadow = CCGetDirLightShadowFactorSoft5X(pos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 2\n realtimeShadow = CCGetDirLightShadowFactorSoft3X(pos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 1\n realtimeShadow = CCGetDirLightShadowFactorSoft(pos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 0\n realtimeShadow = CCGetDirLightShadowFactorHard(pos);\n #endif\n shadowPosWithDepthBias = pos;\n return mix(realtimeShadow, 1.0, cc_shadowNFLSInfo.w);\n }\n #if CC_SUPPORT_CASCADED_SHADOW_MAP\n bool CCGetCSMLevelWithTransition(out highp float ratio, vec3 clipPos) {\n highp float maxRange = 1.0 - cc_csmSplitsInfo.x;\n highp float minRange = cc_csmSplitsInfo.x;\n highp float thresholdInvert = 1.0 / cc_csmSplitsInfo.x;\n ratio = 0.0;\n if (clipPos.x <= minRange) {\n ratio = clipPos.x * thresholdInvert;\n return true;\n }\n if (clipPos.x >= maxRange) {\n ratio = 1.0 - (clipPos.x - maxRange) * thresholdInvert;\n return true;\n }\n if (clipPos.y <= minRange) {\n ratio = clipPos.y * thresholdInvert;\n return true;\n }\n if (clipPos.y >= maxRange) {\n ratio = 1.0 - (clipPos.y - maxRange) * thresholdInvert;\n return true;\n }\n return false;\n }\n bool CCHasCSMLevel(int level, vec3 worldPos) {\n highp float layerThreshold = cc_csmViewDir0[0].w;\n bool hasLevel = false;\n for (int i = 0; i < 4; i++) {\n if (i == level) {\n vec4 shadowPos = cc_matCSMViewProj[i] * vec4(worldPos.xyz, 1.0);\n vec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\n if (clipPos.x >= layerThreshold && clipPos.x <= (1.0 - layerThreshold) &&\n clipPos.y >= layerThreshold && clipPos.y <= (1.0 - layerThreshold) &&\n clipPos.z >= 0.0 && clipPos.z <= 1.0) {\n hasLevel = true;\n }\n }\n }\n return hasLevel;\n }\n void CCGetCSMLevel(out vec4 csmPos, out vec4 shadowProjDepthInfo, out vec4 shadowProjInfo, out vec3 shadowViewDir0, out vec3 shadowViewDir1, out vec3 shadowViewDir2, vec3 worldPos, int level) {\n highp float layerThreshold = cc_csmViewDir0[0].w;\n for (int i = 0; i < 4; i++) {\n vec4 shadowPos = cc_matCSMViewProj[i] * vec4(worldPos.xyz, 1.0);\n vec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\n if (clipPos.x >= layerThreshold && clipPos.x <= (1.0 - layerThreshold) &&\n clipPos.y >= layerThreshold && clipPos.y <= (1.0 - layerThreshold) &&\n clipPos.z >= 0.0 && clipPos.z <= 1.0 && i == level) {\n csmPos = cc_matCSMViewProj[i] * vec4(worldPos.xyz, 1.0);\n csmPos.xy = csmPos.xy * cc_csmAtlas[i].xy + cc_csmAtlas[i].zw;\n shadowProjDepthInfo = cc_csmProjDepthInfo[i];\n shadowProjInfo = cc_csmProjInfo[i];\n shadowViewDir0 = cc_csmViewDir0[i].xyz;\n shadowViewDir1 = cc_csmViewDir1[i].xyz;\n shadowViewDir2 = cc_csmViewDir2[i].xyz;\n }\n }\n }\n int CCGetCSMLevel(out bool isTransitionArea, out highp float transitionRatio, out vec4 csmPos, out vec4 shadowProjDepthInfo, out vec4 shadowProjInfo, out vec3 shadowViewDir0, out vec3 shadowViewDir1, out vec3 shadowViewDir2, vec3 worldPos)\n {\n int level = -1;\n highp float layerThreshold = cc_csmViewDir0[0].w;\n for (int i = 0; i < 4; i++) {\n vec4 shadowPos = cc_matCSMViewProj[i] * vec4(worldPos.xyz, 1.0);\n vec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\n if (clipPos.x >= layerThreshold && clipPos.x <= (1.0 - layerThreshold) &&\n clipPos.y >= layerThreshold && clipPos.y <= (1.0 - layerThreshold) &&\n clipPos.z >= 0.0 && clipPos.z <= 1.0 && level < 0) {\n #if CC_CASCADED_LAYERS_TRANSITION\n isTransitionArea = CCGetCSMLevelWithTransition(transitionRatio, clipPos);\n #endif\n csmPos = cc_matCSMViewProj[i] * vec4(worldPos.xyz, 1.0);\n csmPos.xy = csmPos.xy * cc_csmAtlas[i].xy + cc_csmAtlas[i].zw;\n shadowProjDepthInfo = cc_csmProjDepthInfo[i];\n shadowProjInfo = cc_csmProjInfo[i];\n shadowViewDir0 = cc_csmViewDir0[i].xyz;\n shadowViewDir1 = cc_csmViewDir1[i].xyz;\n shadowViewDir2 = cc_csmViewDir2[i].xyz;\n level = i;\n }\n }\n return level;\n }\n int CCGetCSMLevel(out vec4 csmPos, out vec4 shadowProjDepthInfo, out vec4 shadowProjInfo, out vec3 shadowViewDir0, out vec3 shadowViewDir1, out vec3 shadowViewDir2, vec3 worldPos)\n {\n bool isTransitionArea = false;\n highp float transitionRatio = 0.0;\n return CCGetCSMLevel(isTransitionArea, transitionRatio, csmPos, shadowProjDepthInfo, shadowProjInfo, shadowViewDir0, shadowViewDir1, shadowViewDir2, worldPos);\n }\n float CCCSMFactorBase(out vec4 csmPos, out vec4 csmPosWithBias, vec3 worldPos, vec3 N, vec2 shadowBias)\n {\n bool isTransitionArea = false;\n highp float ratio = 0.0;\n csmPos = vec4(1.0);\n vec4 shadowProjDepthInfo, shadowProjInfo;\n vec3 shadowViewDir0, shadowViewDir1, shadowViewDir2;\n int level = -1;\n #if CC_CASCADED_LAYERS_TRANSITION\n level = CCGetCSMLevel(isTransitionArea, ratio, csmPos, shadowProjDepthInfo, shadowProjInfo, shadowViewDir0, shadowViewDir1, shadowViewDir2, worldPos);\n #else\n level = CCGetCSMLevel(csmPos, shadowProjDepthInfo, shadowProjInfo, shadowViewDir0, shadowViewDir1, shadowViewDir2, worldPos);\n #endif\n if (level < 0) { return 1.0; }\n vec4 pos = ApplyShadowDepthBias_FaceNormal(csmPos, N, shadowBias.y, shadowViewDir0, shadowViewDir1, shadowViewDir2, shadowProjInfo.xy);\n pos = ApplyShadowDepthBias_Orthographic(pos, shadowBias.x, shadowProjDepthInfo.x, shadowProjDepthInfo.y);\n csmPosWithBias = pos;\n float realtimeShadow = 1.0;\n #if CC_DIR_SHADOW_PCF_TYPE == 3\n realtimeShadow = CCGetDirLightShadowFactorSoft5X(pos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 2\n realtimeShadow = CCGetDirLightShadowFactorSoft3X(pos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 1\n realtimeShadow = CCGetDirLightShadowFactorSoft(pos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 0\n realtimeShadow = CCGetDirLightShadowFactorHard(pos);\n #endif\n #if CC_CASCADED_LAYERS_TRANSITION\n vec4 nextCSMPos = vec4(1.0);\n vec4 nextShadowProjDepthInfo, nextShadowProjInfo;\n vec3 nextShadowViewDir0, nextShadowViewDir1, nextShadowViewDir2;\n float nextRealtimeShadow = 1.0;\n CCGetCSMLevel(nextCSMPos, nextShadowProjDepthInfo, nextShadowProjInfo, nextShadowViewDir0, nextShadowViewDir1, nextShadowViewDir2, worldPos, level + 1);\n bool hasNextLevel = CCHasCSMLevel(level + 1, worldPos);\n if (hasNextLevel && isTransitionArea) {\n vec4 nexPos = ApplyShadowDepthBias_FaceNormal(nextCSMPos, N, shadowBias.y, nextShadowViewDir0, nextShadowViewDir1, nextShadowViewDir2, nextShadowProjInfo.xy);\n nexPos = ApplyShadowDepthBias_Orthographic(nexPos, shadowBias.x, nextShadowProjDepthInfo.x, nextShadowProjDepthInfo.y);\n #if CC_DIR_SHADOW_PCF_TYPE == 3\n nextRealtimeShadow = CCGetDirLightShadowFactorSoft5X(nexPos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 2\n nextRealtimeShadow = CCGetDirLightShadowFactorSoft3X(nexPos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 1\n nextRealtimeShadow = CCGetDirLightShadowFactorSoft(nexPos);\n #endif\n #if CC_DIR_SHADOW_PCF_TYPE == 0\n nextRealtimeShadow = CCGetDirLightShadowFactorHard(nexPos);\n #endif\n return mix(mix(nextRealtimeShadow, realtimeShadow, ratio), 1.0, cc_shadowNFLSInfo.w);\n }\n return mix(realtimeShadow, 1.0, cc_shadowNFLSInfo.w);\n #else\n return mix(realtimeShadow, 1.0, cc_shadowNFLSInfo.w);\n #endif\n }\n #else\n int CCGetCSMLevel(out vec4 csmPos, out vec4 shadowProjDepthInfo, out vec4 shadowProjInfo, out vec3 shadowViewDir0, out vec3 shadowViewDir1, out vec3 shadowViewDir2, vec3 worldPos) {\n return -1;\n }\n float CCCSMFactorBase(out vec4 csmPos, out vec4 csmPosWithBias, vec3 worldPos, vec3 N, vec2 shadowBias) {\n csmPos = cc_matLightViewProj * vec4(worldPos, 1.0);\n return CCShadowFactorBase(csmPosWithBias, csmPos, N, shadowBias);\n }\n #endif\n float CCShadowFactorBase(vec4 shadowPos, vec3 N, vec2 shadowBias) {\n vec4 shadowPosWithDepthBias;\n return CCShadowFactorBase(shadowPosWithDepthBias, shadowPos, N, shadowBias);\n }\n float CCCSMFactorBase(vec3 worldPos, vec3 N, vec2 shadowBias) {\n vec4 csmPos, csmPosWithBias;\n return CCCSMFactorBase(csmPos, csmPosWithBias, worldPos, N, shadowBias);\n }\n float CCSpotShadowFactorBase(vec4 shadowPos, vec3 worldPos, vec2 shadowBias)\n {\n vec4 shadowPosWithDepthBias;\n return CCSpotShadowFactorBase(shadowPosWithDepthBias, shadowPos, worldPos, shadowBias);\n }\n#endif\n#if CC_USE_FOG != 4\n float LinearFog(vec4 pos, vec3 cameraPos, float fogStart, float fogEnd) {\n vec4 wPos = pos;\n float cam_dis = distance(cameraPos, wPos.xyz);\n return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n }\n float ExpFog(vec4 pos, vec3 cameraPos, float fogStart, float fogDensity, float fogAtten) {\n vec4 wPos = pos;\n float cam_dis = max(distance(cameraPos, wPos.xyz) - fogStart, 0.0) / fogAtten * 4.;\n float f = exp(-cam_dis * fogDensity);\n return f;\n }\n float ExpSquaredFog(vec4 pos, vec3 cameraPos, float fogStart, float fogDensity, float fogAtten) {\n vec4 wPos = pos;\n float cam_dis = max(distance(cameraPos, wPos.xyz) - fogStart, 0.0) / fogAtten * 4.;\n float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\n return f;\n }\n float LayeredFog(vec4 pos, vec3 cameraPos, float fogTop, float fogRange, float fogAtten) {\n vec4 wPos = pos;\n vec3 camWorldProj = cameraPos.xyz;\n camWorldProj.y = 0.;\n vec3 worldPosProj = wPos.xyz;\n worldPosProj.y = 0.;\n float fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\n float fDeltaY, fDensityIntegral;\n if (cameraPos.y > fogTop) {\n if (wPos.y < fogTop) {\n fDeltaY = (fogTop - wPos.y) / fogRange * 2.0;\n fDensityIntegral = fDeltaY * fDeltaY * 0.5;\n }\n else {\n fDeltaY = 0.;\n fDensityIntegral = 0.;\n }\n }\n else {\n if (wPos.y < fogTop) {\n float fDeltaA = (fogTop - cameraPos.y) / fogRange * 2.;\n float fDeltaB = (fogTop - wPos.y) / fogRange * 2.;\n fDeltaY = abs(fDeltaA - fDeltaB);\n fDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n }\n else {\n fDeltaY = abs(fogTop - cameraPos.y) / fogRange * 2.;\n fDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n }\n }\n float fDensity;\n if (fDeltaY != 0.) {\n fDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n }\n else {\n fDensity = 0.;\n }\n float f = exp(-fDensity);\n return f;\n }\n#endif\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\n\tfactor = LinearFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.y);\n#elif CC_USE_FOG == 1\n\tfactor = ExpFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z);\n#elif CC_USE_FOG == 2\n\tfactor = ExpSquaredFog(pos, cc_cameraPos.xyz, cc_fogBase.x, cc_fogBase.z, cc_fogAdd.z);\n#elif CC_USE_FOG == 3\n\tfactor = LayeredFog(pos, cc_cameraPos.xyz, cc_fogAdd.x, cc_fogAdd.y, cc_fogAdd.z);\n#else\n\tfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\n\tcolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\n#if CC_USE_LIGHT_PROBE\n #if CC_USE_LIGHT_PROBE\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n #endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n uniform sampler2D cc_lightingMap;\n void SampleAndDecodeLightMapColor(out vec3 lightmapColor, out float dirShadow, out float ao, sampler2D lightingMap, vec2 luv, float lum, vec3 worldNormal)\n {\n #if CC_LIGHT_MAP_VERSION > 2\n #elif CC_LIGHT_MAP_VERSION > 1\n \tvec4 dataLow = texture2D(lightingMap, luv);\n \tvec4 dataHigh = texture2D(lightingMap, luv + vec2(0.5, 0.0));\n \tlightmapColor.xyz = dataLow.xyz + dataHigh.xyz * 0.00392156862745098;\n lightmapColor.rgb *= lum;\n \tdirShadow = dataLow.a;\n \tao = dataHigh.a;\n #else\n vec4 lightmap = texture2D(lightingMap, luv);\n lightmapColor = lightmap.rgb * lum;\n \tdirShadow = lightmap.a;\n \tao = 1.0;\n #endif\n }\n void GetLightMapColor(out vec3 lightmapColor, out float dirShadow, out float ao, sampler2D lightingMap, vec2 luv, float lum, vec3 worldNormal)\n {\n \tvec4 lightmap;\n \tvec2 occlusion;\n \tSampleAndDecodeLightMapColor(lightmapColor, dirShadow, ao, lightingMap, luv, lum, worldNormal);\n #if CC_USE_HDR\n lightmapColor.rgb *= cc_exposure.w * cc_exposure.x;\n #endif\n }\n#endif\n uniform vec4 baseColor;\n uniform vec4 colorScaleAndCutoff;\n uniform vec4 shadeColor1;\n uniform vec4 shadeColor2;\n uniform vec4 specular;\n uniform vec4 shadeParams;\n uniform vec4 miscParams;\n uniform vec4 emissive;\n uniform vec4 emissiveScaleAndStrenth;\n#if USE_BASE_COLOR_MAP\n uniform sampler2D baseColorMap;\n#endif\n#if USE_NORMAL_MAP\n uniform sampler2D normalMap;\n#endif\n#if USE_1ST_SHADE_MAP\n uniform sampler2D shadeMap1;\n#endif\n#if USE_2ND_SHADE_MAP\n uniform sampler2D shadeMap2;\n#endif\n#if USE_SPECULAR_MAP\n uniform sampler2D specularMap;\n#endif\n#if USE_EMISSIVE_MAP\n uniform sampler2D emissiveMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\n#define CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TOONSHADE\nvoid SurfacesFragmentModifyBaseColorAndToonShade(out vec4 baseColorAndTransparency, out vec3 shade1, out vec3 shade2)\n{\n shade2 = shadeColor2.rgb * colorScaleAndCutoff.rgb;\n #if USE_2ND_SHADE_MAP\n shade2 *= SRGBToLinear(texture2D(shadeMap2, FSInput_texcoord).rgb);\n #endif\n shade1 = shadeColor1.rgb * colorScaleAndCutoff.rgb;\n #if USE_1ST_SHADE_MAP\n shade1 *= SRGBToLinear(texture2D(shadeMap1, FSInput_texcoord).rgb);\n #if SHADE_MAP_1_AS_SHADE_MAP_2\n shade2 *= shade1.rgb;\n #endif\n #endif\n vec4 color = baseColor;\n #if USE_BASE_COLOR_MAP\n vec4 texColor = texture2D(baseColorMap, FSInput_texcoord);\n texColor.rgb = SRGBToLinear(texColor.rgb);\n color *= texColor;\n #if BASE_COLOR_MAP_AS_SHADE_MAP_1\n shade1 *= texColor.rgb;\n #endif\n #if BASE_COLOR_MAP_AS_SHADE_MAP_2\n shade2 *= texColor.rgb;\n #endif\n #endif\n baseColorAndTransparency = color;\n baseColorAndTransparency.rgb *= colorScaleAndCutoff.xyz;\n #if USE_ALPHA_TEST\n if (baseColorAndTransparency.ALPHA_TEST_CHANNEL < colorScaleAndCutoff.w) discard;\n #endif\n}\n#define CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY\n#define CC_SURFACES_FRAGMENT_MODIFY_WORLD_NORMAL\nvec3 SurfacesFragmentModifyWorldNormal()\n{\n vec3 normal = FSInput_worldNormal;\n #if USE_NORMAL_MAP\n vec3 nmmp = texture2D(normalMap, FSInput_texcoord).xyz - vec3(0.5);\n normal = CalculateNormalFromTangentSpace(nmmp, emissiveScaleAndStrenth.w, normalize(normal.xyz), normalize(FSInput_worldTangent), FSInput_mirrorNormal);\n #endif\n return normalize(normal);\n}\n#define CC_SURFACES_FRAGMENT_MODIFY_EMISSIVE\nvec3 SurfacesFragmentModifyEmissive()\n{\n vec3 emissive = emissive.rgb * emissiveScaleAndStrenth.xyz;\n #if USE_EMISSIVE_MAP\n emissive *= SRGBToLinear(texture2D(emissiveMap, FSInput_texcoord).rgb);\n #endif\n return emissive;\n}\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_STEP_AND_FEATHER\nvec4 SurfacesFragmentModifyToonStepAndFeather()\n{\n return shadeParams;\n}\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_SHADOW_COVER\nfloat SurfacesFragmentModifyToonShadowCover()\n{\n return miscParams.x;\n}\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_SPECULAR\nvec4 SurfacesFragmentModifyToonSpecular()\n{\n vec4 specularParam = specular;\n #if USE_SPECULAR_MAP\n specularParam.rgb *= SRGBToLinear(texture2D(specularMap, FSInput_texcoord).rgb);\n #endif\n return specularParam;\n}\nstruct LightingIntermediateData\n{\n vec3 N, H, L, V;\n float distToLight, distToLightSqr;\n float distToCamera, distToCameraSqr;\n float angleAttenuation, distAttenuation;\n float NoL, NoV, NoH, VoH;\n float NoLSat, NoVSat, NoHSat;\n float NoVAbsSat, VoHAbsSat;\n #if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\n vec3 worldPosition, worldPosition_fract_part;\n #else\n vec3 worldPosition;\n #endif\n vec3 T, B;\n float specularParam;\n float ior, layerOpacity;\n#if CC_SURFACES_LIGHTING_ANISOTROPIC\n float anisotropyShape;\n#endif\n#if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n vec4 shadowPosAndDepth;\n vec4 transmitDiffuseParams;\n#endif\n#if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR || CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n vec4 transmitScatteringParams;\n vec3 outScatteringColor, inScatteringColor;\n#endif\n#if CC_SURFACES_LIGHTING_TT\n vec3 baseColorTT;\n float ttIntensity, ttScatterCoef;\n#endif\n};\nvoid CCSurfacesLightingGetIntermediateData_PerPixel(inout LightingIntermediateData data, vec3 worldNormal, vec3 worldPos, vec3 worldTangent, vec3 worldBinormal\n#if CC_SURFACES_LIGHTING_ANISOTROPIC\n , float anisotropyShape\n#endif\n)\n{\n data.N = worldNormal;\n data.V = cc_cameraPos.xyz - worldPos;\n data.distToCameraSqr = dot(data.V, data.V);\n data.distToCamera = sqrt(data.distToCameraSqr);\n data.V /= data.distToCamera;\n data.angleAttenuation = data.distAttenuation = 1.0;\n data.NoV = dot(data.N, data.V);\n data.NoVSat = max(data.NoV, 0.0);\n data.NoVAbsSat = max(abs(data.NoV), 0.0);\n #if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\n packHighpData(data.worldPosition, data.worldPosition_fract_part, worldPos);\n #else\n data.worldPosition = worldPos;\n #endif\n data.T = worldTangent;\n data.B = worldBinormal;\n#if CC_SURFACES_LIGHTING_ANISOTROPIC\n data.anisotropyShape = anisotropyShape;\n#endif\n#if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR || CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n data.outScatteringColor = vec3(1.0);\n data.inScatteringColor = vec3(0.0);\n data.transmitScatteringParams = vec4(0.0);\n#endif\n#if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n data.shadowPosAndDepth = vec4(0.0, 0.0, SURFACES_MAX_TRANSMIT_DEPTH_VALUE, SURFACES_MAX_TRANSMIT_DEPTH_VALUE);\n#endif\n#if CC_SURFACES_LIGHTING_TT\n data.baseColorTT = vec3(0.0);\n data.ttIntensity = data.ttScatterCoef = 0.0;\n#endif\n}\nvoid CCSurfacesLightingGetIntermediateData_PerLight(inout LightingIntermediateData data, vec3 lightDirWithDist)\n{\n data.L = lightDirWithDist;\n data.distToLightSqr = dot(data.L, data.L);\n data.distToLight = sqrt(data.distToLightSqr);\n data.L /= data.distToLight;\n data.H = normalize(data.L + data.V);\n data.NoL = dot(data.N, data.L);\n data.NoH = dot(data.N, data.H);\n data.VoH = dot(data.V, data.H);\n data.NoLSat = max(data.NoL, 0.0);\n data.NoHSat = max(data.NoH, 0.0);\n data.VoHAbsSat = max(abs(data.VoH), 0.0);\n}\nstruct LightingResult\n{\n vec3 diffuseColorWithLighting, specularColorWithLighting;\n vec3 directDiffuse, directSpecular, directGF;\n vec3 environmentDiffuse, environmentSpecular, environmentGF;\n float shadow, ao;\n vec3 lightmapColor;\n vec3 emissive;\n vec3 fresnel;\n#if CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n vec3 directDiffuseSubLayers, directSpecularSubLayers;\n vec3 environmentDiffuseSubLayers, environmentSpecularSubLayers;\n#endif\n#if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n vec3 directTransmitSpecular, environmentTransmitSpecular;\n#endif\n#if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n vec3 directTransmitDiffuse, environmentTransmitDiffuse;\n#endif\n#if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n vec3 direct2ndSpecular, environment2ndSpecular;\n vec3 specularColorWithLighting2ndSpecular;\n vec3 directGF2ndSpecular, environmentGF2ndSpecular;\n vec3 directSubLayerF, environmentSubLayerF;\n#endif\n#if CC_SURFACES_LIGHTING_TT\n vec3 directTT;\n vec3 diffuseColorWithLightingTT;\n#endif\n};\nstruct LightingMiscData\n{\n float lightType;\n vec3 lightPos, lightDir;\n vec4 lightColorAndIntensity;\n vec4 lightSizeRangeAngle;\n};\n#define DiffuseCoefficient_EnergyConservation INV_PI\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\n float factor = distSqr * invSqrAttRadius;\n float smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\n return smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\n float attenuation = 1.0 / max(distSqr, 0.01*0.01);\n attenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\n return attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\n float cd = dot(litDir, L);\n float attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\n return (attenuation * attenuation);\n}\nfloat GetOutOfRange (vec3 worldPos, vec3 lightPos, vec3 lookAt, vec3 right, vec3 BoundingHalfSizeVS) {\n vec3 v = vec3(0.0);\n vec3 up = cross(right, lookAt);\n worldPos -= lightPos;\n v.x = dot(worldPos, right);\n v.y = dot(worldPos, up);\n v.z = dot(worldPos, lookAt);\n vec3 result = step(abs(v), BoundingHalfSizeVS);\n return result.x * result.y * result.z;\n}\nfloat CalculateDistanceAttenuation(float distToLightSqr, float lightRadius, float lightRange, float lightType)\n{\n float attRadiusSqrInv = 1.0 / max(lightRange, 0.01);\n attRadiusSqrInv *= attRadiusSqrInv;\n float litRadiusSqr = lightRadius * lightRadius;\n float edgeAttenuation = (IS_POINT_LIGHT(lightType) || IS_RANGED_DIRECTIONAL_LIGHT(lightType)) ? 1.0 : litRadiusSqr / max(litRadiusSqr, distToLightSqr);\n return GetDistAtt(distToLightSqr, attRadiusSqrInv) * edgeAttenuation;\n}\nfloat CalculateAngleAttenuation(vec3 spotLightDir, vec3 L, float cosAngleOuter)\n{\n float cosInner = max(dot(spotLightDir, L), 0.01);\n float litAngleScale = 1.0 / max(0.001, cosInner - cosAngleOuter);\n float litAngleOffset = -cosAngleOuter * litAngleScale;\n return GetAngleAtt(L, spotLightDir, litAngleScale, litAngleOffset);\n}\nbool CCSurfacesLightingEnableShadow(in float NoL)\n{\n return NoL > 0.0;\n}\nfloat CCSurfacesLightingCalculateDistanceAttenuation(in LightingIntermediateData lightingData, in vec4 lightSizeRangeAngle, in float lightType)\n{\n return CalculateDistanceAttenuation(lightingData.distToLightSqr, lightSizeRangeAngle.x, lightSizeRangeAngle.y, lightType);\n}\nfloat CCSurfacesLightingCalculateAngleAttenuation(in LightingIntermediateData lightingData, in vec4 lightSizeRangeAngle, in vec3 spotLightDir)\n{\n return CalculateAngleAttenuation(spotLightDir, lightingData.L, lightSizeRangeAngle.z);\n}\nvoid CCSurfacesLightingCalculateDirect(out vec3 lightingDiffuse, out vec3 lightingSpecular, in LightingIntermediateData lightingData, in vec4 lightSourceColorAndIntensity)\n{\n vec3 irradiance = lightSourceColorAndIntensity.rgb * lightSourceColorAndIntensity.w;\n lightingDiffuse = irradiance;\n#if CC_FORWARD_ADD\n float NL = 0.5 * lightingData.NoL + 0.5;\n lightingDiffuse *= NL;\n#endif\n float NH = 0.5 * lightingData.NoH + 0.5;\n float specularWeight = 1.0 - pow(lightingData.specularParam, 5.0);\n float specularMask = step(specularWeight + EPSILON_LOWP, NH);\n lightingSpecular = irradiance * specularMask;\n}\nvoid CCSurfacesLightingCalculateEnvironment(out vec3 lightingDiffuse, out vec3 lightingSpecular, in LightingIntermediateData lightingData, float lightIntensity)\n{\n lightingDiffuse = vec3(0.0);\n lightingSpecular = vec3(0.0);\n}\n#if CC_SURFACES_LIGHTING_USE_FRESNEL\nvec3 CCSurfaceLightingCalculateExtraFresnel(in LightingIntermediateData lightingData)\n{\n return vec3(1.0);\n}\n#endif\nvoid CCSurfaceLightingCalculateDirectFresnel(out vec3 fresnel, in LightingIntermediateData lightingData, vec3 specularColor, in vec3 environmentGF)\n{\n fresnel = vec3(1.0);\n}\nvoid CCSurfaceLightingCalculateEnvironmentFresnel(out vec3 integratedGF, out vec3 integratedF, in LightingIntermediateData lightingData, vec3 specularColor)\n{\n integratedF = integratedGF = vec3(1.0);\n}\nstruct SurfacesMaterialData\n{\n #if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\n vec3 worldPos, worldPos_fract_part;\n #else\n vec3 worldPos;\n #endif\n vec4 baseColor;\n vec4 specular;\n vec3 worldNormal;\n vec3 emissive;\n vec3 shade1;\n vec3 shade2;\n float baseStep;\n float baseFeather;\n float shadeStep;\n float shadeFeather;\n float shadowCover;\n};\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TRANSPARENCY\nvec4 SurfacesFragmentModifyBaseColorAndTransparency()\n{\n return FSInput_vertexColor;\n}\n#endif\n#ifndef CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_WORLD_NORMAL\nvec3 SurfacesFragmentModifyWorldNormal()\n{\n return normalize(FSInput_worldNormal);\n}\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_WORLD_TANGENT_AND_BINORMAL\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_IOR\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_ANISOTROPY_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_EMISSIVE\nvec3 SurfacesFragmentModifyEmissive()\n{\n return vec3(0.0, 0.0, 0.0);\n}\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_PBRPARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_SCATTERING_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_IN_SCATTERING_COLOR\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_OUT_SCATTERING_COLOR\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRANSMIT_DIFFUSE_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRT_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TRT_COLOR\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TT_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TT_COLOR\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_SSS_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_DUAL_LOBE_SPECULAR_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_CLEAR_COAT_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_CLEAR_COAT_COLOR\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_CLEAR_COAT_WORLD_NORMAL\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_SHEEN_PARAMS\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_SHEEN_COLOR\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_SHARED_DATA\nvoid SurfacesFragmentModifySharedData(inout SurfacesMaterialData surfaceData)\n{\n}\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TOONSHADE\nvoid SurfacesFragmentModifyBaseColorAndToonShade(out vec4 baseColorAndTransparency, out vec3 shade1, out vec3 shade2, in vec3 baseColor)\n{\n baseColorAndTransparency = FSInput_vertexColor;\n shade1 = shade2 = vec3(0.0);\n}\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TOON_STEP_AND_FEATHER\nvec4 SurfacesFragmentModifyToonStepAndFeather()\n{\n return vec3(0.8, 0.001, 0.5, 0.001);\n}\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TOON_SHADOW_COVER\nfloat SurfacesFragmentModifyToonShadowCover()\n{\n return 0.5;\n}\n#endif\n#ifndef CC_SURFACES_FRAGMENT_MODIFY_TOON_SPECULAR\nvec4 SurfacesFragmentModifyToonSpecular()\n{\n return vec4(1.0, 1.0, 1.0, 0.3);\n}\n#endif\nvoid CCSurfacesFragmentGetMaterialData(inout SurfacesMaterialData surfaceData)\n{\n #if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\n packHighpData(surfaceData.worldPos, surfaceData.worldPos_fract_part, FSInput_worldPos);\n #else\n surfaceData.worldPos = FSInput_worldPos;\n #endif\n surfaceData.worldNormal = SurfacesFragmentModifyWorldNormal();\n surfaceData.emissive = SurfacesFragmentModifyEmissive();\n SurfacesFragmentModifyBaseColorAndToonShade(surfaceData.baseColor, surfaceData.shade1, surfaceData.shade2);\n surfaceData.specular = SurfacesFragmentModifyToonSpecular();\n surfaceData.shadowCover = SurfacesFragmentModifyToonShadowCover();\n vec4 shaderParams = SurfacesFragmentModifyToonStepAndFeather();\n surfaceData.baseStep = shadeParams.x;\n surfaceData.baseFeather = shadeParams.y;\n surfaceData.shadeStep = shadeParams.z;\n surfaceData.shadeFeather = shadeParams.w;\n SurfacesFragmentModifySharedData(surfaceData);\n#if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_NORMAL_MAP)\n surfaceData.worldNormal = normalize(FSInput_worldNormal);\n#endif\n#if CC_USE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_LIGHTING_ENABLE_WITH_ALBEDO) {\n float brightBase = dot(GRAY_VECTOR, surfaceData.baseColor.rgb);\n float brightShade1 = dot(GRAY_VECTOR, surfaceData.shade1.rgb);\n float brightShade2 = dot(GRAY_VECTOR, surfaceData.shade2.rgb);\n surfaceData.baseColor.rgb = vec3(1.0);\n surfaceData.shade1.rgb = vec3(brightShade1 / brightBase);\n surfaceData.shade2.rgb = vec3(brightShade2 / brightBase);\n surfaceData.specular.rgb = vec3(1.0);\n }\n#endif\n}\nvec3 CCSurfacesGetDiffuseColor(in SurfacesMaterialData surfaceData)\n{\n return surfaceData.shade1;\n}\nvec3 CCSurfacesGetSpecularColor(in SurfacesMaterialData surfaceData)\n{\n return surfaceData.specular.xyz;\n}\nvoid CCSurfacesLightingInitializeColorWithLighting(inout vec3 diffuseColorWithLighting, inout vec3 specularColorWithLighting, in SurfacesMaterialData surfaceData, in LightingIntermediateData lightingData)\n{\n diffuseColorWithLighting = vec3(0.0);\n specularColorWithLighting = surfaceData.specular.xyz * surfaceData.baseStep;\n}\nvoid CCSurfacesLightingCalculateColorWithLighting(inout vec3 diffuseColorWithLighting, inout vec3 specularColorWithLighting, in SurfacesMaterialData surfaceData, in LightingIntermediateData lightingData)\n{\n float NL = 0.5 * lightingData.NoL + 0.5;\n vec3 diffuse = mix(surfaceData.shade1, surfaceData.shade2,\n clamp(1.0 + (surfaceData.shadeStep - surfaceData.shadeFeather - NL) / surfaceData.shadeFeather, 0.0, 1.0));\n diffuse = mix(surfaceData.baseColor.rgb, diffuse,\n clamp(1.0 + (surfaceData.baseStep - surfaceData.baseFeather - NL) / surfaceData.baseFeather, 0.0, 1.0));\n diffuseColorWithLighting = diffuse * surfaceData.baseStep;\n}\nvoid CCSurfacesInitializeLightingIntermediateData(inout LightingIntermediateData lightingData, in SurfacesMaterialData surfaceData)\n{\n vec3 worldPos;\n #if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\n worldPos = unpackHighpData(surfaceData.worldPos, surfaceData.worldPos_fract_part);\n #else\n worldPos = surfaceData.worldPos;\n #endif\n CCSurfacesLightingGetIntermediateData_PerPixel(lightingData, surfaceData.worldNormal, worldPos, vec3(0.0), vec3(0.0));\n lightingData.specularParam = surfaceData.specular.a;\n lightingData.ior = 1.0;\n}\nvoid CCSurfacesLightingCalculateIntermediateData_PerLight(inout LightingIntermediateData lightingData, in SurfacesMaterialData surfaceData, vec3 lightDirWithDist)\n{\n CCSurfacesLightingGetIntermediateData_PerLight(lightingData, lightDirWithDist);\n}\nvoid CCSurfacesInitializeLightingResult(inout LightingResult lightingResult, in SurfacesMaterialData surfaceData)\n{\n lightingResult.emissive = surfaceData.emissive;\n}\nvoid CCSurfacesInitializeLightingResult(inout LightingResult lightingResult)\n{\n lightingResult.directDiffuse = lightingResult.directSpecular = vec3(0.0);\n}\nvoid CCSurfacesAccumulateLightingResult(inout LightingResult lightingResultAccumulated, in LightingResult lightingResult)\n{\n lightingResultAccumulated.directDiffuse += lightingResult.directDiffuse * lightingResult.shadow;\n lightingResultAccumulated.directSpecular += lightingResult.directSpecular * lightingResult.shadow;\n}\n#if CC_PIPELINE_TYPE == 1\n vec4 CCSurfacesDeferredOutputBaseColor(in SurfacesMaterialData surfaceData)\n {\n return surfaceData.baseColor;\n }\n vec4 CCSurfacesDeferredOutputNormalMR(in SurfacesMaterialData surfaceData)\n {\n return vec4(float32x3_to_oct(surfaceData.worldNormal), 0.5, 0.0);\n }\n vec4 CCSurfacesDeferredOutputEmissiveAO(in SurfacesMaterialData surfaceData)\n {\n return vec4(surfaceData.emissive, 1.0);\n }\n#endif\nvec4 CCSurfacesShading(in SurfacesMaterialData surfaceData, in LightingResult lightingResult)\n{\n vec4 color = vec4(0.0, 0.0, 0.0, surfaceData.baseColor.a);\n#if CC_FORWARD_ADD\n color.xyz += lightingResult.directDiffuse * lightingResult.diffuseColorWithLighting;\n color.xyz += lightingResult.directSpecular * lightingResult.specularColorWithLighting;\n#else\n float lightmapCoef = 0.0;\n#if CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n color.xyz += (\n mix(lightingResult.directDiffuse, lightingResult.lightmapColor, lightmapCoef) * lightingResult.diffuseColorWithLighting\n + lightingResult.directSpecular * lightingResult.specularColorWithLighting)\n * lightingResult.shadow\n ;\n#else\n LightingIntermediateData lightingData;\n lightingData.NoL = -1.0;\n vec3 backLightingDiffuse, backLightingSpecular;\n CCSurfacesLightingInitializeColorWithLighting(backLightingDiffuse, backLightingSpecular, surfaceData, lightingData);\n CCSurfacesLightingCalculateColorWithLighting(backLightingDiffuse, backLightingSpecular, surfaceData, lightingData);\n color.xyz +=\n mix(lightingResult.directDiffuse, lightingResult.lightmapColor, lightmapCoef) * mix(backLightingDiffuse, lightingResult.diffuseColorWithLighting, lightingResult.shadow)\n + lightingResult.directSpecular * lightingResult.specularColorWithLighting * lightingResult.shadow\n ;\n#endif\n color.xyz += lightingResult.emissive;\n#endif\n return color;\n}\n#if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_SINGLE\nbool CCSurfacesDebugViewSurfaceData(inout vec4 color, in SurfacesMaterialData surfaceData)\n{\n bool enableMaterialAlpha = true;\n float scalar;\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(surfaceData.worldNormal * 0.5 + vec3(0.5), 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(0.0, 0.0, 0.0, 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(0.0, 0.0, 0.0, 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSPARENCY)) && (cc_surfaceTransform.y != 3.0)))\n {\n scalar = surfaceData.baseColor.a;\n color = vec4(scalar, scalar, scalar, 1.0);\n enableMaterialAlpha = false;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_BASE_COLOR)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(LinearToSRGB(surfaceData.baseColor.rgb), 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(LinearToSRGB(CCSurfacesGetDiffuseColor(surfaceData)), 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(LinearToSRGB(CCSurfacesGetSpecularColor(surfaceData)), 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY)) && (cc_surfaceTransform.y != 3.0)))\n {\n scalar = surfaceData.specular.a;\n color = vec4(scalar, scalar, scalar, 1.0);\n }\n return enableMaterialAlpha;\n}\n#endif\n#if (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\n #if CC_FORWARD_ADD\n void CCSurfacesLighting(inout LightingResult lightingResultAccumulated, in SurfacesMaterialData surfaceData, in vec2 shadowBias)\n {\n vec3 worldPos;\n #if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\n worldPos = unpackHighpData(surfaceData.worldPos, surfaceData.worldPos_fract_part);\n #else\n worldPos = surfaceData.worldPos;\n #endif\n CCSurfacesInitializeLightingResult(lightingResultAccumulated);\n LightingIntermediateData lightingData;\n CCSurfacesInitializeLightingIntermediateData(lightingData, surfaceData);\n LightingResult lightingResult;\n CCSurfacesLightingInitializeColorWithLighting(lightingResult.diffuseColorWithLighting, lightingResult.specularColorWithLighting, surfaceData, lightingData);\n lightingResultAccumulated.diffuseColorWithLighting = lightingResult.diffuseColorWithLighting;\n lightingResultAccumulated.specularColorWithLighting = lightingResult.specularColorWithLighting;\n #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n vec3 diff;\n SurfacesMaterialData surfaceData2ndSpecular;\n CCSurfacesGetSurfacesMaterialData2ndSpecular(surfaceData2ndSpecular, surfaceData);\n CCSurfacesLightingInitializeColorWithLighting(diff, lightingResult.specularColorWithLighting2ndSpecular, surfaceData2ndSpecular, lightingData);\n lightingResultAccumulated.specularColorWithLighting2ndSpecular = lightingResult.specularColorWithLighting2ndSpecular;\n #endif\n int numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\n for (int i = 0; i < LIGHTS_PER_PASS; i++) {\n if (i >= numLights) break;\n vec3 lightDirWithLength = IS_RANGED_DIRECTIONAL_LIGHT(cc_lightPos[i].w) ? -normalize(cc_lightDir[i].xyz) : cc_lightPos[i].xyz - worldPos;\n CCSurfacesLightingCalculateIntermediateData_PerLight(lightingData, surfaceData, lightDirWithLength);\n CCSurfacesLightingCalculateColorWithLighting(lightingResult.diffuseColorWithLighting, lightingResult.specularColorWithLighting, surfaceData, lightingData);\n vec3 diffuseLighting, specularLighting;\n CCSurfacesLightingCalculateDirect(diffuseLighting, specularLighting, lightingData, cc_lightColor[i]);\n #if CC_SURFACES_LIGHTING_USE_FRESNEL\n vec3 fresnel = CCSurfaceLightingCalculateExtraFresnel(lightingData);\n #else\n vec3 fresnel = vec3(1.0);\n #endif\n lightingResult.fresnel = fresnel;\n float shadow = 1.0;\n #if CC_RECEIVE_SHADOW && CC_SHADOW_TYPE == 2\n if (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) {\n vec4 shadowPos = vec4(0.0), shadowPosWithDepthBias = vec4(0.0);\n if (CCSurfacesLightingEnableShadow(lightingData.NoL)) {\n shadowPos = cc_matLightViewProj * vec4(worldPos, 1.0);\n shadow = CCSpotShadowFactorBase(shadowPosWithDepthBias, shadowPos, worldPos, shadowBias);\n }\n #if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE && CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n vec3 shadowNDCPos;\n bool isExceedShadowMap = !GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias);\n lightingData.shadowPosAndDepth.xy = shadowNDCPos.xy;\n lightingData.shadowPosAndDepth.z = isExceedShadowMap ? 0.0 : GetViewSpaceDepthFromNDCDepth_Perspective(shadowNDCPos.z, shadowPosWithDepthBias.w, cc_shadowInvProjDepthInfo.x, cc_shadowInvProjDepthInfo.y);\n lightingData.shadowPosAndDepth.w = isExceedShadowMap ? lightingData.shadowPosAndDepth.w : GetViewSpaceDepthFromNDCDepth_Perspective(SampleShadowMapSoft(shadowNDCPos, cc_spotShadowMap, cc_shadowWHPBInfo.xy), shadowPosWithDepthBias.w, cc_shadowInvProjDepthInfo.x, cc_shadowInvProjDepthInfo.y);\n #endif\n }\n #endif\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_SHADOW)\n shadow = 1.0;\n #endif\n lightingResult.shadow = shadow;\n float distAtt = 1.0;\n if(IS_RANGED_DIRECTIONAL_LIGHT(cc_lightPos[i].w)) {\n distAtt = GetOutOfRange(worldPos, cc_lightPos[i].xyz, cc_lightDir[i].xyz, cc_lightSizeRangeAngle[i].xyz, cc_lightBoundingSizeVS[i].xyz);\n } else {\n distAtt = CCSurfacesLightingCalculateDistanceAttenuation(lightingData, cc_lightSizeRangeAngle[i], cc_lightPos[i].w);\n }\n float angleAtt = 1.0;\n if (IS_SPOT_LIGHT(cc_lightPos[i].w)) {\n angleAtt = CCSurfacesLightingCalculateAngleAttenuation(lightingData, cc_lightSizeRangeAngle[i], -cc_lightDir[i].xyz);\n }\n float multiplier = distAtt * angleAtt;\n lightingData.angleAttenuation = angleAtt;\n lightingData.distAttenuation = distAtt;\n lightingResult.directDiffuse = diffuseLighting * multiplier;\n lightingResult.directSpecular = specularLighting * multiplier;\n CCSurfaceLightingCalculateDirectFresnel(lightingResult.directGF, lightingData, lightingResult.specularColorWithLighting, vec3(1.0));\n vec4 attenuatedLightColorAndIntensity = vec4(cc_lightColor[i].xyz, cc_lightColor[i].w * multiplier);\n #if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n vec3 transmitSpecularLighting;\n CCSurfacesLightingCalculateDirectTransmitSpecular(transmitSpecularLighting, lightingData, attenuatedLightColorAndIntensity);\n lightingResult.directTransmitSpecular = transmitSpecularLighting * multiplier * (1.0 - fresnel);\n #endif\n #if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n LightingIntermediateData lightingDataTD;\n CCSurfacesGetLightingIntermediateDataTransmitDiffuse(lightingDataTD, lightingData, surfaceData);\n CCSurfacesLightingCalculateIntermediateData_PerLight(lightingDataTD, surfaceData, lightDirWithLength);\n CCSurfacesLightingCalculateDirectTransmitDiffuse(lightingResult.directTransmitDiffuse, lightingDataTD, attenuatedLightColorAndIntensity, lightingResult.shadow);\n #endif\n #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n LightingIntermediateData lightingData2ndSpecular;\n CCSurfacesInitializeLightingIntermediateData(lightingData2ndSpecular, surfaceData2ndSpecular);\n CCSurfacesLightingCalculateIntermediateData_PerLight(lightingData2ndSpecular, surfaceData, lightDirWithLength);\n #if !CC_SURFACES_LIGHTING_SHEEN\n CCSurfacesLightingCalculateDirect2ndSpecular(lightingResult.direct2ndSpecular, lightingData2ndSpecular, attenuatedLightColorAndIntensity, surfaceData2ndSpecular.intensity2ndSpecular, lightingResult.directSpecular);\n CCSurfaceLightingCalculateDirectFresnel(lightingResult.directGF2ndSpecular, lightingData2ndSpecular, lightingResult.specularColorWithLighting2ndSpecular, vec3(1.0));\n #else\n CCSurfacesLightingCalculateDirectSheen(lightingResult.direct2ndSpecular, lightingResult.directGF2ndSpecular, lightingData2ndSpecular, attenuatedLightColorAndIntensity, surfaceData2ndSpecular.intensity2ndSpecular);\n #endif\n lightingResult.direct2ndSpecular *= multiplier;\n #endif\n #if CC_SURFACES_LIGHTING_TT\n CCSurfacesLightingCalculateDirectTT(lightingResult, lightingData, attenuatedLightColorAndIntensity);\n #endif\n #if CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n lightingResult.specularColorWithLighting2ndSpecular *= surfaceData.color2ndSpecular;\n CCSurfacesLightingCalculateDirectMultiLayerBlending(lightingResult, lightingData2ndSpecular);\n #endif\n #ifdef CC_SURFACES_LIGHTING_MODIFY_FINAL_RESULT\n LightingMiscData miscData;\n miscData.lightType = cc_lightPos[i].w;\n miscData.lightPos = cc_lightPos[i].xyz;\n miscData.lightDir = cc_lightDir[i].xyz;\n miscData.lightColorAndIntensity = cc_lightColor[i];\n miscData.lightSizeRangeAngle = cc_lightSizeRangeAngle[i];\n SurfacesLightingModifyFinalResult(lightingResult, lightingData, surfaceData, miscData);\n #endif\n CCSurfacesAccumulateLightingResult(lightingResultAccumulated, lightingResult);\n }\n }\n #else\n void CCSurfacesLighting(inout LightingResult lightingResult, in SurfacesMaterialData surfaceData, in vec2 shadowBias)\n {\n vec3 worldPos;\n #if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\n worldPos = unpackHighpData(surfaceData.worldPos, surfaceData.worldPos_fract_part);\n #else\n worldPos = surfaceData.worldPos;\n #endif\n LightingIntermediateData lightingData;\n CCSurfacesInitializeLightingIntermediateData(lightingData, surfaceData);\n CCSurfacesInitializeLightingResult(lightingResult, surfaceData);\n CCSurfacesLightingInitializeColorWithLighting(lightingResult.diffuseColorWithLighting, lightingResult.specularColorWithLighting, surfaceData, lightingData);\n CCSurfacesLightingCalculateIntermediateData_PerLight(lightingData, surfaceData, -cc_mainLitDir.xyz);\n lightingResult.shadow = 1.0;\n #if CC_RECEIVE_SHADOW && CC_SHADOW_TYPE == 2\n if (cc_mainLitDir.w > 0.0) {\n vec4 shadowPos = vec4(0.0), shadowPosWithDepthBias = vec4(0.0);\n vec4 shadowProjDepthInfo = vec4(0.0);\n vec3 shadowNDCPos;\n bool isExceedShadowMap = true;\n if (CCSurfacesLightingEnableShadow(lightingData.NoL)) {\n #if CC_DIR_LIGHT_SHADOW_TYPE == 2\n lightingResult.shadow = CCCSMFactorBase(worldPos, lightingData.N, shadowBias);\n #if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE && CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n vec4 shadowProjInfo;\n vec3 shadowViewDir0, shadowViewDir1, shadowViewDir2;\n isExceedShadowMap = 0 > CCGetCSMLevel(shadowPosWithDepthBias, shadowProjDepthInfo, shadowProjInfo, shadowViewDir0, shadowViewDir1, shadowViewDir2, worldPos);\n GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias);\n #endif\n #endif\n #if CC_DIR_LIGHT_SHADOW_TYPE == 1\n shadowPos = cc_matLightViewProj * vec4(worldPos, 1.0);\n lightingResult.shadow = CCShadowFactorBase(shadowPosWithDepthBias, shadowPos, lightingData.N, shadowBias);\n shadowProjDepthInfo = cc_shadowProjDepthInfo;\n isExceedShadowMap = !GetShadowNDCPos(shadowNDCPos, shadowPosWithDepthBias);\n #endif\n }\n #if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE && CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n lightingData.shadowPosAndDepth.xy = shadowNDCPos.xy;\n lightingData.shadowPosAndDepth.z = isExceedShadowMap ? 0.0 : GetViewSpaceDepthFromNDCDepth_Orthgraphic(shadowNDCPos.z, shadowProjDepthInfo.x, shadowProjDepthInfo.y);\n lightingData.shadowPosAndDepth.w = isExceedShadowMap ? lightingData.shadowPosAndDepth.w : GetViewSpaceDepthFromNDCDepth_Orthgraphic(SampleShadowMapSoft(shadowNDCPos, cc_shadowMap, cc_shadowWHPBInfo.xy), shadowProjDepthInfo.x, shadowProjDepthInfo.y);\n #endif\n }\n #endif\n lightingResult.lightmapColor = vec3(0.0);\n #if CC_SURFACES_USE_LIGHT_MAP && !CC_FORWARD_ADD\n float lightmapShadow, lightmapAO;\n GetLightMapColor(lightingResult.lightmapColor, lightmapShadow, lightmapAO, cc_lightingMap, FSInput_lightMapUV.xy, FSInput_lightMapUV.z, surfaceData.worldNormal);\n #if CC_SURFACES_USE_LIGHT_MAP == LIGHT_MAP_TYPE_INDIRECT_OCCLUSION\n lightingResult.shadow *= lightmapShadow;\n #endif\n lightingResult.ao *= lightmapAO;\n #endif\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_SHADOW)\n lightingResult.shadow = 1.0;\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_AO)\n lightingResult.ao = 1.0;\n #endif\n vec3 unused;\n CCSurfacesLightingCalculateEnvironment(lightingResult.environmentDiffuse, lightingResult.environmentSpecular, lightingData, cc_ambientSky.w);\n CCSurfaceLightingCalculateEnvironmentFresnel(lightingResult.environmentGF, unused, lightingData, lightingResult.specularColorWithLighting);\n lightingResult.directDiffuse = lightingResult.directSpecular = vec3(0.0);\n #if !CC_DISABLE_DIRECTIONAL_LIGHT && !CC_FORWARD_ADD\n CCSurfacesLightingCalculateColorWithLighting(lightingResult.diffuseColorWithLighting, lightingResult.specularColorWithLighting, surfaceData, lightingData);\n CCSurfacesLightingCalculateDirect(lightingResult.directDiffuse, lightingResult.directSpecular, lightingData, cc_mainLitColor);\n CCSurfaceLightingCalculateDirectFresnel(lightingResult.directGF, lightingData, lightingResult.specularColorWithLighting, lightingResult.environmentGF);\n #endif\n #if CC_SURFACES_LIGHTING_USE_FRESNEL\n lightingResult.fresnel = CCSurfaceLightingCalculateExtraFresnel(lightingData);\n #else\n lightingResult.fresnel = vec3(1.0);\n #endif\n #if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n CCSurfacesLightingCalculateDirectTransmitSpecular(lightingResult.directTransmitSpecular, lightingData, cc_mainLitColor);\n CCSurfacesLightingCalculateEnvironmentTransmitSpecular(lightingResult.environmentTransmitSpecular, lightingData, cc_ambientSky.w);\n #endif\n #if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n LightingIntermediateData lightingDataTD;\n CCSurfacesGetLightingIntermediateDataTransmitDiffuse(lightingDataTD, lightingData, surfaceData);\n CCSurfacesLightingCalculateIntermediateData_PerLight(lightingDataTD, surfaceData, -cc_mainLitDir.xyz);\n CCSurfacesLightingCalculateDirectTransmitDiffuse(lightingResult.directTransmitDiffuse, lightingDataTD, cc_mainLitColor, lightingResult.shadow);\n CCSurfacesLightingCalculateEnvironmentTransmitDiffuse(lightingResult.environmentTransmitDiffuse, lightingDataTD, cc_ambientSky.w, lightingResult.ao, -cc_mainLitDir.xyz);\n #endif\n #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n SurfacesMaterialData surfaceData2ndSpecular;\n CCSurfacesGetSurfacesMaterialData2ndSpecular(surfaceData2ndSpecular, surfaceData);\n LightingIntermediateData lightingData2ndSpecular;\n CCSurfacesInitializeLightingIntermediateData(lightingData2ndSpecular, surfaceData2ndSpecular);\n CCSurfacesLightingCalculateIntermediateData_PerLight(lightingData2ndSpecular, surfaceData2ndSpecular, -cc_mainLitDir.xyz);\n vec3 diff;\n CCSurfacesLightingInitializeColorWithLighting(diff, lightingResult.specularColorWithLighting2ndSpecular, surfaceData2ndSpecular, lightingData2ndSpecular);\n #if !CC_SURFACES_LIGHTING_SHEEN\n CCSurfacesLightingCalculateEnvironment2ndSpecular(lightingResult.environment2ndSpecular, lightingData2ndSpecular, cc_ambientSky.w, surfaceData2ndSpecular.intensity2ndSpecular, lightingResult.environmentSpecular);\n CCSurfaceLightingCalculateEnvironmentFresnel(lightingResult.environmentGF2ndSpecular, lightingResult.environmentSubLayerF, lightingData2ndSpecular, lightingResult.specularColorWithLighting2ndSpecular);\n CCSurfacesLightingCalculateDirect2ndSpecular(lightingResult.direct2ndSpecular, lightingData2ndSpecular, cc_mainLitColor, surfaceData2ndSpecular.intensity2ndSpecular, lightingResult.directSpecular);\n CCSurfaceLightingCalculateDirectFresnel(lightingResult.directGF2ndSpecular, lightingData2ndSpecular, lightingResult.specularColorWithLighting2ndSpecular, lightingResult.environmentGF2ndSpecular);\n #else\n CCSurfacesLightingCalculateDirectSheen(lightingResult.direct2ndSpecular, lightingResult.directGF2ndSpecular, lightingData2ndSpecular, cc_mainLitColor, surfaceData2ndSpecular.intensity2ndSpecular);\n CCSurfacesLightingCalculateEnvironmentSheen(lightingResult.environment2ndSpecular, lightingResult.environmentGF2ndSpecular, lightingData2ndSpecular, cc_ambientSky.w, surfaceData2ndSpecular.intensity2ndSpecular);\n #endif\n #endif\n #if CC_SURFACES_LIGHTING_TT\n CCSurfacesLightingCalculateDirectTT(lightingResult, lightingData, cc_mainLitColor);\n #endif\n #if CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n lightingResult.specularColorWithLighting2ndSpecular *= surfaceData.color2ndSpecular;\n CCSurfacesLightingCalculateDirectMultiLayerBlending(lightingResult, lightingData2ndSpecular);\n CCSurfacesLightingCalculateEnvironmentMultiLayerBlending(lightingResult, lightingData2ndSpecular);\n #endif\n #ifdef CC_SURFACES_LIGHTING_MODIFY_FINAL_RESULT\n LightingMiscData miscData;\n miscData.lightType = LIGHT_TYPE_DIRECTIONAL;\n miscData.lightPos = vec3(0.0);\n miscData.lightDir = cc_mainLitDir.xyz;\n miscData.lightColorAndIntensity = cc_mainLitColor;\n miscData.lightSizeRangeAngle = vec4(0.0, 0.0, 0.0, 0.0);\n SurfacesLightingModifyFinalResult(lightingResult, lightingData, surfaceData, miscData);\n #endif\n }\n #if CC_ENABLE_CLUSTERED_LIGHT_CULLING\n #endif\n #endif\n#endif\nvec4 CCSurfacesDebugDisplayInvalidNumber(vec4 color)\n{\n float index = mod(cc_time.x * 10.0, 2.0);\n vec4 error = index < 1.0 ? vec4(1.0, 0.0, 0.2, 1.0) : vec4(0.0, 1.0, 0.2, 1.0);\n return (isnans(color.rgb) || isinfs(color.rgb)) ? error : color;\n}\nvec4 CCSurfacesDebugDisplayInvalidInputData(vec4 color, vec3 data)\n{\n float index = mod(cc_time.x * 10.0, 2.0);\n vec4 error = index < 1.0 ? vec4(1.0, 0.0, 0.2, 1.0) : vec4(0.0, 1.0, 0.2, 1.0);\n return (isnans(data) || isinfs(data)) ? error : color;\n}\n#if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_SINGLE && !CC_FORWARD_ADD\n void CCSurfacesDebugViewMeshData(inout vec4 color)\n {\n vec4 white = vec4(1.0, 1.0, 1.0, 1.0);\n vec4 black = vec4(0.0, 0.0, 0.0, 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR)) && (cc_surfaceTransform.y != 3.0)))\n {\n #if CC_SURFACES_USE_VERTEX_COLOR\n color = FSInput_vertexColor;\n #else\n color = white;\n #endif\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(FSInput_worldNormal * 0.5 + vec3(0.5), 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT)) && (cc_surfaceTransform.y != 3.0)))\n {\n #if CC_SURFACES_USE_TANGENT_SPACE\n color = vec4(FSInput_worldTangent * 0.5 + vec3(0.5), 1.0);\n #else\n color = black;\n #endif\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR)) && (cc_surfaceTransform.y != 3.0)))\n {\n #if CC_SURFACES_USE_TANGENT_SPACE\n float sign = FSInput_mirrorNormal * 0.5 + 0.5;\n color = vec4(sign, sign, sign, 1.0);\n #else\n color = black;\n #endif\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_FACE_SIDE)) && (cc_surfaceTransform.y != 3.0)))\n {\n float scalar = clamp(FSInput_faceSideSign, 0.0, 1.0);\n color = vec4(scalar, scalar, scalar, 1.0);\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_UV0)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(FSInput_texcoord.xy, 0.0, 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_UV1)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(FSInput_texcoord1.xy, 0.0, 1.0);\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP)) && (cc_surfaceTransform.y != 3.0)))\n {\n #if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n color = vec4(FSInput_lightMapUV.xy, 0.0, 1.0);\n #else\n color = vec4(0.0, 0.0, 0.0, 1.0);\n #endif\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH)) && (cc_surfaceTransform.y != 3.0)))\n {\n vec4 clipPos = cc_matProj * cc_matView * vec4(FSInput_worldPos.xyz, 1.0);\n float depth = clipPos.z / clipPos.w;\n color = vec4(depth, depth, depth, 1.0);\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH)) && (cc_surfaceTransform.y != 3.0)))\n {\n vec4 viewPos = cc_matView * vec4(FSInput_worldPos.xyz, 1.0);\n float depth = (-viewPos.z - cc_nearFar.x) / cc_nearFar.y;\n color = vec4(depth, depth, depth, 1.0);\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_WORLD_POS)) && (cc_surfaceTransform.y != 3.0)))\n color = vec4(FSInput_worldPos.xyz, 1.0);\n }\n#endif\n#if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_SINGLE\n bool CCSurfacesDebugViewLightingResult(inout vec4 color, in LightingResult lightingResult)\n {\n bool isSRGBColor = false;\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.directDiffuse * lightingResult.diffuseColorWithLighting;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.directSpecular * lightingResult.specularColorWithLighting * lightingResult.directGF;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_ALL)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.directDiffuse * lightingResult.diffuseColorWithLighting + lightingResult.directSpecular * lightingResult.specularColorWithLighting * lightingResult.directGF;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.environmentDiffuse * lightingResult.diffuseColorWithLighting;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.environmentSpecular * lightingResult.specularColorWithLighting * lightingResult.environmentGF;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_ENV_ALL)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.environmentDiffuse * lightingResult.diffuseColorWithLighting + lightingResult.environmentSpecular * lightingResult.specularColorWithLighting * lightingResult.environmentGF;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_LIGHT_MAP)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.lightmapColor;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_EMISSIVE)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = lightingResult.emissive;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_AO)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = vec3(lightingResult.ao);\n isSRGBColor = false;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_SHADOW)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = vec3(lightingResult.shadow);\n isSRGBColor = false;\n }\n vec3 fresnel = lightingResult.fresnel;\n vec3 directTransmitSpecular = vec3(0.0), environmentTransmitSpecular = vec3(0.0);\n vec3 directTransmitDiffuse = vec3(0.0), environmentTransmitDiffuse = vec3(0.0);\n vec3 diffuseColorWithLightingTT = vec3(0.0), specularColorWithLighting2ndSpecular = vec3(0.0);\n vec3 direct2ndSpecular = vec3(0.0), environment2ndSpecular = vec3(0.0);\n #if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n directTransmitSpecular = lightingResult.directTransmitSpecular;\n environmentTransmitSpecular = lightingResult.environmentTransmitSpecular;\n #endif\n #if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n directTransmitDiffuse = lightingResult.directTransmitDiffuse;\n environmentTransmitDiffuse = lightingResult.environmentTransmitDiffuse;\n #endif\n #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n direct2ndSpecular = lightingResult.direct2ndSpecular * lightingResult.directGF2ndSpecular;\n environment2ndSpecular = lightingResult.environment2ndSpecular * lightingResult.environmentGF2ndSpecular;\n specularColorWithLighting2ndSpecular = lightingResult.specularColorWithLighting2ndSpecular;\n #if CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n fresnel = lightingResult.environmentSubLayerF;\n #endif\n #endif\n #if CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n direct2ndSpecular = lightingResult.directSpecularSubLayers;\n environment2ndSpecular = lightingResult.environmentSpecularSubLayers;\n #endif\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_FRESNEL)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = vec3(fresnel);\n isSRGBColor = false;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = directTransmitSpecular;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = environmentTransmitSpecular;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = directTransmitDiffuse;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = environmentTransmitDiffuse;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = directTransmitSpecular + environmentTransmitSpecular + directTransmitDiffuse + environmentTransmitDiffuse;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = direct2ndSpecular * specularColorWithLighting2ndSpecular;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = environment2ndSpecular * specularColorWithLighting2ndSpecular;\n isSRGBColor = true;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL)) && (cc_surfaceTransform.y != 3.0)))\n {\n color.rgb = (direct2ndSpecular + environment2ndSpecular) * specularColorWithLighting2ndSpecular;\n isSRGBColor = true;\n }\n return isSRGBColor;\n }\n#endif\n#if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n void CCSurfacesDebugViewCompositeLightingResult(inout LightingResult lightingResult)\n {\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_DIFFUSE)\n lightingResult.directDiffuse = vec3(0.0);\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_SPECULAR)\n lightingResult.directSpecular = vec3(0.0);\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_DIFFUSE)\n lightingResult.environmentDiffuse = vec3(0.0);\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_SPECULAR)\n lightingResult.environmentSpecular = vec3(0.0);\n #if CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_DIFFUSE)\n lightingResult.directTransmitDiffuse = lightingResult.environmentTransmitDiffuse = vec3(0.0);\n #endif\n #if CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_SPECULAR)\n lightingResult.directTransmitSpecular = lightingResult.environmentTransmitSpecular = vec3(0.0);\n #endif\n #if CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_2ND_SPECULAR)\n lightingResult.direct2ndSpecular = lightingResult.environment2ndSpecular = vec3(0.0);\n #endif\n #if CC_SURFACES_LIGHTING_TT\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_TT)\n lightingResult.directTT = vec3(0.0);\n #endif\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_EMISSIVE)\n lightingResult.emissive = vec3(0.0);\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_LIGHT_MAP)\n lightingResult.lightmapColor = vec3(0.0);\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_SHADOW)\n lightingResult.shadow = 1.0;\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_AO)\n lightingResult.ao = 1.0;\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_FRESNEL)\n lightingResult.fresnel = vec3(1.0);\n }\n#endif\n#if (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\n void main() {\n #if CC_DISABLE_STRUCTURE_IN_FRAGMENT_SHADER\n float NoL = dot(-cc_mainLitDir.xyz, FSInput_worldNormal.xyz);\n vec4 color = SurfacesFragmentModifyBaseColorAndTransparency();\n float fogFactor = 1.0;\n #if CC_FORWARD_ADD\n color.rgb = vec3(0.0);\n #endif\n #else\n SurfacesMaterialData surfaceData;\n CCSurfacesFragmentGetMaterialData(surfaceData);\n vec2 shadowBias = vec2(0.0);\n vec3 colDebugCSMLayer = vec3(1.0);\n #if CC_RECEIVE_SHADOW\n shadowBias = FSInput_shadowBias;\n #if !CC_FORWARD_ADD\n #if CC_USE_DEBUG_VIEW && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (IS_DEBUG_VIEW_MISC_ENABLE_CSM_LAYER_COLORATION)\n {\n vec4 csmPos;\n vec4 shadowProjDepthInfo, shadowProjInfo;\n vec3 shadowViewDir0, shadowViewDir1, shadowViewDir2;\n int csmLayer = -1;\n csmLayer = CCGetCSMLevel(csmPos, shadowProjDepthInfo, shadowProjInfo, shadowViewDir0, shadowViewDir1, shadowViewDir2, surfaceData.worldPos);\n bool OutOfRange = csmLayer < 0;\n if (OutOfRange)\n colDebugCSMLayer = vec3(1.0);\n else if (csmLayer == 0)\n colDebugCSMLayer = vec3(1.0, 0.0, 0.0);\n else if (csmLayer == 1)\n colDebugCSMLayer = vec3(0.0, 1.0, 0.0);\n else if (csmLayer == 2)\n colDebugCSMLayer = vec3(0.0, 0.0, 1.0);\n else if (csmLayer == 3)\n colDebugCSMLayer = vec3(0.0, 1.0, 1.0);\n }\n #endif\n #endif\n #endif\n float fogFactor = 1.0;\n #if !CC_FORWARD_ADD\n #if CC_USE_FOG != 4\n #if !CC_USE_ACCURATE_FOG\n fogFactor = FSInput_fogFactor;\n #else\n CC_TRANSFER_FOG_BASE(vec4(FSInput_worldPos, 1.0), fogFactor);\n #endif\n #endif\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (!IS_DEBUG_VIEW_COMPOSITE_ENABLE_FOG) {\n fogFactor = 1.0;\n }\n #endif\n #endif\n LightingResult lightingResult;\n CCSurfacesLighting(lightingResult, surfaceData, shadowBias);\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_SINGLE && CC_SURFACES_ENABLE_DEBUG_VIEW\n vec4 debugColor = vec4(0.0, 0.0, 0.0, 1.0);\n float materialTransparency = CCSurfacesShading(surfaceData, lightingResult).a;\n #if !CC_FORWARD_ADD && !CC_SURFACES_LIGHTING_DISABLE_DIFFUSE\n CCSurfacesDebugViewMeshData(debugColor);\n if (CCSurfacesDebugViewSurfaceData(debugColor, surfaceData))\n {\n debugColor.a = materialTransparency;\n }\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_FOG)) && (cc_surfaceTransform.y != 3.0)))\n {\n debugColor.rgb = vec3(1.0 - fogFactor);\n }\n #endif\n #if CC_FORWARD_ADD\n if ((equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE)) && (cc_surfaceTransform.y != 3.0)) || (equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR)) && (cc_surfaceTransform.y != 3.0)) || (equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_ALL)) && (cc_surfaceTransform.y != 3.0)) ||\n (equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE)) && (cc_surfaceTransform.y != 3.0)) || (equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR)) && (cc_surfaceTransform.y != 3.0)) || (equalf_mode(cc_debug_view_mode.x, float(CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR)) && (cc_surfaceTransform.y != 3.0)))\n #endif\n {\n if (CCSurfacesDebugViewLightingResult(debugColor, lightingResult))\n {\n debugColor.a = materialTransparency;\n #if !CC_USE_FLOAT_OUTPUT\n debugColor.rgb = HDRToLDR(debugColor.rgb);\n debugColor.rgb = LinearToSRGB(debugColor.rgb);\n #endif\n }\n }\n if (IS_DEBUG_VIEW_ENABLE_WITH_CAMERA) {\n gl_FragData[0] = debugColor;\n return;\n }\n #elif CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC && CC_SURFACES_ENABLE_DEBUG_VIEW\n CCSurfacesDebugViewCompositeLightingResult(lightingResult);\n #endif\n vec4 color = CCSurfacesShading(surfaceData, lightingResult);\n #if CC_USE_DEBUG_VIEW && CC_SURFACES_ENABLE_DEBUG_VIEW\n if (IS_DEBUG_VIEW_MISC_ENABLE_CSM_LAYER_COLORATION) {\n color.rgb *= colDebugCSMLayer.rgb;\n }\n #if CC_SURFACES_USE_TANGENT_SPACE\n color = CCSurfacesDebugDisplayInvalidInputData(color, FSInput_worldTangent);\n #endif\n #endif\n #endif\n #if CC_USE_FOG != 4 && (!CC_USE_FLOAT_OUTPUT || CC_IS_TRANSPARENCY_PASS)\n #if !CC_FORWARD_ADD\n #ifdef CC_SURFACES_LIGHTING_MODIFY_FOG\n color.rgb = CCSurfacesLightingModifyFog(fogFactor, color.rgb, surfaceData, lightingResult);\n #else\n CC_APPLY_FOG_BASE(color, fogFactor);\n #endif\n #endif\n #endif\n #if CC_USE_RGBE_OUTPUT\n color = packRGBE(color.rgb);\n #else\n color = CCSurfacesDebugDisplayInvalidNumber(color);\n #if !CC_USE_FLOAT_OUTPUT || CC_IS_TRANSPARENCY_PASS\n color.rgb = HDRToLDR(color.rgb);\n color.rgb = LinearToSRGB(color.rgb);\n #endif\n #endif\n gl_FragData[0] = color;\n }\n#elif CC_PIPELINE_TYPE == 1\n void main () {\n SurfacesMaterialData surfaceData;\n CCSurfacesFragmentGetMaterialData(surfaceData);\n gl_FragData[0] = CCSurfacesDeferredOutputBaseColor(surfaceData);\n gl_FragData[2] = CCSurfacesDeferredOutputNormalMR(surfaceData);\n gl_FragData[1] = CCSurfacesDeferredOutputEmissiveAO(surfaceData);\n #if CC_USE_DEBUG_VIEW == CC_SURFACES_DEBUG_VIEW_SINGLE && CC_SURFACES_ENABLE_DEBUG_VIEW\n vec4 debugColor = vec4(0.0, 0.0, 0.0, 1.0);\n CCSurfacesDebugViewMeshData(debugColor);\n CCSurfacesDebugViewSurfaceData(debugColor, surfaceData);\n if (IS_DEBUG_VIEW_ENABLE_WITH_CAMERA) {\n gl_FragData[0] = debugColor;\n }\n #endif\n }\n#endif"
- },
- "builtins": {
- "globals": {
- "blocks": [
- {
- "name": "CCGlobal",
- "defines": []
- },
- {
- "name": "CCCamera",
- "defines": []
- },
- {
- "name": "CCShadow",
- "defines": []
- },
- {
- "name": "CCCSM",
- "defines": [
- "CC_SUPPORT_CASCADED_SHADOW_MAP"
- ]
- }
- ],
- "samplerTextures": [
- {
- "name": "cc_environment",
- "defines": []
- },
- {
- "name": "cc_diffuseMap",
- "defines": [
- "CC_USE_IBL",
- "CC_USE_DIFFUSEMAP"
- ]
- },
- {
- "name": "cc_shadowMap",
- "defines": [
- "CC_RECEIVE_SHADOW"
- ]
- },
- {
- "name": "cc_spotShadowMap",
- "defines": [
- "CC_RECEIVE_SHADOW"
- ]
- }
- ],
- "buffers": [],
- "images": []
- },
- "locals": {
- "blocks": [
- {
- "name": "CCLocal",
- "defines": [
- "!USE_INSTANCING"
- ]
- },
- {
- "name": "CCMorph",
- "defines": [
- "CC_USE_MORPH"
- ]
- },
- {
- "name": "CCSkinningTexture",
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ]
- },
- {
- "name": "CCSkinningAnimation",
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ]
- },
- {
- "name": "CCSkinning",
- "defines": [
- "CC_USE_SKINNING",
- "!CC_USE_BAKED_ANIMATION",
- "!CC_USE_REAL_TIME_JOINT_TEXTURE"
- ]
- },
- {
- "name": "CCForwardLight",
- "defines": [
- "CC_FORWARD_ADD",
- "CC_ENABLE_CLUSTERED_LIGHT_CULLING"
- ]
- },
- {
- "name": "CCSH",
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "!USE_INSTANCING"
- ]
- }
- ],
- "samplerTextures": [
- {
- "name": "cc_PositionDisplacements",
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_POSITION"
- ]
- },
- {
- "name": "cc_NormalDisplacements",
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_NORMAL"
- ]
- },
- {
- "name": "cc_TangentDisplacements",
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_TANGENT"
- ]
- },
- {
- "name": "cc_jointTexture",
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ]
- },
- {
- "name": "cc_realtimeJoint",
- "defines": [
- "CC_USE_SKINNING",
- "!CC_USE_BAKED_ANIMATION",
- "CC_USE_REAL_TIME_JOINT_TEXTURE"
- ]
- },
- {
- "name": "cc_reflectionProbeCubemap",
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ]
- },
- {
- "name": "cc_reflectionProbePlanarMap",
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ]
- },
- {
- "name": "cc_reflectionProbeDataMap",
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ]
- },
- {
- "name": "cc_reflectionProbeBlendCubemap",
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ]
- },
- {
- "name": "cc_lightingMap",
- "defines": [
- "CC_USE_LIGHTMAP",
- "!CC_FORWARD_ADD"
- ]
- }
- ],
- "buffers": [],
- "images": []
- },
- "statistics": {
- "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 100,
- "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 130
- }
- },
- "defines": [
- {
- "name": "USE_COMPATIBLE_LIGHTING",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "USE_NORMAL_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "USE_INSTANCING",
- "type": "boolean",
- "defines": [],
- "editor": {
- "elevated": true
- }
- },
- {
- "name": "CC_USE_LIGHTMAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_SKINNING",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_BAKED_ANIMATION",
- "type": "boolean",
- "defines": [
- "USE_INSTANCING"
- ]
- },
- {
- "name": "CC_RECEIVE_SHADOW",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_REFLECTION_PROBE",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 3
- ]
- },
- {
- "name": "CC_USE_LIGHT_PROBE",
- "type": "boolean",
- "defines": [],
- "default": 0
- },
- {
- "name": "CC_USE_MORPH",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_FORWARD_ADD",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_FOG",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 4
- ]
- },
- {
- "name": "CC_USE_ACCURATE_FOG",
- "type": "boolean",
- "defines": [
- "CC_USE_FOG"
- ]
- },
- {
- "name": "CC_MORPH_TARGET_COUNT",
- "type": "number",
- "defines": [
- "CC_USE_MORPH"
- ],
- "range": [
- 2,
- 8
- ]
- },
- {
- "name": "CC_MORPH_TARGET_HAS_POSITION",
- "type": "boolean",
- "defines": [
- "CC_USE_MORPH"
- ]
- },
- {
- "name": "CC_MORPH_TARGET_HAS_NORMAL",
- "type": "boolean",
- "defines": [
- "CC_USE_MORPH"
- ]
- },
- {
- "name": "CC_MORPH_TARGET_HAS_TANGENT",
- "type": "boolean",
- "defines": [
- "CC_USE_MORPH"
- ]
- },
- {
- "name": "CC_MORPH_PRECOMPUTED",
- "type": "boolean",
- "defines": [
- "CC_USE_MORPH"
- ]
- },
- {
- "name": "CC_USE_REAL_TIME_JOINT_TEXTURE",
- "type": "boolean",
- "defines": [
- "CC_USE_SKINNING",
- "!CC_USE_BAKED_ANIMATION"
- ]
- },
- {
- "name": "CC_DISABLE_STRUCTURE_IN_FRAGMENT_SHADER",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 1
- ]
- },
- {
- "name": "CC_PIPELINE_TYPE",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 1
- ]
- },
- {
- "name": "CC_FORCE_FORWARD_SHADING",
- "type": "boolean",
- "defines": [
- "CC_PIPELINE_TYPE"
- ]
- },
- {
- "name": "CC_ENABLE_CLUSTERED_LIGHT_CULLING",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 3
- ]
- },
- {
- "name": "CC_SUPPORT_CASCADED_SHADOW_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_IBL",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 2
- ]
- },
- {
- "name": "CC_USE_DIFFUSEMAP",
- "type": "number",
- "defines": [
- "CC_USE_IBL"
- ],
- "range": [
- 0,
- 2
- ]
- },
- {
- "name": "CC_USE_HDR",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_DEBUG_VIEW",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 3
- ]
- },
- {
- "name": "CC_TONE_MAPPING_TYPE",
- "type": "number",
- "defines": [
- "CC_USE_HDR"
- ],
- "range": [
- 0,
- 3
- ]
- },
- {
- "name": "HDR_TONE_MAPPING_ACES",
- "type": "boolean",
- "defines": [
- "CC_TONE_MAPPING_TYPE",
- "CC_USE_HDR"
- ]
- },
- {
- "name": "CC_SHADOWMAP_FORMAT",
- "type": "number",
- "defines": [
- "CC_RECEIVE_SHADOW"
- ],
- "range": [
- 0,
- 3
- ]
- },
- {
- "name": "CC_SHADOWMAP_USE_LINEAR_DEPTH",
- "type": "boolean",
- "defines": [
- "CC_RECEIVE_SHADOW"
- ]
- },
- {
- "name": "CC_DIR_SHADOW_PCF_TYPE",
- "type": "number",
- "defines": [
- "CC_RECEIVE_SHADOW"
- ],
- "range": [
- 0,
- 3
- ]
- },
- {
- "name": "CC_CASCADED_LAYERS_TRANSITION",
- "type": "boolean",
- "defines": [
- "CC_RECEIVE_SHADOW",
- "CC_SUPPORT_CASCADED_SHADOW_MAP"
- ]
- },
- {
- "name": "CC_LIGHT_MAP_VERSION",
- "type": "number",
- "defines": [
- "CC_USE_LIGHTMAP",
- "!CC_FORWARD_ADD"
- ],
- "range": [
- 0,
- 3
- ]
- },
- {
- "name": "USE_BASE_COLOR_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "USE_1ST_SHADE_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "USE_2ND_SHADE_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "USE_SPECULAR_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "USE_EMISSIVE_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "USE_ALPHA_TEST",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "ALPHA_TEST_CHANNEL",
- "type": "string",
- "defines": [
- "USE_ALPHA_TEST"
- ],
- "options": [
- "a",
- "r",
- "g",
- "b"
- ]
- },
- {
- "name": "SHADE_MAP_1_AS_SHADE_MAP_2",
- "type": "boolean",
- "defines": [
- "USE_1ST_SHADE_MAP"
- ]
- },
- {
- "name": "BASE_COLOR_MAP_AS_SHADE_MAP_1",
- "type": "boolean",
- "defines": [
- "USE_BASE_COLOR_MAP"
- ]
- },
- {
- "name": "BASE_COLOR_MAP_AS_SHADE_MAP_2",
- "type": "boolean",
- "defines": [
- "USE_BASE_COLOR_MAP"
- ]
- },
- {
- "name": "CC_SHADOW_TYPE",
- "type": "number",
- "defines": [
- "CC_RECEIVE_SHADOW"
- ],
- "range": [
- 0,
- 3
- ]
- },
- {
- "name": "CC_DIR_LIGHT_SHADOW_TYPE",
- "type": "number",
- "defines": [
- "CC_RECEIVE_SHADOW",
- "CC_SHADOW_TYPE"
- ],
- "range": [
- 0,
- 3
- ]
- },
- {
- "name": "CC_DISABLE_DIRECTIONAL_LIGHT",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_SURFACES_LIGHTING_DISABLE_DIFFUSE",
- "type": "boolean",
- "defines": [
- "!CC_FORWARD_ADD",
- "!CC_DISABLE_STRUCTURE_IN_FRAGMENT_SHADER",
- "CC_USE_DEBUG_VIEW",
- "CC_SURFACES_DEBUG_VIEW_SINGLE",
- "CC_SURFACES_ENABLE_DEBUG_VIEW"
- ]
- },
- {
- "name": "CC_USE_FLOAT_OUTPUT",
- "type": "boolean",
- "defines": [
- "CC_USE_FOG"
- ]
- },
- {
- "name": "CC_IS_TRANSPARENCY_PASS",
- "type": "boolean",
- "defines": [
- "CC_USE_FOG",
- "CC_USE_FLOAT_OUTPUT"
- ]
- },
- {
- "name": "CC_USE_RGBE_OUTPUT",
- "type": "boolean",
- "defines": []
- }
- ],
- "name": "builtin-toon|toon-vs|toon-fs"
- },
- {
- "blocks": [
- {
- "name": "Constants",
- "members": [
- {
- "name": "tilingOffset",
- "type": 16,
- "count": 1
- },
- {
- "name": "baseColor",
- "type": 16,
- "count": 1
- },
- {
- "name": "colorScaleAndCutoff",
- "type": 16,
- "count": 1
- },
- {
- "name": "shadeColor1",
- "type": 16,
- "count": 1
- },
- {
- "name": "shadeColor2",
- "type": 16,
- "count": 1
- },
- {
- "name": "specular",
- "type": 16,
- "count": 1
- },
- {
- "name": "shadeParams",
- "type": 16,
- "count": 1
- },
- {
- "name": "miscParams",
- "type": 16,
- "count": 1
- },
- {
- "name": "emissive",
- "type": 16,
- "count": 1
- },
- {
- "name": "emissiveScaleAndStrenth",
- "type": 16,
- "count": 1
- }
- ],
- "defines": [],
- "stageFlags": 17,
- "binding": 0
- }
- ],
- "samplerTextures": [
- {
- "name": "baseColorMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_BASE_COLOR_MAP"
- ],
- "stageFlags": 16,
- "binding": 1
- },
- {
- "name": "normalMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_NORMAL_MAP"
- ],
- "stageFlags": 16,
- "binding": 2
- },
- {
- "name": "shadeMap1",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_1ST_SHADE_MAP"
- ],
- "stageFlags": 16,
- "binding": 3
- },
- {
- "name": "shadeMap2",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_2ND_SHADE_MAP"
- ],
- "stageFlags": 16,
- "binding": 4
- },
- {
- "name": "specularMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_SPECULAR_MAP"
- ],
- "stageFlags": 16,
- "binding": 5
- },
- {
- "name": "emissiveMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_EMISSIVE_MAP"
- ],
- "stageFlags": 16,
- "binding": 6
- }
- ],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": [],
- "attributes": [
- {
- "name": "a_position",
- "defines": [],
- "format": 32,
- "location": 0
- },
- {
- "name": "a_normal",
- "defines": [],
- "format": 32,
- "location": 1
- },
- {
- "name": "a_texCoord",
- "defines": [],
- "format": 21,
- "location": 2
- },
- {
- "name": "a_tangent",
- "defines": [
- "USE_NORMAL_MAP"
- ],
- "format": 44,
- "location": 3
- },
- {
- "name": "a_color",
- "defines": [],
- "format": 44,
- "location": 6
- },
- {
- "name": "a_texCoord1",
- "defines": [],
- "format": 21,
- "location": 7
- },
- {
- "name": "a_joints",
- "defines": [
- "CC_USE_SKINNING"
- ],
- "location": 4
- },
- {
- "name": "a_weights",
- "defines": [
- "CC_USE_SKINNING"
- ],
- "format": 44,
- "location": 5
- },
- {
- "name": "a_jointAnimInfo",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_BAKED_ANIMATION"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 8
- },
- {
- "name": "a_matWorld0",
- "defines": [
- "USE_INSTANCING"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 9
- },
- {
- "name": "a_matWorld1",
- "defines": [
- "USE_INSTANCING"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 10
- },
- {
- "name": "a_matWorld2",
- "defines": [
- "USE_INSTANCING"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 11
- },
- {
- "name": "a_lightingMapUVParam",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_LIGHTMAP"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 12
- },
- {
- "name": "a_localShadowBiasAndProbeId",
- "defines": [
- "USE_INSTANCING"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 13
- },
- {
- "name": "a_reflectionProbeData",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_REFLECTION_PROBE"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 14
- },
- {
- "name": "a_sh_linear_const_r",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_LIGHT_PROBE"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 15
- },
- {
- "name": "a_sh_linear_const_g",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_LIGHT_PROBE"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 16
- },
- {
- "name": "a_sh_linear_const_b",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_LIGHT_PROBE"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 17
- },
- {
- "name": "a_vertexId",
- "defines": [
- "CC_USE_MORPH"
- ],
- "format": 11,
- "location": 18
- }
- ],
- "varyings": [
- {
- "name": "v_worldPos",
- "type": 15,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 0
- },
- {
- "name": "v_normal",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 1
- },
- {
- "name": "v_uv",
- "type": 14,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 2
- },
- {
- "name": "v_color",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 3
- },
- {
- "name": "v_tangent",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 4
- },
- {
- "name": "v_uv1",
- "type": 14,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 5
- },
- {
- "name": "v_luv",
- "type": 15,
- "count": 1,
- "defines": [
- "CC_USE_LIGHTMAP",
- "!CC_FORWARD_ADD"
- ],
- "stageFlags": 17,
- "location": 6
- },
- {
- "name": "v_shadowBiasAndProbeId",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 7
- },
- {
- "name": "v_reflectionProbeData",
- "type": 16,
- "count": 1,
- "defines": [
- "CC_USE_REFLECTION_PROBE",
- "USE_INSTANCING"
- ],
- "stageFlags": 17,
- "location": 8
- },
- {
- "name": "v_fogFactor",
- "type": 13,
- "count": 1,
- "defines": [
- "CC_USE_FOG",
- "!CC_USE_ACCURATE_FOG"
- ],
- "stageFlags": 17,
- "location": 9
- },
- {
- "name": "v_localPos",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 10
- },
- {
- "name": "v_clipPos",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 11
- },
- {
- "name": "v_sh_linear_const_r",
- "type": 16,
- "count": 1,
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "USE_INSTANCING"
- ],
- "stageFlags": 17,
- "location": 12
- },
- {
- "name": "v_sh_linear_const_g",
- "type": 16,
- "count": 1,
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "USE_INSTANCING"
- ],
- "stageFlags": 17,
- "location": 13
- },
- {
- "name": "v_sh_linear_const_b",
- "type": 16,
- "count": 1,
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "USE_INSTANCING"
- ],
- "stageFlags": 17,
- "location": 14
- },
- {
- "name": "v_clip_depth",
- "type": 14,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 15
- }
- ],
- "fragColors": [
- {
- "name": "fragColorX",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 16,
- "location": 0
- }
- ],
- "descriptors": [
- {
- "rate": 0,
- "blocks": [
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCLocal",
- "members": [
- {
- "name": "cc_matWorld",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matWorldIT",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_lightingMapUVParam",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_localShadowBias",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeData1",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeData2",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeBlendData1",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeBlendData2",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- }
- ],
- "defines": [
- "!USE_INSTANCING"
- ],
- "stageFlags": 17
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCMorph",
- "members": [
- {
- "name": "cc_displacementWeights",
- "typename": "vec4",
- "type": 16,
- "count": 15,
- "isArray": true
- },
- {
- "name": "cc_displacementTextureInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1
- }
- ],
- "defines": [
- "CC_USE_MORPH"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCSkinningTexture",
- "members": [
- {
- "name": "cc_jointTextureInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- }
- ],
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCSkinningAnimation",
- "members": [
- {
- "name": "cc_jointAnimInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- }
- ],
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCSkinning",
- "members": [
- {
- "name": "cc_joints",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "precision": "highp ",
- "isArray": true
- }
- ],
- "defines": [
- "CC_USE_SKINNING",
- "!CC_USE_BAKED_ANIMATION",
- "!CC_USE_REAL_TIME_JOINT_TEXTURE"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCForwardLight",
- "members": [
- {
- "name": "cc_lightPos",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_lightColor",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "isArray": true
- },
- {
- "name": "cc_lightSizeRangeAngle",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "isArray": true
- },
- {
- "name": "cc_lightDir",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "isArray": true
- },
- {
- "name": "cc_lightBoundingSizeVS",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "isArray": true
- }
- ],
- "defines": [
- "CC_FORWARD_ADD",
- "CC_ENABLE_CLUSTERED_LIGHT_CULLING"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCSH",
- "members": [
- {
- "name": "cc_sh_linear_const_r",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_linear_const_g",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_linear_const_b",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_r",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_g",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_b",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_a",
- "typename": "vec4",
- "type": 16,
- "count": 1
- }
- ],
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "!USE_INSTANCING"
- ],
- "stageFlags": 16
- }
- ],
- "samplerTextures": [
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_PositionDisplacements",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_POSITION"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_NormalDisplacements",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_NORMAL"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_TangentDisplacements",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_TANGENT"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_jointTexture",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "precision": "highp ",
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_realtimeJoint",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "precision": "highp ",
- "defines": [
- "CC_USE_SKINNING",
- "!CC_USE_BAKED_ANIMATION",
- "CC_USE_REAL_TIME_JOINT_TEXTURE"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_reflectionProbeCubemap",
- "typename": "samplerCube",
- "type": 31,
- "count": 1,
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_reflectionProbePlanarMap",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_reflectionProbeDataMap",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_reflectionProbeBlendCubemap",
- "typename": "samplerCube",
- "type": 31,
- "count": 1,
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_lightingMap",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_LIGHTMAP",
- "!CC_FORWARD_ADD"
- ],
- "stageFlags": 16
- }
- ],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- },
- {
- "rate": 1,
- "blocks": [
- {
- "name": "Constants",
- "members": [
- {
- "name": "tilingOffset",
- "type": 16,
- "count": 1
- },
- {
- "name": "baseColor",
- "type": 16,
- "count": 1
- },
- {
- "name": "colorScaleAndCutoff",
- "type": 16,
- "count": 1
- },
- {
- "name": "shadeColor1",
- "type": 16,
- "count": 1
- },
- {
- "name": "shadeColor2",
- "type": 16,
- "count": 1
- },
- {
- "name": "specular",
- "type": 16,
- "count": 1
- },
- {
- "name": "shadeParams",
- "type": 16,
- "count": 1
- },
- {
- "name": "miscParams",
- "type": 16,
- "count": 1
- },
- {
- "name": "emissive",
- "type": 16,
- "count": 1
- },
- {
- "name": "emissiveScaleAndStrenth",
- "type": 16,
- "count": 1
- }
- ],
- "defines": [],
- "stageFlags": 17,
- "binding": 0
- }
- ],
- "samplerTextures": [
- {
- "name": "baseColorMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_BASE_COLOR_MAP"
- ],
- "stageFlags": 16,
- "binding": 1
- },
- {
- "name": "normalMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_NORMAL_MAP"
- ],
- "stageFlags": 16,
- "binding": 2
- },
- {
- "name": "shadeMap1",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_1ST_SHADE_MAP"
- ],
- "stageFlags": 16,
- "binding": 3
- },
- {
- "name": "shadeMap2",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_2ND_SHADE_MAP"
- ],
- "stageFlags": 16,
- "binding": 4
- },
- {
- "name": "specularMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_SPECULAR_MAP"
- ],
- "stageFlags": 16,
- "binding": 5
- },
- {
- "name": "emissiveMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_EMISSIVE_MAP"
- ],
- "stageFlags": 16,
- "binding": 6
- }
- ],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- },
- {
- "rate": 2,
- "blocks": [],
- "samplerTextures": [],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- },
- {
- "rate": 3,
- "blocks": [
- {
- "tags": {
- "builtin": "global"
- },
- "name": "CCGlobal",
- "members": [
- {
- "name": "cc_time",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_screenSize",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_nativeSize",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_probeInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_debug_view_mode",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- }
- ],
- "defines": [],
- "stageFlags": 17
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "CCCamera",
- "members": [
- {
- "name": "cc_matView",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matViewInv",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matProj",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matProjInv",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matViewProj",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matViewProjInv",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_cameraPos",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_surfaceTransform",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_screenScale",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_exposure",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_mainLitDir",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_mainLitColor",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_ambientSky",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_ambientGround",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_fogColor",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_fogBase",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_fogAdd",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_nearFar",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_viewPort",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- }
- ],
- "defines": [],
- "stageFlags": 17
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "CCShadow",
- "members": [
- {
- "name": "cc_matLightView",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matLightViewProj",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_shadowInvProjDepthInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_shadowProjDepthInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_shadowProjInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_shadowNFLSInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_shadowWHPBInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_shadowLPNNInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_shadowColor",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "lowp "
- },
- {
- "name": "cc_planarNDInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- }
- ],
- "defines": [],
- "stageFlags": 17
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "CCCSM",
- "members": [
- {
- "name": "cc_csmViewDir0",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmViewDir1",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmViewDir2",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmAtlas",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_matCSMViewProj",
- "typename": "mat4",
- "type": 25,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmProjDepthInfo",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmProjInfo",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmSplitsInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- }
- ],
- "defines": [
- "CC_SUPPORT_CASCADED_SHADOW_MAP"
- ],
- "stageFlags": 16
- }
- ],
- "samplerTextures": [
- {
- "tags": {
- "builtin": "global"
- },
- "name": "cc_environment",
- "typename": "samplerCube",
- "type": 31,
- "count": 1,
- "defines": [],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "cc_diffuseMap",
- "typename": "samplerCube",
- "type": 31,
- "count": 1,
- "defines": [
- "CC_USE_IBL",
- "CC_USE_DIFFUSEMAP"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "cc_shadowMap",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "precision": "highp ",
- "defines": [
- "CC_RECEIVE_SHADOW"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "cc_spotShadowMap",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "precision": "highp ",
- "defines": [
- "CC_RECEIVE_SHADOW"
- ],
- "stageFlags": 16
- }
- ],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- }
- ],
- "hash": 2622802007,
- "glsl4": {
- "vert": "#extension GL_EXT_shader_explicit_arithmetic_types_int32: require\nprecision highp float;\n#define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING USE_COMPATIBLE_LIGHTING\n#define CC_SURFACES_USE_TANGENT_SPACE USE_NORMAL_MAP\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec3 a_normal;\nlayout(location = 2) in vec2 a_texCoord;\n#if CC_SURFACES_USE_TANGENT_SPACE\n layout(location = 3) in vec4 a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n layout(location = 6) in vec4 a_color;\n#endif\n#if CC_SURFACES_USE_SECOND_UV || CC_USE_LIGHTMAP\n layout(location = 7) in vec2 a_texCoord1;\n#endif\n#if CC_USE_SKINNING\n layout(location = 4) in u32vec4 a_joints;\n layout(location = 5) in vec4 a_weights;\n#endif\n#if USE_INSTANCING\n #if CC_USE_BAKED_ANIMATION\n layout(location = 8) in highp vec4 a_jointAnimInfo;\n #endif\n layout(location = 9) in vec4 a_matWorld0;\n layout(location = 10) in vec4 a_matWorld1;\n layout(location = 11) in vec4 a_matWorld2;\n #if CC_USE_LIGHTMAP\n layout(location = 12) in vec4 a_lightingMapUVParam;\n #endif\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n layout(location = 13) in vec4 a_localShadowBiasAndProbeId;\n #endif\n #if CC_USE_REFLECTION_PROBE\n layout(location = 14) in vec4 a_reflectionProbeData;\n #endif\n #if CC_USE_LIGHT_PROBE\n layout(location = 15) in vec4 a_sh_linear_const_r;\n layout(location = 16) in vec4 a_sh_linear_const_g;\n layout(location = 17) in vec4 a_sh_linear_const_b;\n #endif\n#endif\n#if CC_USE_MORPH\n#endif\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nlayout(location = 0) out highp vec3 v_worldPos;\nlayout(location = 1) out vec4 v_normal;\nlayout(location = 2) out vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n layout(location = 3) out lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n layout(location = 4) out mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n layout(location = 5) out mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n layout(location = 6) out mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n layout(location = 7) out mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n layout(location = 8) out mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n layout(location = 9) out mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n layout(location = 10) out highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n layout(location = 11) out highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n layout(location = 12) out mediump vec4 v_sh_linear_const_r;\n layout(location = 13) out mediump vec4 v_sh_linear_const_g;\n layout(location = 14) out mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define VSOutput_worldPos v_worldPos\n#define VSOutput_worldNormal v_normal.xyz\n#define VSOutput_faceSideSign v_normal.w\n#define VSOutput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define VSOutput_vertexColor v_color\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define VSOutput_worldTangent v_tangent.xyz\n #define VSOutput_mirrorNormal v_tangent.w\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define VSOutput_texcoord1 v_uv1\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define VSOutput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define VSOutput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define VSOutput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define VSOutput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define VSOutput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define VSOutput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define VSOutput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define VSOutput_clipPos v_clipPos\n#endif\nstruct SurfacesStandardVertexIntermediate\n{\n highp vec4 position;\n vec3 normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n vec4 tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n vec4 color;\n#endif\n vec2 texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n vec2 texCoord1;\n#endif\n highp vec4 clipPos;\n highp vec3 worldPos;\n vec4 worldNormal;\n #if CC_SURFACES_USE_TANGENT_SPACE\n vec3 worldTangent, worldBinormal;\n #endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n vec4 shadowBiasAndProbeId;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n float fogFactor;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n vec3 lightmapUV;\n#endif\n};\n#if CC_USE_MORPH\n int getVertexId() {\n return gl_VertexIndex;\n }\n#endif\nlayout(set = 0, binding = 0) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\nlayout(set = 0, binding = 2) uniform CCShadow {\n highp mat4 cc_matLightView;\n highp mat4 cc_matLightViewProj;\n highp vec4 cc_shadowInvProjDepthInfo;\n highp vec4 cc_shadowProjDepthInfo;\n highp vec4 cc_shadowProjInfo;\n mediump vec4 cc_shadowNFLSInfo;\n mediump vec4 cc_shadowWHPBInfo;\n mediump vec4 cc_shadowLPNNInfo;\n lowp vec4 cc_shadowColor;\n mediump vec4 cc_planarNDInfo;\n};\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\n#if !USE_INSTANCING\n layout(set = 2, binding = 0) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n highp vec4 cc_localShadowBias;\n highp vec4 cc_reflectionProbeData1;\n highp vec4 cc_reflectionProbeData2;\n highp vec4 cc_reflectionProbeBlendData1;\n highp vec4 cc_reflectionProbeBlendData2;\n };\n#endif\nvoid CCGetWorldMatrixFull(out mat4 matWorld, out mat4 matWorldIT)\n{\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n vec3 scale = 1.0 / vec3(length(a_matWorld0.xyz), length(a_matWorld1.xyz), length(a_matWorld2.xyz));\n vec3 scale2 = scale * scale;\n matWorldIT = mat4(\n vec4(a_matWorld0.xyz * scale2.x, 0.0),\n vec4(a_matWorld1.xyz * scale2.y, 0.0),\n vec4(a_matWorld2.xyz * scale2.z, 0.0),\n vec4(0.0, 0.0, 0.0, 1.0)\n );\n #else\n matWorld = cc_matWorld;\n matWorldIT = cc_matWorldIT;\n #endif\n}\n#if CC_USE_MORPH\n layout(set = 2, binding = 4) uniform CCMorph {\n vec4 cc_displacementWeights[15];\n vec4 cc_displacementTextureInfo;\n };\n #if CC_MORPH_TARGET_HAS_POSITION\n layout(set = 2, binding = 8) uniform sampler2D cc_PositionDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n layout(set = 2, binding = 9) uniform sampler2D cc_NormalDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n layout(set = 2, binding = 10) uniform sampler2D cc_TangentDisplacements;\n #endif\n vec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n }\n vec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n }\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\n ivec2 texSize = textureSize(tex, 0);\n return texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n }\n #else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture(tex, x)),\n decode32(texture(tex, y)),\n decode32(texture(tex, z)),\n 1.0\n );\n }\n #endif\n float getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n }\n vec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n #if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n #else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n #endif\n }\n #if CC_MORPH_TARGET_HAS_POSITION\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n #endif\n void applyMorph (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n int vertexId = getVertexId();\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n normal.xyz = normal.xyz + getNormalDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n tangent.xyz = tangent.xyz + getTangentDisplacement(vertexId);\n #endif\n }\n void applyMorph (inout vec4 position) {\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n #endif\n }\n#endif\n#if CC_USE_SKINNING\n #if CC_USE_BAKED_ANIMATION\n layout(set = 2, binding = 3) uniform CCSkinningTexture {\n highp vec4 cc_jointTextureInfo;\n };\n layout(set = 2, binding = 2) uniform CCSkinningAnimation {\n highp vec4 cc_jointAnimInfo;\n };\n layout(set = 2, binding = 7) uniform highp sampler2D cc_jointTexture;\n void CCGetJointTextureCoords(float pixelsPerJoint, float jointIdx, out highp float x, out highp float y, out highp float invSize)\n {\n #if USE_INSTANCING\n highp float temp = pixelsPerJoint * (a_jointAnimInfo.x * a_jointAnimInfo.y + jointIdx) + a_jointAnimInfo.z;\n #else\n highp float temp = pixelsPerJoint * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + jointIdx) + cc_jointTextureInfo.z;\n #endif\n invSize = cc_jointTextureInfo.w;\n highp float tempY = floor(temp * invSize);\n x = floor(temp - tempY * cc_jointTextureInfo.x);\n y = (tempY + 0.5) * invSize;\n }\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n layout(set = 2, binding = 7) uniform highp sampler2D cc_realtimeJoint;\n #else\n layout(set = 2, binding = 3) uniform CCSkinning {\n highp vec4 cc_joints[CC_JOINT_UNIFORM_CAPACITY * 3];\n };\n #endif\n #endif\n #if CC_USE_BAKED_ANIMATION\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(3.0, i, x, y, invSize);\n vec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(12.0, i, x, y, invSize);\n vec4 v1 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n float x = i;\n vec4 v1 = texture(cc_realtimeJoint, vec2( x / 256.0, 0.5 / 3.0));\n vec4 v2 = texture(cc_realtimeJoint, vec2( x / 256.0, 1.5 / 3.0));\n vec4 v3 = texture(cc_realtimeJoint, vec2( x / 256.0, 2.5 / 3.0));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n float x = 4.0 * i;\n vec4 v1 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 0.5 / 3.0)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 1.5 / 3.0)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 2.5 / 3.0)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #endif\n mat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n }\n void CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n }\n void CCSkin (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n mat4 m = skinMatrix();\n position = m * position;\n normal = (m * vec4(normal, 0.0)).xyz;\n tangent.xyz = (m * vec4(tangent.xyz, 0.0)).xyz;\n }\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #if CC_USE_FOG != 4\n #endif\n#endif\nlayout(set = 1, binding = 0) uniform Constants {\n vec4 tilingOffset;\n vec4 baseColor;\n vec4 colorScaleAndCutoff;\n vec4 shadeColor1;\n vec4 shadeColor2;\n vec4 specular;\n vec4 shadeParams;\n vec4 miscParams;\n vec4 emissive;\n vec4 emissiveScaleAndStrenth;\n};\n#define CC_SURFACES_VERTEX_MODIFY_UV\nvoid SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)\n{\n In.texCoord = In.texCoord * tilingOffset.xy + tilingOffset.zw;\n}\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_POS\nvec3 SurfacesVertexModifyLocalPos(in SurfacesStandardVertexIntermediate In)\n{\n return vec3(In.position.xyz);\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_NORMAL\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_TANGENT\n #if CC_SURFACES_USE_TANGENT_SPACE\n #endif\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_SHARED_DATA\nvoid SurfacesVertexModifyLocalSharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_POS\nvec3 SurfacesVertexModifyWorldPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.worldPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_CLIP_POS\nvec4 SurfacesVertexModifyClipPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.clipPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_UV\nvoid SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_NORMAL\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHADOW_BIAS\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHARED_DATA\nvoid SurfacesVertexModifySharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\nvoid CCSurfacesVertexInput(out SurfacesStandardVertexIntermediate In)\n{\n In.position = vec4(a_position, 1.0);\n In.normal = a_normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n In.tangent = a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n In.color = a_color;\n#endif\n In.texCoord = a_texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = a_texCoord1;\n#endif\n}\nvoid CCSurfacesVertexOutput(in SurfacesStandardVertexIntermediate In)\n{\n gl_Position = In.clipPos;\n VSOutput_worldNormal = In.worldNormal.xyz;\n VSOutput_faceSideSign = In.worldNormal.w;\n VSOutput_worldPos = In.worldPos;\n#if CC_SURFACES_USE_TANGENT_SPACE\n VSOutput_worldTangent = In.worldTangent.xyz;\n VSOutput_mirrorNormal = In.tangent.w > 0.0 ? 1.0 : -1.0;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n VSOutput_vertexColor = In.color;\n#endif\n VSOutput_texcoord = In.texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n VSOutput_texcoord1 = In.texCoord1;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n VSOutput_fogFactor = In.fogFactor;\n#endif\n#if CC_RECEIVE_SHADOW\n VSOutput_shadowBias = In.shadowBiasAndProbeId.xy;\n#endif\n#if CC_USE_REFLECTION_PROBE\n VSOutput_reflectionProbeId = In.shadowBiasAndProbeId.z;\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n VSOutput_reflectionProbeBlendId = In.shadowBiasAndProbeId.w;\n #endif\n #if USE_INSTANCING\n v_reflectionProbeData = a_reflectionProbeData;\n #endif\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n VSOutput_lightMapUV = In.lightmapUV;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n VSOutput_localPos = In.position;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n VSOutput_clipPos = In.clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n v_sh_linear_const_r = a_sh_linear_const_r;\n v_sh_linear_const_g = a_sh_linear_const_g;\n v_sh_linear_const_b = a_sh_linear_const_b;\n #endif\n#endif\n}\nvoid CCSurfacesVertexAnimation(inout SurfacesStandardVertexIntermediate In)\n{\nvec4 temp = vec4(0.0);\n#if CC_USE_MORPH\n #if CC_SURFACES_USE_TANGENT_SPACE\n applyMorph(In.position, In.normal, In.tangent);\n #else\n applyMorph(In.position, In.normal, temp);\n #endif\n#endif\n#if CC_USE_SKINNING\n #if CC_SURFACES_USE_TANGENT_SPACE\n CCSkin(In.position, In.normal, In.tangent);\n #else\n CCSkin(In.position, In.normal, temp);\n #endif\n#endif\n}\nvoid CCSurfacesVertexWorldTransform(inout SurfacesStandardVertexIntermediate In)\n{\n mat4 matWorld, matWorldIT;\n CCGetWorldMatrixFull(matWorld, matWorldIT);\n In.worldPos = (matWorld * In.position).xyz;\n In.worldNormal.xyz = normalize((matWorldIT * vec4(In.normal.xyz, 0.0)).xyz);\n #if CC_SURFACES_USE_TANGENT_SPACE\n In.worldTangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\n In.worldBinormal = cross(In.worldNormal.xyz, In.worldTangent) * In.tangent.w;\n #endif\n}\nvoid CCSurfacesVertexTransformUV(inout SurfacesStandardVertexIntermediate In)\n{\n #if CC_SURFACES_FLIP_UV\n In.texCoord = cc_cameraPos.w > 1.0 ? vec2(In.texCoord.x, 1.0 - In.texCoord.y) : In.texCoord;\n #if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = cc_cameraPos.w > 1.0 ? vec2(In.texCoord1.x, 1.0 - In.texCoord1.y) : In.texCoord1;\n #endif\n #endif\n}\nlayout(location = 15) out highp vec2 v_clip_depth;\nvoid main()\n{\n SurfacesStandardVertexIntermediate In;\n CCSurfacesVertexInput(In);\n CCSurfacesVertexAnimation(In);\n In.position.xyz = SurfacesVertexModifyLocalPos(In);\n SurfacesVertexModifyLocalSharedData(In);\n CCSurfacesVertexWorldTransform(In);\n In.worldPos = SurfacesVertexModifyWorldPos(In);\n In.clipPos = cc_matLightViewProj * vec4(In.worldPos, 1.0);\n In.clipPos = SurfacesVertexModifyClipPos(In);\n SurfacesVertexModifyUV(In);\n SurfacesVertexModifySharedData(In);\n CCSurfacesVertexTransformUV(In);\n CCSurfacesVertexOutput(In);\n v_clip_depth = In.clipPos.zw;\n}",
- "frag": "\nprecision highp float;\n#define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING USE_COMPATIBLE_LIGHTING\n#define CC_SURFACES_USE_TANGENT_SPACE USE_NORMAL_MAP\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nlayout(location = 0) in highp vec3 v_worldPos;\nlayout(location = 1) in vec4 v_normal;\nlayout(location = 2) in vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n layout(location = 3) in lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n layout(location = 4) in mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n layout(location = 5) in mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n layout(location = 6) in mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n layout(location = 7) in mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n layout(location = 8) in mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n layout(location = 9) in mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n layout(location = 10) in highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n layout(location = 11) in highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n layout(location = 12) in mediump vec4 v_sh_linear_const_r;\n layout(location = 13) in mediump vec4 v_sh_linear_const_g;\n layout(location = 14) in mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define FSInput_worldPos v_worldPos\n#define FSInput_worldNormal v_normal.xyz\n#define FSInput_faceSideSign v_normal.w\n#define FSInput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define FSInput_vertexColor v_color\n#else\n #define FSInput_vertexColor vec4(1.0)\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define FSInput_worldTangent v_tangent.xyz\n #define FSInput_mirrorNormal v_tangent.w\n#else\n #define FSInput_worldTangent vec3(1.0, 1.0, 1.0)\n #define FSInput_mirrorNormal 1.0\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define FSInput_texcoord1 v_uv1\n#else\n #define FSInput_texcoord1 vec2(0.0, 0.0)\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define FSInput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define FSInput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define FSInput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define FSInput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define FSInput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define FSInput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define FSInput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define FSInput_clipPos v_clipPos\n#endif\nlayout(set = 0, binding = 0) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_WORLD_POS CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR CC_SURFACES_DEBUG_VIEW_WORLD_POS + 1\n#define CC_SURFACES_DEBUG_VIEW_FACE_SIDE CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR + 1\n#define CC_SURFACES_DEBUG_VIEW_UV0 CC_SURFACES_DEBUG_VIEW_FACE_SIDE + 1\n#define CC_SURFACES_DEBUG_VIEW_UV1 CC_SURFACES_DEBUG_VIEW_UV0 + 1\n#define CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP CC_SURFACES_DEBUG_VIEW_UV1 + 1\n#define CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP + 1\n#define CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_BASE_COLOR CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR CC_SURFACES_DEBUG_VIEW_BASE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSPARENCY CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_METALLIC CC_SURFACES_DEBUG_VIEW_TRANSPARENCY + 1\n#define CC_SURFACES_DEBUG_VIEW_ROUGHNESS CC_SURFACES_DEBUG_VIEW_METALLIC + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY CC_SURFACES_DEBUG_VIEW_ROUGHNESS + 1\n#define CC_SURFACES_DEBUG_VIEW_IOR CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_IOR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_ALL CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_DIRECT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_ALL CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_EMISSIVE CC_SURFACES_DEBUG_VIEW_ENV_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_LIGHT_MAP CC_SURFACES_DEBUG_VIEW_EMISSIVE + 1\n#define CC_SURFACES_DEBUG_VIEW_SHADOW CC_SURFACES_DEBUG_VIEW_LIGHT_MAP + 1\n#define CC_SURFACES_DEBUG_VIEW_AO CC_SURFACES_DEBUG_VIEW_SHADOW + 1\n#define CC_SURFACES_DEBUG_VIEW_FRESNEL CC_SURFACES_DEBUG_VIEW_AO + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_FRESNEL + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_FOG CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL + 1\n#define IS_DEBUG_VIEW_ENABLE_WITH_CAMERA (cc_surfaceTransform.y != 3.0)\n#define IS_DEBUG_VIEW_LIGHTING_ENABLE_WITH_ALBEDO (UnpackBitFromFloat(cc_debug_view_mode.w, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_MISC_ENABLE_CSM_LAYER_COLORATION (UnpackBitFromFloat(cc_debug_view_mode.w, 7) && IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_EMISSIVE (UnpackBitFromFloat(cc_debug_view_mode.y, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_LIGHT_MAP (UnpackBitFromFloat(cc_debug_view_mode.y, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_SHADOW (UnpackBitFromFloat(cc_debug_view_mode.y, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_AO (UnpackBitFromFloat(cc_debug_view_mode.y, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_NORMAL_MAP (UnpackBitFromFloat(cc_debug_view_mode.z, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FOG (UnpackBitFromFloat(cc_debug_view_mode.z, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TONE_MAPPING (UnpackBitFromFloat(cc_debug_view_mode.z, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION (UnpackBitFromFloat(cc_debug_view_mode.z, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FRESNEL (UnpackBitFromFloat(cc_debug_view_mode.z, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.z, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_2ND_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TT (UnpackBitFromFloat(cc_debug_view_mode.w, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#if (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\n #if CC_FORWARD_ADD\n #if CC_PIPELINE_TYPE == 0\n #define LIGHTS_PER_PASS 1\n #else\n #define LIGHTS_PER_PASS 10\n #endif\n #if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\n layout(set = 2, binding = 1) uniform CCForwardLight {\n highp vec4 cc_lightPos[LIGHTS_PER_PASS];\n vec4 cc_lightColor[LIGHTS_PER_PASS];\n vec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\n vec4 cc_lightDir[LIGHTS_PER_PASS];\n vec4 cc_lightBoundingSizeVS[LIGHTS_PER_PASS];\n };\n #endif\n #endif\n#endif\n#if CC_USE_LIGHT_PROBE\n #if !USE_INSTANCING\n layout(set = 2, binding = 6) uniform CCSH {\n vec4 cc_sh_linear_const_r;\n vec4 cc_sh_linear_const_g;\n vec4 cc_sh_linear_const_b;\n vec4 cc_sh_quadratic_r;\n vec4 cc_sh_quadratic_g;\n vec4 cc_sh_quadratic_b;\n vec4 cc_sh_quadratic_a;\n };\n #endif\n#endif\nlayout(set = 0, binding = 2) uniform CCShadow {\n highp mat4 cc_matLightView;\n highp mat4 cc_matLightViewProj;\n highp vec4 cc_shadowInvProjDepthInfo;\n highp vec4 cc_shadowProjDepthInfo;\n highp vec4 cc_shadowProjInfo;\n mediump vec4 cc_shadowNFLSInfo;\n mediump vec4 cc_shadowWHPBInfo;\n mediump vec4 cc_shadowLPNNInfo;\n lowp vec4 cc_shadowColor;\n mediump vec4 cc_planarNDInfo;\n};\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n layout(set = 0, binding = 3) uniform CCCSM {\n highp vec4 cc_csmViewDir0[4];\n highp vec4 cc_csmViewDir1[4];\n highp vec4 cc_csmViewDir2[4];\n highp vec4 cc_csmAtlas[4];\n highp mat4 cc_matCSMViewProj[4];\n highp vec4 cc_csmProjDepthInfo[4];\n highp vec4 cc_csmProjInfo[4];\n highp vec4 cc_csmSplitsInfo;\n };\n#endif\nlayout(set = 0, binding = 5) uniform samplerCube cc_environment;\n#if CC_USE_IBL\n #if CC_USE_DIFFUSEMAP\n layout(set = 0, binding = 7) uniform samplerCube cc_diffuseMap;\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n layout(set = 2, binding = 15) uniform samplerCube cc_reflectionProbeCubemap;\n layout(set = 2, binding = 16) uniform sampler2D cc_reflectionProbePlanarMap;\n layout(set = 2, binding = 17) uniform sampler2D cc_reflectionProbeDataMap;\n layout(set = 2, binding = 18) uniform samplerCube cc_reflectionProbeBlendCubemap;\n#endif\nvec4 packDepthToRGBA (float depth) {\n vec4 ret = vec4(1.0, 255.0, 65025.0, 16581375.0) * depth;\n ret = fract(ret);\n ret -= vec4(ret.yzw, 0.0) / 255.0;\n return ret;\n}\n#define UnpackBitFromFloat(value, bit) (mod(floor(value / pow(10.0, float(bit))), 10.0) > 0.0)\n#if defined(CC_USE_METAL) || defined(CC_USE_WGPU)\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y) y = -y\n#else\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y)\n#endif\nfloat GetLinearDepthFromViewSpace(vec3 viewPos, float near, float far) {\n float dist = length(viewPos);\n return (dist - near) / (far - near);\n}\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n#endif\nfloat CCGetLinearDepth(vec3 worldPos, float viewSpaceBias) {\n\tvec4 viewPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\n viewPos.z += viewSpaceBias;\n\treturn GetLinearDepthFromViewSpace(viewPos.xyz, cc_shadowNFLSInfo.x, cc_shadowNFLSInfo.y);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\n\treturn CCGetLinearDepth(worldPos, 0.0);\n}\n#if CC_RECEIVE_SHADOW\n layout(set = 0, binding = 4) uniform highp sampler2D cc_shadowMap;\n layout(set = 0, binding = 6) uniform highp sampler2D cc_spotShadowMap;\n #if CC_SUPPORT_CASCADED_SHADOW_MAP\n #else\n #endif\n#endif\n#if CC_USE_FOG != 4\n#endif\n#if CC_USE_LIGHT_PROBE\n #if CC_USE_LIGHT_PROBE\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n layout(set = 2, binding = 0) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n highp vec4 cc_localShadowBias;\n highp vec4 cc_reflectionProbeData1;\n highp vec4 cc_reflectionProbeData2;\n highp vec4 cc_reflectionProbeBlendData1;\n highp vec4 cc_reflectionProbeBlendData2;\n };\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n layout(set = 2, binding = 11) uniform sampler2D cc_lightingMap;\n#endif\nlayout(set = 1, binding = 0) uniform Constants {\n vec4 tilingOffset;\n vec4 baseColor;\n vec4 colorScaleAndCutoff;\n vec4 shadeColor1;\n vec4 shadeColor2;\n vec4 specular;\n vec4 shadeParams;\n vec4 miscParams;\n vec4 emissive;\n vec4 emissiveScaleAndStrenth;\n};\n#if USE_BASE_COLOR_MAP\n layout(set = 1, binding = 1) uniform sampler2D baseColorMap;\n#endif\n#if USE_NORMAL_MAP\n layout(set = 1, binding = 2) uniform sampler2D normalMap;\n#endif\n#if USE_1ST_SHADE_MAP\n layout(set = 1, binding = 3) uniform sampler2D shadeMap1;\n#endif\n#if USE_2ND_SHADE_MAP\n layout(set = 1, binding = 4) uniform sampler2D shadeMap2;\n#endif\n#if USE_SPECULAR_MAP\n layout(set = 1, binding = 5) uniform sampler2D specularMap;\n#endif\n#if USE_EMISSIVE_MAP\n layout(set = 1, binding = 6) uniform sampler2D emissiveMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\n#define CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TOONSHADE\n#define CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY\nvoid SurfacesFragmentAlphaClipOnly()\n{\n #if USE_ALPHA_TEST\n float alpha = baseColor.ALPHA_TEST_CHANNEL;\n #if USE_BASE_COLOR_MAP\n alpha = texture(baseColorMap, FSInput_texcoord).ALPHA_TEST_CHANNEL;\n #endif\n if (alpha < colorScaleAndCutoff.w) discard;\n #endif\n}\n#define CC_SURFACES_FRAGMENT_MODIFY_WORLD_NORMAL\n#define CC_SURFACES_FRAGMENT_MODIFY_EMISSIVE\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_STEP_AND_FEATHER\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_SHADOW_COVER\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_SPECULAR\nlayout(location = 15) in highp vec2 v_clip_depth;\nlayout(location = 0) out vec4 fragColorX;\nvoid main () {\n#ifdef CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY\n SurfacesFragmentAlphaClipOnly();\n#endif\n highp float clipDepth = v_clip_depth.x / v_clip_depth.y * 0.5 + 0.5;\n #if CC_SHADOWMAP_USE_LINEAR_DEPTH\n if (IS_SPOT_LIGHT(cc_shadowLPNNInfo.x)) {\n clipDepth = CCGetLinearDepth(FSInput_worldPos.xyz);\n }\n #endif\n #if CC_SHADOWMAP_FORMAT == 1\n fragColorX = packDepthToRGBA(clipDepth);\n #else\n fragColorX = vec4(clipDepth, 1.0, 1.0, 1.0);\n #endif\n}"
- },
- "glsl3": {
- "vert": "\nprecision highp float;\n#define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING USE_COMPATIBLE_LIGHTING\n#define CC_SURFACES_USE_TANGENT_SPACE USE_NORMAL_MAP\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\n#if CC_SURFACES_USE_TANGENT_SPACE\n in vec4 a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n in vec4 a_color;\n#endif\n#if CC_SURFACES_USE_SECOND_UV || CC_USE_LIGHTMAP\n in vec2 a_texCoord1;\n#endif\n#if CC_USE_SKINNING\n in vec4 a_joints;\n in vec4 a_weights;\n#endif\n#if USE_INSTANCING\n #if CC_USE_BAKED_ANIMATION\n in highp vec4 a_jointAnimInfo;\n #endif\n in vec4 a_matWorld0;\n in vec4 a_matWorld1;\n in vec4 a_matWorld2;\n #if CC_USE_LIGHTMAP\n in vec4 a_lightingMapUVParam;\n #endif\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n in vec4 a_localShadowBiasAndProbeId;\n #endif\n #if CC_USE_REFLECTION_PROBE\n in vec4 a_reflectionProbeData;\n #endif\n #if CC_USE_LIGHT_PROBE\n in vec4 a_sh_linear_const_r;\n in vec4 a_sh_linear_const_g;\n in vec4 a_sh_linear_const_b;\n #endif\n#endif\n#if CC_USE_MORPH\n in float a_vertexId;\n#endif\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nout highp vec3 v_worldPos;\nout vec4 v_normal;\nout vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n out lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n out mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n out mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n out mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n out mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n out mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n out mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n out highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n out highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n out mediump vec4 v_sh_linear_const_r;\n out mediump vec4 v_sh_linear_const_g;\n out mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define VSOutput_worldPos v_worldPos\n#define VSOutput_worldNormal v_normal.xyz\n#define VSOutput_faceSideSign v_normal.w\n#define VSOutput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define VSOutput_vertexColor v_color\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define VSOutput_worldTangent v_tangent.xyz\n #define VSOutput_mirrorNormal v_tangent.w\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define VSOutput_texcoord1 v_uv1\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define VSOutput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define VSOutput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define VSOutput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define VSOutput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define VSOutput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define VSOutput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define VSOutput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define VSOutput_clipPos v_clipPos\n#endif\nstruct SurfacesStandardVertexIntermediate\n{\n highp vec4 position;\n vec3 normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n vec4 tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n vec4 color;\n#endif\n vec2 texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n vec2 texCoord1;\n#endif\n highp vec4 clipPos;\n highp vec3 worldPos;\n vec4 worldNormal;\n #if CC_SURFACES_USE_TANGENT_SPACE\n vec3 worldTangent, worldBinormal;\n #endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n vec4 shadowBiasAndProbeId;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n float fogFactor;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n vec3 lightmapUV;\n#endif\n};\n#if CC_USE_MORPH\n int getVertexId() {\n return int(a_vertexId);\n }\n#endif\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightView;\n highp mat4 cc_matLightViewProj;\n highp vec4 cc_shadowInvProjDepthInfo;\n highp vec4 cc_shadowProjDepthInfo;\n highp vec4 cc_shadowProjInfo;\n mediump vec4 cc_shadowNFLSInfo;\n mediump vec4 cc_shadowWHPBInfo;\n mediump vec4 cc_shadowLPNNInfo;\n lowp vec4 cc_shadowColor;\n mediump vec4 cc_planarNDInfo;\n};\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\n#if !USE_INSTANCING\n layout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n highp vec4 cc_localShadowBias;\n highp vec4 cc_reflectionProbeData1;\n highp vec4 cc_reflectionProbeData2;\n highp vec4 cc_reflectionProbeBlendData1;\n highp vec4 cc_reflectionProbeBlendData2;\n };\n#endif\nvoid CCGetWorldMatrixFull(out mat4 matWorld, out mat4 matWorldIT)\n{\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n vec3 scale = 1.0 / vec3(length(a_matWorld0.xyz), length(a_matWorld1.xyz), length(a_matWorld2.xyz));\n vec3 scale2 = scale * scale;\n matWorldIT = mat4(\n vec4(a_matWorld0.xyz * scale2.x, 0.0),\n vec4(a_matWorld1.xyz * scale2.y, 0.0),\n vec4(a_matWorld2.xyz * scale2.z, 0.0),\n vec4(0.0, 0.0, 0.0, 1.0)\n );\n #else\n matWorld = cc_matWorld;\n matWorldIT = cc_matWorldIT;\n #endif\n}\n#if CC_USE_MORPH\n layout(std140) uniform CCMorph {\n vec4 cc_displacementWeights[15];\n vec4 cc_displacementTextureInfo;\n };\n #if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n #endif\n vec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n }\n vec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n }\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\n ivec2 texSize = textureSize(tex, 0);\n return texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n }\n #else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture(tex, x)),\n decode32(texture(tex, y)),\n decode32(texture(tex, z)),\n 1.0\n );\n }\n #endif\n float getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n }\n vec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n #if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n #else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n #endif\n }\n #if CC_MORPH_TARGET_HAS_POSITION\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n #endif\n void applyMorph (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n int vertexId = getVertexId();\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n normal.xyz = normal.xyz + getNormalDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n tangent.xyz = tangent.xyz + getTangentDisplacement(vertexId);\n #endif\n }\n void applyMorph (inout vec4 position) {\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n #endif\n }\n#endif\n#if CC_USE_SKINNING\n #if CC_USE_BAKED_ANIMATION\n layout(std140) uniform CCSkinningTexture {\n highp vec4 cc_jointTextureInfo;\n };\n layout(std140) uniform CCSkinningAnimation {\n highp vec4 cc_jointAnimInfo;\n };\n uniform highp sampler2D cc_jointTexture;\n void CCGetJointTextureCoords(float pixelsPerJoint, float jointIdx, out highp float x, out highp float y, out highp float invSize)\n {\n #if USE_INSTANCING\n highp float temp = pixelsPerJoint * (a_jointAnimInfo.x * a_jointAnimInfo.y + jointIdx) + a_jointAnimInfo.z;\n #else\n highp float temp = pixelsPerJoint * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + jointIdx) + cc_jointTextureInfo.z;\n #endif\n invSize = cc_jointTextureInfo.w;\n highp float tempY = floor(temp * invSize);\n x = floor(temp - tempY * cc_jointTextureInfo.x);\n y = (tempY + 0.5) * invSize;\n }\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n uniform highp sampler2D cc_realtimeJoint;\n #else\n layout(std140) uniform CCSkinning {\n highp vec4 cc_joints[CC_JOINT_UNIFORM_CAPACITY * 3];\n };\n #endif\n #endif\n #if CC_USE_BAKED_ANIMATION\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(3.0, i, x, y, invSize);\n vec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(12.0, i, x, y, invSize);\n vec4 v1 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n float x = i;\n vec4 v1 = texture(cc_realtimeJoint, vec2( x / 256.0, 0.5 / 3.0));\n vec4 v2 = texture(cc_realtimeJoint, vec2( x / 256.0, 1.5 / 3.0));\n vec4 v3 = texture(cc_realtimeJoint, vec2( x / 256.0, 2.5 / 3.0));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n float x = 4.0 * i;\n vec4 v1 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 0.5 / 3.0)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 1.5 / 3.0)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 2.5 / 3.0)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #endif\n mat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n }\n void CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n }\n void CCSkin (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n mat4 m = skinMatrix();\n position = m * position;\n normal = (m * vec4(normal, 0.0)).xyz;\n tangent.xyz = (m * vec4(tangent.xyz, 0.0)).xyz;\n }\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #if CC_USE_FOG != 4\n #endif\n#endif\nlayout(std140) uniform Constants {\n vec4 tilingOffset;\n vec4 baseColor;\n vec4 colorScaleAndCutoff;\n vec4 shadeColor1;\n vec4 shadeColor2;\n vec4 specular;\n vec4 shadeParams;\n vec4 miscParams;\n vec4 emissive;\n vec4 emissiveScaleAndStrenth;\n};\n#define CC_SURFACES_VERTEX_MODIFY_UV\nvoid SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)\n{\n In.texCoord = In.texCoord * tilingOffset.xy + tilingOffset.zw;\n}\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_POS\nvec3 SurfacesVertexModifyLocalPos(in SurfacesStandardVertexIntermediate In)\n{\n return vec3(In.position.xyz);\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_NORMAL\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_TANGENT\n #if CC_SURFACES_USE_TANGENT_SPACE\n #endif\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_SHARED_DATA\nvoid SurfacesVertexModifyLocalSharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_POS\nvec3 SurfacesVertexModifyWorldPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.worldPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_CLIP_POS\nvec4 SurfacesVertexModifyClipPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.clipPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_UV\nvoid SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_NORMAL\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHADOW_BIAS\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHARED_DATA\nvoid SurfacesVertexModifySharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\nvoid CCSurfacesVertexInput(out SurfacesStandardVertexIntermediate In)\n{\n In.position = vec4(a_position, 1.0);\n In.normal = a_normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n In.tangent = a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n In.color = a_color;\n#endif\n In.texCoord = a_texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = a_texCoord1;\n#endif\n}\nvoid CCSurfacesVertexOutput(in SurfacesStandardVertexIntermediate In)\n{\n gl_Position = In.clipPos;\n VSOutput_worldNormal = In.worldNormal.xyz;\n VSOutput_faceSideSign = In.worldNormal.w;\n VSOutput_worldPos = In.worldPos;\n#if CC_SURFACES_USE_TANGENT_SPACE\n VSOutput_worldTangent = In.worldTangent.xyz;\n VSOutput_mirrorNormal = In.tangent.w > 0.0 ? 1.0 : -1.0;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n VSOutput_vertexColor = In.color;\n#endif\n VSOutput_texcoord = In.texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n VSOutput_texcoord1 = In.texCoord1;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n VSOutput_fogFactor = In.fogFactor;\n#endif\n#if CC_RECEIVE_SHADOW\n VSOutput_shadowBias = In.shadowBiasAndProbeId.xy;\n#endif\n#if CC_USE_REFLECTION_PROBE\n VSOutput_reflectionProbeId = In.shadowBiasAndProbeId.z;\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n VSOutput_reflectionProbeBlendId = In.shadowBiasAndProbeId.w;\n #endif\n #if USE_INSTANCING\n v_reflectionProbeData = a_reflectionProbeData;\n #endif\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n VSOutput_lightMapUV = In.lightmapUV;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n VSOutput_localPos = In.position;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n VSOutput_clipPos = In.clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n v_sh_linear_const_r = a_sh_linear_const_r;\n v_sh_linear_const_g = a_sh_linear_const_g;\n v_sh_linear_const_b = a_sh_linear_const_b;\n #endif\n#endif\n}\nvoid CCSurfacesVertexAnimation(inout SurfacesStandardVertexIntermediate In)\n{\nvec4 temp = vec4(0.0);\n#if CC_USE_MORPH\n #if CC_SURFACES_USE_TANGENT_SPACE\n applyMorph(In.position, In.normal, In.tangent);\n #else\n applyMorph(In.position, In.normal, temp);\n #endif\n#endif\n#if CC_USE_SKINNING\n #if CC_SURFACES_USE_TANGENT_SPACE\n CCSkin(In.position, In.normal, In.tangent);\n #else\n CCSkin(In.position, In.normal, temp);\n #endif\n#endif\n}\nvoid CCSurfacesVertexWorldTransform(inout SurfacesStandardVertexIntermediate In)\n{\n mat4 matWorld, matWorldIT;\n CCGetWorldMatrixFull(matWorld, matWorldIT);\n In.worldPos = (matWorld * In.position).xyz;\n In.worldNormal.xyz = normalize((matWorldIT * vec4(In.normal.xyz, 0.0)).xyz);\n #if CC_SURFACES_USE_TANGENT_SPACE\n In.worldTangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\n In.worldBinormal = cross(In.worldNormal.xyz, In.worldTangent) * In.tangent.w;\n #endif\n}\nvoid CCSurfacesVertexTransformUV(inout SurfacesStandardVertexIntermediate In)\n{\n #if CC_SURFACES_FLIP_UV\n In.texCoord = cc_cameraPos.w > 1.0 ? vec2(In.texCoord.x, 1.0 - In.texCoord.y) : In.texCoord;\n #if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = cc_cameraPos.w > 1.0 ? vec2(In.texCoord1.x, 1.0 - In.texCoord1.y) : In.texCoord1;\n #endif\n #endif\n}\nout highp vec2 v_clip_depth;\nvoid main()\n{\n SurfacesStandardVertexIntermediate In;\n CCSurfacesVertexInput(In);\n CCSurfacesVertexAnimation(In);\n In.position.xyz = SurfacesVertexModifyLocalPos(In);\n SurfacesVertexModifyLocalSharedData(In);\n CCSurfacesVertexWorldTransform(In);\n In.worldPos = SurfacesVertexModifyWorldPos(In);\n In.clipPos = cc_matLightViewProj * vec4(In.worldPos, 1.0);\n In.clipPos = SurfacesVertexModifyClipPos(In);\n SurfacesVertexModifyUV(In);\n SurfacesVertexModifySharedData(In);\n CCSurfacesVertexTransformUV(In);\n CCSurfacesVertexOutput(In);\n v_clip_depth = In.clipPos.zw;\n}",
- "frag": "\nprecision highp float;\n#define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING USE_COMPATIBLE_LIGHTING\n#define CC_SURFACES_USE_TANGENT_SPACE USE_NORMAL_MAP\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nin highp vec3 v_worldPos;\nin vec4 v_normal;\nin vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n in lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n in mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n in mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n in mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n in mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n in mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n in mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n in highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n in highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n in mediump vec4 v_sh_linear_const_r;\n in mediump vec4 v_sh_linear_const_g;\n in mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define FSInput_worldPos v_worldPos\n#define FSInput_worldNormal v_normal.xyz\n#define FSInput_faceSideSign v_normal.w\n#define FSInput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define FSInput_vertexColor v_color\n#else\n #define FSInput_vertexColor vec4(1.0)\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define FSInput_worldTangent v_tangent.xyz\n #define FSInput_mirrorNormal v_tangent.w\n#else\n #define FSInput_worldTangent vec3(1.0, 1.0, 1.0)\n #define FSInput_mirrorNormal 1.0\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define FSInput_texcoord1 v_uv1\n#else\n #define FSInput_texcoord1 vec2(0.0, 0.0)\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define FSInput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define FSInput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define FSInput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define FSInput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define FSInput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define FSInput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define FSInput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define FSInput_clipPos v_clipPos\n#endif\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_WORLD_POS CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR CC_SURFACES_DEBUG_VIEW_WORLD_POS + 1\n#define CC_SURFACES_DEBUG_VIEW_FACE_SIDE CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR + 1\n#define CC_SURFACES_DEBUG_VIEW_UV0 CC_SURFACES_DEBUG_VIEW_FACE_SIDE + 1\n#define CC_SURFACES_DEBUG_VIEW_UV1 CC_SURFACES_DEBUG_VIEW_UV0 + 1\n#define CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP CC_SURFACES_DEBUG_VIEW_UV1 + 1\n#define CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP + 1\n#define CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_BASE_COLOR CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR CC_SURFACES_DEBUG_VIEW_BASE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSPARENCY CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_METALLIC CC_SURFACES_DEBUG_VIEW_TRANSPARENCY + 1\n#define CC_SURFACES_DEBUG_VIEW_ROUGHNESS CC_SURFACES_DEBUG_VIEW_METALLIC + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY CC_SURFACES_DEBUG_VIEW_ROUGHNESS + 1\n#define CC_SURFACES_DEBUG_VIEW_IOR CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_IOR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_ALL CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_DIRECT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_ALL CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_EMISSIVE CC_SURFACES_DEBUG_VIEW_ENV_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_LIGHT_MAP CC_SURFACES_DEBUG_VIEW_EMISSIVE + 1\n#define CC_SURFACES_DEBUG_VIEW_SHADOW CC_SURFACES_DEBUG_VIEW_LIGHT_MAP + 1\n#define CC_SURFACES_DEBUG_VIEW_AO CC_SURFACES_DEBUG_VIEW_SHADOW + 1\n#define CC_SURFACES_DEBUG_VIEW_FRESNEL CC_SURFACES_DEBUG_VIEW_AO + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_FRESNEL + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_FOG CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL + 1\n#define IS_DEBUG_VIEW_ENABLE_WITH_CAMERA (cc_surfaceTransform.y != 3.0)\n#define IS_DEBUG_VIEW_LIGHTING_ENABLE_WITH_ALBEDO (UnpackBitFromFloat(cc_debug_view_mode.w, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_MISC_ENABLE_CSM_LAYER_COLORATION (UnpackBitFromFloat(cc_debug_view_mode.w, 7) && IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_EMISSIVE (UnpackBitFromFloat(cc_debug_view_mode.y, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_LIGHT_MAP (UnpackBitFromFloat(cc_debug_view_mode.y, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_SHADOW (UnpackBitFromFloat(cc_debug_view_mode.y, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_AO (UnpackBitFromFloat(cc_debug_view_mode.y, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_NORMAL_MAP (UnpackBitFromFloat(cc_debug_view_mode.z, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FOG (UnpackBitFromFloat(cc_debug_view_mode.z, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TONE_MAPPING (UnpackBitFromFloat(cc_debug_view_mode.z, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION (UnpackBitFromFloat(cc_debug_view_mode.z, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FRESNEL (UnpackBitFromFloat(cc_debug_view_mode.z, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.z, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_2ND_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TT (UnpackBitFromFloat(cc_debug_view_mode.w, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#if (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\n #if CC_FORWARD_ADD\n #if CC_PIPELINE_TYPE == 0\n #define LIGHTS_PER_PASS 1\n #else\n #define LIGHTS_PER_PASS 10\n #endif\n #if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\n layout(std140) uniform CCForwardLight {\n highp vec4 cc_lightPos[LIGHTS_PER_PASS];\n vec4 cc_lightColor[LIGHTS_PER_PASS];\n vec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\n vec4 cc_lightDir[LIGHTS_PER_PASS];\n vec4 cc_lightBoundingSizeVS[LIGHTS_PER_PASS];\n };\n #endif\n #endif\n#endif\n#if CC_USE_LIGHT_PROBE\n #if !USE_INSTANCING\n layout(std140) uniform CCSH {\n vec4 cc_sh_linear_const_r;\n vec4 cc_sh_linear_const_g;\n vec4 cc_sh_linear_const_b;\n vec4 cc_sh_quadratic_r;\n vec4 cc_sh_quadratic_g;\n vec4 cc_sh_quadratic_b;\n vec4 cc_sh_quadratic_a;\n };\n #endif\n#endif\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightView;\n highp mat4 cc_matLightViewProj;\n highp vec4 cc_shadowInvProjDepthInfo;\n highp vec4 cc_shadowProjDepthInfo;\n highp vec4 cc_shadowProjInfo;\n mediump vec4 cc_shadowNFLSInfo;\n mediump vec4 cc_shadowWHPBInfo;\n mediump vec4 cc_shadowLPNNInfo;\n lowp vec4 cc_shadowColor;\n mediump vec4 cc_planarNDInfo;\n};\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n layout(std140) uniform CCCSM {\n highp vec4 cc_csmViewDir0[4];\n highp vec4 cc_csmViewDir1[4];\n highp vec4 cc_csmViewDir2[4];\n highp vec4 cc_csmAtlas[4];\n highp mat4 cc_matCSMViewProj[4];\n highp vec4 cc_csmProjDepthInfo[4];\n highp vec4 cc_csmProjInfo[4];\n highp vec4 cc_csmSplitsInfo;\n };\n#endif\nuniform samplerCube cc_environment;\n#if CC_USE_IBL\n #if CC_USE_DIFFUSEMAP\n uniform samplerCube cc_diffuseMap;\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n uniform samplerCube cc_reflectionProbeCubemap;\n uniform sampler2D cc_reflectionProbePlanarMap;\n uniform sampler2D cc_reflectionProbeDataMap;\n uniform samplerCube cc_reflectionProbeBlendCubemap;\n#endif\nvec4 packDepthToRGBA (float depth) {\n vec4 ret = vec4(1.0, 255.0, 65025.0, 16581375.0) * depth;\n ret = fract(ret);\n ret -= vec4(ret.yzw, 0.0) / 255.0;\n return ret;\n}\n#define UnpackBitFromFloat(value, bit) (mod(floor(value / pow(10.0, float(bit))), 10.0) > 0.0)\n#if defined(CC_USE_METAL) || defined(CC_USE_WGPU)\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y) y = -y\n#else\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y)\n#endif\nfloat GetLinearDepthFromViewSpace(vec3 viewPos, float near, float far) {\n float dist = length(viewPos);\n return (dist - near) / (far - near);\n}\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n#endif\nfloat CCGetLinearDepth(vec3 worldPos, float viewSpaceBias) {\n\tvec4 viewPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\n viewPos.z += viewSpaceBias;\n\treturn GetLinearDepthFromViewSpace(viewPos.xyz, cc_shadowNFLSInfo.x, cc_shadowNFLSInfo.y);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\n\treturn CCGetLinearDepth(worldPos, 0.0);\n}\n#if CC_RECEIVE_SHADOW\n uniform highp sampler2D cc_shadowMap;\n uniform highp sampler2D cc_spotShadowMap;\n #if CC_SUPPORT_CASCADED_SHADOW_MAP\n #else\n #endif\n#endif\n#if CC_USE_FOG != 4\n#endif\n#if CC_USE_LIGHT_PROBE\n #if CC_USE_LIGHT_PROBE\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n layout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n highp vec4 cc_localShadowBias;\n highp vec4 cc_reflectionProbeData1;\n highp vec4 cc_reflectionProbeData2;\n highp vec4 cc_reflectionProbeBlendData1;\n highp vec4 cc_reflectionProbeBlendData2;\n };\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n uniform sampler2D cc_lightingMap;\n#endif\nlayout(std140) uniform Constants {\n vec4 tilingOffset;\n vec4 baseColor;\n vec4 colorScaleAndCutoff;\n vec4 shadeColor1;\n vec4 shadeColor2;\n vec4 specular;\n vec4 shadeParams;\n vec4 miscParams;\n vec4 emissive;\n vec4 emissiveScaleAndStrenth;\n};\n#if USE_BASE_COLOR_MAP\n uniform sampler2D baseColorMap;\n#endif\n#if USE_NORMAL_MAP\n uniform sampler2D normalMap;\n#endif\n#if USE_1ST_SHADE_MAP\n uniform sampler2D shadeMap1;\n#endif\n#if USE_2ND_SHADE_MAP\n uniform sampler2D shadeMap2;\n#endif\n#if USE_SPECULAR_MAP\n uniform sampler2D specularMap;\n#endif\n#if USE_EMISSIVE_MAP\n uniform sampler2D emissiveMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\n#define CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TOONSHADE\n#define CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY\nvoid SurfacesFragmentAlphaClipOnly()\n{\n #if USE_ALPHA_TEST\n float alpha = baseColor.ALPHA_TEST_CHANNEL;\n #if USE_BASE_COLOR_MAP\n alpha = texture(baseColorMap, FSInput_texcoord).ALPHA_TEST_CHANNEL;\n #endif\n if (alpha < colorScaleAndCutoff.w) discard;\n #endif\n}\n#define CC_SURFACES_FRAGMENT_MODIFY_WORLD_NORMAL\n#define CC_SURFACES_FRAGMENT_MODIFY_EMISSIVE\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_STEP_AND_FEATHER\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_SHADOW_COVER\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_SPECULAR\nin highp vec2 v_clip_depth;\nlayout(location = 0) out vec4 fragColorX;\nvoid main () {\n#ifdef CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY\n SurfacesFragmentAlphaClipOnly();\n#endif\n highp float clipDepth = v_clip_depth.x / v_clip_depth.y * 0.5 + 0.5;\n #if CC_SHADOWMAP_USE_LINEAR_DEPTH\n if (IS_SPOT_LIGHT(cc_shadowLPNNInfo.x)) {\n clipDepth = CCGetLinearDepth(FSInput_worldPos.xyz);\n }\n #endif\n #if CC_SHADOWMAP_FORMAT == 1\n fragColorX = packDepthToRGBA(clipDepth);\n #else\n fragColorX = vec4(clipDepth, 1.0, 1.0, 1.0);\n #endif\n}"
- },
- "glsl1": {
- "vert": "\nprecision highp float;\n#define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING USE_COMPATIBLE_LIGHTING\n#define CC_SURFACES_USE_TANGENT_SPACE USE_NORMAL_MAP\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\n#if CC_SURFACES_USE_TANGENT_SPACE\n attribute vec4 a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n attribute vec4 a_color;\n#endif\n#if CC_SURFACES_USE_SECOND_UV || CC_USE_LIGHTMAP\n attribute vec2 a_texCoord1;\n#endif\n#if CC_USE_SKINNING\n attribute vec4 a_joints;\n attribute vec4 a_weights;\n#endif\n#if USE_INSTANCING\n #if CC_USE_BAKED_ANIMATION\n attribute highp vec4 a_jointAnimInfo;\n #endif\n attribute vec4 a_matWorld0;\n attribute vec4 a_matWorld1;\n attribute vec4 a_matWorld2;\n #if CC_USE_LIGHTMAP\n attribute vec4 a_lightingMapUVParam;\n #endif\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n attribute vec4 a_localShadowBiasAndProbeId;\n #endif\n #if CC_USE_REFLECTION_PROBE\n attribute vec4 a_reflectionProbeData;\n #endif\n #if CC_USE_LIGHT_PROBE\n attribute vec4 a_sh_linear_const_r;\n attribute vec4 a_sh_linear_const_g;\n attribute vec4 a_sh_linear_const_b;\n #endif\n#endif\n#if CC_USE_MORPH\n attribute float a_vertexId;\n#endif\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nvarying highp vec3 v_worldPos;\nvarying vec4 v_normal;\nvarying vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n varying lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n varying mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n varying mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n varying mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n varying mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n varying mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n varying mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n varying highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n varying highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n varying mediump vec4 v_sh_linear_const_r;\n varying mediump vec4 v_sh_linear_const_g;\n varying mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define VSOutput_worldPos v_worldPos\n#define VSOutput_worldNormal v_normal.xyz\n#define VSOutput_faceSideSign v_normal.w\n#define VSOutput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define VSOutput_vertexColor v_color\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define VSOutput_worldTangent v_tangent.xyz\n #define VSOutput_mirrorNormal v_tangent.w\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define VSOutput_texcoord1 v_uv1\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define VSOutput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define VSOutput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define VSOutput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define VSOutput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define VSOutput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define VSOutput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define VSOutput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define VSOutput_clipPos v_clipPos\n#endif\nstruct SurfacesStandardVertexIntermediate\n{\n highp vec4 position;\n vec3 normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n vec4 tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n vec4 color;\n#endif\n vec2 texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n vec2 texCoord1;\n#endif\n highp vec4 clipPos;\n highp vec3 worldPos;\n vec4 worldNormal;\n #if CC_SURFACES_USE_TANGENT_SPACE\n vec3 worldTangent, worldBinormal;\n #endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n vec4 shadowBiasAndProbeId;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n float fogFactor;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n vec3 lightmapUV;\n#endif\n};\n#if CC_USE_MORPH\n int getVertexId() {\n return int(a_vertexId);\n }\n#endif\nuniform highp vec4 cc_cameraPos;\nuniform highp mat4 cc_matLightViewProj;\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\n#if !USE_INSTANCING\n uniform highp mat4 cc_matWorld;\n uniform highp mat4 cc_matWorldIT;\n#endif\nvoid CCGetWorldMatrixFull(out mat4 matWorld, out mat4 matWorldIT)\n{\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n vec3 scale = 1.0 / vec3(length(a_matWorld0.xyz), length(a_matWorld1.xyz), length(a_matWorld2.xyz));\n vec3 scale2 = scale * scale;\n matWorldIT = mat4(\n vec4(a_matWorld0.xyz * scale2.x, 0.0),\n vec4(a_matWorld1.xyz * scale2.y, 0.0),\n vec4(a_matWorld2.xyz * scale2.z, 0.0),\n vec4(0.0, 0.0, 0.0, 1.0)\n );\n #else\n matWorld = cc_matWorld;\n matWorldIT = cc_matWorldIT;\n #endif\n}\n#if CC_USE_MORPH\n uniform vec4 cc_displacementWeights[15];\n uniform vec4 cc_displacementTextureInfo;\n #if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n #endif\n vec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n }\n vec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n }\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\n return texture2D(tex, uv);\n }\n #else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture2D(tex, x)),\n decode32(texture2D(tex, y)),\n decode32(texture2D(tex, z)),\n 1.0\n );\n }\n #endif\n float getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n }\n vec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n #if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n #else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n #endif\n }\n #if CC_MORPH_TARGET_HAS_POSITION\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n #endif\n void applyMorph (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n int vertexId = getVertexId();\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n normal.xyz = normal.xyz + getNormalDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n tangent.xyz = tangent.xyz + getTangentDisplacement(vertexId);\n #endif\n }\n void applyMorph (inout vec4 position) {\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n #endif\n }\n#endif\n#if CC_USE_SKINNING\n #if CC_USE_BAKED_ANIMATION\n uniform highp vec4 cc_jointTextureInfo;\n uniform highp vec4 cc_jointAnimInfo;\n uniform highp sampler2D cc_jointTexture;\n void CCGetJointTextureCoords(float pixelsPerJoint, float jointIdx, out highp float x, out highp float y, out highp float invSize)\n {\n #if USE_INSTANCING\n highp float temp = pixelsPerJoint * (a_jointAnimInfo.x * a_jointAnimInfo.y + jointIdx) + a_jointAnimInfo.z;\n #else\n highp float temp = pixelsPerJoint * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + jointIdx) + cc_jointTextureInfo.z;\n #endif\n invSize = cc_jointTextureInfo.w;\n highp float tempY = floor(temp * invSize);\n x = floor(temp - tempY * cc_jointTextureInfo.x);\n y = (tempY + 0.5) * invSize;\n }\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n uniform highp sampler2D cc_realtimeJoint;\n #else\n uniform highp vec4 cc_joints[CC_JOINT_UNIFORM_CAPACITY * 3];\n #endif\n #endif\n #if CC_USE_BAKED_ANIMATION\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(3.0, i, x, y, invSize);\n vec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(12.0, i, x, y, invSize);\n vec4 v1 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n float x = i;\n vec4 v1 = texture2D(cc_realtimeJoint, vec2( x / 256.0, 0.5 / 3.0));\n vec4 v2 = texture2D(cc_realtimeJoint, vec2( x / 256.0, 1.5 / 3.0));\n vec4 v3 = texture2D(cc_realtimeJoint, vec2( x / 256.0, 2.5 / 3.0));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n float x = 4.0 * i;\n vec4 v1 = vec4(\n decode32(texture2D(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 0.5 / 3.0)))\n );\n vec4 v2 = vec4(\n decode32(texture2D(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 1.5 / 3.0)))\n );\n vec4 v3 = vec4(\n decode32(texture2D(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 2.5 / 3.0)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #endif\n mat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n }\n void CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n }\n void CCSkin (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n mat4 m = skinMatrix();\n position = m * position;\n normal = (m * vec4(normal, 0.0)).xyz;\n tangent.xyz = (m * vec4(tangent.xyz, 0.0)).xyz;\n }\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #if CC_USE_FOG != 4\n #endif\n#endif\n uniform vec4 tilingOffset;\n#define CC_SURFACES_VERTEX_MODIFY_UV\nvoid SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)\n{\n In.texCoord = In.texCoord * tilingOffset.xy + tilingOffset.zw;\n}\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_POS\nvec3 SurfacesVertexModifyLocalPos(in SurfacesStandardVertexIntermediate In)\n{\n return vec3(In.position.xyz);\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_NORMAL\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_TANGENT\n #if CC_SURFACES_USE_TANGENT_SPACE\n #endif\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_SHARED_DATA\nvoid SurfacesVertexModifyLocalSharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_POS\nvec3 SurfacesVertexModifyWorldPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.worldPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_CLIP_POS\nvec4 SurfacesVertexModifyClipPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.clipPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_UV\nvoid SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_NORMAL\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHADOW_BIAS\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHARED_DATA\nvoid SurfacesVertexModifySharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\nvoid CCSurfacesVertexInput(out SurfacesStandardVertexIntermediate In)\n{\n In.position = vec4(a_position, 1.0);\n In.normal = a_normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n In.tangent = a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n In.color = a_color;\n#endif\n In.texCoord = a_texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = a_texCoord1;\n#endif\n}\nvoid CCSurfacesVertexOutput(in SurfacesStandardVertexIntermediate In)\n{\n gl_Position = In.clipPos;\n VSOutput_worldNormal = In.worldNormal.xyz;\n VSOutput_faceSideSign = In.worldNormal.w;\n VSOutput_worldPos = In.worldPos;\n#if CC_SURFACES_USE_TANGENT_SPACE\n VSOutput_worldTangent = In.worldTangent.xyz;\n VSOutput_mirrorNormal = In.tangent.w > 0.0 ? 1.0 : -1.0;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n VSOutput_vertexColor = In.color;\n#endif\n VSOutput_texcoord = In.texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n VSOutput_texcoord1 = In.texCoord1;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n VSOutput_fogFactor = In.fogFactor;\n#endif\n#if CC_RECEIVE_SHADOW\n VSOutput_shadowBias = In.shadowBiasAndProbeId.xy;\n#endif\n#if CC_USE_REFLECTION_PROBE\n VSOutput_reflectionProbeId = In.shadowBiasAndProbeId.z;\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n VSOutput_reflectionProbeBlendId = In.shadowBiasAndProbeId.w;\n #endif\n #if USE_INSTANCING\n v_reflectionProbeData = a_reflectionProbeData;\n #endif\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n VSOutput_lightMapUV = In.lightmapUV;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n VSOutput_localPos = In.position;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n VSOutput_clipPos = In.clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n v_sh_linear_const_r = a_sh_linear_const_r;\n v_sh_linear_const_g = a_sh_linear_const_g;\n v_sh_linear_const_b = a_sh_linear_const_b;\n #endif\n#endif\n}\nvoid CCSurfacesVertexAnimation(inout SurfacesStandardVertexIntermediate In)\n{\nvec4 temp = vec4(0.0);\n#if CC_USE_MORPH\n #if CC_SURFACES_USE_TANGENT_SPACE\n applyMorph(In.position, In.normal, In.tangent);\n #else\n applyMorph(In.position, In.normal, temp);\n #endif\n#endif\n#if CC_USE_SKINNING\n #if CC_SURFACES_USE_TANGENT_SPACE\n CCSkin(In.position, In.normal, In.tangent);\n #else\n CCSkin(In.position, In.normal, temp);\n #endif\n#endif\n}\nvoid CCSurfacesVertexWorldTransform(inout SurfacesStandardVertexIntermediate In)\n{\n mat4 matWorld, matWorldIT;\n CCGetWorldMatrixFull(matWorld, matWorldIT);\n In.worldPos = (matWorld * In.position).xyz;\n In.worldNormal.xyz = normalize((matWorldIT * vec4(In.normal.xyz, 0.0)).xyz);\n #if CC_SURFACES_USE_TANGENT_SPACE\n In.worldTangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\n In.worldBinormal = cross(In.worldNormal.xyz, In.worldTangent) * In.tangent.w;\n #endif\n}\nvoid CCSurfacesVertexTransformUV(inout SurfacesStandardVertexIntermediate In)\n{\n #if CC_SURFACES_FLIP_UV\n In.texCoord = cc_cameraPos.w > 1.0 ? vec2(In.texCoord.x, 1.0 - In.texCoord.y) : In.texCoord;\n #if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = cc_cameraPos.w > 1.0 ? vec2(In.texCoord1.x, 1.0 - In.texCoord1.y) : In.texCoord1;\n #endif\n #endif\n}\nvarying highp vec2 v_clip_depth;\nvoid main()\n{\n SurfacesStandardVertexIntermediate In;\n CCSurfacesVertexInput(In);\n CCSurfacesVertexAnimation(In);\n In.position.xyz = SurfacesVertexModifyLocalPos(In);\n SurfacesVertexModifyLocalSharedData(In);\n CCSurfacesVertexWorldTransform(In);\n In.worldPos = SurfacesVertexModifyWorldPos(In);\n In.clipPos = cc_matLightViewProj * vec4(In.worldPos, 1.0);\n In.clipPos = SurfacesVertexModifyClipPos(In);\n SurfacesVertexModifyUV(In);\n SurfacesVertexModifySharedData(In);\n CCSurfacesVertexTransformUV(In);\n CCSurfacesVertexOutput(In);\n v_clip_depth = In.clipPos.zw;\n}",
- "frag": "\n#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives: enable\n#endif\n#ifdef GL_EXT_shader_texture_lod\n#extension GL_EXT_shader_texture_lod: enable\n#endif\nprecision highp float;\n#define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING USE_COMPATIBLE_LIGHTING\n#define CC_SURFACES_USE_TANGENT_SPACE USE_NORMAL_MAP\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nvarying highp vec3 v_worldPos;\nvarying vec4 v_normal;\nvarying vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n varying lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n varying mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n varying mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n varying mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n varying mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n varying mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n varying mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n varying highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n varying highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n varying mediump vec4 v_sh_linear_const_r;\n varying mediump vec4 v_sh_linear_const_g;\n varying mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define FSInput_worldPos v_worldPos\n#define FSInput_worldNormal v_normal.xyz\n#define FSInput_faceSideSign v_normal.w\n#define FSInput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define FSInput_vertexColor v_color\n#else\n #define FSInput_vertexColor vec4(1.0)\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define FSInput_worldTangent v_tangent.xyz\n #define FSInput_mirrorNormal v_tangent.w\n#else\n #define FSInput_worldTangent vec3(1.0, 1.0, 1.0)\n #define FSInput_mirrorNormal 1.0\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define FSInput_texcoord1 v_uv1\n#else\n #define FSInput_texcoord1 vec2(0.0, 0.0)\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define FSInput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define FSInput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define FSInput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define FSInput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define FSInput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define FSInput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define FSInput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define FSInput_clipPos v_clipPos\n#endif\nuniform mediump vec4 cc_debug_view_mode;\nuniform mediump vec4 cc_surfaceTransform;\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_WORLD_POS CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR CC_SURFACES_DEBUG_VIEW_WORLD_POS + 1\n#define CC_SURFACES_DEBUG_VIEW_FACE_SIDE CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR + 1\n#define CC_SURFACES_DEBUG_VIEW_UV0 CC_SURFACES_DEBUG_VIEW_FACE_SIDE + 1\n#define CC_SURFACES_DEBUG_VIEW_UV1 CC_SURFACES_DEBUG_VIEW_UV0 + 1\n#define CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP CC_SURFACES_DEBUG_VIEW_UV1 + 1\n#define CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP + 1\n#define CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_BASE_COLOR CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR CC_SURFACES_DEBUG_VIEW_BASE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSPARENCY CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_METALLIC CC_SURFACES_DEBUG_VIEW_TRANSPARENCY + 1\n#define CC_SURFACES_DEBUG_VIEW_ROUGHNESS CC_SURFACES_DEBUG_VIEW_METALLIC + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY CC_SURFACES_DEBUG_VIEW_ROUGHNESS + 1\n#define CC_SURFACES_DEBUG_VIEW_IOR CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_IOR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_ALL CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_DIRECT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_ALL CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_EMISSIVE CC_SURFACES_DEBUG_VIEW_ENV_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_LIGHT_MAP CC_SURFACES_DEBUG_VIEW_EMISSIVE + 1\n#define CC_SURFACES_DEBUG_VIEW_SHADOW CC_SURFACES_DEBUG_VIEW_LIGHT_MAP + 1\n#define CC_SURFACES_DEBUG_VIEW_AO CC_SURFACES_DEBUG_VIEW_SHADOW + 1\n#define CC_SURFACES_DEBUG_VIEW_FRESNEL CC_SURFACES_DEBUG_VIEW_AO + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_FRESNEL + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_FOG CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL + 1\n#define IS_DEBUG_VIEW_ENABLE_WITH_CAMERA (cc_surfaceTransform.y != 3.0)\n#define IS_DEBUG_VIEW_LIGHTING_ENABLE_WITH_ALBEDO (UnpackBitFromFloat(cc_debug_view_mode.w, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_MISC_ENABLE_CSM_LAYER_COLORATION (UnpackBitFromFloat(cc_debug_view_mode.w, 7) && IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_EMISSIVE (UnpackBitFromFloat(cc_debug_view_mode.y, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_LIGHT_MAP (UnpackBitFromFloat(cc_debug_view_mode.y, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_SHADOW (UnpackBitFromFloat(cc_debug_view_mode.y, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_AO (UnpackBitFromFloat(cc_debug_view_mode.y, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_NORMAL_MAP (UnpackBitFromFloat(cc_debug_view_mode.z, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FOG (UnpackBitFromFloat(cc_debug_view_mode.z, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TONE_MAPPING (UnpackBitFromFloat(cc_debug_view_mode.z, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION (UnpackBitFromFloat(cc_debug_view_mode.z, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FRESNEL (UnpackBitFromFloat(cc_debug_view_mode.z, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.z, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_2ND_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TT (UnpackBitFromFloat(cc_debug_view_mode.w, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#if (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\n #if CC_FORWARD_ADD\n #if CC_PIPELINE_TYPE == 0\n #define LIGHTS_PER_PASS 1\n #else\n #define LIGHTS_PER_PASS 10\n #endif\n #if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\n #endif\n #endif\n#endif\n#if CC_USE_LIGHT_PROBE\n #if !USE_INSTANCING\n #endif\n#endif\nuniform highp mat4 cc_matLightView;\n uniform mediump vec4 cc_shadowNFLSInfo;\n uniform mediump vec4 cc_shadowLPNNInfo;\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n #endif\nuniform samplerCube cc_environment;\n#if CC_USE_IBL\n #if CC_USE_DIFFUSEMAP\n uniform samplerCube cc_diffuseMap;\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n uniform samplerCube cc_reflectionProbeCubemap;\n uniform sampler2D cc_reflectionProbePlanarMap;\n uniform sampler2D cc_reflectionProbeDataMap;\n uniform samplerCube cc_reflectionProbeBlendCubemap;\n#endif\nvec4 packDepthToRGBA (float depth) {\n vec4 ret = vec4(1.0, 255.0, 65025.0, 16581375.0) * depth;\n ret = fract(ret);\n ret -= vec4(ret.yzw, 0.0) / 255.0;\n return ret;\n}\n#define UnpackBitFromFloat(value, bit) (mod(floor(value / pow(10.0, float(bit))), 10.0) > 0.0)\n#if defined(CC_USE_METAL) || defined(CC_USE_WGPU)\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y) y = -y\n#else\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y)\n#endif\nfloat GetLinearDepthFromViewSpace(vec3 viewPos, float near, float far) {\n float dist = length(viewPos);\n return (dist - near) / (far - near);\n}\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n#endif\nfloat CCGetLinearDepth(vec3 worldPos, float viewSpaceBias) {\n\tvec4 viewPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\n viewPos.z += viewSpaceBias;\n\treturn GetLinearDepthFromViewSpace(viewPos.xyz, cc_shadowNFLSInfo.x, cc_shadowNFLSInfo.y);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\n\treturn CCGetLinearDepth(worldPos, 0.0);\n}\n#if CC_RECEIVE_SHADOW\n uniform highp sampler2D cc_shadowMap;\n uniform highp sampler2D cc_spotShadowMap;\n #if CC_SUPPORT_CASCADED_SHADOW_MAP\n #else\n #endif\n#endif\n#if CC_USE_FOG != 4\n#endif\n#if CC_USE_LIGHT_PROBE\n #if CC_USE_LIGHT_PROBE\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n #endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n uniform sampler2D cc_lightingMap;\n#endif\n uniform vec4 baseColor;\n uniform vec4 colorScaleAndCutoff;\n#if USE_BASE_COLOR_MAP\n uniform sampler2D baseColorMap;\n#endif\n#if USE_NORMAL_MAP\n uniform sampler2D normalMap;\n#endif\n#if USE_1ST_SHADE_MAP\n uniform sampler2D shadeMap1;\n#endif\n#if USE_2ND_SHADE_MAP\n uniform sampler2D shadeMap2;\n#endif\n#if USE_SPECULAR_MAP\n uniform sampler2D specularMap;\n#endif\n#if USE_EMISSIVE_MAP\n uniform sampler2D emissiveMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\n#define CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TOONSHADE\n#define CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY\nvoid SurfacesFragmentAlphaClipOnly()\n{\n #if USE_ALPHA_TEST\n float alpha = baseColor.ALPHA_TEST_CHANNEL;\n #if USE_BASE_COLOR_MAP\n alpha = texture2D(baseColorMap, FSInput_texcoord).ALPHA_TEST_CHANNEL;\n #endif\n if (alpha < colorScaleAndCutoff.w) discard;\n #endif\n}\n#define CC_SURFACES_FRAGMENT_MODIFY_WORLD_NORMAL\n#define CC_SURFACES_FRAGMENT_MODIFY_EMISSIVE\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_STEP_AND_FEATHER\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_SHADOW_COVER\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_SPECULAR\nvarying highp vec2 v_clip_depth;\nvoid main () {\n#ifdef CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY\n SurfacesFragmentAlphaClipOnly();\n#endif\n highp float clipDepth = v_clip_depth.x / v_clip_depth.y * 0.5 + 0.5;\n #if CC_SHADOWMAP_USE_LINEAR_DEPTH\n if (IS_SPOT_LIGHT(cc_shadowLPNNInfo.x)) {\n clipDepth = CCGetLinearDepth(FSInput_worldPos.xyz);\n }\n #endif\n #if CC_SHADOWMAP_FORMAT == 1\n gl_FragColor = packDepthToRGBA(clipDepth);\n #else\n gl_FragColor = vec4(clipDepth, 1.0, 1.0, 1.0);\n #endif\n}"
- },
- "builtins": {
- "globals": {
- "blocks": [
- {
- "name": "CCGlobal",
- "defines": []
- },
- {
- "name": "CCCamera",
- "defines": []
- },
- {
- "name": "CCShadow",
- "defines": []
- },
- {
- "name": "CCCSM",
- "defines": [
- "CC_SUPPORT_CASCADED_SHADOW_MAP"
- ]
- }
- ],
- "samplerTextures": [
- {
- "name": "cc_environment",
- "defines": []
- },
- {
- "name": "cc_diffuseMap",
- "defines": [
- "CC_USE_IBL",
- "CC_USE_DIFFUSEMAP"
- ]
- },
- {
- "name": "cc_shadowMap",
- "defines": [
- "CC_RECEIVE_SHADOW"
- ]
- },
- {
- "name": "cc_spotShadowMap",
- "defines": [
- "CC_RECEIVE_SHADOW"
- ]
- }
- ],
- "buffers": [],
- "images": []
- },
- "locals": {
- "blocks": [
- {
- "name": "CCLocal",
- "defines": [
- "!USE_INSTANCING"
- ]
- },
- {
- "name": "CCMorph",
- "defines": [
- "CC_USE_MORPH"
- ]
- },
- {
- "name": "CCSkinningTexture",
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ]
- },
- {
- "name": "CCSkinningAnimation",
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ]
- },
- {
- "name": "CCSkinning",
- "defines": [
- "CC_USE_SKINNING",
- "!CC_USE_BAKED_ANIMATION",
- "!CC_USE_REAL_TIME_JOINT_TEXTURE"
- ]
- },
- {
- "name": "CCForwardLight",
- "defines": [
- "CC_FORWARD_ADD",
- "CC_ENABLE_CLUSTERED_LIGHT_CULLING"
- ]
- },
- {
- "name": "CCSH",
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "!USE_INSTANCING"
- ]
- }
- ],
- "samplerTextures": [
- {
- "name": "cc_PositionDisplacements",
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_POSITION"
- ]
- },
- {
- "name": "cc_NormalDisplacements",
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_NORMAL"
- ]
- },
- {
- "name": "cc_TangentDisplacements",
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_TANGENT"
- ]
- },
- {
- "name": "cc_jointTexture",
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ]
- },
- {
- "name": "cc_realtimeJoint",
- "defines": [
- "CC_USE_SKINNING",
- "!CC_USE_BAKED_ANIMATION",
- "CC_USE_REAL_TIME_JOINT_TEXTURE"
- ]
- },
- {
- "name": "cc_reflectionProbeCubemap",
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ]
- },
- {
- "name": "cc_reflectionProbePlanarMap",
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ]
- },
- {
- "name": "cc_reflectionProbeDataMap",
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ]
- },
- {
- "name": "cc_reflectionProbeBlendCubemap",
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ]
- },
- {
- "name": "cc_lightingMap",
- "defines": [
- "CC_USE_LIGHTMAP",
- "!CC_FORWARD_ADD"
- ]
- }
- ],
- "buffers": [],
- "images": []
- },
- "statistics": {
- "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 100,
- "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 130
- }
- },
- "defines": [
- {
- "name": "USE_COMPATIBLE_LIGHTING",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "USE_NORMAL_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "USE_INSTANCING",
- "type": "boolean",
- "defines": [],
- "editor": {
- "elevated": true
- }
- },
- {
- "name": "CC_USE_LIGHTMAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_SKINNING",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_BAKED_ANIMATION",
- "type": "boolean",
- "defines": [
- "USE_INSTANCING"
- ]
- },
- {
- "name": "CC_RECEIVE_SHADOW",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_REFLECTION_PROBE",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 3
- ]
- },
- {
- "name": "CC_USE_LIGHT_PROBE",
- "type": "boolean",
- "defines": [],
- "default": 0
- },
- {
- "name": "CC_USE_MORPH",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_FORWARD_ADD",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_FOG",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 4
- ]
- },
- {
- "name": "CC_USE_ACCURATE_FOG",
- "type": "boolean",
- "defines": [
- "CC_USE_FOG"
- ]
- },
- {
- "name": "CC_MORPH_TARGET_COUNT",
- "type": "number",
- "defines": [
- "CC_USE_MORPH"
- ],
- "range": [
- 2,
- 8
- ]
- },
- {
- "name": "CC_MORPH_TARGET_HAS_POSITION",
- "type": "boolean",
- "defines": [
- "CC_USE_MORPH"
- ]
- },
- {
- "name": "CC_MORPH_TARGET_HAS_NORMAL",
- "type": "boolean",
- "defines": [
- "CC_USE_MORPH"
- ]
- },
- {
- "name": "CC_MORPH_TARGET_HAS_TANGENT",
- "type": "boolean",
- "defines": [
- "CC_USE_MORPH"
- ]
- },
- {
- "name": "CC_MORPH_PRECOMPUTED",
- "type": "boolean",
- "defines": [
- "CC_USE_MORPH"
- ]
- },
- {
- "name": "CC_USE_REAL_TIME_JOINT_TEXTURE",
- "type": "boolean",
- "defines": [
- "CC_USE_SKINNING",
- "!CC_USE_BAKED_ANIMATION"
- ]
- },
- {
- "name": "CC_DISABLE_STRUCTURE_IN_FRAGMENT_SHADER",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 1
- ]
- },
- {
- "name": "CC_PIPELINE_TYPE",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 1
- ]
- },
- {
- "name": "CC_FORCE_FORWARD_SHADING",
- "type": "boolean",
- "defines": [
- "CC_PIPELINE_TYPE"
- ]
- },
- {
- "name": "CC_ENABLE_CLUSTERED_LIGHT_CULLING",
- "type": "number",
- "defines": [
- "CC_FORWARD_ADD"
- ],
- "range": [
- 0,
- 3
- ]
- },
- {
- "name": "CC_SUPPORT_CASCADED_SHADOW_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_IBL",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 2
- ]
- },
- {
- "name": "CC_USE_DIFFUSEMAP",
- "type": "number",
- "defines": [
- "CC_USE_IBL"
- ],
- "range": [
- 0,
- 2
- ]
- },
- {
- "name": "USE_BASE_COLOR_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "USE_1ST_SHADE_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "USE_2ND_SHADE_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "USE_SPECULAR_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "USE_EMISSIVE_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "USE_ALPHA_TEST",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "ALPHA_TEST_CHANNEL",
- "type": "string",
- "defines": [
- "USE_ALPHA_TEST"
- ],
- "options": [
- "a",
- "r",
- "g",
- "b"
- ]
- },
- {
- "name": "CC_SHADOWMAP_USE_LINEAR_DEPTH",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_SHADOWMAP_FORMAT",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 3
- ]
- }
- ],
- "name": "builtin-toon|shadow-caster-vs|shadow-caster-fs"
- },
- {
- "blocks": [
- {
- "name": "Constants",
- "members": [
- {
- "name": "tilingOffset",
- "type": 16,
- "count": 1
- },
- {
- "name": "baseColor",
- "type": 16,
- "count": 1
- },
- {
- "name": "colorScaleAndCutoff",
- "type": 16,
- "count": 1
- },
- {
- "name": "shadeColor1",
- "type": 16,
- "count": 1
- },
- {
- "name": "shadeColor2",
- "type": 16,
- "count": 1
- },
- {
- "name": "specular",
- "type": 16,
- "count": 1
- },
- {
- "name": "shadeParams",
- "type": 16,
- "count": 1
- },
- {
- "name": "miscParams",
- "type": 16,
- "count": 1
- },
- {
- "name": "emissive",
- "type": 16,
- "count": 1
- },
- {
- "name": "emissiveScaleAndStrenth",
- "type": 16,
- "count": 1
- }
- ],
- "defines": [],
- "stageFlags": 17,
- "binding": 0
- }
- ],
- "samplerTextures": [
- {
- "name": "baseColorMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_BASE_COLOR_MAP"
- ],
- "stageFlags": 16,
- "binding": 1
- },
- {
- "name": "normalMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_NORMAL_MAP"
- ],
- "stageFlags": 16,
- "binding": 2
- },
- {
- "name": "shadeMap1",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_1ST_SHADE_MAP"
- ],
- "stageFlags": 16,
- "binding": 3
- },
- {
- "name": "shadeMap2",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_2ND_SHADE_MAP"
- ],
- "stageFlags": 16,
- "binding": 4
- },
- {
- "name": "specularMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_SPECULAR_MAP"
- ],
- "stageFlags": 16,
- "binding": 5
- },
- {
- "name": "emissiveMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_EMISSIVE_MAP"
- ],
- "stageFlags": 16,
- "binding": 6
- }
- ],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": [],
- "attributes": [
- {
- "name": "a_position",
- "defines": [],
- "format": 32,
- "location": 0
- },
- {
- "name": "a_normal",
- "defines": [],
- "format": 32,
- "location": 1
- },
- {
- "name": "a_texCoord",
- "defines": [],
- "format": 21,
- "location": 2
- },
- {
- "name": "a_tangent",
- "defines": [
- "USE_NORMAL_MAP"
- ],
- "format": 44,
- "location": 3
- },
- {
- "name": "a_color",
- "defines": [],
- "format": 44,
- "location": 6
- },
- {
- "name": "a_texCoord1",
- "defines": [],
- "format": 21,
- "location": 7
- },
- {
- "name": "a_joints",
- "defines": [
- "CC_USE_SKINNING"
- ],
- "location": 4
- },
- {
- "name": "a_weights",
- "defines": [
- "CC_USE_SKINNING"
- ],
- "format": 44,
- "location": 5
- },
- {
- "name": "a_jointAnimInfo",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_BAKED_ANIMATION"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 8
- },
- {
- "name": "a_matWorld0",
- "defines": [
- "USE_INSTANCING"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 9
- },
- {
- "name": "a_matWorld1",
- "defines": [
- "USE_INSTANCING"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 10
- },
- {
- "name": "a_matWorld2",
- "defines": [
- "USE_INSTANCING"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 11
- },
- {
- "name": "a_lightingMapUVParam",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_LIGHTMAP"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 12
- },
- {
- "name": "a_localShadowBiasAndProbeId",
- "defines": [
- "USE_INSTANCING"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 13
- },
- {
- "name": "a_reflectionProbeData",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_REFLECTION_PROBE"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 14
- },
- {
- "name": "a_sh_linear_const_r",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_LIGHT_PROBE"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 15
- },
- {
- "name": "a_sh_linear_const_g",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_LIGHT_PROBE"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 16
- },
- {
- "name": "a_sh_linear_const_b",
- "defines": [
- "USE_INSTANCING",
- "CC_USE_LIGHT_PROBE"
- ],
- "format": 44,
- "isInstanced": true,
- "location": 17
- },
- {
- "name": "a_vertexId",
- "defines": [
- "CC_USE_MORPH"
- ],
- "format": 11,
- "location": 18
- }
- ],
- "varyings": [
- {
- "name": "v_worldPos",
- "type": 15,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 0
- },
- {
- "name": "v_normal",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 1
- },
- {
- "name": "v_uv",
- "type": 14,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 2
- },
- {
- "name": "v_color",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 3
- },
- {
- "name": "v_tangent",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 4
- },
- {
- "name": "v_uv1",
- "type": 14,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 5
- },
- {
- "name": "v_luv",
- "type": 15,
- "count": 1,
- "defines": [
- "CC_USE_LIGHTMAP",
- "!CC_FORWARD_ADD"
- ],
- "stageFlags": 17,
- "location": 6
- },
- {
- "name": "v_shadowBiasAndProbeId",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 7
- },
- {
- "name": "v_reflectionProbeData",
- "type": 16,
- "count": 1,
- "defines": [
- "CC_USE_REFLECTION_PROBE",
- "USE_INSTANCING"
- ],
- "stageFlags": 17,
- "location": 8
- },
- {
- "name": "v_fogFactor",
- "type": 13,
- "count": 1,
- "defines": [
- "CC_USE_FOG",
- "!CC_USE_ACCURATE_FOG"
- ],
- "stageFlags": 17,
- "location": 9
- },
- {
- "name": "v_localPos",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 10
- },
- {
- "name": "v_clipPos",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 11
- },
- {
- "name": "v_sh_linear_const_r",
- "type": 16,
- "count": 1,
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "USE_INSTANCING"
- ],
- "stageFlags": 17,
- "location": 12
- },
- {
- "name": "v_sh_linear_const_g",
- "type": 16,
- "count": 1,
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "USE_INSTANCING"
- ],
- "stageFlags": 17,
- "location": 13
- },
- {
- "name": "v_sh_linear_const_b",
- "type": 16,
- "count": 1,
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "USE_INSTANCING"
- ],
- "stageFlags": 17,
- "location": 14
- },
- {
- "name": "v_dist",
- "type": 13,
- "count": 1,
- "defines": [],
- "stageFlags": 17,
- "location": 15
- }
- ],
- "fragColors": [
- {
- "name": "fragColorX",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "defines": [],
- "stageFlags": 16,
- "location": 0
- }
- ],
- "descriptors": [
- {
- "rate": 0,
- "blocks": [
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCLocal",
- "members": [
- {
- "name": "cc_matWorld",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matWorldIT",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_lightingMapUVParam",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_localShadowBias",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeData1",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeData2",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeBlendData1",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_reflectionProbeBlendData2",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- }
- ],
- "defines": [
- "!USE_INSTANCING"
- ],
- "stageFlags": 17
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCMorph",
- "members": [
- {
- "name": "cc_displacementWeights",
- "typename": "vec4",
- "type": 16,
- "count": 15,
- "isArray": true
- },
- {
- "name": "cc_displacementTextureInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1
- }
- ],
- "defines": [
- "CC_USE_MORPH"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCSkinningTexture",
- "members": [
- {
- "name": "cc_jointTextureInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- }
- ],
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCSkinningAnimation",
- "members": [
- {
- "name": "cc_jointAnimInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- }
- ],
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCSkinning",
- "members": [
- {
- "name": "cc_joints",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "precision": "highp ",
- "isArray": true
- }
- ],
- "defines": [
- "CC_USE_SKINNING",
- "!CC_USE_BAKED_ANIMATION",
- "!CC_USE_REAL_TIME_JOINT_TEXTURE"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCForwardLight",
- "members": [
- {
- "name": "cc_lightPos",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_lightColor",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "isArray": true
- },
- {
- "name": "cc_lightSizeRangeAngle",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "isArray": true
- },
- {
- "name": "cc_lightDir",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "isArray": true
- },
- {
- "name": "cc_lightBoundingSizeVS",
- "typename": "vec4",
- "type": 16,
- "count": 0,
- "isArray": true
- }
- ],
- "defines": [
- "CC_FORWARD_ADD",
- "CC_ENABLE_CLUSTERED_LIGHT_CULLING"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "CCSH",
- "members": [
- {
- "name": "cc_sh_linear_const_r",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_linear_const_g",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_linear_const_b",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_r",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_g",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_b",
- "typename": "vec4",
- "type": 16,
- "count": 1
- },
- {
- "name": "cc_sh_quadratic_a",
- "typename": "vec4",
- "type": 16,
- "count": 1
- }
- ],
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "!USE_INSTANCING"
- ],
- "stageFlags": 16
- }
- ],
- "samplerTextures": [
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_PositionDisplacements",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_POSITION"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_NormalDisplacements",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_NORMAL"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_TangentDisplacements",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_TANGENT"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_jointTexture",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "precision": "highp ",
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_realtimeJoint",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "precision": "highp ",
- "defines": [
- "CC_USE_SKINNING",
- "!CC_USE_BAKED_ANIMATION",
- "CC_USE_REAL_TIME_JOINT_TEXTURE"
- ],
- "stageFlags": 1
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_reflectionProbeCubemap",
- "typename": "samplerCube",
- "type": 31,
- "count": 1,
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_reflectionProbePlanarMap",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_reflectionProbeDataMap",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_reflectionProbeBlendCubemap",
- "typename": "samplerCube",
- "type": 31,
- "count": 1,
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "local"
- },
- "name": "cc_lightingMap",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "defines": [
- "CC_USE_LIGHTMAP",
- "!CC_FORWARD_ADD"
- ],
- "stageFlags": 16
- }
- ],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- },
- {
- "rate": 1,
- "blocks": [
- {
- "name": "Constants",
- "members": [
- {
- "name": "tilingOffset",
- "type": 16,
- "count": 1
- },
- {
- "name": "baseColor",
- "type": 16,
- "count": 1
- },
- {
- "name": "colorScaleAndCutoff",
- "type": 16,
- "count": 1
- },
- {
- "name": "shadeColor1",
- "type": 16,
- "count": 1
- },
- {
- "name": "shadeColor2",
- "type": 16,
- "count": 1
- },
- {
- "name": "specular",
- "type": 16,
- "count": 1
- },
- {
- "name": "shadeParams",
- "type": 16,
- "count": 1
- },
- {
- "name": "miscParams",
- "type": 16,
- "count": 1
- },
- {
- "name": "emissive",
- "type": 16,
- "count": 1
- },
- {
- "name": "emissiveScaleAndStrenth",
- "type": 16,
- "count": 1
- }
- ],
- "defines": [],
- "stageFlags": 17,
- "binding": 0
- }
- ],
- "samplerTextures": [
- {
- "name": "baseColorMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_BASE_COLOR_MAP"
- ],
- "stageFlags": 16,
- "binding": 1
- },
- {
- "name": "normalMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_NORMAL_MAP"
- ],
- "stageFlags": 16,
- "binding": 2
- },
- {
- "name": "shadeMap1",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_1ST_SHADE_MAP"
- ],
- "stageFlags": 16,
- "binding": 3
- },
- {
- "name": "shadeMap2",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_2ND_SHADE_MAP"
- ],
- "stageFlags": 16,
- "binding": 4
- },
- {
- "name": "specularMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_SPECULAR_MAP"
- ],
- "stageFlags": 16,
- "binding": 5
- },
- {
- "name": "emissiveMap",
- "type": 28,
- "count": 1,
- "defines": [
- "USE_EMISSIVE_MAP"
- ],
- "stageFlags": 16,
- "binding": 6
- }
- ],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- },
- {
- "rate": 2,
- "blocks": [],
- "samplerTextures": [],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- },
- {
- "rate": 3,
- "blocks": [
- {
- "tags": {
- "builtin": "global"
- },
- "name": "CCGlobal",
- "members": [
- {
- "name": "cc_time",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_screenSize",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_nativeSize",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_probeInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_debug_view_mode",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- }
- ],
- "defines": [],
- "stageFlags": 17
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "CCCamera",
- "members": [
- {
- "name": "cc_matView",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matViewInv",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matProj",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matProjInv",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matViewProj",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matViewProjInv",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_cameraPos",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_surfaceTransform",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_screenScale",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_exposure",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_mainLitDir",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_mainLitColor",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_ambientSky",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_ambientGround",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_fogColor",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_fogBase",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_fogAdd",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_nearFar",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_viewPort",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- }
- ],
- "defines": [],
- "stageFlags": 17
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "CCShadow",
- "members": [
- {
- "name": "cc_matLightView",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_matLightViewProj",
- "typename": "mat4",
- "type": 25,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_shadowInvProjDepthInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_shadowProjDepthInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_shadowProjInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- },
- {
- "name": "cc_shadowNFLSInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_shadowWHPBInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_shadowLPNNInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- },
- {
- "name": "cc_shadowColor",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "lowp "
- },
- {
- "name": "cc_planarNDInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "mediump "
- }
- ],
- "defines": [],
- "stageFlags": 17
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "CCCSM",
- "members": [
- {
- "name": "cc_csmViewDir0",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmViewDir1",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmViewDir2",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmAtlas",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_matCSMViewProj",
- "typename": "mat4",
- "type": 25,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmProjDepthInfo",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmProjInfo",
- "typename": "vec4",
- "type": 16,
- "count": 4,
- "precision": "highp ",
- "isArray": true
- },
- {
- "name": "cc_csmSplitsInfo",
- "typename": "vec4",
- "type": 16,
- "count": 1,
- "precision": "highp "
- }
- ],
- "defines": [
- "CC_SUPPORT_CASCADED_SHADOW_MAP"
- ],
- "stageFlags": 16
- }
- ],
- "samplerTextures": [
- {
- "tags": {
- "builtin": "global"
- },
- "name": "cc_environment",
- "typename": "samplerCube",
- "type": 31,
- "count": 1,
- "defines": [],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "cc_diffuseMap",
- "typename": "samplerCube",
- "type": 31,
- "count": 1,
- "defines": [
- "CC_USE_IBL",
- "CC_USE_DIFFUSEMAP"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "cc_shadowMap",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "precision": "highp ",
- "defines": [
- "CC_RECEIVE_SHADOW"
- ],
- "stageFlags": 16
- },
- {
- "tags": {
- "builtin": "global"
- },
- "name": "cc_spotShadowMap",
- "typename": "sampler2D",
- "type": 28,
- "count": 1,
- "precision": "highp ",
- "defines": [
- "CC_RECEIVE_SHADOW"
- ],
- "stageFlags": 16
- }
- ],
- "samplers": [],
- "textures": [],
- "buffers": [],
- "images": [],
- "subpassInputs": []
- }
- ],
- "hash": 2666727366,
- "glsl4": {
- "vert": "#extension GL_EXT_shader_explicit_arithmetic_types_int32: require\nprecision highp float;\n#define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING USE_COMPATIBLE_LIGHTING\n#define CC_SURFACES_USE_TANGENT_SPACE USE_NORMAL_MAP\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\nlayout(location = 0) in vec3 a_position;\nlayout(location = 1) in vec3 a_normal;\nlayout(location = 2) in vec2 a_texCoord;\n#if CC_SURFACES_USE_TANGENT_SPACE\n layout(location = 3) in vec4 a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n layout(location = 6) in vec4 a_color;\n#endif\n#if CC_SURFACES_USE_SECOND_UV || CC_USE_LIGHTMAP\n layout(location = 7) in vec2 a_texCoord1;\n#endif\n#if CC_USE_SKINNING\n layout(location = 4) in u32vec4 a_joints;\n layout(location = 5) in vec4 a_weights;\n#endif\n#if USE_INSTANCING\n #if CC_USE_BAKED_ANIMATION\n layout(location = 8) in highp vec4 a_jointAnimInfo;\n #endif\n layout(location = 9) in vec4 a_matWorld0;\n layout(location = 10) in vec4 a_matWorld1;\n layout(location = 11) in vec4 a_matWorld2;\n #if CC_USE_LIGHTMAP\n layout(location = 12) in vec4 a_lightingMapUVParam;\n #endif\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n layout(location = 13) in vec4 a_localShadowBiasAndProbeId;\n #endif\n #if CC_USE_REFLECTION_PROBE\n layout(location = 14) in vec4 a_reflectionProbeData;\n #endif\n #if CC_USE_LIGHT_PROBE\n layout(location = 15) in vec4 a_sh_linear_const_r;\n layout(location = 16) in vec4 a_sh_linear_const_g;\n layout(location = 17) in vec4 a_sh_linear_const_b;\n #endif\n#endif\n#if CC_USE_MORPH\n#endif\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\nfloat saturate(float value) { return clamp(value, 0.0, 1.0); }\nvec2 saturate(vec2 value) { return clamp(value, vec2(0.0), vec2(1.0)); }\nvec3 saturate(vec3 value) { return clamp(value, vec3(0.0), vec3(1.0)); }\nvec4 saturate(vec4 value) { return clamp(value, vec4(0.0), vec4(1.0)); }\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nlayout(location = 0) out highp vec3 v_worldPos;\nlayout(location = 1) out vec4 v_normal;\nlayout(location = 2) out vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n layout(location = 3) out lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n layout(location = 4) out mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n layout(location = 5) out mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n layout(location = 6) out mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n layout(location = 7) out mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n layout(location = 8) out mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n layout(location = 9) out mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n layout(location = 10) out highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n layout(location = 11) out highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n layout(location = 12) out mediump vec4 v_sh_linear_const_r;\n layout(location = 13) out mediump vec4 v_sh_linear_const_g;\n layout(location = 14) out mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define VSOutput_worldPos v_worldPos\n#define VSOutput_worldNormal v_normal.xyz\n#define VSOutput_faceSideSign v_normal.w\n#define VSOutput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define VSOutput_vertexColor v_color\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define VSOutput_worldTangent v_tangent.xyz\n #define VSOutput_mirrorNormal v_tangent.w\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define VSOutput_texcoord1 v_uv1\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define VSOutput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define VSOutput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define VSOutput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define VSOutput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define VSOutput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define VSOutput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define VSOutput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define VSOutput_clipPos v_clipPos\n#endif\nstruct SurfacesStandardVertexIntermediate\n{\n highp vec4 position;\n vec3 normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n vec4 tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n vec4 color;\n#endif\n vec2 texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n vec2 texCoord1;\n#endif\n highp vec4 clipPos;\n highp vec3 worldPos;\n vec4 worldNormal;\n #if CC_SURFACES_USE_TANGENT_SPACE\n vec3 worldTangent, worldBinormal;\n #endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n vec4 shadowBiasAndProbeId;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n float fogFactor;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n vec3 lightmapUV;\n#endif\n};\n#if CC_USE_MORPH\n int getVertexId() {\n return gl_VertexIndex;\n }\n#endif\nlayout(set = 0, binding = 0) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\nlayout(set = 0, binding = 2) uniform CCShadow {\n highp mat4 cc_matLightView;\n highp mat4 cc_matLightViewProj;\n highp vec4 cc_shadowInvProjDepthInfo;\n highp vec4 cc_shadowProjDepthInfo;\n highp vec4 cc_shadowProjInfo;\n mediump vec4 cc_shadowNFLSInfo;\n mediump vec4 cc_shadowWHPBInfo;\n mediump vec4 cc_shadowLPNNInfo;\n lowp vec4 cc_shadowColor;\n mediump vec4 cc_planarNDInfo;\n};\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\n#if !USE_INSTANCING\n layout(set = 2, binding = 0) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n highp vec4 cc_localShadowBias;\n highp vec4 cc_reflectionProbeData1;\n highp vec4 cc_reflectionProbeData2;\n highp vec4 cc_reflectionProbeBlendData1;\n highp vec4 cc_reflectionProbeBlendData2;\n };\n#endif\nvoid CCGetWorldMatrixFull(out mat4 matWorld, out mat4 matWorldIT)\n{\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n vec3 scale = 1.0 / vec3(length(a_matWorld0.xyz), length(a_matWorld1.xyz), length(a_matWorld2.xyz));\n vec3 scale2 = scale * scale;\n matWorldIT = mat4(\n vec4(a_matWorld0.xyz * scale2.x, 0.0),\n vec4(a_matWorld1.xyz * scale2.y, 0.0),\n vec4(a_matWorld2.xyz * scale2.z, 0.0),\n vec4(0.0, 0.0, 0.0, 1.0)\n );\n #else\n matWorld = cc_matWorld;\n matWorldIT = cc_matWorldIT;\n #endif\n}\n#if CC_USE_MORPH\n layout(set = 2, binding = 4) uniform CCMorph {\n vec4 cc_displacementWeights[15];\n vec4 cc_displacementTextureInfo;\n };\n #if CC_MORPH_TARGET_HAS_POSITION\n layout(set = 2, binding = 8) uniform sampler2D cc_PositionDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n layout(set = 2, binding = 9) uniform sampler2D cc_NormalDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n layout(set = 2, binding = 10) uniform sampler2D cc_TangentDisplacements;\n #endif\n vec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n }\n vec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n }\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\n ivec2 texSize = textureSize(tex, 0);\n return texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n }\n #else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture(tex, x)),\n decode32(texture(tex, y)),\n decode32(texture(tex, z)),\n 1.0\n );\n }\n #endif\n float getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n }\n vec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n #if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n #else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n #endif\n }\n #if CC_MORPH_TARGET_HAS_POSITION\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n #endif\n void applyMorph (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n int vertexId = getVertexId();\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n normal.xyz = normal.xyz + getNormalDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n tangent.xyz = tangent.xyz + getTangentDisplacement(vertexId);\n #endif\n }\n void applyMorph (inout vec4 position) {\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n #endif\n }\n#endif\n#if CC_USE_SKINNING\n #if CC_USE_BAKED_ANIMATION\n layout(set = 2, binding = 3) uniform CCSkinningTexture {\n highp vec4 cc_jointTextureInfo;\n };\n layout(set = 2, binding = 2) uniform CCSkinningAnimation {\n highp vec4 cc_jointAnimInfo;\n };\n layout(set = 2, binding = 7) uniform highp sampler2D cc_jointTexture;\n void CCGetJointTextureCoords(float pixelsPerJoint, float jointIdx, out highp float x, out highp float y, out highp float invSize)\n {\n #if USE_INSTANCING\n highp float temp = pixelsPerJoint * (a_jointAnimInfo.x * a_jointAnimInfo.y + jointIdx) + a_jointAnimInfo.z;\n #else\n highp float temp = pixelsPerJoint * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + jointIdx) + cc_jointTextureInfo.z;\n #endif\n invSize = cc_jointTextureInfo.w;\n highp float tempY = floor(temp * invSize);\n x = floor(temp - tempY * cc_jointTextureInfo.x);\n y = (tempY + 0.5) * invSize;\n }\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n layout(set = 2, binding = 7) uniform highp sampler2D cc_realtimeJoint;\n #else\n layout(set = 2, binding = 3) uniform CCSkinning {\n highp vec4 cc_joints[CC_JOINT_UNIFORM_CAPACITY * 3];\n };\n #endif\n #endif\n #if CC_USE_BAKED_ANIMATION\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(3.0, i, x, y, invSize);\n vec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(12.0, i, x, y, invSize);\n vec4 v1 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n float x = i;\n vec4 v1 = texture(cc_realtimeJoint, vec2( x / 256.0, 0.5 / 3.0));\n vec4 v2 = texture(cc_realtimeJoint, vec2( x / 256.0, 1.5 / 3.0));\n vec4 v3 = texture(cc_realtimeJoint, vec2( x / 256.0, 2.5 / 3.0));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n float x = 4.0 * i;\n vec4 v1 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 0.5 / 3.0)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 1.5 / 3.0)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 2.5 / 3.0)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #endif\n mat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n }\n void CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n }\n void CCSkin (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n mat4 m = skinMatrix();\n position = m * position;\n normal = (m * vec4(normal, 0.0)).xyz;\n tangent.xyz = (m * vec4(tangent.xyz, 0.0)).xyz;\n }\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #if CC_USE_FOG != 4\n #endif\n#endif\nlayout(set = 1, binding = 0) uniform Constants {\n vec4 tilingOffset;\n vec4 baseColor;\n vec4 colorScaleAndCutoff;\n vec4 shadeColor1;\n vec4 shadeColor2;\n vec4 specular;\n vec4 shadeParams;\n vec4 miscParams;\n vec4 emissive;\n vec4 emissiveScaleAndStrenth;\n};\n#define CC_SURFACES_VERTEX_MODIFY_UV\nvoid SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)\n{\n In.texCoord = In.texCoord * tilingOffset.xy + tilingOffset.zw;\n}\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_POS\nvec3 SurfacesVertexModifyLocalPos(in SurfacesStandardVertexIntermediate In)\n{\n return vec3(In.position.xyz);\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_NORMAL\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_TANGENT\n #if CC_SURFACES_USE_TANGENT_SPACE\n #endif\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_SHARED_DATA\nvoid SurfacesVertexModifyLocalSharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_POS\nvec3 SurfacesVertexModifyWorldPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.worldPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_CLIP_POS\nvec4 SurfacesVertexModifyClipPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.clipPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_UV\nvoid SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_NORMAL\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHADOW_BIAS\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHARED_DATA\nvoid SurfacesVertexModifySharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\nvoid CCSurfacesVertexInput(out SurfacesStandardVertexIntermediate In)\n{\n In.position = vec4(a_position, 1.0);\n In.normal = a_normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n In.tangent = a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n In.color = a_color;\n#endif\n In.texCoord = a_texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = a_texCoord1;\n#endif\n}\nvoid CCSurfacesVertexOutput(in SurfacesStandardVertexIntermediate In)\n{\n gl_Position = In.clipPos;\n VSOutput_worldNormal = In.worldNormal.xyz;\n VSOutput_faceSideSign = In.worldNormal.w;\n VSOutput_worldPos = In.worldPos;\n#if CC_SURFACES_USE_TANGENT_SPACE\n VSOutput_worldTangent = In.worldTangent.xyz;\n VSOutput_mirrorNormal = In.tangent.w > 0.0 ? 1.0 : -1.0;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n VSOutput_vertexColor = In.color;\n#endif\n VSOutput_texcoord = In.texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n VSOutput_texcoord1 = In.texCoord1;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n VSOutput_fogFactor = In.fogFactor;\n#endif\n#if CC_RECEIVE_SHADOW\n VSOutput_shadowBias = In.shadowBiasAndProbeId.xy;\n#endif\n#if CC_USE_REFLECTION_PROBE\n VSOutput_reflectionProbeId = In.shadowBiasAndProbeId.z;\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n VSOutput_reflectionProbeBlendId = In.shadowBiasAndProbeId.w;\n #endif\n #if USE_INSTANCING\n v_reflectionProbeData = a_reflectionProbeData;\n #endif\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n VSOutput_lightMapUV = In.lightmapUV;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n VSOutput_localPos = In.position;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n VSOutput_clipPos = In.clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n v_sh_linear_const_r = a_sh_linear_const_r;\n v_sh_linear_const_g = a_sh_linear_const_g;\n v_sh_linear_const_b = a_sh_linear_const_b;\n #endif\n#endif\n}\nvoid CCSurfacesVertexAnimation(inout SurfacesStandardVertexIntermediate In)\n{\nvec4 temp = vec4(0.0);\n#if CC_USE_MORPH\n #if CC_SURFACES_USE_TANGENT_SPACE\n applyMorph(In.position, In.normal, In.tangent);\n #else\n applyMorph(In.position, In.normal, temp);\n #endif\n#endif\n#if CC_USE_SKINNING\n #if CC_SURFACES_USE_TANGENT_SPACE\n CCSkin(In.position, In.normal, In.tangent);\n #else\n CCSkin(In.position, In.normal, temp);\n #endif\n#endif\n}\nvoid CCSurfacesVertexWorldTransform(inout SurfacesStandardVertexIntermediate In)\n{\n mat4 matWorld, matWorldIT;\n CCGetWorldMatrixFull(matWorld, matWorldIT);\n In.worldPos = (matWorld * In.position).xyz;\n In.worldNormal.xyz = normalize((matWorldIT * vec4(In.normal.xyz, 0.0)).xyz);\n #if CC_SURFACES_USE_TANGENT_SPACE\n In.worldTangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\n In.worldBinormal = cross(In.worldNormal.xyz, In.worldTangent) * In.tangent.w;\n #endif\n}\nvoid CCSurfacesVertexTransformUV(inout SurfacesStandardVertexIntermediate In)\n{\n #if CC_SURFACES_FLIP_UV\n In.texCoord = cc_cameraPos.w > 1.0 ? vec2(In.texCoord.x, 1.0 - In.texCoord.y) : In.texCoord;\n #if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = cc_cameraPos.w > 1.0 ? vec2(In.texCoord1.x, 1.0 - In.texCoord1.y) : In.texCoord1;\n #endif\n #endif\n}\nvec4 CalculatePlanarShadowPos(vec3 meshWorldPos, vec3 cameraPos, vec3 lightDir, vec4 plane) {\n vec3 P = meshWorldPos;\n vec3 L = lightDir;\n vec3 N = plane.xyz;\n float d = plane.w + EPSILON_LOWP;\n float dist = (-d - dot(P, N)) / (dot(L, N) + EPSILON_LOWP);\n vec3 shadowPos = P + L * dist;\n return vec4(shadowPos, dist);\n}\nvec4 CalculatePlanarShadowClipPos(vec4 shadowPos, vec3 cameraPos, mat4 matView, mat4 matProj, vec4 nearFar, float bias) {\n vec4 camPos = matView * vec4(shadowPos.xyz, 1.0);\n float lerpCoef = saturate((nearFar.z < 0.0 ? -camPos.z : camPos.z) / (nearFar.y - nearFar.x));\n camPos.z += mix(nearFar.x * 0.01, nearFar.y * EPSILON_LOWP * bias, lerpCoef);\n return matProj * camPos;\n}\nlayout(location = 15) out highp float v_dist;\nvoid main()\n{\n SurfacesStandardVertexIntermediate In;\n CCSurfacesVertexInput(In);\n CCSurfacesVertexAnimation(In);\n In.position.xyz = SurfacesVertexModifyLocalPos(In);\n SurfacesVertexModifyLocalSharedData(In);\n CCSurfacesVertexWorldTransform(In);\n In.worldPos = SurfacesVertexModifyWorldPos(In);\n vec4 shadowPos = CalculatePlanarShadowPos(In.worldPos, cc_cameraPos.xyz, cc_mainLitDir.xyz, cc_planarNDInfo);\n In.worldPos = shadowPos.xyz;\n In.clipPos = CalculatePlanarShadowClipPos(shadowPos, cc_cameraPos.xyz, cc_matView, cc_matProj, cc_nearFar, cc_shadowWHPBInfo.w);\n In.clipPos = SurfacesVertexModifyClipPos(In);\n SurfacesVertexModifyUV(In);\n SurfacesVertexModifySharedData(In);\n CCSurfacesVertexTransformUV(In);\n CCSurfacesVertexOutput(In);\n v_dist = shadowPos.w;\n}",
- "frag": "\nprecision highp float;\n#define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING USE_COMPATIBLE_LIGHTING\n#define CC_SURFACES_USE_TANGENT_SPACE USE_NORMAL_MAP\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nlayout(location = 0) in highp vec3 v_worldPos;\nlayout(location = 1) in vec4 v_normal;\nlayout(location = 2) in vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n layout(location = 3) in lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n layout(location = 4) in mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n layout(location = 5) in mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n layout(location = 6) in mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n layout(location = 7) in mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n layout(location = 8) in mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n layout(location = 9) in mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n layout(location = 10) in highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n layout(location = 11) in highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n layout(location = 12) in mediump vec4 v_sh_linear_const_r;\n layout(location = 13) in mediump vec4 v_sh_linear_const_g;\n layout(location = 14) in mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define FSInput_worldPos v_worldPos\n#define FSInput_worldNormal v_normal.xyz\n#define FSInput_faceSideSign v_normal.w\n#define FSInput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define FSInput_vertexColor v_color\n#else\n #define FSInput_vertexColor vec4(1.0)\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define FSInput_worldTangent v_tangent.xyz\n #define FSInput_mirrorNormal v_tangent.w\n#else\n #define FSInput_worldTangent vec3(1.0, 1.0, 1.0)\n #define FSInput_mirrorNormal 1.0\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define FSInput_texcoord1 v_uv1\n#else\n #define FSInput_texcoord1 vec2(0.0, 0.0)\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define FSInput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define FSInput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define FSInput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define FSInput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define FSInput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define FSInput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define FSInput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define FSInput_clipPos v_clipPos\n#endif\nlayout(set = 0, binding = 0) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(set = 0, binding = 1) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_WORLD_POS CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR CC_SURFACES_DEBUG_VIEW_WORLD_POS + 1\n#define CC_SURFACES_DEBUG_VIEW_FACE_SIDE CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR + 1\n#define CC_SURFACES_DEBUG_VIEW_UV0 CC_SURFACES_DEBUG_VIEW_FACE_SIDE + 1\n#define CC_SURFACES_DEBUG_VIEW_UV1 CC_SURFACES_DEBUG_VIEW_UV0 + 1\n#define CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP CC_SURFACES_DEBUG_VIEW_UV1 + 1\n#define CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP + 1\n#define CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_BASE_COLOR CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR CC_SURFACES_DEBUG_VIEW_BASE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSPARENCY CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_METALLIC CC_SURFACES_DEBUG_VIEW_TRANSPARENCY + 1\n#define CC_SURFACES_DEBUG_VIEW_ROUGHNESS CC_SURFACES_DEBUG_VIEW_METALLIC + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY CC_SURFACES_DEBUG_VIEW_ROUGHNESS + 1\n#define CC_SURFACES_DEBUG_VIEW_IOR CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_IOR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_ALL CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_DIRECT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_ALL CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_EMISSIVE CC_SURFACES_DEBUG_VIEW_ENV_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_LIGHT_MAP CC_SURFACES_DEBUG_VIEW_EMISSIVE + 1\n#define CC_SURFACES_DEBUG_VIEW_SHADOW CC_SURFACES_DEBUG_VIEW_LIGHT_MAP + 1\n#define CC_SURFACES_DEBUG_VIEW_AO CC_SURFACES_DEBUG_VIEW_SHADOW + 1\n#define CC_SURFACES_DEBUG_VIEW_FRESNEL CC_SURFACES_DEBUG_VIEW_AO + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_FRESNEL + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_FOG CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL + 1\n#define IS_DEBUG_VIEW_ENABLE_WITH_CAMERA (cc_surfaceTransform.y != 3.0)\n#define IS_DEBUG_VIEW_LIGHTING_ENABLE_WITH_ALBEDO (UnpackBitFromFloat(cc_debug_view_mode.w, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_MISC_ENABLE_CSM_LAYER_COLORATION (UnpackBitFromFloat(cc_debug_view_mode.w, 7) && IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_EMISSIVE (UnpackBitFromFloat(cc_debug_view_mode.y, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_LIGHT_MAP (UnpackBitFromFloat(cc_debug_view_mode.y, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_SHADOW (UnpackBitFromFloat(cc_debug_view_mode.y, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_AO (UnpackBitFromFloat(cc_debug_view_mode.y, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_NORMAL_MAP (UnpackBitFromFloat(cc_debug_view_mode.z, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FOG (UnpackBitFromFloat(cc_debug_view_mode.z, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TONE_MAPPING (UnpackBitFromFloat(cc_debug_view_mode.z, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION (UnpackBitFromFloat(cc_debug_view_mode.z, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FRESNEL (UnpackBitFromFloat(cc_debug_view_mode.z, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.z, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_2ND_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TT (UnpackBitFromFloat(cc_debug_view_mode.w, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#if (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\n #if CC_FORWARD_ADD\n #if CC_PIPELINE_TYPE == 0\n #define LIGHTS_PER_PASS 1\n #else\n #define LIGHTS_PER_PASS 10\n #endif\n #if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\n layout(set = 2, binding = 1) uniform CCForwardLight {\n highp vec4 cc_lightPos[LIGHTS_PER_PASS];\n vec4 cc_lightColor[LIGHTS_PER_PASS];\n vec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\n vec4 cc_lightDir[LIGHTS_PER_PASS];\n vec4 cc_lightBoundingSizeVS[LIGHTS_PER_PASS];\n };\n #endif\n #endif\n#endif\n#if CC_USE_LIGHT_PROBE\n #if !USE_INSTANCING\n layout(set = 2, binding = 6) uniform CCSH {\n vec4 cc_sh_linear_const_r;\n vec4 cc_sh_linear_const_g;\n vec4 cc_sh_linear_const_b;\n vec4 cc_sh_quadratic_r;\n vec4 cc_sh_quadratic_g;\n vec4 cc_sh_quadratic_b;\n vec4 cc_sh_quadratic_a;\n };\n #endif\n#endif\nlayout(set = 0, binding = 2) uniform CCShadow {\n highp mat4 cc_matLightView;\n highp mat4 cc_matLightViewProj;\n highp vec4 cc_shadowInvProjDepthInfo;\n highp vec4 cc_shadowProjDepthInfo;\n highp vec4 cc_shadowProjInfo;\n mediump vec4 cc_shadowNFLSInfo;\n mediump vec4 cc_shadowWHPBInfo;\n mediump vec4 cc_shadowLPNNInfo;\n lowp vec4 cc_shadowColor;\n mediump vec4 cc_planarNDInfo;\n};\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n layout(set = 0, binding = 3) uniform CCCSM {\n highp vec4 cc_csmViewDir0[4];\n highp vec4 cc_csmViewDir1[4];\n highp vec4 cc_csmViewDir2[4];\n highp vec4 cc_csmAtlas[4];\n highp mat4 cc_matCSMViewProj[4];\n highp vec4 cc_csmProjDepthInfo[4];\n highp vec4 cc_csmProjInfo[4];\n highp vec4 cc_csmSplitsInfo;\n };\n#endif\nlayout(set = 0, binding = 5) uniform samplerCube cc_environment;\n#if CC_USE_IBL\n #if CC_USE_DIFFUSEMAP\n layout(set = 0, binding = 7) uniform samplerCube cc_diffuseMap;\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n layout(set = 2, binding = 15) uniform samplerCube cc_reflectionProbeCubemap;\n layout(set = 2, binding = 16) uniform sampler2D cc_reflectionProbePlanarMap;\n layout(set = 2, binding = 17) uniform sampler2D cc_reflectionProbeDataMap;\n layout(set = 2, binding = 18) uniform samplerCube cc_reflectionProbeBlendCubemap;\n#endif\n#define UnpackBitFromFloat(value, bit) (mod(floor(value / pow(10.0, float(bit))), 10.0) > 0.0)\n#if defined(CC_USE_METAL) || defined(CC_USE_WGPU)\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y) y = -y\n#else\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y)\n#endif\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n#endif\n#if CC_RECEIVE_SHADOW\n layout(set = 0, binding = 4) uniform highp sampler2D cc_shadowMap;\n layout(set = 0, binding = 6) uniform highp sampler2D cc_spotShadowMap;\n #if CC_SUPPORT_CASCADED_SHADOW_MAP\n #else\n #endif\n#endif\n#if CC_USE_FOG != 4\n#endif\n#if CC_USE_LIGHT_PROBE\n #if CC_USE_LIGHT_PROBE\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n layout(set = 2, binding = 0) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n highp vec4 cc_localShadowBias;\n highp vec4 cc_reflectionProbeData1;\n highp vec4 cc_reflectionProbeData2;\n highp vec4 cc_reflectionProbeBlendData1;\n highp vec4 cc_reflectionProbeBlendData2;\n };\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n layout(set = 2, binding = 11) uniform sampler2D cc_lightingMap;\n#endif\nlayout(set = 1, binding = 0) uniform Constants {\n vec4 tilingOffset;\n vec4 baseColor;\n vec4 colorScaleAndCutoff;\n vec4 shadeColor1;\n vec4 shadeColor2;\n vec4 specular;\n vec4 shadeParams;\n vec4 miscParams;\n vec4 emissive;\n vec4 emissiveScaleAndStrenth;\n};\n#if USE_BASE_COLOR_MAP\n layout(set = 1, binding = 1) uniform sampler2D baseColorMap;\n#endif\n#if USE_NORMAL_MAP\n layout(set = 1, binding = 2) uniform sampler2D normalMap;\n#endif\n#if USE_1ST_SHADE_MAP\n layout(set = 1, binding = 3) uniform sampler2D shadeMap1;\n#endif\n#if USE_2ND_SHADE_MAP\n layout(set = 1, binding = 4) uniform sampler2D shadeMap2;\n#endif\n#if USE_SPECULAR_MAP\n layout(set = 1, binding = 5) uniform sampler2D specularMap;\n#endif\n#if USE_EMISSIVE_MAP\n layout(set = 1, binding = 6) uniform sampler2D emissiveMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\n#define CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TOONSHADE\n#define CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY\nvoid SurfacesFragmentAlphaClipOnly()\n{\n #if USE_ALPHA_TEST\n float alpha = baseColor.ALPHA_TEST_CHANNEL;\n #if USE_BASE_COLOR_MAP\n alpha = texture(baseColorMap, FSInput_texcoord).ALPHA_TEST_CHANNEL;\n #endif\n if (alpha < colorScaleAndCutoff.w) discard;\n #endif\n}\n#define CC_SURFACES_FRAGMENT_MODIFY_WORLD_NORMAL\n#define CC_SURFACES_FRAGMENT_MODIFY_EMISSIVE\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_STEP_AND_FEATHER\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_SHADOW_COVER\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_SPECULAR\nlayout(location = 15) in highp float v_dist;\nlayout(location = 0) out vec4 fragColorX;\nvoid main () {\n#ifdef CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY\n SurfacesFragmentAlphaClipOnly();\n#endif\n if(v_dist < 0.0)\n discard;\n fragColorX = cc_shadowColor;\n}"
- },
- "glsl3": {
- "vert": "\nprecision highp float;\n#define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING USE_COMPATIBLE_LIGHTING\n#define CC_SURFACES_USE_TANGENT_SPACE USE_NORMAL_MAP\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\n#if CC_SURFACES_USE_TANGENT_SPACE\n in vec4 a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n in vec4 a_color;\n#endif\n#if CC_SURFACES_USE_SECOND_UV || CC_USE_LIGHTMAP\n in vec2 a_texCoord1;\n#endif\n#if CC_USE_SKINNING\n in vec4 a_joints;\n in vec4 a_weights;\n#endif\n#if USE_INSTANCING\n #if CC_USE_BAKED_ANIMATION\n in highp vec4 a_jointAnimInfo;\n #endif\n in vec4 a_matWorld0;\n in vec4 a_matWorld1;\n in vec4 a_matWorld2;\n #if CC_USE_LIGHTMAP\n in vec4 a_lightingMapUVParam;\n #endif\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n in vec4 a_localShadowBiasAndProbeId;\n #endif\n #if CC_USE_REFLECTION_PROBE\n in vec4 a_reflectionProbeData;\n #endif\n #if CC_USE_LIGHT_PROBE\n in vec4 a_sh_linear_const_r;\n in vec4 a_sh_linear_const_g;\n in vec4 a_sh_linear_const_b;\n #endif\n#endif\n#if CC_USE_MORPH\n in float a_vertexId;\n#endif\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\nfloat saturate(float value) { return clamp(value, 0.0, 1.0); }\nvec2 saturate(vec2 value) { return clamp(value, vec2(0.0), vec2(1.0)); }\nvec3 saturate(vec3 value) { return clamp(value, vec3(0.0), vec3(1.0)); }\nvec4 saturate(vec4 value) { return clamp(value, vec4(0.0), vec4(1.0)); }\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nout highp vec3 v_worldPos;\nout vec4 v_normal;\nout vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n out lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n out mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n out mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n out mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n out mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n out mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n out mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n out highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n out highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n out mediump vec4 v_sh_linear_const_r;\n out mediump vec4 v_sh_linear_const_g;\n out mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define VSOutput_worldPos v_worldPos\n#define VSOutput_worldNormal v_normal.xyz\n#define VSOutput_faceSideSign v_normal.w\n#define VSOutput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define VSOutput_vertexColor v_color\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define VSOutput_worldTangent v_tangent.xyz\n #define VSOutput_mirrorNormal v_tangent.w\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define VSOutput_texcoord1 v_uv1\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define VSOutput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define VSOutput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define VSOutput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define VSOutput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define VSOutput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define VSOutput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define VSOutput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define VSOutput_clipPos v_clipPos\n#endif\nstruct SurfacesStandardVertexIntermediate\n{\n highp vec4 position;\n vec3 normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n vec4 tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n vec4 color;\n#endif\n vec2 texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n vec2 texCoord1;\n#endif\n highp vec4 clipPos;\n highp vec3 worldPos;\n vec4 worldNormal;\n #if CC_SURFACES_USE_TANGENT_SPACE\n vec3 worldTangent, worldBinormal;\n #endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n vec4 shadowBiasAndProbeId;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n float fogFactor;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n vec3 lightmapUV;\n#endif\n};\n#if CC_USE_MORPH\n int getVertexId() {\n return int(a_vertexId);\n }\n#endif\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightView;\n highp mat4 cc_matLightViewProj;\n highp vec4 cc_shadowInvProjDepthInfo;\n highp vec4 cc_shadowProjDepthInfo;\n highp vec4 cc_shadowProjInfo;\n mediump vec4 cc_shadowNFLSInfo;\n mediump vec4 cc_shadowWHPBInfo;\n mediump vec4 cc_shadowLPNNInfo;\n lowp vec4 cc_shadowColor;\n mediump vec4 cc_planarNDInfo;\n};\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\n#if !USE_INSTANCING\n layout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n highp vec4 cc_localShadowBias;\n highp vec4 cc_reflectionProbeData1;\n highp vec4 cc_reflectionProbeData2;\n highp vec4 cc_reflectionProbeBlendData1;\n highp vec4 cc_reflectionProbeBlendData2;\n };\n#endif\nvoid CCGetWorldMatrixFull(out mat4 matWorld, out mat4 matWorldIT)\n{\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n vec3 scale = 1.0 / vec3(length(a_matWorld0.xyz), length(a_matWorld1.xyz), length(a_matWorld2.xyz));\n vec3 scale2 = scale * scale;\n matWorldIT = mat4(\n vec4(a_matWorld0.xyz * scale2.x, 0.0),\n vec4(a_matWorld1.xyz * scale2.y, 0.0),\n vec4(a_matWorld2.xyz * scale2.z, 0.0),\n vec4(0.0, 0.0, 0.0, 1.0)\n );\n #else\n matWorld = cc_matWorld;\n matWorldIT = cc_matWorldIT;\n #endif\n}\n#if CC_USE_MORPH\n layout(std140) uniform CCMorph {\n vec4 cc_displacementWeights[15];\n vec4 cc_displacementTextureInfo;\n };\n #if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n #endif\n vec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n }\n vec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n }\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\n ivec2 texSize = textureSize(tex, 0);\n return texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n }\n #else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture(tex, x)),\n decode32(texture(tex, y)),\n decode32(texture(tex, z)),\n 1.0\n );\n }\n #endif\n float getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n }\n vec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n #if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n #else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n #endif\n }\n #if CC_MORPH_TARGET_HAS_POSITION\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n #endif\n void applyMorph (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n int vertexId = getVertexId();\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n normal.xyz = normal.xyz + getNormalDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n tangent.xyz = tangent.xyz + getTangentDisplacement(vertexId);\n #endif\n }\n void applyMorph (inout vec4 position) {\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n #endif\n }\n#endif\n#if CC_USE_SKINNING\n #if CC_USE_BAKED_ANIMATION\n layout(std140) uniform CCSkinningTexture {\n highp vec4 cc_jointTextureInfo;\n };\n layout(std140) uniform CCSkinningAnimation {\n highp vec4 cc_jointAnimInfo;\n };\n uniform highp sampler2D cc_jointTexture;\n void CCGetJointTextureCoords(float pixelsPerJoint, float jointIdx, out highp float x, out highp float y, out highp float invSize)\n {\n #if USE_INSTANCING\n highp float temp = pixelsPerJoint * (a_jointAnimInfo.x * a_jointAnimInfo.y + jointIdx) + a_jointAnimInfo.z;\n #else\n highp float temp = pixelsPerJoint * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + jointIdx) + cc_jointTextureInfo.z;\n #endif\n invSize = cc_jointTextureInfo.w;\n highp float tempY = floor(temp * invSize);\n x = floor(temp - tempY * cc_jointTextureInfo.x);\n y = (tempY + 0.5) * invSize;\n }\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n uniform highp sampler2D cc_realtimeJoint;\n #else\n layout(std140) uniform CCSkinning {\n highp vec4 cc_joints[CC_JOINT_UNIFORM_CAPACITY * 3];\n };\n #endif\n #endif\n #if CC_USE_BAKED_ANIMATION\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(3.0, i, x, y, invSize);\n vec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(12.0, i, x, y, invSize);\n vec4 v1 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n float x = i;\n vec4 v1 = texture(cc_realtimeJoint, vec2( x / 256.0, 0.5 / 3.0));\n vec4 v2 = texture(cc_realtimeJoint, vec2( x / 256.0, 1.5 / 3.0));\n vec4 v3 = texture(cc_realtimeJoint, vec2( x / 256.0, 2.5 / 3.0));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n float x = 4.0 * i;\n vec4 v1 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 0.5 / 3.0)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 1.5 / 3.0)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 2.5 / 3.0)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #endif\n mat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n }\n void CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n }\n void CCSkin (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n mat4 m = skinMatrix();\n position = m * position;\n normal = (m * vec4(normal, 0.0)).xyz;\n tangent.xyz = (m * vec4(tangent.xyz, 0.0)).xyz;\n }\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #if CC_USE_FOG != 4\n #endif\n#endif\nlayout(std140) uniform Constants {\n vec4 tilingOffset;\n vec4 baseColor;\n vec4 colorScaleAndCutoff;\n vec4 shadeColor1;\n vec4 shadeColor2;\n vec4 specular;\n vec4 shadeParams;\n vec4 miscParams;\n vec4 emissive;\n vec4 emissiveScaleAndStrenth;\n};\n#define CC_SURFACES_VERTEX_MODIFY_UV\nvoid SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)\n{\n In.texCoord = In.texCoord * tilingOffset.xy + tilingOffset.zw;\n}\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_POS\nvec3 SurfacesVertexModifyLocalPos(in SurfacesStandardVertexIntermediate In)\n{\n return vec3(In.position.xyz);\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_NORMAL\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_TANGENT\n #if CC_SURFACES_USE_TANGENT_SPACE\n #endif\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_SHARED_DATA\nvoid SurfacesVertexModifyLocalSharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_POS\nvec3 SurfacesVertexModifyWorldPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.worldPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_CLIP_POS\nvec4 SurfacesVertexModifyClipPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.clipPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_UV\nvoid SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_NORMAL\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHADOW_BIAS\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHARED_DATA\nvoid SurfacesVertexModifySharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\nvoid CCSurfacesVertexInput(out SurfacesStandardVertexIntermediate In)\n{\n In.position = vec4(a_position, 1.0);\n In.normal = a_normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n In.tangent = a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n In.color = a_color;\n#endif\n In.texCoord = a_texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = a_texCoord1;\n#endif\n}\nvoid CCSurfacesVertexOutput(in SurfacesStandardVertexIntermediate In)\n{\n gl_Position = In.clipPos;\n VSOutput_worldNormal = In.worldNormal.xyz;\n VSOutput_faceSideSign = In.worldNormal.w;\n VSOutput_worldPos = In.worldPos;\n#if CC_SURFACES_USE_TANGENT_SPACE\n VSOutput_worldTangent = In.worldTangent.xyz;\n VSOutput_mirrorNormal = In.tangent.w > 0.0 ? 1.0 : -1.0;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n VSOutput_vertexColor = In.color;\n#endif\n VSOutput_texcoord = In.texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n VSOutput_texcoord1 = In.texCoord1;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n VSOutput_fogFactor = In.fogFactor;\n#endif\n#if CC_RECEIVE_SHADOW\n VSOutput_shadowBias = In.shadowBiasAndProbeId.xy;\n#endif\n#if CC_USE_REFLECTION_PROBE\n VSOutput_reflectionProbeId = In.shadowBiasAndProbeId.z;\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n VSOutput_reflectionProbeBlendId = In.shadowBiasAndProbeId.w;\n #endif\n #if USE_INSTANCING\n v_reflectionProbeData = a_reflectionProbeData;\n #endif\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n VSOutput_lightMapUV = In.lightmapUV;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n VSOutput_localPos = In.position;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n VSOutput_clipPos = In.clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n v_sh_linear_const_r = a_sh_linear_const_r;\n v_sh_linear_const_g = a_sh_linear_const_g;\n v_sh_linear_const_b = a_sh_linear_const_b;\n #endif\n#endif\n}\nvoid CCSurfacesVertexAnimation(inout SurfacesStandardVertexIntermediate In)\n{\nvec4 temp = vec4(0.0);\n#if CC_USE_MORPH\n #if CC_SURFACES_USE_TANGENT_SPACE\n applyMorph(In.position, In.normal, In.tangent);\n #else\n applyMorph(In.position, In.normal, temp);\n #endif\n#endif\n#if CC_USE_SKINNING\n #if CC_SURFACES_USE_TANGENT_SPACE\n CCSkin(In.position, In.normal, In.tangent);\n #else\n CCSkin(In.position, In.normal, temp);\n #endif\n#endif\n}\nvoid CCSurfacesVertexWorldTransform(inout SurfacesStandardVertexIntermediate In)\n{\n mat4 matWorld, matWorldIT;\n CCGetWorldMatrixFull(matWorld, matWorldIT);\n In.worldPos = (matWorld * In.position).xyz;\n In.worldNormal.xyz = normalize((matWorldIT * vec4(In.normal.xyz, 0.0)).xyz);\n #if CC_SURFACES_USE_TANGENT_SPACE\n In.worldTangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\n In.worldBinormal = cross(In.worldNormal.xyz, In.worldTangent) * In.tangent.w;\n #endif\n}\nvoid CCSurfacesVertexTransformUV(inout SurfacesStandardVertexIntermediate In)\n{\n #if CC_SURFACES_FLIP_UV\n In.texCoord = cc_cameraPos.w > 1.0 ? vec2(In.texCoord.x, 1.0 - In.texCoord.y) : In.texCoord;\n #if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = cc_cameraPos.w > 1.0 ? vec2(In.texCoord1.x, 1.0 - In.texCoord1.y) : In.texCoord1;\n #endif\n #endif\n}\nvec4 CalculatePlanarShadowPos(vec3 meshWorldPos, vec3 cameraPos, vec3 lightDir, vec4 plane) {\n vec3 P = meshWorldPos;\n vec3 L = lightDir;\n vec3 N = plane.xyz;\n float d = plane.w + EPSILON_LOWP;\n float dist = (-d - dot(P, N)) / (dot(L, N) + EPSILON_LOWP);\n vec3 shadowPos = P + L * dist;\n return vec4(shadowPos, dist);\n}\nvec4 CalculatePlanarShadowClipPos(vec4 shadowPos, vec3 cameraPos, mat4 matView, mat4 matProj, vec4 nearFar, float bias) {\n vec4 camPos = matView * vec4(shadowPos.xyz, 1.0);\n float lerpCoef = saturate((nearFar.z < 0.0 ? -camPos.z : camPos.z) / (nearFar.y - nearFar.x));\n camPos.z += mix(nearFar.x * 0.01, nearFar.y * EPSILON_LOWP * bias, lerpCoef);\n return matProj * camPos;\n}\nout highp float v_dist;\nvoid main()\n{\n SurfacesStandardVertexIntermediate In;\n CCSurfacesVertexInput(In);\n CCSurfacesVertexAnimation(In);\n In.position.xyz = SurfacesVertexModifyLocalPos(In);\n SurfacesVertexModifyLocalSharedData(In);\n CCSurfacesVertexWorldTransform(In);\n In.worldPos = SurfacesVertexModifyWorldPos(In);\n vec4 shadowPos = CalculatePlanarShadowPos(In.worldPos, cc_cameraPos.xyz, cc_mainLitDir.xyz, cc_planarNDInfo);\n In.worldPos = shadowPos.xyz;\n In.clipPos = CalculatePlanarShadowClipPos(shadowPos, cc_cameraPos.xyz, cc_matView, cc_matProj, cc_nearFar, cc_shadowWHPBInfo.w);\n In.clipPos = SurfacesVertexModifyClipPos(In);\n SurfacesVertexModifyUV(In);\n SurfacesVertexModifySharedData(In);\n CCSurfacesVertexTransformUV(In);\n CCSurfacesVertexOutput(In);\n v_dist = shadowPos.w;\n}",
- "frag": "\nprecision highp float;\n#define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING USE_COMPATIBLE_LIGHTING\n#define CC_SURFACES_USE_TANGENT_SPACE USE_NORMAL_MAP\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nin highp vec3 v_worldPos;\nin vec4 v_normal;\nin vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n in lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n in mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n in mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n in mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n in mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n in mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n in mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n in highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n in highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n in mediump vec4 v_sh_linear_const_r;\n in mediump vec4 v_sh_linear_const_g;\n in mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define FSInput_worldPos v_worldPos\n#define FSInput_worldNormal v_normal.xyz\n#define FSInput_faceSideSign v_normal.w\n#define FSInput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define FSInput_vertexColor v_color\n#else\n #define FSInput_vertexColor vec4(1.0)\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define FSInput_worldTangent v_tangent.xyz\n #define FSInput_mirrorNormal v_tangent.w\n#else\n #define FSInput_worldTangent vec3(1.0, 1.0, 1.0)\n #define FSInput_mirrorNormal 1.0\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define FSInput_texcoord1 v_uv1\n#else\n #define FSInput_texcoord1 vec2(0.0, 0.0)\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define FSInput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define FSInput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define FSInput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define FSInput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define FSInput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define FSInput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define FSInput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define FSInput_clipPos v_clipPos\n#endif\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n mediump vec4 cc_probeInfo;\n mediump vec4 cc_debug_view_mode;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_surfaceTransform;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n mediump vec4 cc_nearFar;\n mediump vec4 cc_viewPort;\n};\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_WORLD_POS CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR CC_SURFACES_DEBUG_VIEW_WORLD_POS + 1\n#define CC_SURFACES_DEBUG_VIEW_FACE_SIDE CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR + 1\n#define CC_SURFACES_DEBUG_VIEW_UV0 CC_SURFACES_DEBUG_VIEW_FACE_SIDE + 1\n#define CC_SURFACES_DEBUG_VIEW_UV1 CC_SURFACES_DEBUG_VIEW_UV0 + 1\n#define CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP CC_SURFACES_DEBUG_VIEW_UV1 + 1\n#define CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP + 1\n#define CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_BASE_COLOR CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR CC_SURFACES_DEBUG_VIEW_BASE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSPARENCY CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_METALLIC CC_SURFACES_DEBUG_VIEW_TRANSPARENCY + 1\n#define CC_SURFACES_DEBUG_VIEW_ROUGHNESS CC_SURFACES_DEBUG_VIEW_METALLIC + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY CC_SURFACES_DEBUG_VIEW_ROUGHNESS + 1\n#define CC_SURFACES_DEBUG_VIEW_IOR CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_IOR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_ALL CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_DIRECT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_ALL CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_EMISSIVE CC_SURFACES_DEBUG_VIEW_ENV_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_LIGHT_MAP CC_SURFACES_DEBUG_VIEW_EMISSIVE + 1\n#define CC_SURFACES_DEBUG_VIEW_SHADOW CC_SURFACES_DEBUG_VIEW_LIGHT_MAP + 1\n#define CC_SURFACES_DEBUG_VIEW_AO CC_SURFACES_DEBUG_VIEW_SHADOW + 1\n#define CC_SURFACES_DEBUG_VIEW_FRESNEL CC_SURFACES_DEBUG_VIEW_AO + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_FRESNEL + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_FOG CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL + 1\n#define IS_DEBUG_VIEW_ENABLE_WITH_CAMERA (cc_surfaceTransform.y != 3.0)\n#define IS_DEBUG_VIEW_LIGHTING_ENABLE_WITH_ALBEDO (UnpackBitFromFloat(cc_debug_view_mode.w, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_MISC_ENABLE_CSM_LAYER_COLORATION (UnpackBitFromFloat(cc_debug_view_mode.w, 7) && IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_EMISSIVE (UnpackBitFromFloat(cc_debug_view_mode.y, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_LIGHT_MAP (UnpackBitFromFloat(cc_debug_view_mode.y, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_SHADOW (UnpackBitFromFloat(cc_debug_view_mode.y, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_AO (UnpackBitFromFloat(cc_debug_view_mode.y, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_NORMAL_MAP (UnpackBitFromFloat(cc_debug_view_mode.z, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FOG (UnpackBitFromFloat(cc_debug_view_mode.z, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TONE_MAPPING (UnpackBitFromFloat(cc_debug_view_mode.z, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION (UnpackBitFromFloat(cc_debug_view_mode.z, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FRESNEL (UnpackBitFromFloat(cc_debug_view_mode.z, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.z, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_2ND_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TT (UnpackBitFromFloat(cc_debug_view_mode.w, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#if (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\n #if CC_FORWARD_ADD\n #if CC_PIPELINE_TYPE == 0\n #define LIGHTS_PER_PASS 1\n #else\n #define LIGHTS_PER_PASS 10\n #endif\n #if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\n layout(std140) uniform CCForwardLight {\n highp vec4 cc_lightPos[LIGHTS_PER_PASS];\n vec4 cc_lightColor[LIGHTS_PER_PASS];\n vec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\n vec4 cc_lightDir[LIGHTS_PER_PASS];\n vec4 cc_lightBoundingSizeVS[LIGHTS_PER_PASS];\n };\n #endif\n #endif\n#endif\n#if CC_USE_LIGHT_PROBE\n #if !USE_INSTANCING\n layout(std140) uniform CCSH {\n vec4 cc_sh_linear_const_r;\n vec4 cc_sh_linear_const_g;\n vec4 cc_sh_linear_const_b;\n vec4 cc_sh_quadratic_r;\n vec4 cc_sh_quadratic_g;\n vec4 cc_sh_quadratic_b;\n vec4 cc_sh_quadratic_a;\n };\n #endif\n#endif\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightView;\n highp mat4 cc_matLightViewProj;\n highp vec4 cc_shadowInvProjDepthInfo;\n highp vec4 cc_shadowProjDepthInfo;\n highp vec4 cc_shadowProjInfo;\n mediump vec4 cc_shadowNFLSInfo;\n mediump vec4 cc_shadowWHPBInfo;\n mediump vec4 cc_shadowLPNNInfo;\n lowp vec4 cc_shadowColor;\n mediump vec4 cc_planarNDInfo;\n};\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n layout(std140) uniform CCCSM {\n highp vec4 cc_csmViewDir0[4];\n highp vec4 cc_csmViewDir1[4];\n highp vec4 cc_csmViewDir2[4];\n highp vec4 cc_csmAtlas[4];\n highp mat4 cc_matCSMViewProj[4];\n highp vec4 cc_csmProjDepthInfo[4];\n highp vec4 cc_csmProjInfo[4];\n highp vec4 cc_csmSplitsInfo;\n };\n#endif\nuniform samplerCube cc_environment;\n#if CC_USE_IBL\n #if CC_USE_DIFFUSEMAP\n uniform samplerCube cc_diffuseMap;\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n uniform samplerCube cc_reflectionProbeCubemap;\n uniform sampler2D cc_reflectionProbePlanarMap;\n uniform sampler2D cc_reflectionProbeDataMap;\n uniform samplerCube cc_reflectionProbeBlendCubemap;\n#endif\n#define UnpackBitFromFloat(value, bit) (mod(floor(value / pow(10.0, float(bit))), 10.0) > 0.0)\n#if defined(CC_USE_METAL) || defined(CC_USE_WGPU)\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y) y = -y\n#else\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y)\n#endif\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n#endif\n#if CC_RECEIVE_SHADOW\n uniform highp sampler2D cc_shadowMap;\n uniform highp sampler2D cc_spotShadowMap;\n #if CC_SUPPORT_CASCADED_SHADOW_MAP\n #else\n #endif\n#endif\n#if CC_USE_FOG != 4\n#endif\n#if CC_USE_LIGHT_PROBE\n #if CC_USE_LIGHT_PROBE\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n layout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n highp vec4 cc_localShadowBias;\n highp vec4 cc_reflectionProbeData1;\n highp vec4 cc_reflectionProbeData2;\n highp vec4 cc_reflectionProbeBlendData1;\n highp vec4 cc_reflectionProbeBlendData2;\n };\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n uniform sampler2D cc_lightingMap;\n#endif\nlayout(std140) uniform Constants {\n vec4 tilingOffset;\n vec4 baseColor;\n vec4 colorScaleAndCutoff;\n vec4 shadeColor1;\n vec4 shadeColor2;\n vec4 specular;\n vec4 shadeParams;\n vec4 miscParams;\n vec4 emissive;\n vec4 emissiveScaleAndStrenth;\n};\n#if USE_BASE_COLOR_MAP\n uniform sampler2D baseColorMap;\n#endif\n#if USE_NORMAL_MAP\n uniform sampler2D normalMap;\n#endif\n#if USE_1ST_SHADE_MAP\n uniform sampler2D shadeMap1;\n#endif\n#if USE_2ND_SHADE_MAP\n uniform sampler2D shadeMap2;\n#endif\n#if USE_SPECULAR_MAP\n uniform sampler2D specularMap;\n#endif\n#if USE_EMISSIVE_MAP\n uniform sampler2D emissiveMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\n#define CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TOONSHADE\n#define CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY\nvoid SurfacesFragmentAlphaClipOnly()\n{\n #if USE_ALPHA_TEST\n float alpha = baseColor.ALPHA_TEST_CHANNEL;\n #if USE_BASE_COLOR_MAP\n alpha = texture(baseColorMap, FSInput_texcoord).ALPHA_TEST_CHANNEL;\n #endif\n if (alpha < colorScaleAndCutoff.w) discard;\n #endif\n}\n#define CC_SURFACES_FRAGMENT_MODIFY_WORLD_NORMAL\n#define CC_SURFACES_FRAGMENT_MODIFY_EMISSIVE\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_STEP_AND_FEATHER\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_SHADOW_COVER\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_SPECULAR\nin highp float v_dist;\nlayout(location = 0) out vec4 fragColorX;\nvoid main () {\n#ifdef CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY\n SurfacesFragmentAlphaClipOnly();\n#endif\n if(v_dist < 0.0)\n discard;\n fragColorX = cc_shadowColor;\n}"
- },
- "glsl1": {
- "vert": "\nprecision highp float;\n#define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING USE_COMPATIBLE_LIGHTING\n#define CC_SURFACES_USE_TANGENT_SPACE USE_NORMAL_MAP\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\n#if CC_SURFACES_USE_TANGENT_SPACE\n attribute vec4 a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n attribute vec4 a_color;\n#endif\n#if CC_SURFACES_USE_SECOND_UV || CC_USE_LIGHTMAP\n attribute vec2 a_texCoord1;\n#endif\n#if CC_USE_SKINNING\n attribute vec4 a_joints;\n attribute vec4 a_weights;\n#endif\n#if USE_INSTANCING\n #if CC_USE_BAKED_ANIMATION\n attribute highp vec4 a_jointAnimInfo;\n #endif\n attribute vec4 a_matWorld0;\n attribute vec4 a_matWorld1;\n attribute vec4 a_matWorld2;\n #if CC_USE_LIGHTMAP\n attribute vec4 a_lightingMapUVParam;\n #endif\n #if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n attribute vec4 a_localShadowBiasAndProbeId;\n #endif\n #if CC_USE_REFLECTION_PROBE\n attribute vec4 a_reflectionProbeData;\n #endif\n #if CC_USE_LIGHT_PROBE\n attribute vec4 a_sh_linear_const_r;\n attribute vec4 a_sh_linear_const_g;\n attribute vec4 a_sh_linear_const_b;\n #endif\n#endif\n#if CC_USE_MORPH\n attribute float a_vertexId;\n#endif\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\nfloat saturate(float value) { return clamp(value, 0.0, 1.0); }\nvec2 saturate(vec2 value) { return clamp(value, vec2(0.0), vec2(1.0)); }\nvec3 saturate(vec3 value) { return clamp(value, vec3(0.0), vec3(1.0)); }\nvec4 saturate(vec4 value) { return clamp(value, vec4(0.0), vec4(1.0)); }\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nvarying highp vec3 v_worldPos;\nvarying vec4 v_normal;\nvarying vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n varying lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n varying mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n varying mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n varying mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n varying mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n varying mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n varying mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n varying highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n varying highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n varying mediump vec4 v_sh_linear_const_r;\n varying mediump vec4 v_sh_linear_const_g;\n varying mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define VSOutput_worldPos v_worldPos\n#define VSOutput_worldNormal v_normal.xyz\n#define VSOutput_faceSideSign v_normal.w\n#define VSOutput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define VSOutput_vertexColor v_color\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define VSOutput_worldTangent v_tangent.xyz\n #define VSOutput_mirrorNormal v_tangent.w\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define VSOutput_texcoord1 v_uv1\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define VSOutput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define VSOutput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define VSOutput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define VSOutput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define VSOutput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define VSOutput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define VSOutput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define VSOutput_clipPos v_clipPos\n#endif\nstruct SurfacesStandardVertexIntermediate\n{\n highp vec4 position;\n vec3 normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n vec4 tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n vec4 color;\n#endif\n vec2 texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n vec2 texCoord1;\n#endif\n highp vec4 clipPos;\n highp vec3 worldPos;\n vec4 worldNormal;\n #if CC_SURFACES_USE_TANGENT_SPACE\n vec3 worldTangent, worldBinormal;\n #endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n vec4 shadowBiasAndProbeId;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n float fogFactor;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n vec3 lightmapUV;\n#endif\n};\n#if CC_USE_MORPH\n int getVertexId() {\n return int(a_vertexId);\n }\n#endif\nuniform highp mat4 cc_matView;\n uniform highp mat4 cc_matProj;\n uniform highp vec4 cc_cameraPos;\n uniform mediump vec4 cc_mainLitDir;\n uniform mediump vec4 cc_nearFar;\nuniform mediump vec4 cc_shadowWHPBInfo;\n uniform mediump vec4 cc_planarNDInfo;\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\n#if !USE_INSTANCING\n uniform highp mat4 cc_matWorld;\n uniform highp mat4 cc_matWorldIT;\n#endif\nvoid CCGetWorldMatrixFull(out mat4 matWorld, out mat4 matWorldIT)\n{\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n vec3 scale = 1.0 / vec3(length(a_matWorld0.xyz), length(a_matWorld1.xyz), length(a_matWorld2.xyz));\n vec3 scale2 = scale * scale;\n matWorldIT = mat4(\n vec4(a_matWorld0.xyz * scale2.x, 0.0),\n vec4(a_matWorld1.xyz * scale2.y, 0.0),\n vec4(a_matWorld2.xyz * scale2.z, 0.0),\n vec4(0.0, 0.0, 0.0, 1.0)\n );\n #else\n matWorld = cc_matWorld;\n matWorldIT = cc_matWorldIT;\n #endif\n}\n#if CC_USE_MORPH\n uniform vec4 cc_displacementWeights[15];\n uniform vec4 cc_displacementTextureInfo;\n #if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n #endif\n vec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n }\n vec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n }\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\n return texture2D(tex, uv);\n }\n #else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture2D(tex, x)),\n decode32(texture2D(tex, y)),\n decode32(texture2D(tex, z)),\n 1.0\n );\n }\n #endif\n float getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n }\n vec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n #if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n #else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n #endif\n }\n #if CC_MORPH_TARGET_HAS_POSITION\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n #endif\n void applyMorph (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n int vertexId = getVertexId();\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_NORMAL\n normal.xyz = normal.xyz + getNormalDisplacement(vertexId);\n #endif\n #if CC_MORPH_TARGET_HAS_TANGENT\n tangent.xyz = tangent.xyz + getTangentDisplacement(vertexId);\n #endif\n }\n void applyMorph (inout vec4 position) {\n #if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n #endif\n }\n#endif\n#if CC_USE_SKINNING\n #if CC_USE_BAKED_ANIMATION\n uniform highp vec4 cc_jointTextureInfo;\n uniform highp vec4 cc_jointAnimInfo;\n uniform highp sampler2D cc_jointTexture;\n void CCGetJointTextureCoords(float pixelsPerJoint, float jointIdx, out highp float x, out highp float y, out highp float invSize)\n {\n #if USE_INSTANCING\n highp float temp = pixelsPerJoint * (a_jointAnimInfo.x * a_jointAnimInfo.y + jointIdx) + a_jointAnimInfo.z;\n #else\n highp float temp = pixelsPerJoint * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + jointIdx) + cc_jointTextureInfo.z;\n #endif\n invSize = cc_jointTextureInfo.w;\n highp float tempY = floor(temp * invSize);\n x = floor(temp - tempY * cc_jointTextureInfo.x);\n y = (tempY + 0.5) * invSize;\n }\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n uniform highp sampler2D cc_realtimeJoint;\n #else\n uniform highp vec4 cc_joints[CC_JOINT_UNIFORM_CAPACITY * 3];\n #endif\n #endif\n #if CC_USE_BAKED_ANIMATION\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(3.0, i, x, y, invSize);\n vec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n highp float x, y, invSize;\n CCGetJointTextureCoords(12.0, i, x, y, invSize);\n vec4 v1 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n #if CC_USE_REAL_TIME_JOINT_TEXTURE\n #if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n float x = i;\n vec4 v1 = texture2D(cc_realtimeJoint, vec2( x / 256.0, 0.5 / 3.0));\n vec4 v2 = texture2D(cc_realtimeJoint, vec2( x / 256.0, 1.5 / 3.0));\n vec4 v3 = texture2D(cc_realtimeJoint, vec2( x / 256.0, 2.5 / 3.0));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n float x = 4.0 * i;\n vec4 v1 = vec4(\n decode32(texture2D(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 0.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 0.5 / 3.0)))\n );\n vec4 v2 = vec4(\n decode32(texture2D(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 1.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 1.5 / 3.0)))\n );\n vec4 v3 = vec4(\n decode32(texture2D(cc_realtimeJoint, vec2((x + 0.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 1.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 2.5)/ 1024.0, 2.5 / 3.0))),\n decode32(texture2D(cc_realtimeJoint, vec2((x + 3.5)/ 1024.0, 2.5 / 3.0)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n #endif\n mat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n }\n void CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n }\n void CCSkin (inout vec4 position, inout vec3 normal, inout vec4 tangent) {\n mat4 m = skinMatrix();\n position = m * position;\n normal = (m * vec4(normal, 0.0)).xyz;\n tangent.xyz = (m * vec4(tangent.xyz, 0.0)).xyz;\n }\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #if CC_USE_FOG != 4\n #endif\n#endif\n uniform vec4 tilingOffset;\n#define CC_SURFACES_VERTEX_MODIFY_UV\nvoid SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)\n{\n In.texCoord = In.texCoord * tilingOffset.xy + tilingOffset.zw;\n}\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_POS\nvec3 SurfacesVertexModifyLocalPos(in SurfacesStandardVertexIntermediate In)\n{\n return vec3(In.position.xyz);\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_NORMAL\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_TANGENT\n #if CC_SURFACES_USE_TANGENT_SPACE\n #endif\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_LOCAL_SHARED_DATA\nvoid SurfacesVertexModifyLocalSharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_POS\nvec3 SurfacesVertexModifyWorldPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.worldPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_CLIP_POS\nvec4 SurfacesVertexModifyClipPos(in SurfacesStandardVertexIntermediate In)\n{\n return In.clipPos;\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_UV\nvoid SurfacesVertexModifyUV(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_WORLD_NORMAL\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHADOW_BIAS\n#endif\n#ifndef CC_SURFACES_VERTEX_MODIFY_SHARED_DATA\nvoid SurfacesVertexModifySharedData(inout SurfacesStandardVertexIntermediate In)\n{\n}\n#endif\nvoid CCSurfacesVertexInput(out SurfacesStandardVertexIntermediate In)\n{\n In.position = vec4(a_position, 1.0);\n In.normal = a_normal;\n#if CC_SURFACES_USE_TANGENT_SPACE\n In.tangent = a_tangent;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n In.color = a_color;\n#endif\n In.texCoord = a_texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = a_texCoord1;\n#endif\n}\nvoid CCSurfacesVertexOutput(in SurfacesStandardVertexIntermediate In)\n{\n gl_Position = In.clipPos;\n VSOutput_worldNormal = In.worldNormal.xyz;\n VSOutput_faceSideSign = In.worldNormal.w;\n VSOutput_worldPos = In.worldPos;\n#if CC_SURFACES_USE_TANGENT_SPACE\n VSOutput_worldTangent = In.worldTangent.xyz;\n VSOutput_mirrorNormal = In.tangent.w > 0.0 ? 1.0 : -1.0;\n#endif\n#if CC_SURFACES_USE_VERTEX_COLOR\n VSOutput_vertexColor = In.color;\n#endif\n VSOutput_texcoord = In.texCoord;\n#if CC_SURFACES_USE_SECOND_UV\n VSOutput_texcoord1 = In.texCoord1;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n VSOutput_fogFactor = In.fogFactor;\n#endif\n#if CC_RECEIVE_SHADOW\n VSOutput_shadowBias = In.shadowBiasAndProbeId.xy;\n#endif\n#if CC_USE_REFLECTION_PROBE\n VSOutput_reflectionProbeId = In.shadowBiasAndProbeId.z;\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n VSOutput_reflectionProbeBlendId = In.shadowBiasAndProbeId.w;\n #endif\n #if USE_INSTANCING\n v_reflectionProbeData = a_reflectionProbeData;\n #endif\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n VSOutput_lightMapUV = In.lightmapUV;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n VSOutput_localPos = In.position;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n VSOutput_clipPos = In.clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n v_sh_linear_const_r = a_sh_linear_const_r;\n v_sh_linear_const_g = a_sh_linear_const_g;\n v_sh_linear_const_b = a_sh_linear_const_b;\n #endif\n#endif\n}\nvoid CCSurfacesVertexAnimation(inout SurfacesStandardVertexIntermediate In)\n{\nvec4 temp = vec4(0.0);\n#if CC_USE_MORPH\n #if CC_SURFACES_USE_TANGENT_SPACE\n applyMorph(In.position, In.normal, In.tangent);\n #else\n applyMorph(In.position, In.normal, temp);\n #endif\n#endif\n#if CC_USE_SKINNING\n #if CC_SURFACES_USE_TANGENT_SPACE\n CCSkin(In.position, In.normal, In.tangent);\n #else\n CCSkin(In.position, In.normal, temp);\n #endif\n#endif\n}\nvoid CCSurfacesVertexWorldTransform(inout SurfacesStandardVertexIntermediate In)\n{\n mat4 matWorld, matWorldIT;\n CCGetWorldMatrixFull(matWorld, matWorldIT);\n In.worldPos = (matWorld * In.position).xyz;\n In.worldNormal.xyz = normalize((matWorldIT * vec4(In.normal.xyz, 0.0)).xyz);\n #if CC_SURFACES_USE_TANGENT_SPACE\n In.worldTangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\n In.worldBinormal = cross(In.worldNormal.xyz, In.worldTangent) * In.tangent.w;\n #endif\n}\nvoid CCSurfacesVertexTransformUV(inout SurfacesStandardVertexIntermediate In)\n{\n #if CC_SURFACES_FLIP_UV\n In.texCoord = cc_cameraPos.w > 1.0 ? vec2(In.texCoord.x, 1.0 - In.texCoord.y) : In.texCoord;\n #if CC_SURFACES_USE_SECOND_UV\n In.texCoord1 = cc_cameraPos.w > 1.0 ? vec2(In.texCoord1.x, 1.0 - In.texCoord1.y) : In.texCoord1;\n #endif\n #endif\n}\nvec4 CalculatePlanarShadowPos(vec3 meshWorldPos, vec3 cameraPos, vec3 lightDir, vec4 plane) {\n vec3 P = meshWorldPos;\n vec3 L = lightDir;\n vec3 N = plane.xyz;\n float d = plane.w + EPSILON_LOWP;\n float dist = (-d - dot(P, N)) / (dot(L, N) + EPSILON_LOWP);\n vec3 shadowPos = P + L * dist;\n return vec4(shadowPos, dist);\n}\nvec4 CalculatePlanarShadowClipPos(vec4 shadowPos, vec3 cameraPos, mat4 matView, mat4 matProj, vec4 nearFar, float bias) {\n vec4 camPos = matView * vec4(shadowPos.xyz, 1.0);\n float lerpCoef = saturate((nearFar.z < 0.0 ? -camPos.z : camPos.z) / (nearFar.y - nearFar.x));\n camPos.z += mix(nearFar.x * 0.01, nearFar.y * EPSILON_LOWP * bias, lerpCoef);\n return matProj * camPos;\n}\nvarying highp float v_dist;\nvoid main()\n{\n SurfacesStandardVertexIntermediate In;\n CCSurfacesVertexInput(In);\n CCSurfacesVertexAnimation(In);\n In.position.xyz = SurfacesVertexModifyLocalPos(In);\n SurfacesVertexModifyLocalSharedData(In);\n CCSurfacesVertexWorldTransform(In);\n In.worldPos = SurfacesVertexModifyWorldPos(In);\n vec4 shadowPos = CalculatePlanarShadowPos(In.worldPos, cc_cameraPos.xyz, cc_mainLitDir.xyz, cc_planarNDInfo);\n In.worldPos = shadowPos.xyz;\n In.clipPos = CalculatePlanarShadowClipPos(shadowPos, cc_cameraPos.xyz, cc_matView, cc_matProj, cc_nearFar, cc_shadowWHPBInfo.w);\n In.clipPos = SurfacesVertexModifyClipPos(In);\n SurfacesVertexModifyUV(In);\n SurfacesVertexModifySharedData(In);\n CCSurfacesVertexTransformUV(In);\n CCSurfacesVertexOutput(In);\n v_dist = shadowPos.w;\n}",
- "frag": "\n#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives: enable\n#endif\n#ifdef GL_EXT_shader_texture_lod\n#extension GL_EXT_shader_texture_lod: enable\n#endif\nprecision highp float;\n#define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING USE_COMPATIBLE_LIGHTING\n#define CC_SURFACES_USE_TANGENT_SPACE USE_NORMAL_MAP\n#ifndef CC_SURFACES_USE_SECOND_UV\n #define CC_SURFACES_USE_SECOND_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TANGENT_SPACE\n #define CC_SURFACES_USE_TANGENT_SPACE 0\n#endif\n#ifndef CC_SURFACES_USE_VERTEX_COLOR\n #define CC_SURFACES_USE_VERTEX_COLOR 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_LOCAL_POS\n #define CC_SURFACES_TRANSFER_LOCAL_POS 0\n#endif\n#ifndef CC_SURFACES_TRANSFER_CLIP_POS\n #define CC_SURFACES_TRANSFER_CLIP_POS 0\n#endif\n#ifndef CC_SURFACES_USE_LIGHT_MAP\n #ifdef CC_USE_LIGHTMAP\n #define CC_SURFACES_USE_LIGHT_MAP CC_USE_LIGHTMAP\n #else\n #define CC_SURFACES_USE_LIGHT_MAP 0\n #endif\n#endif\n#ifndef CC_SURFACES_FLIP_UV\n #define CC_SURFACES_FLIP_UV 0\n#endif\n#ifndef CC_SURFACES_USE_TWO_SIDED\n #define CC_SURFACES_USE_TWO_SIDED 0\n#endif\n#ifndef CC_SURFACES_USE_REFLECTION_DENOISE\n #define CC_SURFACES_USE_REFLECTION_DENOISE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC\n #define CC_SURFACES_LIGHTING_ANISOTROPIC 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT\n #define CC_SURFACES_LIGHTING_ANISOTROPIC_ENVCONVOLUTION_COUNT 0\n#endif\n#ifndef CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING\n #define CC_SURFACES_USE_LEGACY_COMPATIBLE_LIGHTING 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_FRESNEL\n #define CC_SURFACES_LIGHTING_USE_FRESNEL 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR\n #define CC_SURFACES_LIGHTING_TRANSMIT_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE\n #define CC_SURFACES_LIGHTING_TRANSMIT_DIFFUSE 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT\n #define CC_SURFACES_LIGHTING_USE_SHADOWMAP_TRANSMIT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TRT\n #define CC_SURFACES_LIGHTING_TRT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR\n #define CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SHEEN\n #define CC_SURFACES_LIGHTING_SHEEN 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_CLEAR_COAT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_TT\n #define CC_SURFACES_LIGHTING_TT 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_SSS\n #define CC_SURFACES_LIGHTING_SSS 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #if CC_SURFACES_LIGHTING_TRT || CC_SURFACES_LIGHTING_DUAL_LOBE_SPECULAR || CC_SURFACES_LIGHTING_SHEEN || CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR\n #define CC_SURFACES_LIGHTING_2ND_LAYER_SPECULAR 0\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #if CC_SURFACES_LIGHTING_CLEAR_COAT\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 1\n #endif\n#endif\n#ifndef CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND\n #define CC_SURFACES_LIGHTING_USE_MULTIPLE_LAYER_BLEND 0\n#endif\n#ifndef CC_SURFACES_ENABLE_DEBUG_VIEW\n #define CC_SURFACES_ENABLE_DEBUG_VIEW 1\n#endif\n#define CC_USE_SURFACE_SHADER 1\n#define QUATER_PI 0.78539816340\n#define HALF_PI 1.57079632679\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI4 12.5663706144\n#define INV_QUATER_PI 1.27323954474\n#define INV_HALF_PI 0.63661977237\n#define INV_PI 0.31830988618\n#define INV_PI2 0.15915494309\n#define INV_PI4 0.07957747155\n#define EPSILON 1e-6\n#define EPSILON_LOWP 1e-4\n#define LOG2 1.442695\n#define EXP_VALUE 2.71828183\n#define FP_MAX 65504.0\n#define FP_SCALE 0.0009765625\n#define FP_SCALE_INV 1024.0\n#define GRAY_VECTOR vec3(0.299, 0.587, 0.114)\n#define LIGHT_MAP_TYPE_DISABLED 0\n#define LIGHT_MAP_TYPE_ALL_IN_ONE 1\n#define LIGHT_MAP_TYPE_INDIRECT_OCCLUSION 2\n#define REFLECTION_PROBE_TYPE_NONE 0\n#define REFLECTION_PROBE_TYPE_CUBE 1\n#define REFLECTION_PROBE_TYPE_PLANAR 2\n#define REFLECTION_PROBE_TYPE_BLEND 3\n#define REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX 4\n#define LIGHT_TYPE_DIRECTIONAL 0.0\n#define LIGHT_TYPE_SPHERE 1.0\n#define LIGHT_TYPE_SPOT 2.0\n#define LIGHT_TYPE_POINT 3.0\n#define LIGHT_TYPE_RANGED_DIRECTIONAL 4.0\n#define IS_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_DIRECTIONAL)) < EPSILON_LOWP)\n#define IS_SPHERE_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPHERE)) < EPSILON_LOWP)\n#define IS_SPOT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_SPOT)) < EPSILON_LOWP)\n#define IS_POINT_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_POINT)) < EPSILON_LOWP)\n#define IS_RANGED_DIRECTIONAL_LIGHT(light_type) (abs(float(light_type) - float(LIGHT_TYPE_RANGED_DIRECTIONAL)) < EPSILON_LOWP)\n#define TONE_MAPPING_ACES 0\n#define TONE_MAPPING_LINEAR 1\n#define SURFACES_MAX_TRANSMIT_DEPTH_VALUE 999999.0\n#ifndef CC_SURFACES_DEBUG_VIEW_SINGLE\n #define CC_SURFACES_DEBUG_VIEW_SINGLE 1\n#endif\n#ifndef CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC\n #define CC_SURFACES_DEBUG_VIEW_COMPOSITE_AND_MISC 2\n#endif\nvarying highp vec3 v_worldPos;\nvarying vec4 v_normal;\nvarying vec2 v_uv;\n#if CC_SURFACES_USE_VERTEX_COLOR\n varying lowp vec4 v_color;\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n varying mediump vec4 v_tangent;\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n varying mediump vec2 v_uv1;\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n varying mediump vec3 v_luv;\n#endif\n#if CC_RECEIVE_SHADOW || CC_USE_REFLECTION_PROBE\n varying mediump vec4 v_shadowBiasAndProbeId;\n#endif\n#if CC_USE_REFLECTION_PROBE && USE_INSTANCING\n varying mediump vec4 v_reflectionProbeData;\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n varying mediump float v_fogFactor;\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n varying highp vec4 v_localPos;\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n varying highp vec4 v_clipPos;\n#endif\n#if CC_USE_LIGHT_PROBE\n #if USE_INSTANCING\n varying mediump vec4 v_sh_linear_const_r;\n varying mediump vec4 v_sh_linear_const_g;\n varying mediump vec4 v_sh_linear_const_b;\n #endif\n#endif\n#define FSInput_worldPos v_worldPos\n#define FSInput_worldNormal v_normal.xyz\n#define FSInput_faceSideSign v_normal.w\n#define FSInput_texcoord v_uv\n#if CC_SURFACES_USE_VERTEX_COLOR\n #define FSInput_vertexColor v_color\n#else\n #define FSInput_vertexColor vec4(1.0)\n#endif\n#if CC_SURFACES_USE_TANGENT_SPACE\n #define FSInput_worldTangent v_tangent.xyz\n #define FSInput_mirrorNormal v_tangent.w\n#else\n #define FSInput_worldTangent vec3(1.0, 1.0, 1.0)\n #define FSInput_mirrorNormal 1.0\n#endif\n#if CC_SURFACES_USE_SECOND_UV\n #define FSInput_texcoord1 v_uv1\n#else\n #define FSInput_texcoord1 vec2(0.0, 0.0)\n#endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n #define FSInput_lightMapUV v_luv\n#endif\n#if CC_RECEIVE_SHADOW\n #define FSInput_shadowBias v_shadowBiasAndProbeId.xy\n#endif\n#if CC_USE_REFLECTION_PROBE\n #define FSInput_reflectionProbeId v_shadowBiasAndProbeId.z\n #if CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND || CC_USE_REFLECTION_PROBE == REFLECTION_PROBE_TYPE_BLEND_AND_SKYBOX\n #define FSInput_reflectionProbeBlendId v_shadowBiasAndProbeId.w\n #endif\n #if USE_INSTANCING\n #define FSInput_reflectionProbeData v_reflectionProbeData\n #endif\n#endif\n#if CC_USE_FOG != 4 && !CC_USE_ACCURATE_FOG\n #define FSInput_fogFactor v_fogFactor\n#endif\n#if CC_SURFACES_TRANSFER_LOCAL_POS\n #define FSInput_localPos v_localPos\n#endif\n#if CC_SURFACES_TRANSFER_CLIP_POS\n #define FSInput_clipPos v_clipPos\n#endif\nuniform mediump vec4 cc_debug_view_mode;\nuniform mediump vec4 cc_surfaceTransform;\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL CC_SURFACES_DEBUG_VIEW_VERTEX_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT CC_SURFACES_DEBUG_VIEW_VERTEX_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_WORLD_POS CC_SURFACES_DEBUG_VIEW_VERTEX_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR CC_SURFACES_DEBUG_VIEW_WORLD_POS + 1\n#define CC_SURFACES_DEBUG_VIEW_FACE_SIDE CC_SURFACES_DEBUG_VIEW_VERTEX_MIRROR + 1\n#define CC_SURFACES_DEBUG_VIEW_UV0 CC_SURFACES_DEBUG_VIEW_FACE_SIDE + 1\n#define CC_SURFACES_DEBUG_VIEW_UV1 CC_SURFACES_DEBUG_VIEW_UV0 + 1\n#define CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP CC_SURFACES_DEBUG_VIEW_UV1 + 1\n#define CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH CC_SURFACES_DEBUG_VIEW_UVLIGHTMAP + 1\n#define CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH CC_SURFACES_DEBUG_VIEW_PROJ_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL CC_SURFACES_DEBUG_VIEW_LINEAR_DEPTH + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT CC_SURFACES_DEBUG_VIEW_FRAGMENT_NORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL CC_SURFACES_DEBUG_VIEW_FRAGMENT_TANGENT + 1\n#define CC_SURFACES_DEBUG_VIEW_BASE_COLOR CC_SURFACES_DEBUG_VIEW_FRAGMENT_BINORMAL + 1\n#define CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR CC_SURFACES_DEBUG_VIEW_BASE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR CC_SURFACES_DEBUG_VIEW_DIFFUSE_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSPARENCY CC_SURFACES_DEBUG_VIEW_SPECULAR_COLOR + 1\n#define CC_SURFACES_DEBUG_VIEW_METALLIC CC_SURFACES_DEBUG_VIEW_TRANSPARENCY + 1\n#define CC_SURFACES_DEBUG_VIEW_ROUGHNESS CC_SURFACES_DEBUG_VIEW_METALLIC + 1\n#define CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY CC_SURFACES_DEBUG_VIEW_ROUGHNESS + 1\n#define CC_SURFACES_DEBUG_VIEW_IOR CC_SURFACES_DEBUG_VIEW_SPECULAR_INTENSITY + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_IOR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_ALL CC_SURFACES_DEBUG_VIEW_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_DIRECT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_ENV_ALL CC_SURFACES_DEBUG_VIEW_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_EMISSIVE CC_SURFACES_DEBUG_VIEW_ENV_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_LIGHT_MAP CC_SURFACES_DEBUG_VIEW_EMISSIVE + 1\n#define CC_SURFACES_DEBUG_VIEW_SHADOW CC_SURFACES_DEBUG_VIEW_LIGHT_MAP + 1\n#define CC_SURFACES_DEBUG_VIEW_AO CC_SURFACES_DEBUG_VIEW_SHADOW + 1\n#define CC_SURFACES_DEBUG_VIEW_FRESNEL CC_SURFACES_DEBUG_VIEW_AO + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE CC_SURFACES_DEBUG_VIEW_FRESNEL + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE CC_SURFACES_DEBUG_VIEW_TRANSMIT_DIRECT_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_DIFFUSE + 1\n#define CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL CC_SURFACES_DEBUG_VIEW_TRANSMIT_ENV_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_TRANSMIT_ALL + 1\n#define CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR CC_SURFACES_DEBUG_VIEW_DIRECT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL CC_SURFACES_DEBUG_VIEW_ENVIRONMENT_2ND_SPECULAR + 1\n#define CC_SURFACES_DEBUG_VIEW_FOG CC_SURFACES_DEBUG_VIEW_2ND_SPECULAR_ALL + 1\n#define IS_DEBUG_VIEW_ENABLE_WITH_CAMERA (cc_surfaceTransform.y != 3.0)\n#define IS_DEBUG_VIEW_LIGHTING_ENABLE_WITH_ALBEDO (UnpackBitFromFloat(cc_debug_view_mode.w, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_MISC_ENABLE_CSM_LAYER_COLORATION (UnpackBitFromFloat(cc_debug_view_mode.w, 7) && IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_DIRECT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.y, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_ENV_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.y, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_EMISSIVE (UnpackBitFromFloat(cc_debug_view_mode.y, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_LIGHT_MAP (UnpackBitFromFloat(cc_debug_view_mode.y, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_SHADOW (UnpackBitFromFloat(cc_debug_view_mode.y, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_AO (UnpackBitFromFloat(cc_debug_view_mode.y, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_NORMAL_MAP (UnpackBitFromFloat(cc_debug_view_mode.z, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FOG (UnpackBitFromFloat(cc_debug_view_mode.z, 1) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TONE_MAPPING (UnpackBitFromFloat(cc_debug_view_mode.z, 2) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_GAMMA_CORRECTION (UnpackBitFromFloat(cc_debug_view_mode.z, 3) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_FRESNEL (UnpackBitFromFloat(cc_debug_view_mode.z, 4) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_DIFFUSE (UnpackBitFromFloat(cc_debug_view_mode.z, 5) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TRANSMIT_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 6) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_2ND_SPECULAR (UnpackBitFromFloat(cc_debug_view_mode.z, 7) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#define IS_DEBUG_VIEW_COMPOSITE_ENABLE_TT (UnpackBitFromFloat(cc_debug_view_mode.w, 0) || !IS_DEBUG_VIEW_ENABLE_WITH_CAMERA)\n#if (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\n #if CC_FORWARD_ADD\n #if CC_PIPELINE_TYPE == 0\n #define LIGHTS_PER_PASS 1\n #else\n #define LIGHTS_PER_PASS 10\n #endif\n #if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\n #endif\n #endif\n#endif\n#if CC_USE_LIGHT_PROBE\n #if !USE_INSTANCING\n #endif\n#endif\nuniform lowp vec4 cc_shadowColor;\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n #endif\nuniform samplerCube cc_environment;\n#if CC_USE_IBL\n #if CC_USE_DIFFUSEMAP\n uniform samplerCube cc_diffuseMap;\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n uniform samplerCube cc_reflectionProbeCubemap;\n uniform sampler2D cc_reflectionProbePlanarMap;\n uniform sampler2D cc_reflectionProbeDataMap;\n uniform samplerCube cc_reflectionProbeBlendCubemap;\n#endif\n#define UnpackBitFromFloat(value, bit) (mod(floor(value / pow(10.0, float(bit))), 10.0) > 0.0)\n#if defined(CC_USE_METAL) || defined(CC_USE_WGPU)\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y) y = -y\n#else\n#define CC_HANDLE_SAMPLE_NDC_FLIP_STATIC(y)\n#endif\n#if CC_SUPPORT_CASCADED_SHADOW_MAP\n#endif\n#if CC_RECEIVE_SHADOW\n uniform highp sampler2D cc_shadowMap;\n uniform highp sampler2D cc_spotShadowMap;\n #if CC_SUPPORT_CASCADED_SHADOW_MAP\n #else\n #endif\n#endif\n#if CC_USE_FOG != 4\n#endif\n#if CC_USE_LIGHT_PROBE\n #if CC_USE_LIGHT_PROBE\n #endif\n#endif\n#if CC_USE_REFLECTION_PROBE\n #endif\n#if CC_USE_LIGHTMAP && !CC_FORWARD_ADD\n uniform sampler2D cc_lightingMap;\n#endif\n uniform vec4 baseColor;\n uniform vec4 colorScaleAndCutoff;\n#if USE_BASE_COLOR_MAP\n uniform sampler2D baseColorMap;\n#endif\n#if USE_NORMAL_MAP\n uniform sampler2D normalMap;\n#endif\n#if USE_1ST_SHADE_MAP\n uniform sampler2D shadeMap1;\n#endif\n#if USE_2ND_SHADE_MAP\n uniform sampler2D shadeMap2;\n#endif\n#if USE_SPECULAR_MAP\n uniform sampler2D specularMap;\n#endif\n#if USE_EMISSIVE_MAP\n uniform sampler2D emissiveMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\n#define CC_SURFACES_FRAGMENT_MODIFY_BASECOLOR_AND_TOONSHADE\n#define CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY\nvoid SurfacesFragmentAlphaClipOnly()\n{\n #if USE_ALPHA_TEST\n float alpha = baseColor.ALPHA_TEST_CHANNEL;\n #if USE_BASE_COLOR_MAP\n alpha = texture2D(baseColorMap, FSInput_texcoord).ALPHA_TEST_CHANNEL;\n #endif\n if (alpha < colorScaleAndCutoff.w) discard;\n #endif\n}\n#define CC_SURFACES_FRAGMENT_MODIFY_WORLD_NORMAL\n#define CC_SURFACES_FRAGMENT_MODIFY_EMISSIVE\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_STEP_AND_FEATHER\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_SHADOW_COVER\n#define CC_SURFACES_FRAGMENT_MODIFY_TOON_SPECULAR\nvarying highp float v_dist;\nvoid main () {\n#ifdef CC_SURFACES_FRAGMENT_ALPHA_CLIP_ONLY\n SurfacesFragmentAlphaClipOnly();\n#endif\n if(v_dist < 0.0)\n discard;\n gl_FragColor = cc_shadowColor;\n}"
- },
- "builtins": {
- "globals": {
- "blocks": [
- {
- "name": "CCGlobal",
- "defines": []
- },
- {
- "name": "CCCamera",
- "defines": []
- },
- {
- "name": "CCShadow",
- "defines": []
- },
- {
- "name": "CCCSM",
- "defines": [
- "CC_SUPPORT_CASCADED_SHADOW_MAP"
- ]
- }
- ],
- "samplerTextures": [
- {
- "name": "cc_environment",
- "defines": []
- },
- {
- "name": "cc_diffuseMap",
- "defines": [
- "CC_USE_IBL",
- "CC_USE_DIFFUSEMAP"
- ]
- },
- {
- "name": "cc_shadowMap",
- "defines": [
- "CC_RECEIVE_SHADOW"
- ]
- },
- {
- "name": "cc_spotShadowMap",
- "defines": [
- "CC_RECEIVE_SHADOW"
- ]
- }
- ],
- "buffers": [],
- "images": []
- },
- "locals": {
- "blocks": [
- {
- "name": "CCLocal",
- "defines": [
- "!USE_INSTANCING"
- ]
- },
- {
- "name": "CCMorph",
- "defines": [
- "CC_USE_MORPH"
- ]
- },
- {
- "name": "CCSkinningTexture",
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ]
- },
- {
- "name": "CCSkinningAnimation",
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ]
- },
- {
- "name": "CCSkinning",
- "defines": [
- "CC_USE_SKINNING",
- "!CC_USE_BAKED_ANIMATION",
- "!CC_USE_REAL_TIME_JOINT_TEXTURE"
- ]
- },
- {
- "name": "CCForwardLight",
- "defines": [
- "CC_FORWARD_ADD",
- "CC_ENABLE_CLUSTERED_LIGHT_CULLING"
- ]
- },
- {
- "name": "CCSH",
- "defines": [
- "CC_USE_LIGHT_PROBE",
- "!USE_INSTANCING"
- ]
- }
- ],
- "samplerTextures": [
- {
- "name": "cc_PositionDisplacements",
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_POSITION"
- ]
- },
- {
- "name": "cc_NormalDisplacements",
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_NORMAL"
- ]
- },
- {
- "name": "cc_TangentDisplacements",
- "defines": [
- "CC_USE_MORPH",
- "CC_MORPH_TARGET_HAS_TANGENT"
- ]
- },
- {
- "name": "cc_jointTexture",
- "defines": [
- "CC_USE_SKINNING",
- "CC_USE_BAKED_ANIMATION"
- ]
- },
- {
- "name": "cc_realtimeJoint",
- "defines": [
- "CC_USE_SKINNING",
- "!CC_USE_BAKED_ANIMATION",
- "CC_USE_REAL_TIME_JOINT_TEXTURE"
- ]
- },
- {
- "name": "cc_reflectionProbeCubemap",
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ]
- },
- {
- "name": "cc_reflectionProbePlanarMap",
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ]
- },
- {
- "name": "cc_reflectionProbeDataMap",
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ]
- },
- {
- "name": "cc_reflectionProbeBlendCubemap",
- "defines": [
- "CC_USE_REFLECTION_PROBE"
- ]
- },
- {
- "name": "cc_lightingMap",
- "defines": [
- "CC_USE_LIGHTMAP",
- "!CC_FORWARD_ADD"
- ]
- }
- ],
- "buffers": [],
- "images": []
- },
- "statistics": {
- "CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS": 100,
- "CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS": 130
- }
- },
- "defines": [
- {
- "name": "USE_COMPATIBLE_LIGHTING",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "USE_NORMAL_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "USE_INSTANCING",
- "type": "boolean",
- "defines": [],
- "editor": {
- "elevated": true
- }
- },
- {
- "name": "CC_USE_LIGHTMAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_SKINNING",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_BAKED_ANIMATION",
- "type": "boolean",
- "defines": [
- "USE_INSTANCING"
- ]
- },
- {
- "name": "CC_RECEIVE_SHADOW",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_REFLECTION_PROBE",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 3
- ]
- },
- {
- "name": "CC_USE_LIGHT_PROBE",
- "type": "boolean",
- "defines": [],
- "default": 0
- },
- {
- "name": "CC_USE_MORPH",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_FORWARD_ADD",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_FOG",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 4
- ]
- },
- {
- "name": "CC_USE_ACCURATE_FOG",
- "type": "boolean",
- "defines": [
- "CC_USE_FOG"
- ]
- },
- {
- "name": "CC_MORPH_TARGET_COUNT",
- "type": "number",
- "defines": [
- "CC_USE_MORPH"
- ],
- "range": [
- 2,
- 8
- ]
- },
- {
- "name": "CC_MORPH_TARGET_HAS_POSITION",
- "type": "boolean",
- "defines": [
- "CC_USE_MORPH"
- ]
- },
- {
- "name": "CC_MORPH_TARGET_HAS_NORMAL",
- "type": "boolean",
- "defines": [
- "CC_USE_MORPH"
- ]
- },
- {
- "name": "CC_MORPH_TARGET_HAS_TANGENT",
- "type": "boolean",
- "defines": [
- "CC_USE_MORPH"
- ]
- },
- {
- "name": "CC_MORPH_PRECOMPUTED",
- "type": "boolean",
- "defines": [
- "CC_USE_MORPH"
- ]
- },
- {
- "name": "CC_USE_REAL_TIME_JOINT_TEXTURE",
- "type": "boolean",
- "defines": [
- "CC_USE_SKINNING",
- "!CC_USE_BAKED_ANIMATION"
- ]
- },
- {
- "name": "CC_DISABLE_STRUCTURE_IN_FRAGMENT_SHADER",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 1
- ]
- },
- {
- "name": "CC_PIPELINE_TYPE",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 1
- ]
- },
- {
- "name": "CC_FORCE_FORWARD_SHADING",
- "type": "boolean",
- "defines": [
- "CC_PIPELINE_TYPE"
- ]
- },
- {
- "name": "CC_ENABLE_CLUSTERED_LIGHT_CULLING",
- "type": "number",
- "defines": [
- "CC_FORWARD_ADD"
- ],
- "range": [
- 0,
- 3
- ]
- },
- {
- "name": "CC_SUPPORT_CASCADED_SHADOW_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "CC_USE_IBL",
- "type": "number",
- "defines": [],
- "range": [
- 0,
- 2
- ]
- },
- {
- "name": "CC_USE_DIFFUSEMAP",
- "type": "number",
- "defines": [
- "CC_USE_IBL"
- ],
- "range": [
- 0,
- 2
- ]
- },
- {
- "name": "USE_BASE_COLOR_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "USE_1ST_SHADE_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "USE_2ND_SHADE_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "USE_SPECULAR_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "USE_EMISSIVE_MAP",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "USE_ALPHA_TEST",
- "type": "boolean",
- "defines": []
- },
- {
- "name": "ALPHA_TEST_CHANNEL",
- "type": "string",
- "defines": [
- "USE_ALPHA_TEST"
- ],
- "options": [
- "a",
- "r",
- "g",
- "b"
- ]
- }
- ],
- "name": "builtin-toon|planar-shadow-vs|planar-shadow-fs"
- }
- ],
- "combinations": [],
- "hideInEditor": false
- }
|