Jump to content
  • Advertisement
Sign in to follow this  
Tessellator

Massive number of pixel shader inputs?

This topic is 4838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, If we move all lighting calculations into the pixel shader (including transforming our per-pixel normal into world space), so that we avoid changing the number of shader inputs/outputs as the number of lights change, the number of shader inputs becomes quite large. For example:
struct PS_INPUT
{
    float4 Position   : POSITION;
    float3 Normal     : TEXCOORD0;
    float3 Tangent    : TEXCOORD1;
    float3 Bitangent  : TEXCOORD2;
    float3 WorldPos   : TEXCOORD3;
    float2 TexCoords  : TEXCOORD4;
};

This allows us access to a per-pixel basis to transform normals into world space, and the world position of the texel we are going to shade. However, we still need to add more texture coords once we factor in things like shadow mapping and projective textures. This seems like quite a lot of inputs to me. So, basically, I'm curious now. On average, how many inputs do you guys have into your shaders? Does the above seem excessive? I guess once you start sending in interpolated lighting normals (rather than doing the math in the PS), the numbers grow quite large anyway..? T

Share this post


Link to post
Share on other sites
Advertisement
So what if there are a lot of inputs?

Oh, and for me in theory, I'm going to have 14 inputs, but of course I can't due to technical limitations so I have to run to deferred shading to precompute some things like bump mapping.

Share this post


Link to post
Share on other sites
I currently have 15 inputs including samplers for 11 texture reads for my terrain, in practice I might reduce this to 6 texture reads and use another pass for the 4 layers that I would lose.

Unless you are changing the input values quite often throughout the frame it doesn't make much difference how many you have, but logically the shader will get slower the more things you ask it to do, and the more things you ask it to do the more inputs you will probably need.

I am rethinking my shader for performance reasons, since for about 95% of the pixels drawn, 5 of the texture reads make no difference to the final output. I'm better off drawing a more optimized pass for the areas where those layers count.

Share this post


Link to post
Share on other sites
I haven't really kept up to date with gfx hardware, but the last time I used pixel shaders, the number of inputs were a lot smaller. I guess it isn't so much of a big deal these days... I'll expermient throwing loads of stuff in and see what happens to performance.

Thanks for sharing guys. :)

T

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!