Jump to content
The Dark Mod Forums

How is the player visibility calculated?


Skaruts

Recommended Posts

I've been slowly trying to make a little stealth game on my own (in the Godot engine), largely inspired in Delver as well as Thief, but I'm not sure how to tackle lights and player visibility. There's a document by Sean Barret where he mentions they might have used floor lightmaps for this in the old Dark Engine, but I assume T:TDS and TDM use totally different methods, since lighting is dynamic.

 

Can someone give me some insights on how this stuff works?

 

 

 

 

 

My FMs: By The Cookbook

Link to comment
Share on other sites

Here is the whole process:

 

1) Create a new low resolution subview with screen cropped to the size of the octohedron from step 3

2) Cull all surfaces that do not cast shadows

3) Replace the player model with an octohedron (lowest number of polys to catch light from all directions) with a two-sided material (light affects both sides)

4) Spawn a camera inside the octohedron facing up

5) Capture a screenshot to a memory buffer (PBO)

6) Scan the screenshot for the brightest pixel and write out the value

7) Rotate the camera facing down and Capture another screenshot to the PBO

8) Scan the new screenshot for the brightest pixel and compare to step 6

9) Bias the brightness value with things like crouch offset, speed, holding a weapon, etc.

10) Send the final value to the AI algorithm to tell it how bright the player is if the player is in the line of sight

  • Like 2

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

Not sure I'm following. What do you mean by "rendered-to-texture"?

 

Render to texture is the ability to render the 3D view of a camera into a 2D surface, in this case a texture, imagine a security camera view being shown in a monitor, that monitor is the texture. With this feature you can do neat stuff like, security cameras obviously, portals like those of Prey and Portal, mirrors, fancy skyboxes, etc.

  • Like 1
Link to comment
Share on other sites

Here is the whole process:

 

1) Create a new low resolution subview with screen cropped to the size of the octohedron from step 3

2) Cull all surfaces that do not cast shadows

3) Replace the player model with an octohedron (lowest number of polys to catch light from all directions) with a two-sided material (light affects both sides)

4) Spawn a camera inside the octohedron facing up

5) Capture a screenshot to a memory buffer (PBO)

6) Scan the screenshot for the brightest pixel and write out the value

7) Rotate the camera facing down and Capture another screenshot to the PBO

8) Scan the new screenshot for the brightest pixel and compare to step 6

9) Bias the brightness value with things like crouch offset, speed, holding a weapon, etc.

10) Send the final value to the AI algorithm to tell it how bright the player is if the player is in the line of sight

Wow that's a rather sophisticated process. More than I was expecting, at least. And yea, I can see the reasons for the octahedron then. Thanks.

 

Out of curiosity, do you know how it was done in Thief 3? (Or was it a similar process?)

 

I wonder if I could use some simpler alternative for my project, but I'm not sure what are the alternatives. I can see raytracing as a possibility, but I'm not sure how I could make it work properly. Someone suggested to me a while ago calculating it based on that and on the distance to the affecting lights.

 

 

Render to texture is the ability to render the 3D view of a camera into a 2D surface, in this case a texture, imagine a security camera view being shown in a monitor, that monitor is the texture. With this feature you can do neat stuff like, security cameras obviously, portals like those of Prey and Portal, mirrors, fancy skyboxes, etc.

Ah ok. I was thinking of that, but wasn't sure. Would've never guessed that would be the way to make Portal-like portals, though. :blink: That's why I wasn't sure, I wasn't seeing the connection.

Edited by Skaruts

My FMs: By The Cookbook

Link to comment
Share on other sites

Thief 3 apparently alternately samples the brightness of 12 bone positions and weights them based on

some priority factors. The sampling probably amounts to running the entire render for a small number of pixels

or a single pixel.

 

I suppose we could make our system closer by cropping to single pixel values on the vertex points of the octohedron

and center points of the triangles as well. So it would be 8 single pixel screenshots in the up direction and 8 in the down.

 

Our lightgem cost is already so low now that it seems that it wouldn't be worth the effort (and precision loss) for this additional optimization.

 

Might be cool to test though...

  • 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

Ah ok. I was thinking of that, but wasn't sure. Would've never guessed that would be the way to make Portal-like portals, though. :blink: That's why I wasn't sure, I wasn't seeing the connection.

 

Render to texture is only a part of a portal system, there's more to it, like teleporting the player, cloning the player movement into a clone, when he is entering the portal but has not traversed fully, so you can be in two places at the same time, etc.

Edited by HMart
  • Like 1
Link to comment
Share on other sites

If the lights were all spherical then you could just trace to their center and lerp the falloff value. No need to render. That's basically what our tdm_lg_weak does but it's not accurate because we have 1D+2D lights that use projection and falloff images.

 

Another way would be to convert the light textures to low resolution arrays and populate the map with voxel data of the light volumes the player is inside of and sample those voxels.

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

    • 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.
      · 2 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...