Sign in to follow this  
flip_mo_kid

Accessing lowest level mipmap of a rendertarget very quickly?

Recommended Posts

flip_mo_kid    151
Hi, I have a rendertarget which I then create mipmaps of. I need to shade my vertex with the colour contained in the 1x1 texture. As I'm using a rendertarget, I cannot lock the surface. Also, copying it to another texture takes way too long due to having to pass back from the gpu to cpu. Is there a fast way to do this and keep everything on the GPU? I thought using a vertex shader might be a good idea but I'm not sure if I can specify passing the vertex the 1x1 mipmap level texture instead of a level of DirectXs choosing. Thanks

Share this post


Link to post
Share on other sites
Illco    928
Just a wild guess but it seems logical the mipmap is chosen before everything is sent down the vertex and pixel shader pipeline. So I'd guess that you cannot access other levels of the surface.

But this seems a bit complicated -- you want just one color value? Why not pre-compute it and send it as a vector to the shader?

Greetz,

Illco

Share this post


Link to post
Share on other sites
flip_mo_kid    151
Thanks for the response.

The colour contained in the 1x1 texture is a result of multiplying a light texture with an occlussion texture for the vertex and then summing all the values to get the average light reaching that vertex. I wanted to do this all on the gpu to speed it up and from help by gamedev.net users (thanks!!!) we think texture blending and mipmaping will allow this to be done quickly. So all that remains is the access of the 1x1 image, which is turning out to be tricky :(

Share this post


Link to post
Share on other sites
neneboricua19    634
Since it seems that you're trying to shade a vertex with the color contained in a particular texel of a texture, then maybe you should look at using the "texldl" instruction. This instruction samples a texture at a particular mipmap level of your choosing. Be aware that this instruction is only available when using Shader Model 3.0.

neneboricua

Share this post


Link to post
Share on other sites
superpig    1825
Assuming you're not planning on only rendering a single vertex, but you only have one colour to choose from, am I right in thinking that you're rendering primitives all the same colour?

If so you could just bind that 1x1 surface to a texture stage and read it in the pixel shader, surely?

Share this post


Link to post
Share on other sites
flip_mo_kid    151
neneboricua19 - Thanks for the texldl idea. I just got a 6600GT and I'll try it out once I've installed it.

superpig - I'm rendering a fair few vertices, each one will be set to the colour of the mipmap assigned to it, as the occlussion will be slightly different per vertex you end up with different colours. I'm not sure exactly what you're suggesting (I'm a newbie to this) but if you think this can be done in an easy way then I would be extremely grateful for any suggestions!!

Heres a pic of one of the results (slightly messed up one because I was loading some of the HDR file incorrectly):

http://www.cs.bath.ac.uk/~cspmsb/waveletlighting/PixelLighting.jpg

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this