![]() ![]() In order not to lose quite a lot of precision, it's probably more helpful to split the value between components, as your vendor almost certainly doesn't support floating point target buffers. Because you're in window coordinates, intensity will range from 0.0 (closest possible unclipped fragment) to 1.0 (farthest possible unclipped fragment). You should get a greyscale with the intensity of the colour representing depth. ![]() just gl_FragColor = vec4(vec3(gl_FragCoord.z), 1.0) To convince yourself, try writing a quick shader that puts gl_FragCoord.z out hastily in low precision, e.g. Alternatively, you can load world-space z as a varying and write that from your fragment shader, in case that's an easier way around. OpenGL ES as a Graphics Pipeline Figure 6-2visualizes OpenGL ES as a graphics pipeline. If you're in ES 2.0, your fragment shader can access the current fragment's depth (in window coordinates) as part of gl_FragCoord, so you can write that to the colour buffer, use glReadPixels to get the result back and proceed. A well-designed app reduces the frequency of calls it makes to OpenGL ES, uses hardware-appropriate data formats to minimize translation costs, and carefully manages the flow of data between itself and OpenGL ES. Using an FBO, you can render without displaying the results. Application-created framebuffer objects encapsulate the state of a framebuffer in a similar manner to the way texture objects encapsulate the state of a texture. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |