iOS Metal line width - Stack Overflow

文章推薦指數: 80 %
投票人數:10人

If you are drawing multiple lines, multiply your instanceCount by the thickness you want and adjust your vertex shader function logic to place ... Home Public Questions Tags Users Companies Collectives ExploreCollectives Teams StackOverflowforTeams –Startcollaboratingandsharingorganizationalknowledge. CreateafreeTeam WhyTeams? Teams CreatefreeTeam Collectives™onStackOverflow Findcentralized,trustedcontentandcollaboratearoundthetechnologiesyouusemost. LearnmoreaboutCollectives Teams Q&Aforwork Connectandshareknowledgewithinasinglelocationthatisstructuredandeasytosearch. LearnmoreaboutTeams iOSMetallinewidth AskQuestion Asked 7years,7monthsago Modified 4years,1monthago Viewed 7ktimes 9 3 IwouldliketosetthewidthofalinethatI'mdrawinginMetal.Icansetthesizeofapointwithpoint_sizeasexplainedhere: https://developer.apple.com/library/prerelease/ios/documentation/Metal/Reference/MTLRenderCommandEncoder_Ref/index.html But,I'mnotsurehowitworkswithlines. iosmetal Share Follow editedJul22,2018at20:46 luk2302 51.4k2222goldbadges9595silverbadges134134bronzebadges askedJan29,2015at6:37 arthurarthur 9311silverbadge44bronzebadges 0 Addacomment  |  2Answers 2 Sortedby: Resettodefault Highestscore(default) Trending(recentvotescountmore) Datemodified(newestfirst) Datecreated(oldestfirst) 7 ShortanswerwouldbethereisnowaytocontrollinewidthinthesamewayasapointsizeinMetal.EveninOpenGLgraphicsAPI,thefunctiontodothis(whichusedtoexistasgllinewidthfunction)isnowdeprecated. Anoptionwouldbetodrawthelineasaquad(abox),withtwotriangles.Thiswouldletyoucontrolthewidthoftheline. Ifyouwanttosticktothelineprimitiveitself,forsomeparticularreason,theequivalentOpenGLquestionhasbeenaskedonStackOverflowalreadyasseenhere.TheshadercanbesimpletranslatedtoMetalshadingAPI. Share Follow editedMay23,2017at12:17 CommunityBot 111silverbadge answeredFeb5,2015at18:45 codingminioncodingminion 40144silverbadges77bronzebadges Addacomment  |  5 Ifyou'redeadsetonusinglinesinsteadofdrawinga2Dboxwithtworectanglesyoucandrawmultiplelinesnexttoeachother.YoucandothatbydrawingthesametwoverticesmultipletimeswithonedrawPrimitivescall,justincreasetheinstanceCounttosimulatethethicknessandtheninyourvertexshaderfunctionyoucoulduseyourvertex_idandamodulusoperationorsomeothertypeoflogictotranslatethepositionofthelinetosimulatethickness.Thiswillprobablybealoteasierthantryingtodosomethingfancyinafragmentshader. Ifyouaredrawingmultiplelines,multiplyyourinstanceCountbythethicknessyouwantandadjustyourvertexshaderfunctionlogictoplacethoseadditionallinesnexttoeachother. Iexperimentedwiththisandfoundthistobeaprettycumbersomeprocess.Asyouneedadditionalmathtopositiontheextralinestothickencorrectly.Forexampleifyou'redrawingahorizontallineandwanttoincreasethicknessbytwoyou'dwanttomodifytheyvalue,butifit'sverticalyou'dwanttomodifythex.Drawingatananglegetsmorecomplicated.You'llalsorunintoissuestryingtomatchlengthswithwidthsifyou'reattemptingtodrawshapes. Ithinkit'smuchbettertojustdrawtwotrianglestomakearectangletofakealine.Themathwillbemucheasierandsimplertounderstand. InGeometry,Euclid'slinesdonothaveanywidth,theyonlyhavelength,thewidththeygetduringdrawingissimplyforrepresentation.SowhileIthinklinesmaybegoodfordebugginganddevelopment,likefordisplayingvectorsorcreatingagridtoseescale,they'renotwhatyouwantifyou'retryingtostylethemtopresentthemtousers.Inthatcaseit'sthewrongtoolforthejob. Share Follow editedSep16,2016at14:11 answeredSep16,2016at12:07 BjornBjorn 65.9k3939goldbadges133133silverbadges163163bronzebadges 1 Thismakesalotofsense...butapplyingrotationtoarectalsoseemstobechallenging(atleast,Iamfindingitso).Manyexamplesonlyshowdrawingasquare/rectangletexturewithoutanyrotation. – JCutting8 Jun16,2020at11:45 Addacomment  |  YourAnswer ThanksforcontributingananswertoStackOverflow!Pleasebesuretoanswerthequestion.Providedetailsandshareyourresearch!Butavoid…Askingforhelp,clarification,orrespondingtootheranswers.Makingstatementsbasedonopinion;backthemupwithreferencesorpersonalexperience.Tolearnmore,seeourtipsonwritinggreatanswers. Draftsaved Draftdiscarded Signuporlogin SignupusingGoogle SignupusingFacebook SignupusingEmailandPassword Submit Postasaguest Name Email Required,butnevershown PostYourAnswer Discard Byclicking“PostYourAnswer”,youagreetoourtermsofservice,privacypolicyandcookiepolicy Nottheansweryou'relookingfor?Browseotherquestionstaggediosmetaloraskyourownquestion. TheOverflowBlog Functionalprogrammingisanidealfitfordevelopingblockchains Environmentson-demand(Ep.479) FeaturedonMeta AnnouncingtheStackOverflowStudentAmbassadorProgram GoogleAnalytics4(GA4)upgrade StagingGroundWorkflow:QuestionLifecycle The[option]tagisbeingburninated CollectivesUpdate:WSO2launches,andGoogleGosunsets Linked 26 Isitpossibletodrawlinethicknessinafragmentshader? 9 StrokeWidthwithaSceneKitlineprimitivetype 0 HowApplerenderscustomlinewidthinUIKitwhenrenderingwithMetal Related 1088 HowtochangethenameofaniOSapp? 1383 HowcanIcheckforanactiveInternetconnectiononiOSormacOS? 410 DesignforFacebookauthenticationinaniOSappthatalsoaccessesasecuredwebservice 600 UIScrollViewScrollableContentSizeAmbiguity 1 Makealinethickerin3D? 0 assigningwillSetblocktoiOSisRestingproperty 1 Errorwhendoing(supported)floattexturewriteiniOSMetal 3 HowcanReactNativeaccesstheiOSdictionarytopullthedefinitionofaword? 0 HowApplerenderscustomlinewidthinUIKitwhenrenderingwithMetal 1 HowtodisableMetalCompilerWarningswhencallingnewLibraryWithSource HotNetworkQuestions HowtotakescreenshotsonmacOS Whatareallofthenon-solotypesinPokemongames? Howtohandleabrokenbearingcuponavintagetenspeed? Howratingchangeshappenfortournamentsstartingneartheendofthemonth? Howtojustifytime-sensitiveencounterswithoutitseemingconvenient? DoesPSRRimprovewithmultipleLDOsinseries? Intheelectrondoubleslitexperiment,whatisinterfering? IsDarkMatterpossibleifthereisdynamicalfriction? Howtoalignanobjectalongaspiralwithoutdistortion? HowcanIefficientlydiffaCSVfileagainstadatabase? Whatarethereasonssomethoughtscannotbesimplified,reducedtoasimplersetorphrases? IsURLrewritingine-mailasoundsecuritypractice? Isitnecessarytousemorethantwogritsforasandingjob? ReactionofxenonwithO₂F₂? Fasterthanlightinformation TwinParadox(SR):Howcanweexpressthecomparativelengthofarbitraryworld-linesmathematically? WhydoestheManin-Mumfordconjectureovernumberfieldsimplytheconjectureoverarbitraryfieldsofcharacteristic0? Whataresomenon-religiousreasonstohavehighly-advancedphysicalandchemicalsimulationswithoutgood"human-factors"AI? Isitlegaltopublisha''copy"oftheConstitutionwithfaketextadded? Whataretheprosandconsofdemanding1.3trillioninreparationfromGermany? CouldCongress"bribe"thePresidenttosignabillbyincludingapresidentialpayraise? TheenigmaoftheSorNword Shortstoryaboutdiscoveringthatgeometryisinconsistent Ifalldemonsarebelievers,thenwhyaresomehumansatheists? morehotquestions Questionfeed SubscribetoRSS Questionfeed TosubscribetothisRSSfeed,copyandpastethisURLintoyourRSSreader. default Yourprivacy Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy. Acceptallcookies Customizesettings  



請為這篇文章評分?