Search Unity

Getting Fragment Coordinates in Shader

Discussion in 'Shaders' started by Chimera3D, Feb 7, 2015.

  1. Chimera3D

    Chimera3D

    Joined:
    Jan 27, 2012
    Posts:
    73
    I feel like what I'm trying to do is really simple but it seems undoable. I have a fragment shader and I want it to display a texture on the screen without a full-screen quad. I asked a similar question on Unity Answers but I got no answer. I have a cube with a material with the aforementioned shader on it but I'm pretty much ignoring the vertex positions of the cube for now. I guess I should also mention that I'm using #pragma glsl. In GLSL I could do vec4 color = tex2D(_Texture, gl_FragCoord.xy) and be fine but in Unity/CG there seems to be no equivalent to this, people on various posts have mentioned "WPOS" or "VPOS" but that doesn't work at all. Surely there has to be some way of doing this considering it's really basic functionality, right?