Sign in to follow this  
lomateron

performance question

Recommended Posts

lomateron    491

Is it bad for performance if when rendering to every texel of a texture, in the pixel shader method I read 8 different texels of another texture to combine them and return a value.

Share this post


Link to post
Share on other sites
Polarist    172

It's not necessarily worse than any other approach  (it will be approximately 8x slower than 1 texture read, for obvious reasons).  For instance, if you wanted to implement an edge-detection kernel, you might need to sample from the 8 surrounding texels of that same texture.

 

There are ways to improve performance though, for instance calculating those texcoords in the vertex shader rather than the pixel shader.

 

Perhaps if you attached your code it would be easier to say whether you're being wasteful of resources or not.

Share this post


Link to post
Share on other sites
L. Spiro    25618

It depends on why you are doing it.

Do you think you are achieving better results on your standard 3D models in your scene?  Yes, it is wasteful.  Anything you gain in quality, which will probably be nothing but a blurrier texture, won’t be worth the extra texture samples.

 

Are you trying to make a special effect that require 8 texture reads?  Then your performance is exactly what it has to be for that effect, and that effect is twice as costly (roughly) as an effect that requires only 4 reads.  You have to decide how much performance you are going to put into your effects.

 

Dependent texture reads (what you are doing, unless you are doing as suggested above in which the texture coordinates are all calculated in the vertex shader) are slow.  Independent texture reads can be cached up-front and thus are fast enough to replace some heavy equations.  That should give you a general idea of the overhead involved in texture reads.

 

 

L. Spiro

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