Doom 3 engine release and game code
Re: Doom 3 engine release and game code
Not using pom myself i use the offset limited one and agree better versions exist now.
Productivity is a state of mind.
Re: Doom 3 engine release and game code
my relief mapping shader with texture lod (hi speed)reckless wrote:Not using pom myself i use the offset limited one and agree better versions exist now.
enginge uniforms
Code: Select all
if(!image->parallaxScale){
scale[0] = r_parallaxScale->value / image->width;
scale[1] = r_parallaxScale->value / image->height;
}
else
{
scale[0] = image->parallaxScale / image->width;
scale[1] = image->parallaxScale / image->height;
}
qglUniform2f(qglGetUniformLocation(id, "u_parallaxScale"), scale[0], scale[1]);
qglUniform2f(qglGetUniformLocation(id, "u_texSize"), image->upload_width, image->upload_height);
Code: Select all
uniform vec2 u_parallaxScale; // parallax height / tex size
uniform vec2 u_texSize; // current texture size
float ComputeLOD( vec2 tc, vec2 texSize ) {
vec2 dx = dFdx( tc );
vec2 dy = dFdy( tc );
vec2 mag = ( abs( dx ) + abs( dy ) ) * texSize;
float lod = log2( max( mag.x, mag.y ) );
return lod;
}
vec2 CalcParallaxOffset (in sampler2D hiMap, in vec2 texCoord, in vec3 viewVec) {
float lod = ComputeLOD(texCoord, u_texSize);
vec3 offsetVector = vec3(viewVec.xy * u_parallaxScale * vec2(-1, -1), -1);
vec3 offsetBest = vec3(texCoord, 1);
offsetVector *= 0.1;
offsetBest += offsetVector * step(texture2DLod(hiMap, offsetBest.xy, lod).a, offsetBest.z);
offsetBest += offsetVector * step(texture2DLod(hiMap, offsetBest.xy, lod).a, offsetBest.z);
offsetBest += offsetVector * step(texture2DLod(hiMap, offsetBest.xy, lod).a, offsetBest.z);
offsetBest += offsetVector * step(texture2DLod(hiMap, offsetBest.xy, lod).a, offsetBest.z);
offsetBest += offsetVector * step(texture2DLod(hiMap, offsetBest.xy, lod).a, offsetBest.z);
offsetBest += offsetVector * step(texture2DLod(hiMap, offsetBest.xy, lod).a, offsetBest.z);
offsetBest += offsetVector * step(texture2DLod(hiMap, offsetBest.xy, lod).a, offsetBest.z);
offsetBest += offsetVector * step(texture2DLod(hiMap, offsetBest.xy, lod).a, offsetBest.z);
offsetBest += offsetVector * step(texture2DLod(hiMap, offsetBest.xy, lod).a, offsetBest.z);
offsetBest += offsetVector * (step(texture2DLod(hiMap, offsetBest.xy, lod).a, offsetBest.z) - 0.5);
offsetBest += offsetVector * (step(texture2DLod(hiMap, offsetBest.xy, lod).a, offsetBest.z) * 0.5 - 0.25);
offsetBest += offsetVector * (step(texture2DLod(hiMap, offsetBest.xy, lod).a, offsetBest.z) * 0.25 - 0.125);
offsetBest += offsetVector * (step(texture2DLod(hiMap, offsetBest.xy, lod).a, offsetBest.z) * 0.125 - 0.0625);
offsetBest += offsetVector * (step(texture2DLod(hiMap, offsetBest.xy, lod).a, offsetBest.z) * 0.0625 - 0.03125);
return offsetBest.xy;
}
Re: Doom 3 engine release and game code
Thanks barnes
Hmm its the same ?
if(!image->parallaxScale){
scale[0] = r_parallaxScale->value / image->width;
scale[1] = r_parallaxScale->value / image->height;
}
else
{
scale[0] = image->parallaxScale / image->width;
scale[1] = image->parallaxScale / image->height;
}
oversight ?
Hmm its the same ?
if(!image->parallaxScale){
scale[0] = r_parallaxScale->value / image->width;
scale[1] = r_parallaxScale->value / image->height;
}
else
{
scale[0] = image->parallaxScale / image->width;
scale[1] = image->parallaxScale / image->height;
}
oversight ?
Productivity is a state of mind.
Re: Doom 3 engine release and game code
@reckless: http://http.developer.nvidia.com/GPUGem ... _ch18.html might be useful
Re: Doom 3 engine release and game code
noreckless wrote:Thanks barnes
Hmm its the same ?
if(!image->parallaxScale){
scale[0] = r_parallaxScale->value / image->width;
scale[1] = r_parallaxScale->value / image->height;
}
else
{
scale[0] = image->parallaxScale / image->width;
scale[1] = image->parallaxScale / image->height;
}
oversight ?
check for texture properties (simple material definition)
Re: Doom 3 engine release and game code
I See now sorry was damn tired so didnt notice the cvar.
@motorsep everything helps
News implemented depthrender path in material properties, should make it possible to do things like real cellshading soft particles etc.
SSAO still a nogo (well sikks shader works but looks wery odd in places with heathaze skyboxes etc. It seems to be related to Doom3's infinite viewmatrix according to Sikkpin.
It looks well and ok on normal surfaces but creates dark outlines of the generated images for heathaze (will probably be better to make it a material effect so it only goes on specified surfaces and not everything).
Commented on Sikkpins experimental engine cause it crashes for me so im implementing his new features one at a time.
One of his changes include moving the cubemaps out of the doom3 code and into the shaders. He also condensed the vertex shader path to use single light color for both diffuse and specular.
the more code savory can see some of it here.
@motorsep everything helps
News implemented depthrender path in material properties, should make it possible to do things like real cellshading soft particles etc.
SSAO still a nogo (well sikks shader works but looks wery odd in places with heathaze skyboxes etc. It seems to be related to Doom3's infinite viewmatrix according to Sikkpin.
It looks well and ok on normal surfaces but creates dark outlines of the generated images for heathaze (will probably be better to make it a material effect so it only goes on specified surfaces and not everything).
Commented on Sikkpins experimental engine cause it crashes for me so im implementing his new features one at a time.
One of his changes include moving the cubemaps out of the doom3 code and into the shaders. He also condensed the vertex shader path to use single light color for both diffuse and specular.
the more code savory can see some of it here.
Code: Select all
void RB_ARB2_DrawInteraction( const drawInteraction_t *din ) {
// load all the vertex program parameters
// ---> sikk - Included non-power-of-two/frag position conversion
// screen power of two correction factor, assuming the copy to _currentRender
// also copied an extra row and column for the bilerp
float parm[ 4 ];
int w = backEnd.viewDef->viewport.x2 - backEnd.viewDef->viewport.x1 + 1;
int h = backEnd.viewDef->viewport.y2 - backEnd.viewDef->viewport.y1 + 1;
parm[0] = (float)w / globalImages->currentRenderImage->uploadWidth;
parm[1] = (float)h / globalImages->currentRenderImage->uploadHeight;
parm[2] = parm[0] / w; // sikk - added - one less fragment shader instruction
parm[3] = parm[1] / h; // sikk - added - one less fragment shader instruction
qglProgramEnvParameter4fvARB( GL_FRAGMENT_PROGRAM_ARB, PP_NPOT_ADJUST, parm );
// window coord to 0.0 to 1.0 conversion
parm[0] = 1.0 / w;
parm[1] = 1.0 / h;
parm[2] = w; // sikk - added - can be useful to have resolution size in shader
parm[3] = h; // sikk - added - can be useful to have resolution size in shader
qglProgramEnvParameter4fvARB( GL_FRAGMENT_PROGRAM_ARB, PP_INVERSE_RES, parm );
// <--- sikk - Included non-power-of-two/frag position conversion
qglProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_LIGHT_ORIGIN, din->localLightOrigin.ToFloatPtr() );
qglProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_VIEW_ORIGIN, din->localViewOrigin.ToFloatPtr() );
qglProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_LIGHT_PROJECT_S, din->lightProjection[0].ToFloatPtr() );
qglProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_LIGHT_PROJECT_T, din->lightProjection[1].ToFloatPtr() );
qglProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_LIGHT_PROJECT_Q, din->lightProjection[2].ToFloatPtr() );
qglProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_LIGHT_FALLOFF_S, din->lightProjection[3].ToFloatPtr() );
qglProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_BUMP_MATRIX_S, din->bumpMatrix[0].ToFloatPtr() );
qglProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_BUMP_MATRIX_T, din->bumpMatrix[1].ToFloatPtr() );
qglProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_DIFFUSE_MATRIX_S, din->diffuseMatrix[0].ToFloatPtr() );
qglProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_DIFFUSE_MATRIX_T, din->diffuseMatrix[1].ToFloatPtr() );
qglProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_SPECULAR_MATRIX_S, din->specularMatrix[0].ToFloatPtr() );
qglProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_SPECULAR_MATRIX_T, din->specularMatrix[1].ToFloatPtr() );
// ---> sikk - Include model matrix for to-world-space transformations
const struct viewEntity_s *space = backEnd.currentSpace;
parm[0] = space->modelMatrix[0];
parm[1] = space->modelMatrix[4];
parm[2] = space->modelMatrix[8];
parm[3] = space->modelMatrix[12];
qglProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_MODEL_MATRIX_X, parm );
parm[0] = space->modelMatrix[1];
parm[1] = space->modelMatrix[5];
parm[2] = space->modelMatrix[9];
parm[3] = space->modelMatrix[13];
qglProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_MODEL_MATRIX_Y, parm );
parm[0] = space->modelMatrix[2];
parm[1] = space->modelMatrix[6];
parm[2] = space->modelMatrix[10];
parm[3] = space->modelMatrix[14];
qglProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_MODEL_MATRIX_Z, parm );
// <--- sikk - Include model matrix for to-world-space transformations
// ---> sikk - Condensed vertex color param
static const float ignore[ 4 ] = { 0.0, 1.0, 1.0, 1.0 };
static const float modulate[ 4 ] = { 1.0, 0.0, 1.0, 1.0 };
static const float inv_modulate[ 4 ] = { -1.0, 1.0, 1.0, 1.0 };
switch ( din->vertexColor ) {
case SVC_IGNORE:
qglProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_COLOR_MODULATE_ADD, ignore );
break;
case SVC_MODULATE:
qglProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_COLOR_MODULATE_ADD, modulate );
break;
case SVC_INVERSE_MODULATE:
qglProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_COLOR_MODULATE_ADD, inv_modulate );
break;
}
// <--- sikk - Condensed vertex color param
// set the constant colors
// ---> sikk - Use single light color value for both diffuse & specular, also changed the position
qglProgramEnvParameter4fvARB( GL_FRAGMENT_PROGRAM_ARB, PP_LIGHT_COLOR, din->diffuseColor.ToFloatPtr() );
// <--- sikk - Use single light color value for both diffuse & specular
// set the textures
// ---> sikk - changed texture order
// texture 0 will be the light projection texture
GL_SelectTextureNoClient( 0 );
din->lightImage->Bind();
// texture 1 will be the light falloff texture
GL_SelectTextureNoClient( 1 );
din->lightFalloffImage->Bind();
// texture 1 will be the per-surface bump map
GL_SelectTextureNoClient( 2 );
din->bumpImage->Bind();
// texture 2 is the per-surface diffuse map
GL_SelectTextureNoClient( 3 );
din->diffuseImage->Bind();
// texture 3 is the per-surface specular map
GL_SelectTextureNoClient( 4 );
din->specularImage->Bind();
// texture 4 is the ssao buffer
GL_SelectTextureNoClient( 5 );
globalImages->ssaoImage->Bind();
// ---> sikk - Auxilary textures for interaction shaders
// per-surface auxilary texture 0 - 9
for ( int i = 0; i < din->surf->material->GetNumInteractionImages(); i++ ) {
GL_SelectTextureNoClient( i + 6 );
din->surf->material->GetInteractionImage( i )->Bind();
}
// <--- sikk - Auxilary textures for interaction shaders
// <--- sikk - changed texture order
// draw it
RB_DrawElementsWithCounters( din->surf->geo );
}
Productivity is a state of mind.
Re: Doom 3 engine release and game code
http://www.iddevnet.com/doom3/
for info on shaders/materials the ID tech 4 engine can handle.
Might help some people
for info on shaders/materials the ID tech 4 engine can handle.
Might help some people
Productivity is a state of mind.
Re: Doom 3 engine release and game code
Just to clarify things with ssao and the depth buffer stuff. In sikkmod, I had to render there scene again, overriding each surface material with a global material that would spit out an encoded view space depth. This is why alpha tested/blended surfaces have their whole surface opaque in this depth render causing ao contributions where there shouldn't be. If you didn't touch the ssao material, then it's most likely still using this depth render hack instead of the depth buffer which is why you have dark outlines around your heathaze surfaces. Regardless, the ssao shader that is in sikkmod won't work with the depth buffer.
Re: Doom 3 engine release and game code
Sikkpin i presume ?
aye its your old version from sikkmod 1.2 not the one from your work on doom3 itself (still cannot get the darn thing to run )
I figured i couldnt use your sikkmod shader if i implemented it engine side but thanks for the warning
Welcome Btw did you get hold on any of the other admins here ? since i see you are using the bugmenot acc.
aye its your old version from sikkmod 1.2 not the one from your work on doom3 itself (still cannot get the darn thing to run )
I figured i couldnt use your sikkmod shader if i implemented it engine side but thanks for the warning
Welcome Btw did you get hold on any of the other admins here ? since i see you are using the bugmenot acc.
Productivity is a state of mind.
Re: Doom 3 engine release and game code
Yeah, I should have signed that post to avoid confusion. And, no, I haven't talked to any admins but I'll just leave this here in case one a happens by:
email: sikkpin at hotmail dot com.
email: sikkpin at hotmail dot com.
Re: Doom 3 engine release and game code
Ok m8 ill see if i can wake one of them if not
Productivity is a state of mind.
-
- InsideQC Staff
- Posts: 1120
- Joined: Sat Oct 16, 2004 3:34 pm
Re: Doom 3 engine release and game code
I've set Sikkpin up an account. He should keep an eye out for a mail from prismrifle, as it contains his password.
Re: Doom 3 engine release and game code
Thank you. Got the email. Everything works, obviously. A very fitting password I was given.
Re: Doom 3 engine release and game code
BUG ALERT!
If you've seen this page: http://www.viva64.com/en/b/0151/#ID0EMEBK you may have implemented some of the fixes in it. There's a further bug in fragment 10: if you just do the obvious and use "memset (ase.currentMesh, 0, sizeof (*ase.currentMesh));" - you'll wipe the transforms and - as these apply to normals - you're going to end up with some models appearing all or mostly black in the game - the little blue/white boxes in many maps, and the floating platforms in Central Processing are two examples.
Suggest something like this instead:
If you've seen this page: http://www.viva64.com/en/b/0151/#ID0EMEBK you may have implemented some of the fixes in it. There's a further bug in fragment 10: if you just do the obvious and use "memset (ase.currentMesh, 0, sizeof (*ase.currentMesh));" - you'll wipe the transforms and - as these apply to normals - you're going to end up with some models appearing all or mostly black in the game - the little blue/white boxes in many maps, and the floating platforms in Central Processing are two examples.
Suggest something like this instead:
Code: Select all
ase.currentMesh = &ase.currentObject->mesh;
// the transform is applied to normals so it must be saved out before we clear the mesh
idVec3 transform[4];
transform[0] = ase.currentMesh->transform[0];
transform[1] = ase.currentMesh->transform[1];
transform[2] = ase.currentMesh->transform[2];
transform[3] = ase.currentMesh->transform[3];
// and now it's safe to clear
memset (ase.currentMesh, 0, sizeof (*ase.currentMesh));
// and now we restore the saved out transform
ase.currentMesh->transform[0] = transform[0];
ase.currentMesh->transform[1] = transform[1];
ase.currentMesh->transform[2] = transform[2];
ase.currentMesh->transform[3] = transform[3];
ASE_ParseBracedBlock (ASE_KeyMESH);
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for