Luke Evans
Luke Evans

Reputation: 93

Identify mip map levels by coloring different screen areas in GLSL

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.

Upvotes: 5

Views: 1563

Answers (3)

Dr. Snoopy
Dr. Snoopy

Reputation: 56377

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

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

Upvotes: 1

elmattic
elmattic

Reputation: 12184

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.

Upvotes: 1

tibur
tibur

Reputation: 11636

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).

Upvotes: 1

Related Questions