œ]ŕ œ€5.5.1f1ţ˙˙˙˙˙Č0ĹňĂôL.`?^Ů0D7€˙˙˙˙€Ś€˛€ЀŚ€Ś€Ś€#Ś€+H€3˙˙˙˙€1€1€˙˙˙˙@ހ€ Q€j€ ™€< Ś€H H€Z˙˙˙˙ €1€1€˙˙˙˙@ހ€Q€j€ЀgŚ€Ś€Ś€#Ś€+v~ € €– €Ÿ €¨ €ą €ş €Ă €Ě €Ő €Ţ  €ç! €ń" €ű# €$ €% €&Ő€#˙˙˙˙'€1€1€˙˙˙˙(€ހ€)H€j€˙˙˙˙*€1€1€˙˙˙˙+@ހ€,Q€j€-™€*.ހ8/AssetMetaDataguiddata[0]data[1]data[2]data[3]pathNametimeCreatedoriginalChangesetoriginalNameoriginalParentHash128originalDigestbytes[0]bytes[1]bytes[2]bytes[3]bytes[4]bytes[5]bytes[6]bytes[7]bytes[8]bytes[9]bytes[10]bytes[11]bytes[12]bytes[13]bytes[14]bytes[15]labelsassetStoreReflicenseTypeď˙˙2ƒ…>”KËĽŁMźHîÁƒ#{7€˙˙˙˙€Ś€˛€Ő€ ހ%.€.†€Ä€ ހ%.€.H€Ť€˙˙˙˙€1€1€˙˙˙˙ @ހ€ Q€j€ Ő€7˙˙˙˙ Ŕ1€1€˙˙˙˙ €ހ€€j€˙˙˙˙€H€›€˙˙˙˙€1€1€˙˙˙˙@ހ€Q€j€°€ € ހ%.€.H€I˙˙˙˙€1€1€˙˙˙˙@ހ€Q€j€H€T˙˙˙˙€1€1€˙˙˙˙@ހ€Q€j€H€f˙˙˙˙€1€1€˙˙˙˙ @ހ€!Q€j€"ShaderImporterPPtrm_FileIDm_PathIDm_DefaultTexturesm_UserDatam_AssetBundleNamem_AssetBundleVariant0˙˙şěŻu`Aă•\á|^FďYŹü 7€˙˙˙˙€Ś€˛€Ő€ ހ.€&†€Ä€ ހ.€&H€Ť€˙˙˙˙€1€1€˙˙˙˙ @ހ€ Q€j€ /@˙˙˙˙ €Mb˙˙˙˙ €Ő€m˙˙˙˙€1€1€˙˙˙˙€ހ€uj€˙˙˙˙€H€Ť€˙˙˙˙€1€1€˙˙˙˙@ހ€Q€j€H€ˆ˙˙˙˙€1€1€˙˙˙˙@ހ€Q€j€Ő€–˙˙˙˙€1€1€˙˙˙˙€ހ€H€j€˙˙˙˙€ 1€1€˙˙˙˙@ ހ€ Q€j€ ހ€!Ś€Ł"Ą€Ť#Ą€š$Ą€Ç%Ą€Ő&ăý˙˙˙˙'€H€ ˙˙˙˙(€1€1€˙˙˙˙)@ ހ€* Q€j€+ހ,Ő€!˙˙˙˙-€1€1€˙˙˙˙.€ހ€/.j€˙˙˙˙0€Ő€B˙˙˙˙1€1€1€˙˙˙˙2€ހ€3Kj€˙˙˙˙4€ń€Z˙˙˙˙5€ 1€1€˙˙˙˙6€ ހ€7 €j€˙˙˙˙8€ H€›€˙˙˙˙9€ 1€1€˙˙˙˙:@ ހ€; Q€j€< ހ €=ހ€>h~˙˙˙˙?€ H€Ť€˙˙˙˙@€ 1€1€˙˙˙˙A@ ހ€B Q€j€C †Ł˙˙˙˙D€ ŹÇ˙˙˙˙E€ Ą€ĐF Š€Ô˙˙˙˙G€ H€Ô˙˙˙˙H€ 1€1€˙˙˙˙I@ހ€JQ€j€K ŹŮ˙˙˙˙L€ Ą€ĐM Š€Ô˙˙˙˙N€ H€Ô˙˙˙˙O€ 1€1€˙˙˙˙P@ހ€QQ€j€R Źă˙˙˙˙S€ Ą€ĐT Š€Ô˙˙˙˙U€ H€Ô˙˙˙˙V€ 1€1€˙˙˙˙W@ހ€XQ€j€Y Źń˙˙˙˙Z€ Ą€Đ[ Š€Ô˙˙˙˙\€ H€Ô˙˙˙˙]€ 1€1€˙˙˙˙^@ހ€_Q€j€` Ź˙˙˙˙a€ Ą€Đb Š€Ô˙˙˙˙c€ H€Ô˙˙˙˙d€ 1€1€˙˙˙˙e@ހ€fQ€j€g Ź˙˙˙˙h€ Ą€Đi Š€Ô˙˙˙˙j€ H€Ô˙˙˙˙k€ 1€1€˙˙˙˙l@ހ€mQ€j€n Ź˙˙˙˙o€ Ą€Đp Š€Ô˙˙˙˙q€ H€Ô˙˙˙˙r€ 1€1€˙˙˙˙s@ހ€tQ€j€u †˙˙˙˙v€ ŹÇ˙˙˙˙w€ Ą€Đx Š€Ô˙˙˙˙y€ H€Ô˙˙˙˙z€ 1€1€˙˙˙˙{@ހ€|Q€j€} ŹŮ˙˙˙˙~€ Ą€Đ Š€Ô˙˙˙˙€€ H€Ô˙˙˙˙€ 1€1€˙˙˙˙‚@ހ€ƒQ€j€„ Źă˙˙˙˙…€ Ą€Đ† Š€Ô˙˙˙˙‡€ H€Ô˙˙˙˙ˆ€ 1€1€˙˙˙˙‰@ހ€ŠQ€j€‹ Źń˙˙˙˙Œ€ Ą€Đ Š€Ô˙˙˙˙Ž€ H€Ô˙˙˙˙€ 1€1€˙˙˙˙@ހ€‘Q€j€’ Ź˙˙˙˙“€ Ą€Đ” Š€Ô˙˙˙˙•€ H€Ô˙˙˙˙–€ 1€1€˙˙˙˙—@ހ€˜Q€j€™ Ź˙˙˙˙š€ Ą€Đ› Š€Ô˙˙˙˙œ€ H€Ô˙˙˙˙€ 1€1€˙˙˙˙ž@ހ€ŸQ€j€  Ź˙˙˙˙Ą€ Ą€Đ˘ Š€Ô˙˙˙˙Ł€ H€Ô˙˙˙˙¤€ 1€1€˙˙˙˙Ľ@ހ€ŚQ€j€§ †&˙˙˙˙¨€ ŹÇ˙˙˙˙Š€ Ą€ĐŞ Š€Ô˙˙˙˙Ť€ H€Ô˙˙˙˙Ź€ 1€1€˙˙˙˙­@ހ€ŽQ€j€Ż ŹŮ˙˙˙˙°€ Ą€Đą Š€Ô˙˙˙˙˛€ H€Ô˙˙˙˙ł€ 1€1€˙˙˙˙´@ހ€ľQ€j€ś Źă˙˙˙˙ˇ€ Ą€Đ¸ Š€Ô˙˙˙˙š€ H€Ô˙˙˙˙ş€ 1€1€˙˙˙˙ť@ހ€źQ€j€˝ Źń˙˙˙˙ž€ Ą€Đż Š€Ô˙˙˙˙Ŕ€ H€Ô˙˙˙˙Á€ 1€1€˙˙˙˙Â@ހ€ĂQ€j€Ä Ź˙˙˙˙ŀ Ą€ĐĆ Š€Ô˙˙˙˙ǀ H€Ô˙˙˙˙Ȁ 1€1€˙˙˙˙É@ހ€ĘQ€j€Ë Ź˙˙˙˙̀ Ą€ĐÍ Š€Ô˙˙˙˙΀ H€Ô˙˙˙˙π 1€1€˙˙˙˙Đ@ހ€ŃQ€j€Ň Ź˙˙˙˙Ӏ Ą€ĐÔ Š€Ô˙˙˙˙Հ H€Ô˙˙˙˙ր 1€1€˙˙˙˙×@ހ€ŘQ€j€Ů †/˙˙˙˙ڀ ŹÇ˙˙˙˙ۀ Ą€ĐÜ Š€Ô˙˙˙˙݀ H€Ô˙˙˙˙ހ 1€1€˙˙˙˙ß@ހ€ŕQ€j€á ŹŮ˙˙˙˙†Ą€Đă Š€Ô˙˙˙˙ä€ H€Ô˙˙˙˙ĺ€ 1€1€˙˙˙˙ć@ހ€çQ€j€č Źă˙˙˙˙é€ Ą€Đę Š€Ô˙˙˙˙ë€ H€Ô˙˙˙˙ě€ 1€1€˙˙˙˙í@ހ€îQ€j€ď Źń˙˙˙˙đ€ Ą€Đń Š€Ô˙˙˙˙ň€ H€Ô˙˙˙˙ó€ 1€1€˙˙˙˙ô@ހ€őQ€j€ö Ź˙˙˙˙÷€ Ą€Đř Š€Ô˙˙˙˙ů€ H€Ô˙˙˙˙ú€ 1€1€˙˙˙˙ű@ހ€üQ€j€ý Ź˙˙˙˙ţ€ Ą€Đ˙ Š€Ô˙˙˙˙€ H€Ô˙˙˙˙€ 1€1€˙˙˙˙@ހ€Q€j€ Ź˙˙˙˙€ Ą€Đ Š€Ô˙˙˙˙€ H€Ô˙˙˙˙€ 1€1€˙˙˙˙ @ހ€ Q€j€  †8˙˙˙˙ € ŹÇ˙˙˙˙ € Ą€Đ Š€Ô˙˙˙˙€ H€Ô˙˙˙˙€ 1€1€˙˙˙˙@ހ€Q€j€ ŹŮ˙˙˙˙€ Ą€Đ Š€Ô˙˙˙˙€ H€Ô˙˙˙˙€ 1€1€˙˙˙˙@ހ€Q€j€ Źă˙˙˙˙€ Ą€Đ Š€Ô˙˙˙˙€ H€Ô˙˙˙˙€ 1€1€˙˙˙˙@ހ€ Q€j€! Źń˙˙˙˙"€ Ą€Đ# Š€Ô˙˙˙˙$€ H€Ô˙˙˙˙%€ 1€1€˙˙˙˙&@ހ€'Q€j€( Ź˙˙˙˙)€ Ą€Đ* Š€Ô˙˙˙˙+€ H€Ô˙˙˙˙,€ 1€1€˙˙˙˙-@ހ€.Q€j€/ Ź˙˙˙˙0€ Ą€Đ1 Š€Ô˙˙˙˙2€ H€Ô˙˙˙˙3€ 1€1€˙˙˙˙4@ހ€5Q€j€6 Ź˙˙˙˙7€ Ą€Đ8 Š€Ô˙˙˙˙9€ H€Ô˙˙˙˙:€ 1€1€˙˙˙˙;@ހ€<Q€j€= †A˙˙˙˙>€ ŹÇ˙˙˙˙?€ Ą€Đ@ Š€Ô˙˙˙˙A€ H€Ô˙˙˙˙B€ 1€1€˙˙˙˙C@ހ€DQ€j€E ŹŮ˙˙˙˙F€ Ą€ĐG Š€Ô˙˙˙˙H€ H€Ô˙˙˙˙I€ 1€1€˙˙˙˙J@ހ€KQ€j€L Źă˙˙˙˙M€ Ą€ĐN Š€Ô˙˙˙˙O€ H€Ô˙˙˙˙P€ 1€1€˙˙˙˙Q@ހ€RQ€j€S Źń˙˙˙˙T€ Ą€ĐU Š€Ô˙˙˙˙V€ H€Ô˙˙˙˙W€ 1€1€˙˙˙˙X@ހ€YQ€j€Z Ź˙˙˙˙[€ Ą€Đ\ Š€Ô˙˙˙˙]€ H€Ô˙˙˙˙^€ 1€1€˙˙˙˙_@ހ€`Q€j€a Ź˙˙˙˙b€ Ą€Đc Š€Ô˙˙˙˙d€ H€Ô˙˙˙˙e€ 1€1€˙˙˙˙f@ހ€gQ€j€h Ź˙˙˙˙i€ Ą€Đj Š€Ô˙˙˙˙k€ H€Ô˙˙˙˙l€ 1€1€˙˙˙˙m@ހ€nQ€j€o †J˙˙˙˙p€ ŹÇ˙˙˙˙q€ Ą€Đr Š€Ô˙˙˙˙s€ H€Ô˙˙˙˙t€ 1€1€˙˙˙˙u@ހ€vQ€j€w ŹŮ˙˙˙˙x€ Ą€Đy Š€Ô˙˙˙˙z€ H€Ô˙˙˙˙{€ 1€1€˙˙˙˙|@ހ€}Q€j€~ Źă˙˙˙˙€ Ą€Đ€ Š€Ô˙˙˙˙€ H€Ô˙˙˙˙‚€ 1€1€˙˙˙˙ƒ@ހ€„Q€j€… Źń˙˙˙˙†€ Ą€Đ‡ Š€Ô˙˙˙˙ˆ€ H€Ô˙˙˙˙‰€ 1€1€˙˙˙˙Š@ހ€‹Q€j€Œ Ź˙˙˙˙€ Ą€ĐŽ Š€Ô˙˙˙˙€ H€Ô˙˙˙˙€ 1€1€˙˙˙˙‘@ހ€’Q€j€“ Ź˙˙˙˙”€ Ą€Đ• Š€Ô˙˙˙˙–€ H€Ô˙˙˙˙—€ 1€1€˙˙˙˙˜@ހ€™Q€j€š Ź˙˙˙˙›€ Ą€Đœ Š€Ô˙˙˙˙€ H€Ô˙˙˙˙ž€ 1€1€˙˙˙˙Ÿ@ހ€ Q€j€Ą †S˙˙˙˙˘€ ŹÇ˙˙˙˙Ł€ Ą€Đ¤ Š€Ô˙˙˙˙Ľ€ H€Ô˙˙˙˙Ś€ 1€1€˙˙˙˙§@ހ€¨Q€j€Š ŹŮ˙˙˙˙Ş€ Ą€ĐŤ Š€Ô˙˙˙˙Ź€ H€Ô˙˙˙˙­€ 1€1€˙˙˙˙Ž@ހ€ŻQ€j€° Źă˙˙˙˙ą€ Ą€Đ˛ Š€Ô˙˙˙˙ł€ H€Ô˙˙˙˙´€ 1€1€˙˙˙˙ľ@ހ€śQ€j€ˇ Źń˙˙˙˙¸€ Ą€Đš Š€Ô˙˙˙˙ş€ H€Ô˙˙˙˙ť€ 1€1€˙˙˙˙ź@ހ€˝Q€j€ž Ź˙˙˙˙ż€ Ą€ĐŔ Š€Ô˙˙˙˙Á€ H€Ô˙˙˙˙€ 1€1€˙˙˙˙Ă@ހ€ÄQ€j€Ĺ Ź˙˙˙˙Ć€ Ą€ĐÇ Š€Ô˙˙˙˙Č€ H€Ô˙˙˙˙É€ 1€1€˙˙˙˙Ę@ހ€ËQ€j€Ě Ź˙˙˙˙Í€ Ą€ĐÎ Š€Ô˙˙˙˙Ď€ H€Ô˙˙˙˙Đ€ 1€1€˙˙˙˙Ń@ހ€ŇQ€j€Ó L€\Ô@ Źl˙˙˙˙Ő€ Ą€ĐÖ Š€Ô˙˙˙˙×€ H€Ô˙˙˙˙Ř€ 1€1€˙˙˙˙Ů@ ހ€Ú Q€j€Ű Źr˙˙˙˙Ü€ Ą€ĐÝ Š€Ô˙˙˙˙Ţ€ H€Ô˙˙˙˙߀ 1€1€˙˙˙˙ŕ@ ހ€á Q€j€â Źy˙˙˙˙〠Ą€Đä Š€Ô˙˙˙˙ĺ€ H€Ô˙˙˙˙ć€ 1€1€˙˙˙˙ç@ ހ€č Q€j€é Ź˙˙˙˙ę€ Ą€Đë Š€Ô˙˙˙˙ě€ H€Ô˙˙˙˙í€ 1€1€˙˙˙˙î@ ހ€ď Q€j€đ ŹŽ˙˙˙˙ń€ Ą€Đň Š€Ô˙˙˙˙ó€ H€Ô˙˙˙˙ô€ 1€1€˙˙˙˙ő@ ހ€ö Q€j€÷ Źš˙˙˙˙ř€ Ą€Đů Š€Ô˙˙˙˙ú€ H€Ô˙˙˙˙ű€ 1€1€˙˙˙˙ü@ ހ€ý Q€j€ţ Śş˙˙˙˙˙€ ŹÄ˙˙˙˙€ Ą€Đ Š€Ô˙˙˙˙€ H€Ô˙˙˙˙€ 1€1€˙˙˙˙@ހ€Q€j€ ŹÉ˙˙˙˙€ Ą€Đ Š€Ô˙˙˙˙ € H€Ô˙˙˙˙ € 1€1€˙˙˙˙ @ހ€ Q€j€  ŹÎ˙˙˙˙€ Ą€Đ Š€Ô˙˙˙˙€ H€Ô˙˙˙˙€ 1€1€˙˙˙˙@ހ€Q€j€ ŹÔ˙˙˙˙€ Ą€Đ Š€Ô˙˙˙˙€ H€Ô˙˙˙˙€ 1€1€˙˙˙˙@ހ€Q€j€ ŚŮ˙˙˙˙€ ŹÄ˙˙˙˙€ Ą€Đ Š€Ô˙˙˙˙€ H€Ô˙˙˙˙ € 1€1€˙˙˙˙!@ހ€"Q€j€# ŹÉ˙˙˙˙$€ Ą€Đ% Š€Ô˙˙˙˙&€ H€Ô˙˙˙˙'€ 1€1€˙˙˙˙(@ހ€)Q€j€* ŹÎ˙˙˙˙+€ Ą€Đ, Š€Ô˙˙˙˙-€ H€Ô˙˙˙˙.€ 1€1€˙˙˙˙/@ހ€0Q€j€1 ŹÔ˙˙˙˙2€ Ą€Đ3 Š€Ô˙˙˙˙4€ H€Ô˙˙˙˙5€ 1€1€˙˙˙˙6@ހ€7Q€j€8 Śč˙˙˙˙9€ ŹÄ˙˙˙˙:€ Ą€Đ; Š€Ô˙˙˙˙<€ H€Ô˙˙˙˙=€ 1€1€˙˙˙˙>@ހ€?Q€j€@ ŹÉ˙˙˙˙A€ Ą€ĐB Š€Ô˙˙˙˙C€ H€Ô˙˙˙˙D€ 1€1€˙˙˙˙E@ހ€FQ€j€G ŹÎ˙˙˙˙H€ Ą€ĐI Š€Ô˙˙˙˙J€ H€Ô˙˙˙˙K€ 1€1€˙˙˙˙L@ހ€MQ€j€N ŹÔ˙˙˙˙O€ Ą€ĐP Š€Ô˙˙˙˙Q€ H€Ô˙˙˙˙R€ 1€1€˙˙˙˙S@ހ€TQ€j€U Źö˙˙˙˙V€ Ą€ĐW Š€Ô˙˙˙˙X€ H€Ô˙˙˙˙Y€ 1€1€˙˙˙˙Z@ ހ€[ Q€j€\ Ź˙˙˙˙]€ Ą€Đ^ Š€Ô˙˙˙˙_€ H€Ô˙˙˙˙`€ 1€1€˙˙˙˙a@ ހ€b Q€j€c Ź˙˙˙˙d€ Ą€Đe Š€Ô˙˙˙˙f€ H€Ô˙˙˙˙g€ 1€1€˙˙˙˙h@ ހ€i Q€j€j Ź"˙˙˙˙k€ Ą€Đl Š€Ô˙˙˙˙m€ H€Ô˙˙˙˙n€ 1€1€˙˙˙˙o@ ހ€p Q€j€q Ź+˙˙˙˙r€ Ą€Đs Š€Ô˙˙˙˙t€ H€Ô˙˙˙˙u€ 1€1€˙˙˙˙v@ ހ€w Q€j€x Ź2˙˙˙˙y€ Ą€Đz Š€Ô˙˙˙˙{€ H€Ô˙˙˙˙|€ 1€1€˙˙˙˙}@ ހ€~ Q€j€ =Y˙˙˙˙€€ Źb˙˙˙˙€ Ą€Đ‚ Š€Ô˙˙˙˙ƒ€ H€Ô˙˙˙˙„€ 1€1€˙˙˙˙…@ހ€†Q€j€‡ Źd˙˙˙˙ˆ€ Ą€Đ‰ Š€Ô˙˙˙˙Š€ H€Ô˙˙˙˙‹€ 1€1€˙˙˙˙Œ@ހ€Q€j€Ž Źf˙˙˙˙€ Ą€Đ Š€Ô˙˙˙˙‘€ H€Ô˙˙˙˙’€ 1€1€˙˙˙˙“@ހ€”Q€j€• Źh˙˙˙˙–€ Ą€Đ— Š€Ô˙˙˙˙˜€ H€Ô˙˙˙˙™€ 1€1€˙˙˙˙š@ހ€›Q€j€œ Š€Ô˙˙˙˙€ H€Ô˙˙˙˙ž€ 1€1€˙˙˙˙Ÿ@ ހ€  Q€j€Ą ހj˘ ހrŁ ˙˙˙˙¤€ ń€—˙˙˙˙Ľ€ 1€1€˙˙˙˙Ś€ ހ€§ €j€˙˙˙˙¨€ H€›€˙˙˙˙Š€1€1€˙˙˙˙Ş@ހ€ŤQ€j€Ź H€ €˙˙˙˙­€1€1€˙˙˙˙Ž@ހ€ŻQ€j€° ހœą L€˘˛@Ś€ŤłšË˙˙˙˙´€ Ő€Ö˙˙˙˙ľ€ 1€1€˙˙˙˙ś€ ހ€ˇ äj€˙˙˙˙¸€ Ś€ůš ˙˙˙˙ş€ Ő€˙˙˙˙ť@1€1€˙˙˙˙źހ€˝#j€ž5€5ż5€<Ŕ Ś€CÁ Ő€O˙˙˙˙ 1€1€˙˙˙˙Ăހ€Ä‹€j€Ĺ 5€`Ć 5€uÇ@ Ő€†˙˙˙˙Č€ 1€1€˙˙˙˙É€ހ€Ę•j€Ë€ހĽĚހƒ€ÍހąÎ5€€Ď5€˝Đ@ Ő€Ă˙˙˙˙Ń€ 1€1€˙˙˙˙Ň€ހ€ÓŇj€Ô€ހĽŐހƒ€Öހą×5€€Ř5€âŮ@ Ő€í˙˙˙˙Ú€ 1€1€˙˙˙˙Ű€ހ€Üýj€ Ý€ހĽŢހƒ€ßހŕ5€˝á@ Ő€˙˙˙˙â 1€1€˙˙˙˙ăހ€ä,j€ĺހĽćހƒ€ç Ő€:˙˙˙˙č€ 1€1€˙˙˙˙é€ހ€ęLj€˙˙˙˙ë€ހĽěŐ€Ă˙˙˙˙í€1€1€˙˙˙˙î€ހ€ďŇj€đ€ހĽńހƒ€ňހąó5€€ô5€âő@Ő€†˙˙˙˙ö€1€1€˙˙˙˙÷€ހ€ř•j€ů€ހĽúހƒ€űހąü5€€ý5€˝ţ@ހ[˙ Ő€b˙˙˙˙ 1€1€˙˙˙˙ހ€,j€ހĽހƒ€ Ő€{˙˙˙˙ 1€1€˙˙˙˙ހ€‡j€ ހĽ ހƒ€ ހ” š¤˙˙˙˙ € Ő€Ö˙˙˙˙€ 1€1€˙˙˙˙€ ހ€ äj€˙˙˙˙€ Ś€ů ˙˙˙˙€ Ő€˙˙˙˙@1€1€˙˙˙˙ހ€#j€5€55€< Ś€C Ő€O˙˙˙˙ 1€1€˙˙˙˙ހ€‹€j€ 5€` 5€u @ Ő€†˙˙˙˙!€ 1€1€˙˙˙˙"€ހ€#•j€$€ހĽ%ހƒ€&ހą'5€€(5€˝)@ Ő€Ă˙˙˙˙*€ 1€1€˙˙˙˙+€ހ€,Ňj€-€ހĽ.ހƒ€/ހą05€€15€â2@ Ő€í˙˙˙˙3€ 1€1€˙˙˙˙4€ހ€5ýj€ 6€ހĽ7ހƒ€8ހ95€˝:@ Ő€˙˙˙˙; 1€1€˙˙˙˙<ހ€=,j€>ހĽ?ހƒ€@ Ő€:˙˙˙˙A€ 1€1€˙˙˙˙B€ހ€CLj€˙˙˙˙D€ހĽEŐ€Ă˙˙˙˙F€1€1€˙˙˙˙G€ހ€HŇj€I€ހĽJހƒ€KހąL5€€M5€âN@Ő€†˙˙˙˙O€1€1€˙˙˙˙P€ހ€Q•j€R€ހĽSހƒ€TހąU5€€V5€˝W@ހ[X Ő€b˙˙˙˙Y 1€1€˙˙˙˙Zހ€[,j€\ހĽ]ހƒ€^ Ő€{˙˙˙˙_ 1€1€˙˙˙˙`ހ€a‡j€ bހĽcހƒ€dހ”ešą˙˙˙˙f€ Ő€Ö˙˙˙˙g€ 1€1€˙˙˙˙h€ ހ€i äj€˙˙˙˙j€ Ś€ůk ˙˙˙˙l€ Ő€˙˙˙˙m@1€1€˙˙˙˙nހ€o#j€p5€5q5€<r Ś€Cs Ő€O˙˙˙˙t 1€1€˙˙˙˙uހ€v‹€j€w 5€`x 5€uy@ Ő€†˙˙˙˙z€ 1€1€˙˙˙˙{€ހ€|•j€}€ހĽ~ހƒ€ހą€5€€5€˝‚@ Ő€Ă˙˙˙˙ƒ€ 1€1€˙˙˙˙„€ހ€…Ňj€†€ހĽ‡ހƒ€ˆހą‰5€€Š5€â‹@ Ő€í˙˙˙˙Œ€ 1€1€˙˙˙˙€ހ€Žýj€ €ހĽހƒ€‘ހ’5€˝“@ Ő€˙˙˙˙” 1€1€˙˙˙˙•ހ€–,j€—ހĽ˜ހƒ€™ Ő€:˙˙˙˙š€ 1€1€˙˙˙˙›€ހ€œLj€˙˙˙˙€ހĽžŐ€Ă˙˙˙˙Ÿ€1€1€˙˙˙˙ €ހ€ĄŇj€˘€ހĽŁހƒ€¤ހąĽ5€€Ś5€â§@Ő€†˙˙˙˙¨€1€1€˙˙˙˙Š€ހ€Ş•j€Ť€ހĽŹހƒ€­ހąŽ5€€Ż5€˝°@ހ[ą Ő€b˙˙˙˙˛ 1€1€˙˙˙˙łހ€´,j€ľހĽśހƒ€ˇ Ő€{˙˙˙˙¸ 1€1€˙˙˙˙šހ€ş‡j€ ťހĽźހƒ€˝ހ”žšž˙˙˙˙ż€ Ő€Ö˙˙˙˙Ŕ€ 1€1€˙˙˙˙Á€ ހ€Â äj€˙˙˙˙Ă€ Ś€ůÄ ˙˙˙˙Ĺ€ Ő€˙˙˙˙Ć@1€1€˙˙˙˙Çހ€Č#j€É5€5Ę5€<Ë Ś€CĚ Ő€O˙˙˙˙Í 1€1€˙˙˙˙Îހ€Ď‹€j€Đ 5€`Ń 5€uŇ@ Ő€†˙˙˙˙Ó€ 1€1€˙˙˙˙Ô€ހ€Ő•j€Ö€ހĽ×ހƒ€ŘހąŮ5€€Ú5€˝Ű@ Ő€Ă˙˙˙˙Ü€ 1€1€˙˙˙˙Ý€ހ€ŢŇj€ß€ހĽŕހƒ€áހąâ5€€ă5€âä@ Ő€í˙˙˙˙ĺ€ 1€1€˙˙˙˙ć€ހ€çýj€ č€ހĽéހƒ€ęހë5€˝ě@ Ő€˙˙˙˙í 1€1€˙˙˙˙îހ€ď,j€đހĽńހƒ€ň Ő€:˙˙˙˙ó€ 1€1€˙˙˙˙ô€ހ€őLj€˙˙˙˙ö€ހĽ÷Ő€Ă˙˙˙˙ř€1€1€˙˙˙˙ů€ހ€úŇj€ű€ހĽüހƒ€ýހąţ5€€˙5€â@Ő€†˙˙˙˙€1€1€˙˙˙˙€ހ€•j€€ހĽހƒ€ހą5€€5€˝ @ހ[  Ő€b˙˙˙˙  1€1€˙˙˙˙ ހ€ ,j€ހĽހƒ€ Ő€{˙˙˙˙ 1€1€˙˙˙˙ހ€‡j€ ހĽހƒ€ހ”šÇ˙˙˙˙€ Ő€Ö˙˙˙˙€ 1€1€˙˙˙˙€ ހ€ äj€˙˙˙˙€ Ś€ů ˙˙˙˙€ Ő€˙˙˙˙@1€1€˙˙˙˙ ހ€!#j€"5€5#5€<$ Ś€C% Ő€O˙˙˙˙& 1€1€˙˙˙˙'ހ€(‹€j€) 5€`* 5€u+@ Ő€†˙˙˙˙,€ 1€1€˙˙˙˙-€ހ€.•j€/€ހĽ0ހƒ€1ހą25€€35€˝4@ Ő€Ă˙˙˙˙5€ 1€1€˙˙˙˙6€ހ€7Ňj€8€ހĽ9ހƒ€:ހą;5€€<5€â=@ Ő€í˙˙˙˙>€ 1€1€˙˙˙˙?€ހ€@ýj€ A€ހĽBހƒ€CހD5€˝E@ Ő€˙˙˙˙F 1€1€˙˙˙˙Gހ€H,j€IހĽJހƒ€K Ő€:˙˙˙˙L€ 1€1€˙˙˙˙M€ހ€NLj€˙˙˙˙O€ހĽPŐ€Ă˙˙˙˙Q€1€1€˙˙˙˙R€ހ€SŇj€T€ހĽUހƒ€VހąW5€€X5€âY@Ő€†˙˙˙˙Z€1€1€˙˙˙˙[€ހ€\•j€]€ހĽ^ހƒ€_ހą`5€€a5€˝b@ހ[c Ő€b˙˙˙˙d 1€1€˙˙˙˙eހ€f,j€gހĽhހƒ€i Ő€{˙˙˙˙j 1€1€˙˙˙˙kހ€l‡j€ mހĽnހƒ€oހ”pL€Ňq@H€é˙˙˙˙r€ 1€1€˙˙˙˙s@ ހ€t Q€j€uH€Ť€˙˙˙˙v€ 1€1€˙˙˙˙w@ ހ€x Q€j€yH€ó˙˙˙˙z€ 1€1€˙˙˙˙{@ ހ€| Q€j€}˙˙˙˙~€ ń€—˙˙˙˙€ 1€1€˙˙˙˙€€ ހ€ €j€˙˙˙˙‚€ H€›€˙˙˙˙ƒ€ 1€1€˙˙˙˙„@ހ€…Q€j€† H€ €˙˙˙˙‡€ 1€1€˙˙˙˙ˆ@ހ€‰Q€j€Š˙˙˙˙‹€ń€—˙˙˙˙Œ€1€1€˙˙˙˙€ހ€Ž€j€˙˙˙˙€ H€›€˙˙˙˙€ 1€1€˙˙˙˙‘@ ހ€’ Q€j€“ H€ €˙˙˙˙”€ 1€1€˙˙˙˙•@ ހ€– Q€j€—ހœ˜H€Ť€˙˙˙˙™€1€1€˙˙˙˙š@ހ€›Q€j€œH€˙˙˙˙€1€1€˙˙˙˙ž@ހ€ŸQ€j€ H€˙˙˙˙Ą€1€1€˙˙˙˙˘@ހ€ŁQ€j€¤Ő€#˙˙˙˙Ľ€1€1€˙˙˙˙Ś€ހ€§2j€˙˙˙˙¨€H€M˙˙˙˙Š€1€1€˙˙˙˙Ş@ހ€ŤQ€j€ŹH€R˙˙˙˙­€1€1€˙˙˙˙Ž@ހ€ŻQ€j€°L€Uą@Ő€r˙˙˙˙˛1€1€˙˙˙˙łހ€´Ś€j€ľŐ€|˙˙˙˙ś1€1€˙˙˙˙ˇހ€¸Ś€j€šŐ€„˙˙˙˙ş1€1€˙˙˙˙ťހ€źŚ€j€˝Ő€–˙˙˙˙ž1€1€˙˙˙˙żހ€ŔŚ€j€ÁŐ€Ş˙˙˙˙€1€1€˙˙˙˙Ă@ހ€Ä €j€ĹŐ€#˙˙˙˙Ć1€1€˙˙˙˙Çހ€Čšj€ ÉހĘ.€&ËL€ĆĚ@ń€Ö˙˙˙˙Í€1€1€˙˙˙˙΀ހ€Ď€j€˙˙˙˙Đ€H€›€˙˙˙˙Ń€1€1€˙˙˙˙Ň@ހ€ÓQ€j€Ô°€ € ŐހÖ.€&×čţ˙˙˙˙Ř€ń€ ˙˙˙˙Ů€1€1€˙˙˙˙Ú€ހ€Ű€j€˙˙˙˙Ü€ހ›€Ý €˙˙˙˙Ţ€H€%˙˙˙˙߀1€1€˙˙˙˙ŕ@ހ€áQ€j€âH€,˙˙˙˙ă€1€1€˙˙˙˙ä@ހ€ĺQ€j€ćŚ€8猀Gčހb錀nęz‚ë €‘ě €ší €Łî €Źď €ľđ €žń €Çň €Đó €Ůô €âő €ëö €ő÷ €˙ř € ů €ú €űL€'ü@ހ3ýŐ€>˙˙˙˙ţ€1€1€˙˙˙˙˙€ހ€Ő€j€˙˙˙˙€ 1€1€˙˙˙˙€ ހ€ H€j€˙˙˙˙€ 1€1€˙˙˙˙@ ހ€ Q€j€Ő€N˙˙˙˙€1€1€˙˙˙˙ €ހ€ Ő€j€˙˙˙˙ € 1€1€˙˙˙˙ € ހ€  H€j€˙˙˙˙€ 1€1€˙˙˙˙@ ހ€ Q€j€Ő€^˙˙˙˙€1€1€˙˙˙˙€ހ€Ő€j€˙˙˙˙€ 1€1€˙˙˙˙€ ހ€ H€j€˙˙˙˙€ 1€1€˙˙˙˙@ ހ€ Q€j€Ő€n˙˙˙˙€1€1€˙˙˙˙€ހ€Ő€j€˙˙˙˙€ 1€1€˙˙˙˙ € ހ€! H€j€˙˙˙˙"€ 1€1€˙˙˙˙#@ ހ€$ Q€j€%Ő€~˙˙˙˙&€1€1€˙˙˙˙'€ހ€(Ő€j€˙˙˙˙)€ 1€1€˙˙˙˙*€ ހ€+ H€j€˙˙˙˙,€ 1€1€˙˙˙˙-@ ހ€. Q€j€/Ő€Ž˙˙˙˙0€1€1€˙˙˙˙1€ހ€2Ő€j€˙˙˙˙3€ 1€1€˙˙˙˙4€ ހ€5 H€j€˙˙˙˙6€ 1€1€˙˙˙˙7@ ހ€8 Q€j€9Ő€ž˙˙˙˙:€1€1€˙˙˙˙;€ހ€<Ő€j€˙˙˙˙=€ 1€1€˙˙˙˙>€ ހ€? H€j€˙˙˙˙@€ 1€1€˙˙˙˙A@ ހ€B Q€j€CŐ€ą˙˙˙˙D€1€1€˙˙˙˙E€ހ€FŐ€j€˙˙˙˙G€ 1€1€˙˙˙˙H€ ހ€I H€j€˙˙˙˙J€ 1€1€˙˙˙˙K@ ހ€L Q€j€MŐ€Ä˙˙˙˙N€1€1€˙˙˙˙O€ހ€PŐ€j€˙˙˙˙Q€ 1€1€˙˙˙˙R€ ހ€S H€j€˙˙˙˙T€ 1€1€˙˙˙˙U@ ހ€V Q€j€WŐ€×˙˙˙˙X€1€1€˙˙˙˙Y€ހ€ZŐ€j€˙˙˙˙[€ 1€1€˙˙˙˙\€ ހ€] H€j€˙˙˙˙^€ 1€1€˙˙˙˙_@ ހ€` Q€j€aŐ€ę˙˙˙˙b€1€1€˙˙˙˙c€ހ€dŐ€j€˙˙˙˙e€ 1€1€˙˙˙˙f€ ހ€g H€j€˙˙˙˙h€ 1€1€˙˙˙˙i@ ހ€j Q€j€kŐ€ý˙˙˙˙l€1€1€˙˙˙˙m€ހ€nŐ€j€˙˙˙˙o€ 1€1€˙˙˙˙p€ ހ€q H€j€˙˙˙˙r€ 1€1€˙˙˙˙s@ ހ€t Q€j€uހ vŐ€ ˙˙˙˙w€1€1€˙˙˙˙x€ހ€yH€j€˙˙˙˙z€ 1€1€˙˙˙˙{@ ހ€| Q€j€}Ő€+ ˙˙˙˙~€1€1€˙˙˙˙€ހ€€H€j€˙˙˙˙€ 1€1€˙˙˙˙‚@ ހ€ƒ Q€j€„Ő€= ˙˙˙˙…€1€1€˙˙˙˙†€ހ€‡H€j€˙˙˙˙ˆ€ 1€1€˙˙˙˙‰@ ހ€Š Q€j€‹Ő€O ˙˙˙˙Œ€1€1€˙˙˙˙€ހ€ŽH€j€˙˙˙˙€ 1€1€˙˙˙˙@ ހ€‘ Q€j€’Ő€a ˙˙˙˙“€1€1€˙˙˙˙”€ހ€•H€j€˙˙˙˙–€ 1€1€˙˙˙˙—@ ހ€˜ Q€j€™Ő€s ˙˙˙˙š€1€1€˙˙˙˙›€ހ€œH€j€˙˙˙˙€ 1€1€˙˙˙˙ž@ ހ€Ÿ Q€j€ H€… ˙˙˙˙Ą€1€1€˙˙˙˙˘@ހ€ŁQ€j€¤H€Ÿ ˙˙˙˙Ľ€1€1€˙˙˙˙Ś@ހ€§Q€j€¨Ś€ą ŠL€Î ŞL€â ŤShaderPPtrm_FileIDm_PathIDSerializedShaderm_ParsedFormSerializedPropertiesm_PropInfom_PropsSerializedPropertym_Descriptionm_Attributesm_Flagsm_DefValue[0]m_DefValue[1]m_DefValue[2]m_DefValue[3]SerializedTexturePropertym_DefTexturem_DefaultNamem_TexDimm_SubShadersSerializedSubShaderm_PassesSerializedPassm_NameIndicesSerializedShaderStatem_StateSerializedShaderRTBlendStatertBlend0SerializedShaderFloatValuesrcBlendvalnamedestBlendsrcBlendAlphadestBlendAlphablendOpblendOpAlphacolMaskrtBlend1rtBlend2rtBlend3rtBlend4rtBlend5rtBlend6rtBlend7rtSeparateBlendzTestzWritecullingoffsetFactoroffsetUnitsalphaToMaskSerializedStencilOpstencilOppassfailzFailcompstencilOpFrontstencilOpBackstencilReadMaskstencilWriteMaskstencilReffogStartfogEndfogDensitySerializedShaderVectorValuefogColorxyzwfogModegpuProgramIDSerializedTagMapm_Tagstagsm_LODlightingm_ProgramMaskSerializedProgramprogVertexm_SubProgramsSerializedSubProgramm_BlobIndexParserBindChannelsm_ChannelsShaderBindChannelsourcetargetm_SourceMapm_KeywordIndicesm_ShaderHardwareTierm_GpuProgramTypem_VectorParamsVectorParameterm_NameIndexm_ArraySizem_Dimm_MatrixParamsMatrixParameterm_RowCountm_TextureParamsTextureParameterm_SamplerIndexm_BufferParamsBufferBindingm_ConstantBuffersConstantBufferm_Sizem_ConstantBufferBindingsm_UAVParamsUAVParameterm_OriginalIndexprogFragmentprogGeometryprogHullprogDomainm_HasInstancingVariantm_UseNamem_TextureNamem_CustomEditorNamem_FallbackNamem_DependenciesSerializedShaderDependencyfromtom_DisableNoSubshadersMessageplatformsoffsetscompressedLengthsdecompressedLengthscompressedBlobPPtrm_ShaderIsBakedm_DefaultTexturesShaderCompilationInfom_CompileInfom_SnippetsShaderSnippetm_Codem_AssetPathm_PlatformMaskm_HardwareTierVariantsMaskm_StartLinem_TypesMaskHash128m_IncludesHashbytes[0]bytes[1]bytes[2]bytes[3]bytes[4]bytes[5]bytes[6]bytes[7]bytes[8]bytes[9]bytes[10]bytes[11]bytes[12]bytes[13]bytes[14]bytes[15]m_FromOtherm_Languagem_VariantsUser0m_VariantsUser1m_VariantsUser2m_VariantsUser3m_VariantsUser4m_VariantsUser5m_VariantsBuiltin0m_VariantsBuiltin1m_VariantsBuiltin2m_VariantsBuiltin3m_VariantsBuiltin4m_VariantsBuiltin5m_Targetm_TargetVariants0m_TargetVariants1m_TargetVariants2m_TargetVariants3m_TargetVariants4m_TargetVariants5m_NonStrippedUserKeywordsm_BuiltinKeywordsm_MeshComponentsFromSnippetsm_HasSurfaceShadersm_HasFixedFunctionShaders´¸0>Ič˘BĘm10ő?NUŽş/óÍČČB\Assets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField/DepthOfFieldScatter.shader_MainTex-black _FgOverlap-black_LowRez-black€? €? €? €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙Li€? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙Ä€? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙n €? €? €? €? €@ €@ €? €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙ëë€? €? €? €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙Ũ€? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙M€? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙@ę @ A  @ A `A €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙L,€? €? €? €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙O+€? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙rÎ €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙P €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙Ę €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙ËÓ €? €? €? €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙*č €? €? €? €? €@ €@ €? €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙-ţ€? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙kź€? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙[ €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙#´€? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙€Ý€? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙ßŐ€? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙Ëŕ@ A €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙e•ŕ@ €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA €? €? pA A A A A C C unity_FogStart unity_FogEndunity_FogDensity unity_FogColor˙˙˙˙<ŐHidden/Dof/DepthOfFieldHdrLiŹS#line 592 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 592 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vert #pragma fragment fragCaptureCoc AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙R=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ONIJS#line 607 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 607 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vertBlurPlusMinus #pragma fragment fragGaussBlur AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙a=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ONn ľS#line 621 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 621 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vertBlurPlusMinus #pragma fragment fragBlurForFgCoc AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙o=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ONëë S#line 640 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 640 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vert #pragma fragment AddFgCoc AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙‚=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ONŨ°S#line 657 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 657 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vert #pragma fragment fragCaptureForegroundCoc AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙“=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ONMŁS#line 671 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 671 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vert #pragma fragment fragBlurBox AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙Ą=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ON@ęŽS#line 685 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 685 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vert #pragma fragment frag4TapBlurForLRSpawn AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙Ż=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ONL,ŞS#line 701 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 701 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vert #pragma fragment fragBlendInHighRez AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙ż=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ONO+´S#line 717 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 717 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vert #pragma fragment fragCaptureForegroundCocMask AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙Ď=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ONrÎ ­S#line 732 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 732 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vert #pragma fragment fragBlurUpsampleCheap AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙Ţ=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ONP ´S#line 746 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 746 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vert #pragma fragment fragCaptureColorAndSignedCoc AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙ě=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ONĘ ¨S#line 760 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 760 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vert #pragma fragment fragBlurInsaneMQ AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙ú=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ONËÓ ąS#line 774 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 774 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vert #pragma fragment fragBlurUpsampleCombineMQ AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ON*č ¤S#line 789 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 789 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vert #pragma fragment fragMergeCoc AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ON-ţ˛S#line 807 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 807 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vert #pragma fragment fragCombineCocWithMaskBlur AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙)=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ONkźŠS#line 821 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 821 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vert #pragma fragment fragBoxDownsample AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙7=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ON[ ¤S#line 834 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 834 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vert #pragma fragment fragVisualize AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙D=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ON#´¨S#line 848 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 848 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vert #pragma fragment fragBlurInsaneHQ AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙R=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ON€ÝąS#line 862 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 862 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vert #pragma fragment fragBlurUpsampleCombineHQ AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙`=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ONßŐşS#line 876 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 876 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vertBlurPlusMinus #pragma fragment fragBlurAlphaWeighted AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙n=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ONËĽS#line 890 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 890 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vert #pragma fragment fragAlphaMask AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙|=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ONe•§S#line 907 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 907 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vertFlip #pragma fragment fragBlurBox AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ON<ŐˇS#line 925 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif #include "HLSLSupport.cginc" #include "UnityShaderVariables.cginc" #line 9 #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; struct v2fRadius { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv1[4] : TEXCOORD1; }; struct v2fBlur { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; float4 uv01 : TEXCOORD1; float4 uv23 : TEXCOORD2; float4 uv45 : TEXCOORD3; float4 uv67 : TEXCOORD4; float4 uv89 : TEXCOORD5; }; uniform sampler2D _MainTex; uniform sampler2D_float _CameraDepthTexture; uniform sampler2D _FgOverlap; uniform sampler2D _LowRez; uniform float4 _CurveParams; uniform float4 _MainTex_TexelSize; half4 _MainTex_ST; uniform float4 _Offsets; half4 _CameraDepthTexture_ST; half4 _LowRez_ST; half4 _FgOverlap_ST; v2f vert( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; #endif return o; } v2f vertFlip( appdata_img v ) { v2f o; o.pos = mul (UNITY_MATRIX_MVP, v.vertex); o.uv1.xy = v.texcoord.xy; o.uv.xy = v.texcoord.xy; #if UNITY_UV_STARTS_AT_TOP if (_MainTex_TexelSize.y < 0) o.uv.y = 1-o.uv.y; if (_MainTex_TexelSize.y < 0) o.uv1.y = 1-o.uv1.y; #endif return o; } v2fBlur vertBlurPlusMinus (appdata_img v) { v2fBlur o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); o.uv.xy = UnityStereoScreenSpaceUVAdjust(v.texcoord.xy, _MainTex_ST); o.uv01 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(1,1, -1,-1) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv23 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(2,2, -2,-2) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv45 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(3,3, -3,-3) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv67 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(4,4, -4,-4) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); o.uv89 = UnityStereoScreenSpaceUVAdjust(v.texcoord.xyxy + _Offsets.xyxy * float4(5,5, -5,-5) * _MainTex_TexelSize.xyxy / 6.0, _MainTex_ST); return o; } #define SCATTER_OVERLAP_SMOOTH (-0.265) inline float BokehWeightDisc(float4 theSample, float sampleDistance, float4 centerSample) { return smoothstep(SCATTER_OVERLAP_SMOOTH, 0.0, theSample.a - centerSample.a*sampleDistance); } inline float2 BokehWeightDisc2(float4 sampleA, float4 sampleB, float2 sampleDistance2, float4 centerSample) { return smoothstep(float2(SCATTER_OVERLAP_SMOOTH, SCATTER_OVERLAP_SMOOTH), float2(0.0,0.0), float2(sampleA.a, sampleB.a) - centerSample.aa*sampleDistance2); } static const int SmallDiscKernelSamples = 12; static const float2 SmallDiscKernel[SmallDiscKernelSamples] = { float2(-0.326212,-0.40581), float2(-0.840144,-0.07358), float2(-0.695914,0.457137), float2(-0.203345,0.620716), float2(0.96234,-0.194983), float2(0.473434,-0.480026), float2(0.519456,0.767022), float2(0.185461,-0.893124), float2(0.507431,0.064425), float2(0.89642,0.412458), float2(-0.32194,-0.932615), float2(-0.791559,-0.59771) }; static const int NumDiscSamples = 28; static const float3 DiscKernel[NumDiscSamples] = { float3(0.62463,0.54337,0.82790), float3(-0.13414,-0.94488,0.95435), float3(0.38772,-0.43475,0.58253), float3(0.12126,-0.19282,0.22778), float3(-0.20388,0.11133,0.23230), float3(0.83114,-0.29218,0.88100), float3(0.10759,-0.57839,0.58831), float3(0.28285,0.79036,0.83945), float3(-0.36622,0.39516,0.53876), float3(0.75591,0.21916,0.78704), float3(-0.52610,0.02386,0.52664), float3(-0.88216,-0.24471,0.91547), float3(-0.48888,-0.29330,0.57011), float3(0.44014,-0.08558,0.44838), float3(0.21179,0.51373,0.55567), float3(0.05483,0.95701,0.95858), float3(-0.59001,-0.70509,0.91938), float3(-0.80065,0.24631,0.83768), float3(-0.19424,-0.18402,0.26757), float3(-0.43667,0.76751,0.88304), float3(0.21666,0.11602,0.24577), float3(0.15696,-0.85600,0.87027), float3(-0.75821,0.58363,0.95682), float3(0.99284,-0.02904,0.99327), float3(-0.22234,-0.57907,0.62029), float3(0.55052,-0.66984,0.86704), float3(0.46431,0.28115,0.54280), float3(-0.07214,0.60554,0.60982), }; float4 fragBlurInsaneMQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float weights = 0; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); if( sample0.a > 0.0 ) { weights = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); sum += sample0 * weights; sampleCount += weights; } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } float4 fragBlurInsaneHQ (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 sum = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w; float sampleCount = max(centerTap.a * 0.25, _Offsets.z); // <- weighing with 0.25 looks nicer for small high freq spec sum *= sampleCount; float2 weights = 0; for(int l=0; l < NumDiscSamples; l++) { float4 sampleUV = i.uv1.xyxy + DiscKernel[l].xyxy * poissonScale.xyxy / float4(1.2,1.2,DiscKernel[l].zz); float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.xy, _MainTex_ST)); float4 sample1 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV.zw, _MainTex_ST)); if( (sample0.a + sample1.a) > 0.0 ) { weights = BokehWeightDisc2(sample0, sample1, float2(DiscKernel[l].z/1.2, 1.0), centerTap); sum += sample0 * weights.x + sample1 * weights.y; sampleCount += dot(weights, 1); } } float4 returnValue = sum / sampleCount; returnValue.a = centerTap.a; return returnValue; } inline float4 BlendLowWithHighHQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.65,0.85, coc); return lerp(low, high, blend); } inline float4 BlendLowWithHighMQ(float coc, float4 low, float4 high) { float blend = smoothstep(0.4,0.6, coc); return lerp(low, high, blend); } float4 fragBlurUpsampleCombineHQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < NumDiscSamples; l++) { float2 sampleUV = i.uv1.xy + DiscKernel[l].xy * poissonScale.xy; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, DiscKernel[l].z, centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighHQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCombineMQ (v2f i) : SV_Target { float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 smallBlur = centerTap; float4 poissonScale = _MainTex_TexelSize.xyxy * centerTap.a * _Offsets.w ; float sampleCount = max(centerTap.a * 0.25, 0.1f); // <- weighing with 0.25 looks nicer for small high freq spec smallBlur *= sampleCount; for(int l=0; l < SmallDiscKernelSamples; l++) { float2 sampleUV = i.uv1.xy + SmallDiscKernel[l].xy * poissonScale.xy*1.1; float4 sample0 = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(sampleUV, _MainTex_ST)); float weight0 = BokehWeightDisc(sample0, length(SmallDiscKernel[l].xy*1.1), centerTap); smallBlur += sample0 * weight0; sampleCount += weight0; } smallBlur /= (sampleCount+1e-5f); smallBlur = BlendLowWithHighMQ(centerTap.a, smallBlur, bigBlur); return centerTap.a < 1e-2f ? centerTap : float4(smallBlur.rgb,centerTap.a); } float4 fragBlurUpsampleCheap (v2f i) : SV_Target { float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float4 bigBlur = tex2D(_LowRez, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _LowRez_ST)); float fgCoc = tex2D(_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; float4 smallBlur = lerp(centerTap, bigBlur, saturate( max(centerTap.a,fgCoc)*8.0 )); return float4(smallBlur.rgb, centerTap.a); } float4 fragBlurBox (v2f i) : SV_Target { const int TAPS = 12; float4 centerTap = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); // TODO: important ? breaks when HR blur is being used //centerTap.a = max(centerTap.a, 0.1f); float sampleCount = centerTap.a; float4 sum = centerTap * sampleCount; float2 lenStep = centerTap.aa * (1.0 / (TAPS-1.0)); float4 steps = (_Offsets.xyxy * _MainTex_TexelSize.xyxy) * lenStep.xyxy * float4(1,1, -1,-1); for(int l=1; l 1e-5f) outColor.rgb = color.rgb/sumWeights; return outColor; } float4 fragCaptureColorAndSignedCoc (v2f i) : SV_Target { float4 color = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x) * sign(d - _CurveParams.w); return color; } float4 fragCaptureCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 AddFgCoc (v2f i) : SV_Target { return tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); } float4 fragMergeCoc (v2f i) : SV_Target { float4 color = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _FgOverlap_ST)); // this is the foreground overlap value float fgCoc = color.a; float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * abs(d - _CurveParams.w) / (d + 1e-5f); color.a = clamp( max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return max(color.aaaa, float4(fgCoc,fgCoc,fgCoc,fgCoc)); } float4 fragCombineCocWithMaskBlur (v2f i) : SV_Target { float bgAndFgCoc = tex2D (_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)).a; float fgOverlapCoc = tex2D (_FgOverlap, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _FgOverlap_ST)).a; return (bgAndFgCoc < 0.01) * saturate(fgOverlapCoc-bgAndFgCoc); } float4 fragCaptureForegroundCoc (v2f i) : SV_Target { float4 color = float4(0,0,0,0); //tex2D (_MainTex, i.uv1.xy); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color; } float4 fragCaptureForegroundCocMask (v2f i) : SV_Target { float4 color = float4(0,0,0,0); float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _CameraDepthTexture_ST)); d = Linear01Depth (d); color.a = _CurveParams.z * (_CurveParams.w-d) / (d + 1e-5f); color.a = clamp(max(0.0, color.a - _CurveParams.y), 0.0, _CurveParams.x); return color.a > 0; } float4 fragBlendInHighRez (v2f i) : SV_Target { float4 tapHighRez = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv.xy, _MainTex_ST)); return float4(tapHighRez.rgb, 1.0-saturate(tapHighRez.a*5.0)); } float4 fragBlendInLowRezParts (v2f i) : SV_Target { float4 from = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); from.a = saturate(from.a * _Offsets.w) / (_CurveParams.x + 1e-5f); float square = from.a * from.a; from.a = square * square * _CurveParams.x; return from; } float4 fragUpsampleWithAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, i.uv1.xy); return c; } float4 fragAlphaMask(v2f i) : SV_Target { float4 c = tex2D(_MainTex, UnityStereoScreenSpaceUVAdjust(i.uv1.xy, _MainTex_ST)); c.a = saturate(c.a*100.0); return c; } #line 925 "" #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING #endif /* UNITY: Original start of shader */ #pragma target 3.0 #pragma vertex vert #pragma fragment fragUpsampleWithAlphaMask AAssets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField˙˙˙˙Ÿ=(´žçˇ‘Šd{´ěy SHADOWS_SOFTDIRLIGHTMAP_COMBINEDDIRLIGHTMAP_SEPARATEDYNAMICLIGHTMAP_ON INSTANCING_ON