openGL2.0:如何禁用顶点着色器?

时间:2014-06-01 18:10:20

标签: vertex-shader opengl-2.0

我正在尝试捕捉游戏中的痕迹,但我使用的glInterceptor不支持顶点着色器。我的研究建议我禁用顶点着色器并使用默认的顶点着色器,但没有关于如何操作的信息。那么,我该如何禁用顶点着色器?这是代码:

pp.fx

#define DISABLE_FOG
#define DISABLE_LIGHTING

technique Default
{
  pass P0
  {
    VertexShader = vertexShaders/diff-tex.vs;
    PixelShader = pixelShaders/pp.ps;

    #ifdef ENABLE_TWOSIDED
        EnableCulling = FALSE;
    #endif

    #ifdef DISABLE_DEPTH_TEST
        EnableDepthTest = FALSE;
    #endif

    #ifdef ENABLE_ADDITIVE
        EnableDepthMask = FALSE;
        EnableBlending = TRUE;
        BlendFuncSrc = ONE;
        BlendFuncDst = ONE;
    #endif

    #ifdef ENABLE_MULTIPLICATIVE
        EnableDepthMask = FALSE;
        EnableBlending = TRUE;
        BlendFuncSrc = DST_COLOR;
        BlendFuncDst = ZERO;
    #endif

    #ifdef ENABLE_ALPHA_BLENDING
        EnableDepthMask = FALSE;
        EnableBlending = TRUE;
        BlendFuncSrc = SRC_ALPHA;
        BlendFuncDst = ONE_MINUS_SRC_ALPHA;
    #endif

    #ifdef ENABLE_PREMULT_ALPHA_BLENDING
        EnableDepthMask = FALSE;
        EnableBlending = TRUE;
        BlendFuncSrc = ONE;
        BlendFuncDst = ONE_MINUS_SRC_ALPHA;
    #endif
  }
}

DIFF-tex.vs

#include "../commons/defines.sh"
#include "../commons/attributes.sh"
#include "../commons/uniforms.sh"
#include "../commons/functions.sh"
#include "../commons/varyings.sh"

void main()
{


#ifdef ENABLE_SKINNING
    // bone 1 influence
    int i = int(DT_BONEINDICES.x);
    float w = DT_BONEWEIGHTS.x;
    mat4 bonetm = BONEWORLDTM[i];
    vec3 worldpos = transform(bonetm, DT_POSITION) * w;

    #ifndef DISABLE_LIGHTING
    V_Normal = rotate( convertToMat3(bonetm), DT_NORMAL ) * w;
    #endif

    #ifdef ENABLE_NORMALMAP
    vec3 worldtangent = rotate( convertToMat3(bonetm), DT_TANGENT ) * w;
    #endif

    // bone 2 influence
    i = int(DT_BONEINDICES.y);
    w = DT_BONEWEIGHTS.y;
    bonetm = BONEWORLDTM[i];
    worldpos += transform(bonetm, DT_POSITION) * w;

    #ifndef DISABLE_LIGHTING
    V_Normal += rotate( convertToMat3(bonetm), DT_NORMAL ) * w;
    #endif

    #ifdef ENABLE_NORMALMAP
    worldtangent += rotate( convertToMat3(bonetm), DT_TANGENT ) * w;
    #endif

    // bone 3 influence
    i = int(DT_BONEINDICES.z);
    w = (1.0 - DT_BONEWEIGHTS.y - DT_BONEWEIGHTS.x);
    bonetm = BONEWORLDTM[i];
    worldpos += transform(bonetm, DT_POSITION) * w;

    // Can be omitted for optimization, effect is quite small
    #ifndef DISABLE_LIGHTING
    V_Normal += rotate( convertToMat3(bonetm), DT_NORMAL ) * w;
    V_Normal = normalize(V_Normal);
    #endif

    #ifdef ENABLE_NORMALMAP
    worldtangent += rotate( convertToMat3(bonetm), DT_TANGENT ) * w;
    worldtangent = normalize(worldtangent);

    vec3 worldbinormal = cross( V_Normal, worldtangent );
    #endif

    gl_Position = VIEWPROJTM * vec4(worldpos, 1);
#else

    #if defined(DISABLE_TRANSFORM_EXCEPT_ORIENTATION)
    // Vertices are already in screen space coordinates
    gl_Position = PROJTM * vec4(DT_POSITION, 1);
    #elif defined(DISABLE_TRANSFORM)
    gl_Position = vec4(DT_POSITION, 1);
    #else
    // Transform coordinates to screen space
    gl_Position = TOTALTM * vec4(DT_POSITION, 1);
    vec3 worldpos = vec3(WORLDTM * vec4(DT_POSITION, 1));
    #endif
#endif
}

0 个答案:

没有答案