GLSL: gl_FragCoord issues

孤人 提交于 2019-12-03 06:26:41

gl_FragCoord is in screen coordinates, so to get normalized coords you need to divide by the viewport width and height. You can use a uniform variable to pass that information to the shader, since there is no built in variable for it.

You can also sample the texture by un-normalized coordinates if:

  • sampling by texture() from GL_TEXTURE_RECTANGLE
  • sampling by texelFetch() from a regular texture or texture buffer
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!