5

I don't wish to bombard this post with code. I've got a main file, fragment shader and a vertex shader file.

I need to know the steps that I should take to color the screen according to mipmap level? I.e. where the loop should go that asks for mipmap level, then sets colour accordingly. I don't know where to implement this or how, a simple example would suffice many thanks.

Luke Evans
  • 93
  • 1
  • 10
  • Maybe I'm just dumb, but I can't tell what you're trying to do. Do you want to manually change the mipmaps so that each mipmap has a different color? Or do you want to figure out which mipmap level is being used in the fragment shader? – Hannesh Mar 11 '11 at 15:33
  • Honestly I don't know, I've been given a program and one of my tasks is to "5. Identify the different Mip Map levels by colouring the regions of the screen differently. " – Luke Evans Mar 11 '11 at 15:47

3 Answers3

1

You should create a texture with a different color for every level, and then retrieve that color in your fragment program. It might also be possible to compute it using dFdx(texcoord.x) and dFdy(texcoord.y).

tibur
  • 11,531
  • 2
  • 37
  • 39
1

Like tibur said, an easy way to do this is to use a debug texture that have a different color for every level as seen here.

Now if you need to compute the mipmap level by hand (usually a floating point value), this is another story since you will need derivatives, but this should put you on track.

elmattic
  • 12,046
  • 5
  • 43
  • 79
  • Thanks for that. I need to do this the easy way, if there is such a thing. But I don't have a clue, my lecturer is rubbish and I can't find any material that just makes sense. e.g. "Put X command in Y function" – Luke Evans Mar 11 '11 at 15:49
1

http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter28.html

This GPU Gems 2 article implements something like what you want.

Dr. Snoopy
  • 55,122
  • 7
  • 121
  • 140