Jump to content
The Dark Mod Forums

Func_portal: fade open?


Bikerdude

Recommended Posts

That's an interesting one. I assume the func_portal would be in a door or window, not an exterior one topped by caulk. I don't know an answer so just thinking aloud here. The portal would have to be open during the transition or there'd be nothing behind it to fade in. Targeting an ordinary FS patch from the func_portal will hide the patch as the portal opens, so if you get the lighting+brightness right, you can plug the gap with a flat textured patch and it could look good from a distance. But I guess you thought of that, and it's still an instant switch. Scripting-wise, I guess you could plug the gap with an FS patch and a custom blend texture (or cubemap) and fade it out after the func_portal opens by increasing its transparency through the alpha spawnarg... (I tried a lot of this kind of thing while working on the cloud/moonlight effect. You can get it looking right if you don't mind tweaking the starting brightness every time for the lighting in that particular spot. The illusion fails if someone stands next to it with a torch, as materials with adjustable transparency don't respond to light). That might look horrible of course, but you'd be able to adjust the starting brightness using the same spawnarg so it'd be worth a shot.

 

If the windows start off with a frosty glass texture like milky_warp or whatever it's called, I can imagine it working.... They already have a transparent material applied, so you might get away with matching the patch texture to the glass, not the local lighting. You'd still have to open the portal at the far distance where you'd want the fade-in to start. I don't know whether that would help in your situation or not..?

Edited by SteveL
Link to comment
Share on other sites

LOD wiki outlines how this is done.

 

You would need an alpha-test image which had a light grey center that fades to black on the edges in your alpha channel of your texture:

 

http://wiki.thedarkm...le=Alpha-fading

 

Then you use that along with ShaderParm3 in your entity definition for the patch you want to fade:

 

http://wiki.thedarkm...rParm_variables

 

Whoops. To have the LOD system control fading you need to lod_fadeout_range.

 

Example entity def:

 


entityDef atdm:nature_grass_base
{
   "inherit"                "atdm:nature_base"
   "editor_displayFolder"    "Nature/Grass"

   "editor_color"            ".4 0.8 0.1"
   "editor_usage"            "Don't use, base for all TDM LOD grass patches."

   "solid"                    "0"

   // grass models usually do not have a clipmodel, resulting in "size == 0"
   // Adjust their density thus:
   "seed_base_density"        "0.01"

   // grass may grow through cracks on gravel, but it certainly grows less dense
   "seed_material_gravel"    "0.05"

   // turn off shadows from this distance on
//    "lod_1_distance"        "250"
//    "model_lod_1"            ""
//    "noshadows_lod_1"        "1"

   // hide it from this distance on (it is a small object, so can vanish fast)
   "hide_distance"            "1000"

   "lod_fadeout_range"        "600"

   // by default use more dense grass
   "skin"                    "nature/long_grass_dense"
}

 

 

Example material:

 


textures/darkmod/decals/vegetation/cattails_green
{
qer_editorimage	textures/darkmod/decals/vegetation/cattail_atlas
surftype15
description "foliage"

//twosided (we use rotated patches to save one surface hence one drawcall)
nonsolid
noshadows

{
	blend diffusemap
  	 map	textures/darkmod/decals/vegetation/cattail_atlas
	alphatest 0.5
}

// TDM Ambient Method Related
{							
	if (global5 == 1)		
	blend add				
	map				textures/darkmod/decals/vegetation/cattail_atlas		
	scale			1, 1		
	red				global2	
	green			global3	
	blue			global4	
}							
{							
	if (global5 == 2)		
	blend add				
	program	ambientEnvironment.vfp	
	vertexParm		0		1, 1, 1, 1		// UV Scales for Diffuse and Bump	
	vertexParm		1		1, 1, 1, 1	// (X,Y) UV Scale for specular		
	vertexParm		2		global2, global3, global4, 1	

	fragmentMap		0		cubeMap env/gen1				
	fragmentMap		1		_flat			// Bump				
	fragmentMap		2		textures/darkmod/decals/vegetation/cattail_atlas			// Diffuse			
	fragmentMap		3		_black			// Specular			
}
}

 

(from tdm_billboards.mtr)

 

Note the "alphatest 0.5"

Edited by nbohr1more

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

This isn't what you're looking for, but thought would be if you can't hide the change with line of sight or distance, how about obscuring it with a blast of smoke/steam/fog?

 

Edit: Nevermind, learn something new everyday.

Edited by RJFerret

"The measure of a man's character is what he would do if he knew he never would be found out."

- Baron Thomas Babington Macauley

Link to comment
Share on other sites

Im helping Kvorning with the latest update to his LnL Fm and it occured to me to ask if there is a way to fade in/out the opening and closing of a 'Func_portal' via scripting or some such? the idea being it dosent snap on and off etc.

 

I don't understand what you're trying to do.

 

A portal is either open or closed. There's no in-between.

Link to comment
Share on other sites

If I understand correctly, this is something that could be done in Quake 4 so you might want to look there for clues. It's a type of portal that doesn't rely on visibility to activate but it relies on distance, and it fades in and out smoothly. You could actually use this technique for an entire area for effective and custom (that can be specifically managed based on areas/heights) distance-culling on everything:-

http://www.violation...71007render.avi

http://www.violation...ea071007vis.avi

Edited by LDAsh
Link to comment
Share on other sites

I don't understand what you're trying to do.

 

A portal is either open or closed. There's no in-between.

 

The idea is to hide the open and close states of the portal in a smooth way.

 

You can set func_portal to close in-view and cover that with a patch that "pops" in-front of the whole thing.

 

If you instead, place a transparent patch in front of the open portal then fade it to opaque with distance

then you can more smoothly conceal the transition.

 

That said, I now see a logic error in my post. The fade behavior in the LOD system works the opposite way. It makes

things disappear the farther they get.

 

So you would need to change the alpha value via script.

Edited by nbohr1more

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

If there is an elegant solution to making it actually work, for instance with a cube map, it would make large areas be easier to pull off, especially if there's a fog volume covering the section.

 

Although after LNLs horribly big areas I've taken a very different approach to solving the issue with outdoor in my next map.

 

Still the fade-in/out effect would be good to have as a standard feature in the func_portals. Is there any chance that could actually be something to see in the future?

Link to comment
Share on other sites

I saw an post on a forum somewhere, maybe it was polycount? At any rate, the idea was to exploit mipmaps by manually editing a DDS so that the downsized versions of a texture were not only smaller, but completely different images. The result is that what you see varies depending on distance and that sounds like exactly what you want here. The bonus is there is no overhead.

 

The only problem is I'm not very familiar with DDS. Do they have an alpha channel? If so it should be applicable and fairly easy to setup. You'd make a black DDS image and alter the alpha channel of each downsized version so that the transparency decreases along with the resolution. Slap that texture on a patch. Stick it in front of your visportal. Then tweak the alpha values until the range is correct.

Link to comment
Share on other sites

The idea is to hide the open and close states of the portal in a smooth way. You can set func_portal to close in-view and cover that with a patch that "pops" in-front of the whole thing. If you instead, place a transparent patch in front of the open portal then fade it to opaque with distance then you can more smoothly conceal the transition.

@Gman, this is what Im after.

The only problem is I'm not very familiar with DDS. Do they have an alpha channel? If so it should be applicable and fairly easy to setup. You'd make a black DDS image and alter the alpha channel of each downsized version so that the transparency decreases along with the resolution. Slap that texture on a patch. Stick it in front of your visportal. Then tweak the alpha values until the range is correct.

I can only answer the DDS/ALPHA question, in that as I understand it yes they do, because all our decals are in .DDS format.

Link to comment
Share on other sites

If no-one beats me to it I'll give it a go when I get home in a couple of days. If it doesn't look awful then maybe the whole window could be turned into a prefab. Not with cubemap of course, but for warp or frosty windows. Can scripts be part of a prefab?

Link to comment
Share on other sites

If someone has figured out a way to create natural, semi-opaque textures in TDM, that will be ground-shaking news. As far as I'm aware there is NO way to do this other than using various blend stages that do not react to light (like an additive blend).

 

(from tdm_billboards.mtr)

 

Note the "alphatest 0.5"

 

I don't see anything in this material that would create the effect you're describing? Alphatest 0.5 is not half transparent, it just controls how severely the alpha channel is applied (anything more than .5 is considered fully transparent, anything below it is fully opaque).

 

(you can fade things in using a gui transition...don't know if that would be feasible for a func_portal or not)

Link to comment
Share on other sites

If someone has figured out a way to create natural, semi-opaque textures in TDM, that will be ground-shaking news. As far as I'm aware there is NO way to do this other than using various blend stages that do not react to light (like an additive blend).

I've never spotted a hint of a way round this either, other than fiddling with the rgb level of the blend material to fake the local lighting level, and that only works on a flat surface as there's no shading. The option I want to try is the least ambitious one: am opaque patch that matches some of the frostier translucent glass textures and fades out as you approach. Could also be used with a cubemap.

 

nboh1more's suggestion (if I read it right) is to manipulate the alphatest value using a script so that different parts of the patch are visible at different times. Used with an alpha channel made from a simple black/grey gradient, I imagine you could make effects like a camera shutter opening and closing. You'd get proper lighting on your patch.

 

Rich's suggestion is intriguing but way beyond my testing skills!

Link to comment
Share on other sites

That said, I now see a logic error in my post. The fade behavior in the LOD system works the opposite way. It makes

things disappear the farther they get.

 

So you would need to change the alpha value via script.

How about setting the alphatest in the material file to 1-parm3? (assuming that LOD fading works by manipulating that shaderparm--the wiki doesn't say). Would that do instead of a script?

Link to comment
Share on other sites

nboh1more's suggestion (if I read it right) is to manipulate the alphatest value using a script so that different parts of the patch are visible at different times. Used with an alpha channel made from a simple black/grey gradient, I imagine you could make effects like a camera shutter opening and closing. You'd get proper lighting on your patch.

 

Right, but I don't think you can call that "fading".

 

Is there any way to do this with vertex blending? I'm thinking of Arcturus' recent puddles...would it be possible to blend one regular texture with one of the transparent warp textures?

Link to comment
Share on other sites

Yes, but it would be a little cumbersome. You would need to assign the vertex ratios for each frame in the md5 then assign a transparent material to one vertex color and the opaque to the other. If md5 doesn't support vertex color, you'd have to do model swapping.

Edited by nbohr1more

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

Since I'm not aware of any script method to alter the vertex color ratio in real time, the idea is to make animation frames where each has a successive ratio change to approximate fading.

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

Is there any way to do this with vertex blending? I'm thinking of Arcturus' recent puddles...would it be possible to blend one regular texture with one of the transparent warp textures?

It doesn't seem to work:

 

 

 

material:

 

 

blend_heathaze
{
stone

{
	program		 heatHaze.vfp
	vertexParm	  0	   time * 0 , time * 0 // scroll
	vertexParm	  1	   0 //magnitude
	fragmentMap	 0	   _currentRender
	fragmentMap	 1	   _flat
  vertexColor
}
{
  blend	   bumpmap
  map	  textures/darkmod/stone/cobblestones/cobblestones05_multicolour_irregular_local
  inverseVertexColor
}
{
  blend	  diffusemap
  map	  textures/darkmod/stone/cobblestones/cobblestones05_multicolour_irregular
  inverseVertexColor
}
}

 

 

The middle part should be completely opaque. The heathaze material is applied to the whole object, whether you type "vertexColor" in or not.

It's only a model...

Link to comment
Share on other sites

Yes, but it would be a little cumbersome. You would need to assign the vertex ratios for each frame in the md5 then assign a transparent material to one vertex color and the opaque to the other. If md5 doesn't support vertex color, you'd have to do model swapping.

I don't think you can have vertex colors in MD5 especially animated.

It's only a model...

Link to comment
Share on other sites

How would vertex blending help? What you need to blend between is some kind of opaque patch and the real room behind. Can vertex blending do stuff that the alpha fadeout method couldn't?

 

EDIT: could it combine the two alpha approaches above, for example, while leaving the material lit? And can a shaderparm be passed to the vertex program by the material?

Link to comment
Share on other sites

@LDAsh: any clues what that technique was in the videos? Or a link to where they got posted? I can see that func portals appear to be opening smoothly but no clue how it was done. The particular example in the vid looks like what I'd expect the alpha fade method to look like if you used a plain black texture, which wouldn't work in a well-lit setting (imagine a lit room behind a window, seen from dark exterior. You don't want fade-from-black), but I don't know know it was done.

Link to comment
Share on other sites

Like I said, it's a Quake 4 thing so I don't know if you guys can dig anything out of the SDK and use it for TDM. It's called "visportal_distance_near#_far#", (you will find it in invisible.mtr) and all I've done is use it to split the map into sections and fill it with fog. The difference between doing this and just having a global clipping distance is that you can still "see over" these sections, so you could still have stuff like tall buildings in the far distance, above the fog. In the MTR file, it has a "portalImage" key, but I vaguely remember not being able to change that correctly. I don't use idTech4 anymore so my memory isn't very sharp about that.

Edited by LDAsh
Link to comment
Share on other sites

I wonder if I'm over-thinking this.

 

If you set the "alpha" material keyword to use a parameter it will change opacity based on the parameter value. The problem

is that this apparently does not work for "lit" materials (as I recall?). Well for trickery involving faking interiors (etc) the image

shouldn't be "lit" either so therefore we don't need to worry ourselves about that requirement.

 

LOD fading object, yes a better solution should probably be looked into (and it would be cool if alpha and lighting got along)... but

for tricks with portal closure? no such need as far as I can tell.

 

I will try to make a mockup.

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

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

    • nbohr1more

      The FAQ wiki is almost a proper FAQ now. Probably need to spin-off a bunch of the "remedies" for playing older TDM versions into their own article.
      · 1 reply
    • nbohr1more

      Was checking out old translation packs and decided to fire up TDM 1.07. Rightful Property with sub-20 FPS areas yay! ( same areas run at 180FPS with cranked eye candy on 2.12 )
      · 3 replies
    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 7 replies
    • 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.
      · 7 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
×
×
  • Create New...