Massive number of pixel shader inputs?

Started by
2 comments, last by Tessellator 18 years, 8 months ago
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
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.
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.
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

This topic is closed to new replies.

Advertisement