Fragment shader for a very simple Android shader example
文章推薦指數: 80 %
precision highp float;. void main(). {. // gl_FragCoord contains the window relative coordinate for the fragment. // we use gl_FragCoord.x position to ... Skiptocontent Allgists BacktoGitHub Signin Signup Sign in Sign up {{message}} Instantlysharecode,notes,andsnippets. lewkoo/shader.frag CreatedFeb27,2014 Star 0 Fork 0 Star Code Revisions 1 Embed Whatwouldyouliketodo? Embed Embedthisgistinyourwebsite. Share Copysharablelinkforthisgist. Clonevia HTTPS ClonewithGitorcheckoutwithSVNusingtherepository’swebaddress. LearnmoreaboutcloneURLs DownloadZIP FragmentshaderforaverysimpleAndroidshaderexample Raw shader.frag ThisfilecontainsbidirectionalUnicodetextthatmaybeinterpretedorcompileddifferentlythanwhatappearsbelow.Toreview,openthefileinaneditorthatrevealshiddenUnicodecharacters. LearnmoreaboutbidirectionalUnicodecharacters Showhiddencharacters precisionhighpfloat; voidmain() { //gl_FragCoordcontainsthewindowrelativecoordinateforthefragment. //weusegl_FragCoord.xpositiontocontroltheredcolorvalue. //weusegl_FragCoord.ypositiontocontrolthegreencolorvalue. //pleasenotethatallr,g,b,avaluesarebetween0and1. floatwindowWidth=1024.0; floatwindowHeight=768.0; floatr=gl_FragCoord.x/windowWidth; floatg=gl_FragCoord.y/windowHeight; floatb=1.0; floata=1.0; gl_FragColor=vec4(r,g,b,a); } Signupforfree tojointhisconversationonGitHub. Alreadyhaveanaccount? Signintocomment Youcan’tperformthatactionatthistime. Yousignedinwithanothertaborwindow.Reloadtorefreshyoursession. Yousignedoutinanothertaborwindow.Reloadtorefreshyoursession.
延伸文章資訊
- 1GLSL. Can someone explain why gl_FragCoord.xy ...
If gl_FragCoord is like pixel coordinates, what does uv get? Why is it often done in GLSL? If som...
- 2gl_FragCoord - OpenGL 4 Reference Pages - Khronos Group
Available only in the fragment language, gl_FragCoord is an input variable that contains the wind...
- 3Uniform Buffer Object - OpenGL Wiki - Khronos Group
- 4ProgrammingTIL #103 WebGL Tutorial Video Screencast 0046
- 5GLSL-to-HLSL reference - UWP applications | Microsoft Docs