GLSL vertex shader gl_Position value - opengl - Stack Overflow
文章推薦指數: 80 %
I'm trying to understand the value of gl_Position in vertex shader. ... and y coordinates translate to screen position in range of -1 to 1, ... 2022DeveloperSurveyisopen!Takesurvey. Home Public Questions Tags Users Companies Collectives ExploreCollectives Teams StackOverflowforTeams –Startcollaboratingandsharingorganizationalknowledge. CreateafreeTeam WhyTeams? Teams CreatefreeTeam Collectives™onStackOverflow Findcentralized,trustedcontentandcollaboratearoundthetechnologiesyouusemost. Learnmore Teams Q&Aforwork Connectandshareknowledgewithinasinglelocationthatisstructuredandeasytosearch. Learnmore GLSLvertexshadergl_Positionvalue AskQuestion Asked 7years,1monthago Modified 7years,1monthago Viewed 6ktimes 2 I'mcreatinggamethatusesorthogonalview(2D).I'mtryingtounderstandthevalueofgl_Positioninvertexshader. FromwhatIunderstandxandycoordinatestranslatetoscreenpositioninrangeof-1to1,butI'mquiteconfusedwithroleofthezandw,Ionlyknowthatthewvalueshouldbesetto1.0 ForthemomentIjustusegl_Position.xyw=vec3(Position,1.0);,wherePositionis2Dvertexposition IuseOpenGL3.2. openglglslopengl-3 Share Improvethisquestion Follow askedApr1,2015at16:11 Magik6kMagik6k 10522silverbadges88bronzebadges Addacomment | 1Answer 1 Sortedby: Resettodefault Highestscore(default) Datemodified(newestfirst) Datecreated(oldestfirst) 4 RememberthatopenGLmustalsoworkfor3Dandit'seasiertoexposethe3Ddetailsthantocreateanewinterfaceforjust2D. TheZcomponentistosetthedepthofthevertex,pointsoutside-1,1(afterperspectivedivide)willnotbedrawnandforthevaluesbetween-1,1itwillbecheckedagainstadepthbuffertoseeifthefragmentisbehindsomepreviouslydrawntriangleandnotdrawitifitshouldbehidden. ThewcomponentisforaperspectivedivideandallowingtheGPUtointerpolatethevaluesinaperspectivecorrectway.Otherwisethetextureslooksweird. Share Improvethisanswer Follow answeredApr1,2015at16:17 ratchetfreakratchetfreak 45.9k55goldbadges6363silverbadges102102bronzebadges 1 1 Oh,Ididn'tthinkofdepthneedatthisstage.Thanksforexplaining! – Magik6k Apr1,2015at16:27 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?Browseotherquestionstaggedopenglglslopengl-3oraskyourownquestion. TheOverflowBlog Makeyouropen-sourceprojectpublicbeforeyou’reready(Ep.444) Thescienceofinterviewingdevelopers FeaturedonMeta AnnouncingthearrivalofValuedAssociate#1214:Dalmarus Improvementstositestatusandincidentcommunication RetiringOurCommunity-SpecificClosureReasonsforServerFaultandSuperUser Temporarilypausingthesitesatisfactionsurvey StagingGround:ReviewerMotivation,Scaling,andOpenQuestions Related 38 VertexshaderattributemappinginGLSL 9 Inglsl,whatistheformulausedtocomputegl_fragCoordfromgl_position? 0 Can'tlinkglslvertexshader 0 VertextoFragmentshader:passvec3orrecalculateeveryfragment? 1 CreatingatrianglewithOpenGL&GLSL 1 GLSL-Ado-nothingvertexshader? 6 Howfragmentshaderdeterminesthenumberoffragmentsfromvertexshaderoutput? 1 CanIuseanarrayof6intfromVertexShadertoGeometryShader? 0 OpenGL/GLSLpassingvertexcoordinatestothevertexshaderwithtypefloat[3] HotNetworkQuestions Using\textsc{}manuallyinsection DidSauroneverconsiderthattheValarand/orEruIlúvatarmaynotallowhimtoconquerMiddle-earth? Howdoyougagafish-personwithouttape? WhatdoesGandalftheWhitemeanbyhisstrangespeechaboutBoromir? Astronautisdeludedintotakinghishelmetoff(anddies) FindthenthFibonaccinumber,wherenisthemthFibonaccinumber WhentochangeoilfornewgenerationMazda? Whyweremarijuanarestrictionsimplementedinthe1970smoresuccessfulinSouthKoreathanintheUnitedStates? IntheU.S.,whyisn'tturnoutandactivismproportionaltoinfluence? Movingplayerinsideofmovingspaceship? Whatis"aerospacegrade"? Partitioningalistbasedonacriterionforsublists Isthereanypracticaluseforafunctionthatdoesnothing? Iwant8bitsforeverycharacter! HowdoesHebrews11:27sayMoseswasnotafraid? DifferencebetweenfirewallandACL SignalprocessinginPythonvsC++(Bandpassfilter) Googlespreadsheets WhywouldIuseatrainerinsteadofridingoutside? Inbetweenfractions USAssistantProfsalarynegotiationwithcounterofferbeforegoingupfortenure Whataresomealternativestotannininplantbark? Fatallackofinformationpriortoexperiment-whatshouldIdonow? Isitdangeroustoconsume30mgofZinc(asZincPicolinate)perday? morehotquestions Questionfeed SubscribetoRSS Questionfeed TosubscribetothisRSSfeed,copyandpastethisURLintoyourRSSreader. lang-c Yourprivacy Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy. Acceptallcookies Customizesettings
延伸文章資訊
- 1gl_Position - OpenGL 4 Reference Pages - Khronos Group
- 2GLSL vertex shader gl_Position value - opengl - Stack Overflow
I'm trying to understand the value of gl_Position in vertex shader. ... and y coordinates transla...
- 312.5 - GLSL Built-in Functions and Variables — LearnWebGL
gl_Position : a vec4 position of a vertex in “clip coordinates”. ... The values for x and y are i...
- 4Advanced GLSL - LearnOpenGL
Setting gl_Position in the vertex shader is a strict requirement if you want ... position's z val...
- 5Why is 'gl_Position' a different data type than 'position' - Stack Overflow