Regarding fragment shaders

I am trying to write a shader that will take into account what part of a “face” I am on (“face” being all fragments that exist between connecting verticies)

Is there a variable that I can use that will tell me where exactly I am in a fragment, and how many total fragments there are in the “face”?

Thanks :smiley:

“face” being all fragments that exist between connecting verticies

That sounds like the description of an “edge”, not a face.

Is there a variable that I can use that will tell me where exactly I am in a fragment, and how many total fragments there are in the “face”?

For the second part, no.

For the first part, how do you define location on a triangle?

You could only do that if you pass the 3 vertices’ positions to each vertex, and not use index-buffer (NumVertices = NumTriangles*3). Transform the 3 vertices in the vtx-shader, and compute area onscreen. Also, compute edges, if you want.

all fragments that exist between given edges, where edges are connecting verticies.

lol

semantics.

If you want to know the screencoordinates, xy
that is easy to find out.

For total fragments rendered, use an occlusion query test.
It returns a value to you. BTW, this isn’t done in the shader.

What I am trying to do is take a really low vertex count sphere, and apply a nice rounded shader to it.

Will it be easier to create a texture and render the normals based off the texture (bump mapping) ?

I think it depends on what you mean by “easier”. Creating a sphere is pretty darn easy, even for me :wink:

Bump mapping is useful if you want to simulate a rough surface.
If your sphere will be smooth, then just interpolate the normals.

http://www.opengl.org/wiki/index.php/Getting_started#External_Links
lighthouse3d has some examples

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.