Shader hell

This is a discussion on Shader hell within the Game Programming forums, part of the General Programming Boards category; Yes, shaders are the best thing since sliced bread. Yes, they are still quite limited. Here is my problem: I ...

  1. #1
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,586

    Shader hell

    Yes, shaders are the best thing since sliced bread.

    Yes, they are still quite limited.

    Here is my problem:

    I want to do Oran-Nayer diffuse shading with pure phong specular as well as per-pixel bump mapping. No problem.

    I also want to do a sky-scattering shader. No problem.

    Doing both = big problem.

    I'm out of pixel shader inputs. The sky scatter shader plus the other shader require far too many inputs.

    So my question is:

    How do you chain shaders w/o performing multiple passes? Multiple passes on terrain that stretches to the far clip plane is totally 100% out of the question.

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    What shader version are you working with? Exactly how many inputs are you using? Can you post some function stubs, maybe something can be massaged or combined.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,586
    Outputs from VS.
    Code:
    struct VS_OUTPUT
    {
    	float4 Pos : POSITION;
    	float3 Light : TEXCOORD0;
    	float3 Norm : TEXCOORD1;
    	float3 View : TEXCOORD2;
       	float4 Inscatter : COLOR0;
    	float4 Extinction : COLOR1;
    	float2 TerrainUV : TEXCOORD3;
    	float2 DetailUV : TEXCOORD4;
    };
    Pos=interpolated vertex pos
    Light=light direction
    Norm=interpolated normal
    View=view direction (camera position)
    Inscatter=Mie and Rayleigh scattering (computed by vertex shader)
    Extinction=Total amount of light being 'removed' by scattering
    TerrainUV=texture coords for base texture
    DetailUV=texture coords for detail texture (u*256.0f,v*256.0f)

    I've used all the TEXCOORD slots I can according to ID3DErrorBuf which reports and error when I attempt to compile a shader using TEXCOORD5 and above.

    Isn't there a way to combine shaders? This effect file is getting huge b/c I'm doing multiple scattering, specular phong, and supporting texture blending.
    Last edited by VirtualAce; 08-17-2006 at 01:22 PM.

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Are you GPU bound or CPU bound in your application? You might consider calculating the scatter (and extinction?) term on the cpu and then setting it in the effect file. Also if your detail uv's are just terrain uv's * 256.0f, that calculation can just be done in the pixel shader. You're using effect files right? Why don't you try putting what you can in global variables like light pos, light material props, maybe view direction.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  5. #5
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    Multiple passes on terrain that stretches to the far clip plane is totally 100% out of the question.
    don't run the shader all the way to the far clip plane, you won't be able to notice it that far away anyway =)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Shaders and parameters
    By VirtualAce in forum Game Programming
    Replies: 2
    Last Post: 12-06-2006, 06:33 AM
  2. Replies: 6
    Last Post: 11-12-2005, 10:57 AM
  3. Phong Pixel Shader for PS1.3
    By Magos in forum C++ Programming
    Replies: 7
    Last Post: 08-27-2005, 10:05 PM
  4. Living in the 00'S
    By mithrandir in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 01-21-2002, 08:31 AM
  5. Heaven, Hell, and Aetheists/Non-believers
    By Aran in forum A Brief History of Cprogramming.com
    Replies: 34
    Last Post: 09-10-2001, 02:18 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21