1

I'd like to implement an algorithm about pencil rendering. Now I've got 32 textures with different stroke intensity and some models. The process goes like this. First, I should render the using Phong shading to determine the intensity. Then I should map the texture to the rendered result.

The textures should be stored in 3d texture space. The problem is that I don't know how to do multipass rendering with opengl and shaders. And I don't know how to access to the textures with the right coordinate. What if the faces of the mesh is smaller than the texture? Can anybody show me some examples of doint this?

2
  • The texture is scaled using the coordinates given as input by you. So, for each vertex you are drawing (probably 3 per step, as you are most likely drawing triangles), you provide the (X,Y) coordinate. now, for all these vertices you must also specify the coordinates of the texture they correspond to (in the interval [0,1]).
    – Yuri
    May 15, 2012 at 5:58
  • Thank you for your help! The author of the algorithm said, 'Determining texture coordinate us done in image space'. And he uses a methed called image space filtering method. Do you know that? May 16, 2012 at 11:29

1 Answer 1

0

You need to render to some sort of offscreen buffer in order to do multi-pass rendering. Framebuffers are the current method of doing offscreen rendering in OpenGL. Apple has a good page describing how to use them. (It's not Mac-specific.)

I'm not sure I understand your question about texturing, so can't answer that part.

5
  • Thanks a lot! The author of the algorithm said, 'Determining texture coordinate us done in image space'. And he uses a methed called image space filtering method. Do you know that? May 16, 2012 at 11:29
  • Image space is the logical area the image occupies. Your texture is defined in pixel space - when you call glTexImage*D(), you tell it the pixel dimensions of the image. Image space is the dimensions you want it to take up rather than the number of pixel it contains. You may want to shrink or grow the image (and maybe only in one direction or the other). The exact transform from one to the other depends entirely on what you're trying to accomplish - it'll be different for mapping a 2D texture onto a globe, than a wood texture onto a table, for example. May 16, 2012 at 16:28
  • Thank you for your help. I've known something about Framebuffers, but something still makes me confused. Even if I can use the framebuffer to draw content to FBO, how can I use framebuffer to do multipass rendering? For example, I want to determine the intensity of strokes, how to use the rendered texture to do this? Have I made myself clear? May 18, 2012 at 7:07
  • When you create a frame buffer object, you attach a texture to it. Any drawing you do goes into that texture. You can then use that texture as input to the next stage of your drawing. May 20, 2012 at 15:05
  • Thank you! I've got a sense of it! May 21, 2012 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.