PDA

View Full Version : OpenGL2.0- Is there a way to disable vertex shaders?



toulipa
06-02-2014, 02:13 AM
I am trying to capture traces from a game but the glInterceptor I use doesn't support vertex shaders. My research suggests I disable vertex shaders and use the default vertex shader but no information about how to do it. Do you know how I can disable vertex shaders? Here is a part of the code:

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
}

rodrigoloc
06-02-2014, 04:26 AM
I don't know how does glInterceptor work but if it is OpenGL 2.x you can use:

glUseProgram(0);
It will disable both vertex shader and fragment shader. Keep in mind that you can't just disable one of these stages.

toulipa
06-02-2014, 05:59 AM
Thank you for your answer. Problem is I don't want to disable fragment shader. The instructions of the tool I use say "disable vertex shaders (as the GLInterceptor library only supports either fixed function T&L or ARB vertex programs)". Maybe I should convert vertex shader to ARB vertex program? I have no idea how to do this either. Any help will be much appreciated.

thokra
06-02-2014, 06:01 AM
OpenGL2.0- Is there a way to disable vertex shaders?

EDIT: I'm not very versed in the GL2.0 spec but core GL 4.4 states:


If there is no active program for the vertex or fragment shader stages, the results of vertex and/or fragment processing will be undefined. However, this is not an error.

Still, what I can say with 100% certainty for GL 2.0 is that making a program object current using glUseProgram() will turn off most of the fixed-function vertex processing and thus you will not get what you want passed to your fragment shader. In general, never do stuff that invokes undefined behavior - you're completely at the mercy of your current implementation and cannot expect anything to work the same or even work at all with a different implementation.


"disable vertex shaders (as the GLInterceptor library only supports either fixed function T&L or ARB vertex programs"

What GL intercept version? Relying on GL_ARB_vertex_program indicates some ancient version.

toulipa
06-02-2014, 06:18 AM
Can you explain how I do this in the above code?

EDIT: It is not GL intercept. I use another tool that is quite old, but i need to use this one in order for the traces to be compatible with the simulator I use. I am stuck using old versions to get the job done. It is not my choice. Anyway, you were very helpful. Maybe I will search for some older game because I am not experienced in GL and it is difficult for me to make those changes.

Thank you all for your help and time.