Jump to content
The Dark Mod Forums

Epi's Many Questions Thread


Epifire

Recommended Posts

So I have a strange question for the Epi-thread tonight. Is it even possible to create a lighting method (theory here) to use a texture light as a blend multiply instead of additive function. In other words a darkness map.

Yes. I've played with this a while ago. Have to search for the map as I can't remember how I've done it right now, though.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

So I have a strange question for the Epi-thread tonight. Is it even possible to create a lighting method (theory here) to use a texture light as a blend multiply instead of additive function. In other words a darkness map.

Yes, many of our lights have attached "blendLights" with blend filter and the image blend mode.

 

http://forums.thedarkmod.com/topic/16303-projected-shadows/page-2?do=findComment&comment=347267

 

This is based on work done long ago at doom3world.org in a thread about "Negative Light".

 

TDM has tinkered with that since before v1.0 with the first example of a blendLight shadow being the tree shadows in "No Honor Among Thieves" mission 3 (forest).

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

Yes, many of our lights have attached "blendLights" with blend filter and the image blend mode.

 

http://forums.thedarkmod.com/topic/16303-projected-shadows/page-2?do=findComment&comment=347267

 

This is based on work done long ago at doom3world.org in a thread about "Negative Light".

 

TDM has tinkered with that since before v1.0 with the first example of a blendLight shadow being the tree shadows in "No Honor Among Thieves" mission 3 (forest).

 

I had thought those were just additive stages? I should go back and start testing that, because if I can throttle back past the ambient level (darker yet) that'll be exactly what I need. You see I had this crazy idea of creating an orthographic projection (top down) of exterior environments to create shadow maps for low/cloistered areas. Intensive? Maybe but as a last step it actually could be as simple as getting a uniform camera screenshot, and turning it into a mask, then run a Gaussian blur pass of it in Photoshop. If I can't get radiosity computed lightmaps out of the editor, I'll still try my damnedest to manually project them in controlled stages. :P

 

Also that brings one more tiny question. Has anyone looked into the usage behind light entity layers? To be more specific, optional channels that can filter light entities to only affect other entities matching the same channel. In the same vein of thinking, you could theoretically make ground patches (that are on a separate channel) using the negative lighting pass. And then be able to decorate with foliage and trees on the regular channel.

Modeler galore & co-authors literally everything

 

 

Link to comment
Share on other sites

There is a "spectrum" keyword that you can add to a light shader def and material def so that the light only affects

textures with the matching "spectrum number". It hasn't been widely used because it's a bit cumbersome. You have to

place duplicate lights everywhere so moving models look correct when they are near it.

 

On thing that I thought of today regarding blendlights, is how you could use them to handle shadows on alpha

objects. I was puzzling over an idea to make some stencil shadows invert and then render lights with alpha masks

from the blocker but there were all sorts of special cases you'd have to handle. BlendLights can let you place one big

light and just eat away at it's projection with filter textures in a very natural way. Just a bit tedious with placement.

  • Like 1

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

Well here's a first stab at just getting a simple occlusion mask going in this blend method. Fairly promising results overall, so I'm happy with the concept.

 

 

First image is with regular ambient world color with a directional parallel on top of that...

 

Mh5jb4z.jpg

 

 

Second image is that plus the blend mask I traced out from an orthographic projection...

 

FiCogNq.jpg

  • Like 4

Modeler galore & co-authors literally everything

 

 

Link to comment
Share on other sites

  • 3 weeks later...

Aight so I have a weird one to ask. What kind of functions might work for creating linear movement/animated mask translation via MTR? Cause I was considering the costs of what it would take to make opening/closing shutter sliding animations for a blend add mask. What it would accomplish is several things:

 

A - The window material that has a supposed louver would look realistic with brightness behind the panel sliding to dark.

B - This same MTR translation could also be used in a light conveying the effects inside the room (and pretty accurately I might add).

 

So in concept it should kill two birds with one stone but the problem is being able to plot mask positioning without a looping affect. You'd basically plot translation position and hold it there until otherwise noted (thus achieving open and closed). Theories would suggest a table that cannot be looped (eg. only playable once). I'm very inexperienced with tables in MTRs so I'm not sure if that's possible either. It could be viable with alternate skins but that may complicate the light situation as I don't think lights can change.

 

If it's too far out of the ballpark I'll just have to settle for unmovable louvers and leave it at that.

Modeler galore & co-authors literally everything

 

 

Link to comment
Share on other sites

I have a rough idea of what you are aiming for and I guess it is doable, but it would be helpful if you could be more precise. Images would be of help.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Non-looping tables are possible: see the 'clamp' keyword described near the top of https://www.iddevnet.com/doom3/materials.php

 

You might need to use a script that sets a shaderParm to the current time, so that the material's transition can be controlled on demand. Here's an example from Doom 3, where the game code sets parm7 to a monster's time of death to begin the 'burnaway' effect, then it's used as a time offset compared to the current time:

{	// burning corpse effect
		if	parm7			// only when dead
		
		// make a burned away alpha test for the normal skin
		blend	gl_zero, gl_one			// don't draw anything
		
		map models/monsters/imp/imp_dis.tga	// replace this with a monster-specific texture
		alphaTest 0.05 + 0.3 * (time - parm7)
	}
	{	// burning corpse effect
		if parm7			// only when dead

		// draw the fire burn at a negative polygonOffset, so it is behind the other stages
		privatePolygonOffset	-1		// stage-only polygon offset
        blend add	
        blend gl_one, gl_zero
		
		map models/monsters/imp/imp_dis.tga	// replace this with a monster-specific texture
		alphaTest 0.3 * (time - parm7)
	}

Since you mention additive blending, if it's okay for the material to be rendered fullbright then using a GUI surface might be an alternative (more complex but more powerful). (I wouldn't bet on GUIs working in light materials, though.)

Edited by VanishedOne
  • Like 1

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

I have a rough idea of what you are aiming for and I guess it is doable, but it would be helpful if you could be more precise. Images would be of help.

 

I'm actually building the scene right now so there's really not a lot I can show as of yet. The concept though, is that on the ceiling there will feature windows with sliding louvers on the outside. The glass is murky so you wont be able to make out the louvers by themselves but more accurately the shape of them. Translating a black and white mask within the mtr stage is why this would work well. A definite easier approach would just have the glass transparent to show the louvers but I can't risk the performance drawback of the exterior being on the same visleaf. For a model I'd say it would be easy to slide the white/blend add coverage beneath something to simply hide it. In a light material however I'd probably need to use the same mask again as an unmovable layer to denote the surrounding frame. Otherwise we'd have a sliding grate that wouldn't appear to close in the lighting stage.

 

This actually gave me a rather interesting idea for lightshafts. As if the supposed lightshafts could be held on a different light spectrum value (only exposed by the light with special material) we could theoretically reveal/hide the godray effect in a similar fashion. Best part is it would require no extra work, as long as the lightshaft's material could be invisible prior to having an active light shined on it.

 

 

Non-looping tables are possible: see the 'clamp' keyword described near the top of https://www.iddevnet.com/doom3/materials.php

 

You might need to use a script that sets a shaderParm to the current time, so that the material's transition can be controlled on demand. Here's an example from Doom 3, where the game code sets parm7 to a monster's time of death to begin the 'burnaway' effect, then it's used as a time offset compared to the current time:

{	// burning corpse effect
		if	parm7			// only when dead
		
		// make a burned away alpha test for the normal skin
		blend	gl_zero, gl_one			// don't draw anything
		
		map models/monsters/imp/imp_dis.tga	// replace this with a monster-specific texture
		alphaTest 0.05 + 0.3 * (time - parm7)
	}
	{	// burning corpse effect
		if parm7			// only when dead

		// draw the fire burn at a negative polygonOffset, so it is behind the other stages
		privatePolygonOffset	-1		// stage-only polygon offset
        blend add	
        blend gl_one, gl_zero
		
		map models/monsters/imp/imp_dis.tga	// replace this with a monster-specific texture
		alphaTest 0.3 * (time - parm7)
	}

 

This is some exciting news! I'm wondering then, is it possible to set a variable from a single param to toggle between two different tables in the same mtr reference? If so I wouldn't even need skins for this! All I'd have to do is just set the same param on or off and it would be done. I've already used this mask blending with different interior windows, so I'd really just wanted to push that a tad further with some control elements. Once it's all said and done you should be able to walk into the room and have a switch open the windows to get some fancy moonlight casting across the room.

Modeler galore & co-authors literally everything

 

 

Link to comment
Share on other sites

 

I'm wondering then, is it possible to set a variable from a single param to toggle between two different tables in the same mtr reference?

You can make stages conditional, so something like this should work:

{
if (parm9 == 0)
map _white
rgb sintable[time]
}

{
if (parm9 > 0)
map _white
rgb pulsetable[time]
}

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

This gives me a lot to go off of. Now lastly I've never aimed a script directed at an entity via a param number, do you have an example of how the syntax would look for that? Assuming the structure of this mtr reference is used, we would give parm9 a value of 0 or 1 respectively.

Modeler galore & co-authors literally everything

 

 

Link to comment
Share on other sites

 

I'm actually building the scene right now so there's really not a lot I can show as of yet.

 

 

I wasn't talking about screenshots, but more of a sketch or similar. Just so I get the idea. So maybe I make a start to see whether I understand you.

post-11230-0-77394300-1509698543_thumb.jpg

 

What I did not get yet is what you need the tables for.

  • Like 1

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Ah I see what you mean. You're interpretation is pretty close though the difference being that I'd just move that black and what mask (a louver's distance up and down) to simulate the opening and closing via translation. It could technically be done frame by frame in an animated texture but that'd be a ridiculous amount of file size to accomplish the same result. Basically you'd be doing this. Which would be calling up the mask twice to create region of affect and the same mask (translating) to modulate the change of the blend add.

 

So one static mask would filter the moving mask like so...

 

 

post-14594-0-54428000-1509704909_thumb.jpg

Modeler galore & co-authors literally everything

 

 

Link to comment
Share on other sites

That could probably be done just by clamping the image and translating it. Edit: although having thought about how to keep the translation within bounds, tables might be the clearest way after all.

This gives me a lot to go off of. Now lastly I've never aimed a script directed at an entity via a param number, do you have an example of how the syntax would look for that? Assuming the structure of this mtr reference is used, we would give parm9 a value of 0 or 1 respectively.

The relevant script event is:

scriptEvent void setShaderParm(float parm, float value);

Sets the value of the specified shader parm.

parm: shader parm index
value: new value

 

So I expect you'd write something like $myObject.setShaderParm(9,1);

 

Alternatively, there are a couple of Doom 3 entity defs that I think may have been removed from TDM but, if they ever worked, probably still would if restored:

entityDef target_setshaderparm {
	"spawnclass"	"idTarget_SetShaderParm"

	"editor_usage"	"sets shaderparameters of targeted entities"

	"editor_color"	"1 1 0"
	"editor_maxs"	"8 8 8"
	"editor_mins"	"-8 -8 -8"

	"editor_color _color"		"color for the targeted entities"
	"editor_bool toggle"		"if set (to 1), all shaderparms set to 0 or 1 will be toggled (0 to 1 and 1 to 0)"
	
	"editor_var shaderParm0"	"value for shaderParm0 of targeted entities"
	"editor_var shaderParm1"	"value for shaderParm1 of targeted entities"
	"editor_var shaderParm2"	"value for shaderParm2 of targeted entities"
	"editor_var shaderParm3"	"value for shaderParm3 of targeted entities"
	"editor_var shaderParm4"	"value for shaderParm4 of targeted entities"
	"editor_var shaderParm5"	"value for shaderParm5 of targeted entities"
	"editor_var shaderParm6"	"value for shaderParm6 of targeted entities"
	"editor_var shaderParm7"	"value for shaderParm7 of targeted entities"
}

entityDef target_setshadertime {
	"spawnclass"	"idTarget_SetShaderTime"

	"editor_usage"	"sets the negative (?!) current game time (as float in seconds) as TIMEOFFSET shader parm (4) when activated on targeted entities"
	"editor_usage"	"it's -MS2SEC( gameLocal.time ), if that's any help..."

	"editor_color"	"1 1 0"
	"editor_maxs"	"8 8 8"
	"editor_mins"	"-8 -8 -8"
}
Edited by VanishedOne

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

Ah I see what you mean. You're interpretation is pretty close though the difference being that I'd just move that black and what mask (a louver's distance up and down) to simulate the opening and closing via translation. It could technically be done frame by frame in an animated texture but that'd be a ridiculous amount of file size to accomplish the same result. Basically you'd be doing this. Which would be calling up the mask twice to create region of affect and the same mask (translating) to modulate the change of the blend add.

 

So one static mask would filter the moving mask like so...

 

 

The translation can be done via the shader, so no animated gif needed :)

 

I take a look at it tomorrow. Shouldn't be too complicated (unless I am overseeing something).

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

I just stumbled upon something:

================
idStaticEntity::Event_Activate
================
*/
void idStaticEntity::Event_Activate( idEntity *activator ) {

	spawnTime = gameLocal.time;
	active = !active;

	const idKeyValue *kv = spawnArgs.FindKey( "hide" );
	if ( kv ) {
		if ( IsHidden() ) {
			Show();
		} else {
			Hide();
		}
	}

	renderEntity.shaderParms[ SHADERPARM_TIMEOFFSET ] = -MS2SEC( spawnTime );
	renderEntity.shaderParms[5] = active;
	// this change should be a good thing, it will automatically turn on 
	// lights etc.. when triggered so that does not have to be specifically done
	// with trigger parms.. it MIGHT break things so need to keep an eye on it
	renderEntity.shaderParms[ SHADERPARM_MODE ] = ( renderEntity.shaderParms[ SHADERPARM_MODE ] ) ?  0.0f : 1.0f;
	BecomeActive( TH_UPDATEVISUALS );
}

(SHADERPARM_TIMEOFFSET is parm4; SHADERPARM_MODE is parm7.)

If I read the intent correctly, triggering a func_static is supposed to set the time offset as per target_setshadertime, and toggle parm7 and parm5 to track on/off state. No need for a script or extra entityDef (unless you want to use a script to fade a parm between values). A quick test with the following material seems to confirm that:

shadertest {
	stone
	{
		blend diffusemap
		map _white
		red (time + parm4)
		green parm5
		blue parm7
	}
}

(Edited because shadertest{ confuses DR's parser and breaks the file.)

Edited by VanishedOne
  • Like 1

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

I take a look at it tomorrow. Shouldn't be too complicated (unless I am overseeing something).

I got it to work basically, but the blend lights seem to be a bit buggy. It renders in areas where it shouldn't. Will have to investigate further.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

Can't tell without seeing them whether it's the same problem, but I've found that big blendlights may need to be (zero?)clamped, or they can act a bit like foglights when the player stands inside them and tint the entire scene.

 

Or if it's to do with light passing through geometry, forceShadows might be worth a try...?

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

 

If I read the intent correctly, triggering a func_static is supposed to set the time offset as per target_setshadertime, and toggle parm7 and parm5 to track on/off state. No need for a script or extra entityDef (unless you want to use a script to fade a parm between values). A quick test with the following material seems to confirm that:

shadertest {
	stone
	{
		blend diffusemap
		map _white
		red (time + parm4)
		green parm5
		blue parm7
	}
}

 

I'm not able to test this out yet, but I'm interested in seeing how you set this up (namely in DR). Are you setting specific spawnargs for the func_static and then just triggering them? It sounds fairly direct which is fantastic. If parm5 and 7 were to hold translate table data, that should theoretically run the open and close sequence then right? This sounds waaaay more simple than I thought it would be at a glance, which is certainly welcome given that doesn't seem to happen all too often.

 

EDIT: this also leaves me super curious as to how this can work with a light material. I don't believe they can be targetted and triggered the same way the func_static can so that may take some doing.

Modeler galore & co-authors literally everything

 

 

Link to comment
Share on other sites

TDM's code is setting the spawnargs; all I'm doing is triggering the func_static (by targetting a button at it).

 

Lights can be triggered on/off* but unfortunately the shaderParm-changing functionality seems to be specific to func_statics (more precisely to the idStaticEntity spawnclass, which lights don't use). I think the programmer's comment about 'lights' probably refers either to additive blends (for Doom 3 control panels and the like with glow-in-the-dark elements representing lights) or to set-ups where you have a func_static representing a light's model and triggered along with the light, instead of a light using its own model. So you're right, it's not a complete solution when you want a light manipulated too.

 

*Or set to a broken state, or dimmed a number of times before turning off, depending on what spawnargs are set.

 

Edit: lights do seem to have code to set SHADERPARM_TIMEOFFSET when they turn on, and to set it and SHADERPARM_MODE when they break; the problem is that here you want to switch between two 'on' states.

 

I suppose having two lights, only one active at a given time, could work. But at that point things are less simple anyway.

Edited by VanishedOne

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

Could you continuously tell a light to turn on and break? Or does the break function kill the entity after it's sequence is played out? Traditionally we wouldn't want to use a break function but it still could carry the off/close mode in this case.

Modeler galore & co-authors literally everything

 

 

Link to comment
Share on other sites

I think breaking was designed as a one-way state change to the 'broken' material/sound/model, so if it's possible to 'unbreak' a light it won't be simpler than just setting the shaderParms with a script or intermediate entity.

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recent Status Updates

    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 3 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
    • nbohr1more

      Looks like the "Reverse April Fools" releases were too well hidden. Darkfate still hasn't acknowledge all the new releases. Did you play any of the new April Fools missions?
      · 5 replies
×
×
  • Create New...