Accessing lowest level mipmap of a rendertarget very quickly?

Started by
4 comments, last by flip_mo_kid 18 years, 10 months ago
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
Advertisement
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
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 :(
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
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?

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

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

This topic is closed to new replies.

Advertisement