Skip to main content
struct
Source Link
PinkTurtle
  • 257
  • 5
  • 22
struct
Source Link
PinkTurtle
  • 257
  • 5
  • 22

I am in trouble at trying to pass a big amount of variables needed for my pixel shader computations.

After trying and failing to link my struct to a cbuffer (data alignement mismatch) I tried passing my variables first to the vertex shader (with an D3D11_INPUT_ELEMENT_DESC / CreateInputLayout) with the intent to link them to the pixel shader through semantics but I hit the 32 shader inputs limit.

I am really stuck (and quite a noob at DX). What is a common / standard way to do this ? Can I only rely on a cbuffer ? Is creating a D3D11_INPUT_ELEMENT_DESC / CreateInputLayout even possible for the pixel shader ?

Example struct I want to pass to my pixel shader :

struct SceneParamsInterface {
    bool DEAOEnabled;
    XMFLOAT4 DEAOColor;
    double DEAOPow;
    bool lightEnabled;
    XMFLOAT4 lightColor;
    XMFLOAT3 lightDirection;
    bool lightMultiply;
    double lightMultiplyFactor;
    bool ambiantLightEnabled;
    XMFLOAT4 ambiantLightColor;
    bool HSEnabled;
    int HSSpread;
    bool fogEnabled;
    XMFLOAT4 fogColor;
    double fogDistanceMax;
    bool glowEnabled;
    XMFLOAT4 glowColor;
    double glowRadius;
    XMFLOAT4 skyColor;
    bool skyBoxEnabled;
    //uniform sampler2D skyBoxTexture;
    int skyBoxScheme0; // top
    int skyBoxScheme1; // left
    int skyBoxScheme2; // front
    int skyBoxScheme3; // right
    int skyBoxScheme4; // back
    int skyBoxScheme5; // bottom
    int skyBoxRotate;
    double skyBoxRotateSpeed;
    XMFLOAT3 skyBoxRotateAround;
    bool orbitTrapsEnabled;
    int orbitTrapsId;
    XMFLOAT4 objectColor;
};

Thanks!

I am in trouble at trying to pass a big amount of variables needed for my pixel shader computations.

After trying and failing to link my struct to a cbuffer (data alignement mismatch) I tried passing my variables first to the vertex shader (with an D3D11_INPUT_ELEMENT_DESC / CreateInputLayout) with the intent to link them to the pixel shader through semantics but I hit the 32 shader inputs limit.

I am really stuck (and quite a noob at DX). What is a common / standard way to do this ? Can I only rely on a cbuffer ? Is creating a D3D11_INPUT_ELEMENT_DESC / CreateInputLayout even possible for the pixel shader ?

Thanks!

I am in trouble at trying to pass a big amount of variables needed for my pixel shader computations.

After trying and failing to link my struct to a cbuffer (data alignement mismatch) I tried passing my variables first to the vertex shader (with an D3D11_INPUT_ELEMENT_DESC / CreateInputLayout) with the intent to link them to the pixel shader through semantics but I hit the 32 shader inputs limit.

I am really stuck (and quite a noob at DX). What is a common / standard way to do this ? Can I only rely on a cbuffer ? Is creating a D3D11_INPUT_ELEMENT_DESC / CreateInputLayout even possible for the pixel shader ?

Example struct I want to pass to my pixel shader :

struct SceneParamsInterface {
    bool DEAOEnabled;
    XMFLOAT4 DEAOColor;
    double DEAOPow;
    bool lightEnabled;
    XMFLOAT4 lightColor;
    XMFLOAT3 lightDirection;
    bool lightMultiply;
    double lightMultiplyFactor;
    bool ambiantLightEnabled;
    XMFLOAT4 ambiantLightColor;
    bool HSEnabled;
    int HSSpread;
    bool fogEnabled;
    XMFLOAT4 fogColor;
    double fogDistanceMax;
    bool glowEnabled;
    XMFLOAT4 glowColor;
    double glowRadius;
    XMFLOAT4 skyColor;
    bool skyBoxEnabled;
    //uniform sampler2D skyBoxTexture;
    int skyBoxScheme0; // top
    int skyBoxScheme1; // left
    int skyBoxScheme2; // front
    int skyBoxScheme3; // right
    int skyBoxScheme4; // back
    int skyBoxScheme5; // bottom
    int skyBoxRotate;
    double skyBoxRotateSpeed;
    XMFLOAT3 skyBoxRotateAround;
    bool orbitTrapsEnabled;
    int orbitTrapsId;
    XMFLOAT4 objectColor;
};

Thanks!

Source Link
PinkTurtle
  • 257
  • 5
  • 22

How to pass a big (60+) amount of variables to an HLSL pixel shader?

I am in trouble at trying to pass a big amount of variables needed for my pixel shader computations.

After trying and failing to link my struct to a cbuffer (data alignement mismatch) I tried passing my variables first to the vertex shader (with an D3D11_INPUT_ELEMENT_DESC / CreateInputLayout) with the intent to link them to the pixel shader through semantics but I hit the 32 shader inputs limit.

I am really stuck (and quite a noob at DX). What is a common / standard way to do this ? Can I only rely on a cbuffer ? Is creating a D3D11_INPUT_ELEMENT_DESC / CreateInputLayout even possible for the pixel shader ?

Thanks!