Author Topic: Ambient cubemap support for sikkmod  (Read 9693 times)

0 Members and 1 Guest are viewing this topic.

Zombie

  • Guest
Ambient cubemap support for sikkmod
« on: October 20, 2014, 04:12:25 AM »
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 :(
« Last Edit: October 20, 2014, 04:15:03 AM by Zombie »

tron

  • Newbie
  • *
  • Posts: 40
  • Karma: +10/-0
  • Doom Newbie
    • View Profile
Re: Ambient cubemap support for sikkmod
« Reply #1 on: October 20, 2014, 04:18:49 AM »
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

  • Sr. Member
  • ****
  • Posts: 374
  • Karma: +96/-87
  • Doom Newbie
    • View Profile
    • Scared Pixel Studios
Re: Ambient cubemap support for sikkmod
« Reply #2 on: October 20, 2014, 04:32:04 AM »
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" ?
« Last Edit: October 20, 2014, 09:16:53 AM by oneofthe8devilz »
I got six little friends and they all run faster than you ;)


Check out our mods at
moddb or the SPS Homepage

nbohr1more

  • Jr. Member
  • **
  • Posts: 97
  • Karma: +13/-8
  • Doom Newbie
    • View Profile
Re: Ambient cubemap support for sikkmod
« Reply #3 on: October 20, 2014, 08:33:03 AM »
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
« Last Edit: October 20, 2014, 08:34:36 AM by nbohr1more »

Zombie

  • Guest
Re: Ambient cubemap support for sikkmod
« Reply #4 on: October 20, 2014, 09:53:08 AM »
Good stuff, but I am not programmer at all :)

solarsplace

  • Jr. Member
  • **
  • Posts: 63
  • Karma: +8/-0
  • Mainly a programmer...
    • View Profile
Re: Ambient cubemap support for sikkmod
« Reply #5 on: October 20, 2014, 10:36:35 AM »
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

  • Jr. Member
  • **
  • Posts: 97
  • Karma: +13/-8
  • Doom Newbie
    • View Profile
Re: Ambient cubemap support for sikkmod
« Reply #6 on: October 20, 2014, 10:41:28 PM »
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:

Code: [Select]
// 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:

Code: [Select]

// 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

Code: [Select]

// 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

Code: [Select]

// 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

Code: [Select]

blendLight = false;
ambientLight = false;


add

Code: [Select]
blendLight = false;
ambientLight = false;
ambientCubeLight = false;

line 1934

Code: [Select]
// ambientLight
else if ( !token.Icmp( "ambientLight" ) ) {
ambientLight = true;
continue;

add

Code: [Select]

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

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

Finally, Material.h line 463

Code: [Select]

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


add

Code: [Select]

// 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

Code: [Select]

bool ambientLight;


add

Code: [Select]

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
« Last Edit: October 21, 2014, 05:42:38 PM by nbohr1more »

Zombie

  • Guest
Re: Ambient cubemap support for sikkmod
« Reply #7 on: October 21, 2014, 01:10:11 AM »
Holy crap you're a trooper!

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

Thanks!

nbohr1more

  • Jr. Member
  • **
  • Posts: 97
  • Karma: +13/-8
  • Doom Newbie
    • View Profile
Re: Ambient cubemap support for sikkmod
« Reply #8 on: October 26, 2014, 01:03:48 PM »
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

  • Hero Member
  • *****
  • Posts: 1,007
  • Karma: +74/-131
  • Artist
    • View Profile
    • Kot in Action Creative Artel
Re: Ambient cubemap support for sikkmod
« Reply #9 on: October 26, 2014, 01:19:23 PM »
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

  • Hero Member
  • *****
  • Posts: 1,007
  • Karma: +74/-131
  • Artist
    • View Profile
    • Kot in Action Creative Artel
Re: Ambient cubemap support for sikkmod
« Reply #10 on: October 27, 2014, 02:05:16 PM »
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

  • Jr. Member
  • **
  • Posts: 97
  • Karma: +13/-8
  • Doom Newbie
    • View Profile
Re: Ambient cubemap support for sikkmod
« Reply #11 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.

BielBdeLuna

  • Full Member
  • ***
  • Posts: 242
  • Karma: +8/-20
  • Doom Newbie
    • View Profile
    • my Github repositories
Re: Ambient cubemap support for sikkmod
« Reply #12 on: October 27, 2014, 07:19:30 PM »
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

  • Hero Member
  • *****
  • Posts: 1,007
  • Karma: +74/-131
  • Artist
    • View Profile
    • Kot in Action Creative Artel
Re: Ambient cubemap support for sikkmod
« Reply #13 on: October 27, 2014, 07:59:02 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

  • Jr. Member
  • **
  • Posts: 97
  • Karma: +13/-8
  • Doom Newbie
    • View Profile
Re: Ambient cubemap support for sikkmod
« Reply #14 on: October 27, 2014, 08:33:32 PM »
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.  :'(