Jump to content
The Dark Mod Forums

Recommended Posts

New version (see attached .zip)

Uses texture diffuse color as fresnel highlight color for the fallback fresnel branch in interaction.ambient.fs. This helps fresnel blend into the surfaces and scene better, instead of looking like a monochromatic haze on everything.

Also, in some missions I'm seeing a pink / red sky (eg: Lord Edgar's Bathhouse). I looked at screenshots of the mission, and it's supposed to be blue. Not sure if something in my shaders is doing that. I thought I had set something to .r *= 10 to highlight what the shader impacts. But, sifted through the shaders and I had all those parts commented out. It could be that the sky is using a branch of shading that I thought wasn't used any more, and I mucked up something. Not sure. That's the main problem I'm having.. I can't tell which textures are using which shaders. So, I can't tell which shaders are worth messing with, and which ones I messed with having adverse impact later. That's why I was hoping there was a project document that maps out what hooks to what.

 

glprogs.stages.interaction.012.zip

  • Like 2
Link to post
Share on other sites
  • Replies 130
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

3 days w/o power in texas. Froze my nuts off. But, power's back on. Upgraded to 2.09, then messed with shaders some more. Mainly the glprogs/stages/interaction/ ... common & ambient, b/c they

v 0.22 BRDF & PBR implemented... in faux fashion Snagged code from... https://github.com/urho3d/Urho3D/blob/master/bin/CoreData/Shaders/GLSL/PBR.glsl        // BRDF main rou

Oh absolutely. And just to be clear, my interest in PBR isn't really in giving TDM a stylistic overhaul, "next-level graphics" or any such nonsense I'm more interested in if it could make our artists

Posted Images

Thank you!

This is starting to look much better.

I will tinker with the amount of Specular and Fresnel in the shaders to see if I can approximate the 1.03 look.

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 post
Share on other sites
16 hours ago, nbohr1more said:

RBDoom3BFG is capturing "probes" (cubemaps) of the "area" which are fed to the ambient light shader. A technique as old as HL2 at least.

ah that explains it thanks. 

Link to post
Share on other sites

I'd be cautious about introducing automated bits of visual language as a gameplay/mapping feature, as opposed to an aesthetic adjustment to taste. It's now easier than it used to be (in the days of selectable simple/enhanced light interaction shaders, one of which almost-but-not-quite disabled specular RGB scaling) for a mapper to understand and control what materials are doing by comparing how things look in TDM to the material decls. Having surface types like water or noisy floors given special treatment outside the explicit material decls would make things more, not less, enigmatic for mappers. (There's actually an open bug relating to floor tiles that don't have the tint the material decl indicates they should because RGB scaling in cubemap stages doesn't work unless there are no light-interactive stages.)

On bright glass, I think my first ever question on this forum was about why my glass block in an alabaster room could be plainly seen without any light. Other people have mentioned additive blends and alpha blended cubemaps, but another (not mutually exclusive) possibility is the 'translucent' keyword. Back then, the state of understanding was that it just made materials not interact with light. We now know that translucent materials can interact with light (someone found you can use 'diffusemap _black' in glass), but precisely what's going on isn't well documented; what I think happens is that light interaction is performed as for opaque materials but the pixels aren't cleared to black first, so the effect is like an additive blend but with light interaction.

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to post
Share on other sites

Pretty much, yes. As far as lighting goes, translucent materials are treated like any other material, only they are added on top of anything solid already rendered. Alpha is not taken into account as a weight for this, so it's rather difficult to control.

This isn't exactly great behaviour in my opinion, but unfortunately it's also not quite easy to fix. One upside is that it's at least order-independent, because otherwise that'd open a whole other can of worms :)

  • Like 1
Link to post
Share on other sites

Oh Builder, the old order-dependency problem. I'd been hoping that, since the engine can perform light interaction on surfaces that are meant to be drawn over other surfaces, we might dare to hope for actual alpha blending on lit materials someday (instead of e.g. using alpha testing for grass edges, as seen in some maps).

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to post
Share on other sites
3 hours ago, VanishedOne said:

Oh Builder, the old order-dependency problem. I'd been hoping that, since the engine can perform light interaction on surfaces that are meant to be drawn over other surfaces, we might dare to hope for actual alpha blending on lit materials someday (instead of e.g. using alpha testing for grass edges, as seen in some maps).

Yes that would be awesome, specially for foliage, grass and such, I still don't know why alpha blending is such a problematic thing but i'm not a graphics coder. Curious how they solved that on Quake Wars, I think it uses more than alpha testing.

 

MV5BNzkyMzkyMDAtOTcyOS00MjAyLTg3Y2ItNDI1

Link to post
Share on other sites

v 0.14

  • Switched fake AO & fallback Spec maps to use dot(raw normal map, 0.33) in both ambient & common fs.
  • Switched specular over to use diffuse.rgb color as specular color if no specular.rgb / map texture instead of default static value

 

Normals as fake maps...

wasn't happy with how over-dark some things were, eg: the pillars on BikerDude's Training MIssion, when using dots of specular or diffuse as fake maps. So, decided to check out normals instead. I knew normals provide edges to help create the bump-mapping. However, using the normalized & TBN'ed version, I got some surfaces that were pitch black. But, when I dotted the raw normal, I got this...

0EHz1P1.jpg

This is a more even-tempered grayscale map for the whole scene. (cut-off seam are from piping the dot product straight through w/o light impacting it).

Compared to this...

VjT45Wd.jpg

Which was using dot of specular map if it had it, otherwise using dot of diffuse.

The over-darkening can possibly be considered a half-arsed materials type of variation on surfaces. But, I'd prefer all surfaces having a more even grayscale to them for a fake AO / specular.

Reason being.. I got aggravated with FUEL when vehicles and riders would look over-dark in overcast skies. They looked out of place. Couldn't figure out what the deal was until I piped some materials lighting values directly through, and realized they were applying a default dark gray to some objects lighting.. which over-darked them. When I ripped that out, it was easier to blend things together to look more natural in a scene.

FUEL_2021-01-29_13-55-04-631.jpg

(crappy base "materials lighting" FUEL game piped to shaders, which made some things over-dark in overcast skies)

So, decided to go with the more equalized fake AO / Specular map. The variations in detail should come from diffuse color, lighting, etc, not from drastic differences in fake maps. (The fake maps are crutches. Shouldn't create drastic differences.)

 

 

Diffuse for Specular Color

TDM shaders did variations on this, mixing in diffuse*0.75+0.25 and such to specular. I pulled that out when I decoupled specular from diffuse, because ideally specular shine amount would be set per-surface / texture. So, dull objects would have a dull shine to let more diffuse color mix in. But, there's static params in the shaders setting amount of specular to use. For shiny metals, it looks ok having white shine come off. But, dull rusty pipes, walls, etc.. not so much.

So, if the specular.rgb is missing (which acts as both specular map and specular color), I made the shaders fallback to using the diffuse.rgb as the specular color.

VCJnIV5.jpg

Using diffuse as-is, everything looks wet like it's raining or just rained. So, toning it down...

N379KLe.jpg

Diffuse * 0.1 as fallback spec color. Now it's looking normal again.

ekFQqPK.jpg

The color variation is more noticeable in shadows, b/c both specular fallback color and fresnel highlight fallback color rely on diffuse colo rnow. So, the brick is a darker highlight. The bronze metal is more orangish. The white metal door is grayish.

bHY8ep4.jpg

Vanity shot... fake AO is darkening seams more now while leaving the "body" of objects to shine through. (IE: the stones on the ground are now having a bit easier time having their highlights on top show up, b/c the normal map as fake AO is more interested in darkening the already dark seams between stones.

 

But, the wet-looking speculars brings up the idea of using a value piped in from the game engine to lerp between dry and wet specular values if environment is raining / damp or not. I'm not sure how level designers flag areas to do rain, or if the value could get piped into the shaders. But, it could create more dynamic environments. EG: walking in the streets in rain, and the streets look wet. Then walk inside some place, and the inside uses dry speculars. The next step on that would be to mix in environmental reflection to make the rain sheen look more rain sheeny. (Because just over-shining speculars tends to make a cheap but tacky wet look.)

outval = mix( dryval.rgb, wetval.rgb, vec3(rainamount) )

Image 5

(EG: The dark rain sheen on the road ahead and the white sheen on the tires is from a cubemap reflection that increases as the game engine's rain value increases, which is used as a lerp factor between dry and wet shading. The FUEL game engine piped in a rain value, and did cubemap reflection for water fresnel reflection. I just put them together in other object shaders to create rain effects on ground, vehicles, etc.)

 

Anyways, shaders are attached.

glprogs.stages.interaction.014.zip

  • Like 2
Link to post
Share on other sites

I think I know why we are perceiving such differences in specular strength.

I usually adjust my configuration to have lower than default gamma.

 

Try either:

 

r_postprocess_gamma 1.0

or

r_ambientGamma 0.85

or

r_postprocess_colorCurveBias 3.5

 

any adjustments that increase contrast will make the specular values look far too strong.

The ambient specular needs to scale relative to gamma in some way.

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 post
Share on other sites

Materials could be made to change dynamically between wet and dry versions by reading a parm set by the mapper, though that would mean making a lot of custom material decls. Also, regular shaderparms are set per-entity, but I'm now wondering: are all the global parms still used, after changes to bloom/ambient rendering?

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to post
Share on other sites

I have mostly tamed the specular and fresnel effect in the latest revision to match 1.03 appearance.

It looks outstanding on the Animated Grass test map with crazy fresnel effects on the rocky peaks.

Rocks in caves and other areas all see some of this benefit.

It also increased the legibility of the ornate normal map on the podium in Caduceus of St Albans

The Cathedral in "St Alban's Cathedral" has that nice dimensional definition near the ceiling by the column supports.

"A New Job" has more contrast and dimensional objects all the pure ambient lit areas of the streets.

One thing I was hopinq would happen is that the Holy Symbols in the first challenge in House of Locked Secrets would become more legible

but it seems they are still a little hard to read with the tamed settings. I will tinker more.

 

Thanks again!

 

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 post
Share on other sites

It's a good idea since tastes vary but it would require passing a parameter from C++ to GLSL and thus shader and "code side" changes.

Once we have a consensus on the final state of this, we can discuss integration and configuration options.

  • Thanks 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 post
Share on other sites
4 hours ago, madtaffer said:

nbohr1more, could you expose specular, fresnel effect with intensity and color parameters in TDM options panel ?

Yeah, kind of agree with this.

Fresnel is one of those things where everyone's gonna want to fiddle with it. Some want none or very small amounts. Others will want a lot.

Fresnel can be a "cheat" to see in the dark. Makes player feel like they have "echo vision" to sense surroundings in darkness. For a sneaking game, it can annoy some players.

It can also bring back PTSD for old gamers that remember playing games when fresnel first became a thing, and game companies were slapping tons of it in things making gamers go "why is everything lit up in darkness? what is this?!" (eg: jason brody in Far Cry 3 going into caves... I think they use amped up fresnel to give him "night vision", and it's odd). I think Thief 3 also did this. Def did fresnel with the frob-highlight, but I think they slapped it on a lot of things, and in monotone fashion, so everything had a dark blue cast to it beyond just ambient light. I guess they were trying to be atmospheric.

The other issue.. I think the lightgem works based on overall lighting (?).. so anything that amps up lighting could potentially impact player's ability to sneak. Fresnel is an additive effect (ie: final light color + fresnel enhancement). In small amounts it doesn't impact, but when ramped up it could possibly mess with light gem in what are supposed to be dark shadows. I don't know how light gem works, just guessing based on my testing.

When I was messing with fresnels in ambient light, the light-gem could never go completely dark, making it harder to sneak in the hammer area of Bikerdude's Training Mission. When I added in faux AO map to darken shadows up, it seemed to counter the brightening of the fresnel, so the light gem darkened again.

I definitely feel the "backlight" effect (if used in TDM) needs an on/off switch. Some folks hated that effect in Thief 4; they didn't want to feel like a dim spotlight was hovering over the player.

I added that effect in to help the player see in very dark areas ... eg: trying to read a sign or look for something on a shelf in a very dark area.. that very small amount of lighting is just enough to help the player see something, as if their vision has focused in. But, the 1-NdotL to kill speculars on the shiny floors in ambient light (b/c they made player look like they had a spotlight at their feet) killed the effect some.

  • Like 1
Link to post
Share on other sites
5 minutes ago, totallytubular said:

I think Thief 3 also did this. Def did fresnel with the frob-highlight, but I think they slapped it on a lot of things, and in monotone fashion, so everything had a dark blue cast to it beyond just ambient light. I guess they were trying to be atmospheric.

Maybe this?

On 2/15/2013 at 12:46 PM, GameDevGoro said:

The important difference, however, is that TDS never used specular maps. They faked it by using cubemaps. It worked out better I think, everything in the game looked softer and more organic thanks to this.

 

Edited by VanishedOne
Fixed cross-thread quoting.

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to post
Share on other sites
5 hours ago, VanishedOne said:

Materials could be made to change dynamically between wet and dry versions by reading a parm set by the mapper, though that would mean making a lot of custom material decls. Also, regular shaderparms are set per-entity, but I'm now wondering: are all the global parms still used, after changes to bloom/ambient rendering?

If things don't have custom textures for it, just use a fallback method of mixing in a reflective cubemap of the game world. That way if the game upgrades to PBR later, old levels still using old non-PBR assets will have a cheap fallback method to help blend in.

For the FUEL shaders, textures didn't have any wetness materials textures or such. I just added a % of reflective cubemap to sun light and shadow light as the rain increased. This gave everything a default wet look. I would tweak it if I could. EG: I was able to capture a flag to determine asphalt vs. dirt/ground. So, that let me tone down dirt sheen (b/c dirt becomes more mud, while asphalt tends to keep water on the surface).

My idea is to just find alternative, cheap approximation methods to simulate something if it can't be done the more technical way.

Is there a reflective cubemap vec3 I could pipe into the interaction & ambient fs shaders?

I could mock up something as a proof-of-concept

Link to post
Share on other sites

By the way, did you examine the source code?

2.09:

https://www.thedarkmod.com/sources/thedarkmod.2.09.src.7z

Latest SVN:

https://svn.thedarkmod.com/publicsvn/darkmod_src/trunk/

 

The lightgem works this way:

1) Replace the player with an Octahedron that has a special noshadow material

2) Place the camera inside the Octahedron

3) Capture an image facing up

4) Capture an image facing down

5) Stream the image data to a PBO

6) Evaluate all pixels to find the average pixel brightness and brightest pixel

7) Output a ligtgem value to the GUI and AI routine

( I'm sure there is more to it now, @cabalistic has significantly reworked where it falls in the rendering pipeline since 2.05 )

 

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 post
Share on other sites

FYI, speculars in Thief 3 were downright broken, that's why they weren't used. There was a specular slot in the materials, but I was never able to get a meaningful result there. That said, cubemaps were kinda broken as well. If you compare how cubemaps work here and in Thief 3, in TDM the reflection is modified by the normalmap, as it should. In Thief 3, it's sort of applied last, so it looks like a separate layer put on the top of diffuse and normalmap – unless you get rid of the diffuse texture. Then it gets modified by the normalmap, that's how they made the silver stuff for example.

But anyway, Thief 3 isn't really a good example of how materials should be used, that renderer was seriously broken and it's nothing short of a miracle that two games were made on it.

Link to post
Share on other sites
14 hours ago, nbohr1more said:

By the way, did you examine the source code?

2.09:

https://www.thedarkmod.com/sources/thedarkmod.2.09.src.7z

Latest SVN:

https://svn.thedarkmod.com/publicsvn/darkmod_src/trunk/

 

The lightgem works this way:

1) Replace the player with an Octahedron that has a special noshadow material

2) Place the camera inside the Octahedron

3) Capture an image facing up

4) Capture an image facing down

5) Stream the image data to a PBO

6) Evaluate all pixels to find the average pixel brightness and brightest pixel

7) Output a ligtgem value to the GUI and AI routine

( I'm sure there is more to it now, @cabalistic has significantly reworked where it falls in the rendering pipeline since 2.05 )

 

I downloaded Visual Studio and opened the source code, but haven't dug around much. Got sucked into the shaders, since I know a bit about those.

But your explanation confirms what I thought. Sort of makes me think that the fresnel backlight effect also needs a 1-NdotL to make it not glow underfoot, too, if it will start making it harder for player to sneak. But, I lowered the AO color and the speculars in ambient got 1-NdotL, which both toned down the shine underfoot.

I tried a cubemap as a rain sheen... in glprogs/parallaxCubeReflect.fs, there's "u_texture0" that says it's an environment cubemap. Figured since it was a uniform, I could tack it on another shader and have it pipe in (if I'm understanding uniforms correctly? They're sitting in register, and you can access them in a shader by calling them via uniform?)

Anyways, it didn't look good. I got it where objects, like tables, benches, chairs, etc.. all looked halfway decent with a cubemap sheen on them.. looked like clear-coat varnish was applied to them. But, things like floors, walls... it's like nothing was applied to them even though they were going through same processing. I could barely see any reflection on them. The cubemap reflection comes through looking like quicksilver / liquid metal, so have to tone down how much to use and then merge it with the diffuse. And, by the time you get something looking nice on one thing, everything else is bleh. So, I gave up on that for the time-being.

My next hack was trying to use the fake AO/spec map derived from dot(normal,0.33) as a depth map for parallax occlusion mapping. I followed the opengl tutorial for it. Basically had it mutli-sampling the dot(normal,0.33) over and over as the depth map for POM layers... it didn't go well, either.. lol. I think I've pushed the limits of how far my little fake map hack can go.

I thought about hacking in PBR code ... already got diffuse which can be used as albedo, got a normal map, can fake an AO map, and use it as fake spec / smoothness / roughness map. ... only thing missing is the metallic map which might be faked some how. Figured I'd just hack it and see how it looks. Haven't gotten around to that yet. My career as a data analyst revolves around making ad-hoc reports that fill a need quickly until a more robust reporting solution can get built. So, fake it until you make it. Sometimes it works, sometimes not. Issue in the working world is when the ad-hoc becomes the main solution rather than what it is: a glorified band-aid. But, a glorified band-aid might look nice temporarily, or as a fallback.

Link to post
Share on other sites
1 hour ago, totallytubular said:

I tried a cubemap as a rain sheen... in glprogs/parallaxCubeReflect.fs, there's "u_texture0" that says it's an environment cubemap. Figured since it was a uniform, I could tack it on another shader and have it pipe in (if I'm understanding uniforms correctly? They're sitting in register, and you can access them in a shader by calling them via uniform?)

No, it doesn't work like that. The cubereflect shader needs to be added in a material as a material stage, and in that stage you define the texture (in this case, a cubemap) that gets bound as u_texture0 to the shader.

The lighting shaders, on the other hand (i.e. everything called interaction) are completely separate and controlled entirely by code. They get exactly the textures they have now, and nothing more. If you add another texture uniform, at best it will point to a random texture, at worst it will give you garbage or even crash your driver.

Also, we don't currently have an automated system to get environment cubemaps. That's sort of on my roadmap for 2.10. But right now, the cubereflect shader is only usable with a manually created cubemap and a manually set up material.

  • Like 1
Link to post
Share on other sites
9 hours ago, totallytubular said:

I thought about hacking in PBR code ... already got diffuse which can be used as albedo, got a normal map, can fake an AO map, and use it as fake spec / smoothness / roughness map. ... only thing missing is the metallic map which might be faked some how. Figured I'd just hack it and see how it looks. Haven't gotten around to that yet. My career as a data analyst revolves around making ad-hoc reports that fill a need quickly until a more robust reporting solution can get built. So, fake it until you make it. Sometimes it works, sometimes not. Issue in the working world is when the ad-hoc becomes the main solution rather than what it is: a glorified band-aid. But, a glorified band-aid might look nice temporarily, or as a fallback.

You might find this of interest. (The shader it talks about can't be dropped into newer TDM versions since the ARB backend is gone.)

Some things I'm repeatedly thinking about...

 

- louder scream when you're dying

Link to post
Share on other sites

v 0.20

More of a cleanup and refactor than anything else, since code changes I made started looking like a hot mess.

  • created interaction.funcs.glsl to consolidate common funcs across common.fs & ambient.fs
  • 1.0 - x*x - y*y = 1.0 + dot( xy, -xy ) ... so switched normals partial derivative formula over to dot()

 

 

glprogs.stages.interaction.020.zip

  • Like 1
Link to post
Share on other sites

Looking pretty nice!

I think something is going wrong with "projected" ambient lights and "blendLights" as I am seeing lots of rectangular and diamond shaped

artifacts in places where these are supposed to exist.

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 post
Share on other sites
7 hours ago, nbohr1more said:

Looking pretty nice!

I think something is going wrong with "projected" ambient lights and "blendLights" as I am seeing lots of rectangular and diamond shaped

artifacts in places where these are supposed to exist.

You mean this...?

CQ6tD40.jpg

.. where it looks like a rectangle shape that's not taking the shaders into account?

I have no clue what's causing that. I see it randomly. On some levels it's like a massive volumetric fog effect is floating around causing cut-off seams to show up. Other times it's just windows. In Training Mission, some windows are fine, but others have this issue. It feels like some level assets are using old shaders or other shaders than what I'm messing with. I don't know.

Link to post
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.


×
×
  • Create New...