News:

One Minute Game Review by The Happy Friar: https://ugetube.com/@OneMinteGameReviews
Also on Rumble: https://rumble.com/c/c-1115371

idTech 4 (aka Doom 3 tech) Discord Server! https://discord.gg/9wtCGHa

Main Menu

Ambient cubemap support for sikkmod

Started by Zombie, October 20, 2014, 04:12:25 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Zombie

Hello,

Is anyone able to merge the shader changes from the ambient cubemap mod in to the current sikkmod?

I don't care about the cubemap projected lights (it seems buggy anyway) but the ambient cubemap would be help a lot with lighting a scene to feel more natural.

https://web.archive.org/web/20130909073250/http://www.doom3world.org/phpbb2/viewtopic.php?t=24193

I have the mod downloaded if it anyone wants to attempt to merge it. I tried but it didn't work :(

tron

As far as I'm aware it's all or nothing, if you want the ambient cubemap you need to have the cubemapped normal lights (which breaks many of the stock game assets)

oneofthe8devilz

#2
Without any intend to derail this thread, how useful can the "web.archive.org" version of "Doom3World.org" be in order to port all the useful threads and tutorials over to "idtechforums.fuzzylogicinc.com" ?
I got six little friends and they all run faster than you ;)


Check out our mods at
moddb or the SPS Homepage

nbohr1more

#3
Well, if you don't mind making a new executable, you could create a new ambientCubeLight material keyword
then link sikkpin's shader to it. That way all your lights can use stock assets and you can still have ambient cubemap
lighting.

I'll post the changes for that this evening. I did a similar change for The Dark Mod that is pending testing but it was for
the projection portion.

For reference:

http://forums.thedarkmod.com/topic/15178-tdm-engine-development-page/page__st__325__p__356495#entry356495

Zombie

Good stuff, but I am not programmer at all :)

solarsplace

Hi Zombie

Just FYI, nbohr1more's changes are done in the engine code. You would need to either go stand-alone or distribute a new .EXE with your mod and have the user place it along side the doom3.exe in the game root folder. You could call it something like "zombie_d3.exe".

Cheers

nbohr1more

#6
OK, here's an example

(I basically copied Rebb's work in The Dark Mod to create a dedicated ambient. You can use this to make all
sorts of dedicated light types.)

First, rename the interaction.vfp in Sikkmod's demo to "sikkcube.vfp" and place it in your glprogs folder.

Next, using https://github.com/TTimo/doom3.gpl as a reference, add these changes to the following files under
renderer:

draw_arb2.cpp lines 152 to 159:


// bind the vertex program
if ( r_testARBProgram.GetBool() ) {
qglBindProgramARB( GL_VERTEX_PROGRAM_ARB, VPROG_TEST );
qglBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, FPROG_TEST );
} else {
qglBindProgramARB( GL_VERTEX_PROGRAM_ARB, VPROG_INTERACTION );
qglBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, FPROG_INTERACTION );
}


you'd add another branch:



// bind the vertex program
if ( backEnd.vLight->lightShader->IsCubicAmbientLight() ) {
    qglBindProgramARB( GL_VERTEX_PROGRAM_ARB, VPROG_CUBIC_AM_LIGHT );
    qglBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, FPROG_CUBIC_AM_LIGHT );
  } else {

                    if ( r_testARBProgram.GetBool() ) {
                      qglBindProgramARB( GL_VERTEX_PROGRAM_ARB, VPROG_TEST );
                      qglBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, FPROG_TEST );
         
          } else {
                    qglBindProgramARB( GL_VERTEX_PROGRAM_ARB, VPROG_INTERACTION );
                    qglBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, FPROG_INTERACTION );
}


then lines 336 to 359



// a single file can have both a vertex program and a fragment program
static progDef_t progs[MAX_GLPROGS] = {
{ GL_VERTEX_PROGRAM_ARB, VPROG_TEST, "test.vfp" },
{ GL_FRAGMENT_PROGRAM_ARB, FPROG_TEST, "test.vfp" },
{ GL_VERTEX_PROGRAM_ARB, VPROG_INTERACTION, "interaction.vfp" },
{ GL_FRAGMENT_PROGRAM_ARB, FPROG_INTERACTION, "interaction.vfp" },
{ GL_VERTEX_PROGRAM_ARB, VPROG_BUMPY_ENVIRONMENT, "bumpyEnvironment.vfp" },
{ GL_FRAGMENT_PROGRAM_ARB, FPROG_BUMPY_ENVIRONMENT, "bumpyEnvironment.vfp" },
{ GL_VERTEX_PROGRAM_ARB, VPROG_AMBIENT, "ambientLight.vfp" },
{ GL_FRAGMENT_PROGRAM_ARB, FPROG_AMBIENT, "ambientLight.vfp" },
{ GL_VERTEX_PROGRAM_ARB, VPROG_STENCIL_SHADOW, "shadow.vp" },
{ GL_VERTEX_PROGRAM_ARB, VPROG_R200_INTERACTION, "R200_interaction.vp" },
{ GL_VERTEX_PROGRAM_ARB, VPROG_NV20_BUMP_AND_LIGHT, "nv20_bumpAndLight.vp" },
{ GL_VERTEX_PROGRAM_ARB, VPROG_NV20_DIFFUSE_COLOR, "nv20_diffuseColor.vp" },
{ GL_VERTEX_PROGRAM_ARB, VPROG_NV20_SPECULAR_COLOR, "nv20_specularColor.vp" },
{ GL_VERTEX_PROGRAM_ARB, VPROG_NV20_DIFFUSE_AND_SPECULAR_COLOR, "nv20_diffuseAndSpecularColor.vp" },
{ GL_VERTEX_PROGRAM_ARB, VPROG_ENVIRONMENT, "environment.vfp" },
{ GL_FRAGMENT_PROGRAM_ARB, FPROG_ENVIRONMENT, "environment.vfp" },
{ GL_VERTEX_PROGRAM_ARB, VPROG_GLASSWARP, "arbVP_glasswarp.txt" },
{ GL_FRAGMENT_PROGRAM_ARB, FPROG_GLASSWARP, "arbFP_glasswarp.txt" },
// additional programs can be dynamically specified in materials
};



add



// a single file can have both a vertex program and a fragment program
static progDef_t progs[MAX_GLPROGS] = {
{ GL_VERTEX_PROGRAM_ARB, VPROG_TEST, "test.vfp" },
{ GL_FRAGMENT_PROGRAM_ARB, FPROG_TEST, "test.vfp" },
{ GL_VERTEX_PROGRAM_ARB, VPROG_INTERACTION, "interaction.vfp" },
{ GL_FRAGMENT_PROGRAM_ARB, FPROG_INTERACTION, "interaction.vfp" },
{ GL_VERTEX_PROGRAM_ARB, VPROG_BUMPY_ENVIRONMENT, "bumpyEnvironment.vfp" },
{ GL_FRAGMENT_PROGRAM_ARB, FPROG_BUMPY_ENVIRONMENT, "bumpyEnvironment.vfp" },
{ GL_VERTEX_PROGRAM_ARB, VPROG_AMBIENT, "ambientLight.vfp" },
{ GL_FRAGMENT_PROGRAM_ARB, FPROG_AMBIENT, "ambientLight.vfp" },
{ GL_VERTEX_PROGRAM_ARB, VPROG_STENCIL_SHADOW, "shadow.vp" },
{ GL_VERTEX_PROGRAM_ARB, VPROG_R200_INTERACTION, "R200_interaction.vp" },
{ GL_VERTEX_PROGRAM_ARB, VPROG_NV20_BUMP_AND_LIGHT, "nv20_bumpAndLight.vp" },
{ GL_VERTEX_PROGRAM_ARB, VPROG_NV20_DIFFUSE_COLOR, "nv20_diffuseColor.vp" },
{ GL_VERTEX_PROGRAM_ARB, VPROG_NV20_SPECULAR_COLOR, "nv20_specularColor.vp" },
{ GL_VERTEX_PROGRAM_ARB, VPROG_NV20_DIFFUSE_AND_SPECULAR_COLOR, "nv20_diffuseAndSpecularColor.vp" },
{ GL_VERTEX_PROGRAM_ARB, VPROG_ENVIRONMENT, "environment.vfp" },
{ GL_FRAGMENT_PROGRAM_ARB, FPROG_ENVIRONMENT, "environment.vfp" },
{ GL_VERTEX_PROGRAM_ARB, VPROG_GLASSWARP, "arbVP_glasswarp.txt" },
{ GL_FRAGMENT_PROGRAM_ARB, FPROG_GLASSWARP, "arbFP_glasswarp.txt" },
// additional programs can be dynamically specified in materials

// dedicated cubemap ambient
{ GL_VERTEX_PROGRAM_ARB, VPROG_CUBIC_AM_LIGHT, "sikkcube.vfp" },
{ GL_FRAGMENT_PROGRAM_ARB, FPROG_CUBIC_AM_LIGHT, "sikkcube.vfp" },
};



Next, create the material tokens

Material.cpp line 100



blendLight = false;
ambientLight = false;



add


blendLight = false;
ambientLight = false;
ambientCubeLight = false;


line 1934


// ambientLight
else if ( !token.Icmp( "ambientLight" ) ) {
ambientLight = true;
continue;


add



// ambientLight
else if ( !token.Icmp( "ambientLight" ) ) {
ambientLight = true;
continue;

// ambientCubeLight
else if ( !token.Icmp( "ambientCubeLight" ) ) {
ambientCubeLight = true;
continue;


Finally, Material.h line 463



// an ambient light has non-directional bump mapping and no specular
bool IsAmbientLight() const { return ambientLight; }



add



// an ambient light has non-directional bump mapping and no specular
bool IsAmbientLight() const { return ambientLight; }

// sikkpins cubemap light interaction
bool IsCubicAmbientLight() const { return ambientCubeLight; }



line 655



bool ambientLight;



add



bool ambientLight;

bool ambientCubeLight



Then add the "ambientCubeLight" keyword to all of Sikkpin's example material shaders and test them out.

Made a github fork:

https://github.com/nbohr1more/Doom3_divide

Zombie

Holy crap you're a trooper!

At some point when I get home I'll give that w whirl :D

Thanks!

nbohr1more

I added Mh's shadow optimization to my github page:

https://github.com/nbohr1more/Doom3_divide

so that if you package this with your mod you won't lose too much performance compared to the native executable. (In some
cases, it may perform faster since it uses a new GL call which has a better CPU and memory profile than the legacy code.).

If you are so inclined, you can easily find many github branches which add back Carmack's Reverse

Example:

https://github.com/ljbade/doom3.gpl/commit/d4de024341e79e0ac1dfb54fb528859f8ccea605

I doubt Creative would C&D any work with this fix included, especially from a developer offering free content to players.

motorsep

Using Carmack's Reverse is illegal in US (and CA perhaps). It's been already said numerous times that potential the legal complications outweigh performance gain (which is so negligible that it's not worth fooling around with).

motorsep

By the way, has anyone even tried Sikkpin's ambient cubemap lights?

It would be nice to see screenshots, or HD video of a level with standard ambient light, and the same level with ambient cubemap lights.

nbohr1more

I can post some screens when I get a chance.

This dropbox link:

http://dl.dropbox.com/u/17706561/ambientcube_test.rar

still works so you can install it as a Doom 3 mod if you've got Vanilla Doom 3 around.

BielBdeLuna

it would be cooler to add this to the GLSLed BFG engine. this seems to be the perfect approach for ambient light term that the engine needs, and do some cube-map mixes and deforms a la HL2 and a la RememberMe.

motorsep

Quote from: nbohr1more on October 27, 2014, 05:51:10 PM
I can post some screens when I get a chance.

This dropbox link:

http://dl.dropbox.com/u/17706561/ambientcube_test.rar

still works so you can install it as a Doom 3 mod if you've got Vanilla Doom 3 around.

That's not really IBL :( It's just a cubemap - 3D projection. I was thinking Sikkpin actually implemented IBL, where you have several local probes with blend in factor.

makeAmbientMap cmd make those probes and Sikkpin's solution is not designed for it. So the lighting won't get any better in idTech 4. Now I recall talking to him about that and to make IBL, like what you see in many modern games, there gotta be different solution, not what he already made.

nbohr1more

Oh yeah, he made a Spherical Harmonic shader at one point but I don't think he ever posted the code. I spent ages around wayback trying to find the doom3world thread to no avail.  :'(