win32: add frame_count_mod to cg shaders

This commit is contained in:
OV2 2013-03-26 15:39:17 +01:00
parent 231f4eea8f
commit 157e2f51d4
6 changed files with 21 additions and 4 deletions

View File

@ -274,6 +274,10 @@ bool CCGShader::LoadShader(const char *path)
sprintf(keyName,"::shader%u",i);
strcpy(pass.cgShaderFile,conf.GetString(keyName,""));
sprintf(keyName,"::frame_count_mod%u",i);
pass.frameCounterMod = conf.GetInt(keyName,0);
shaderPasses.push_back(pass);
}

View File

@ -200,6 +200,7 @@ public:
cgScaleParams scaleParams;
bool linearFilter;
bool filterSet;
unsigned frameCounterMod;
char cgShaderFile[PATH_MAX];
} shaderPass;
typedef struct _lookupTexture {

View File

@ -332,6 +332,8 @@ bool CD3DCG::LoadShader(const TCHAR *shaderFile)
pass.linearFilter = it->linearFilter;
}
pass.frameCounterMod = it->frameCounterMod;
// paths in the meta file can be relative
_tfullpath(tempPath,_tFromChar(it->cgShaderFile),MAX_PATH);
char *fileContents = ReadShaderFileContents(tempPath);
@ -682,7 +684,10 @@ void CD3DCG::setShaderVars(int pass)
setProgramUniform(pass,"IN.video_size",&inputSize);
setProgramUniform(pass,"IN.texture_size",&textureSize);
setProgramUniform(pass,"IN.output_size",&outputSize);
setProgramUniform(pass,"IN.frame_count",&frameCnt);
float shaderFrameCnt = frameCnt;
if(shaderPasses[pass].frameCounterMod)
shaderFrameCnt = (float)(frameCnt % shaderPasses[pass].frameCounterMod);
setProgramUniform(pass,"IN.frame_count",&shaderFrameCnt);
float frameDirection = GUI.rewinding?-1.0f:1.0f;
setProgramUniform(pass,"IN.frame_direction",&frameDirection);

View File

@ -197,6 +197,7 @@ private:
typedef struct _shaderPass {
cgScaleParams scaleParams;
bool linearFilter;
unsigned int frameCounterMod;
CGprogram cgVertexProgram, cgFragmentProgram;
LPDIRECT3DTEXTURE9 tex;
LPDIRECT3DVERTEXBUFFER9 vertexBuffer;
@ -247,7 +248,7 @@ private:
LPDIRECT3DDEVICE9 pDevice;
CGcontext cgContext;
float frameCnt;
unsigned int frameCnt;
D3DXMATRIX mvp;
public:

View File

@ -344,6 +344,8 @@ bool CGLCG::LoadShader(const TCHAR *shaderFile)
pass.linearFilter = it->linearFilter;
}
pass.frameCounterMod = it->frameCounterMod;
// paths in the meta file can be relative
_tfullpath(tempPath,_tFromChar(it->cgShaderFile),MAX_PATH);
char *fileContents = ReadShaderFileContents(tempPath);
@ -666,7 +668,10 @@ void CGLCG::setShaderVars(int pass)
setProgram2fv(pass,"IN.video_size",inputSize);
setProgram2fv(pass,"IN.texture_size",textureSize);
setProgram2fv(pass,"IN.output_size",outputSize);
setProgram1f(pass,"IN.frame_count",(float)frameCnt);
unsigned int shaderFrameCnt = frameCnt;
if(shaderPasses[pass].frameCounterMod)
shaderFrameCnt %= shaderPasses[pass].frameCounterMod;
setProgram1f(pass,"IN.frame_count",(float)shaderFrameCnt);
setProgram1f(pass,"IN.frame_direction",GUI.rewinding?-1.0f:1.0f);
/* ORIG parameter

View File

@ -212,6 +212,7 @@ private:
typedef struct _shaderPass {
cgScaleParams scaleParams;
bool linearFilter;
unsigned frameCounterMod;
CGprogram cgVertexProgram, cgFragmentProgram;
GLuint tex;
GLuint fbo;
@ -256,7 +257,7 @@ private:
bool loadTGA(const TCHAR *filename, STGA& tgaFile);
CGcontext cgContext;
int frameCnt;
unsigned int frameCnt;
static const GLfloat lut_coords[8];