View Issue Details

IDProjectCategoryView StatusLast Update
0005718The Dark ModFeature proposalpublic23.07.2024 11:36
ReporterBikerdude Assigned Toorbweaver  
PrioritynormalSeveritynormalReproducibilityN/A
Status closedResolutionno change required 
PlatformPCOSWindowsOS Version10
Product VersionTDM 2.10 
Fixed in VersionTDM 2.10 
Summary0005718: Vertex blended model material unable to support two bumpmaps.
DescriptionAs Greebo added a new function into DR 2.14 for exported .LWO models to retain vertex colours (blend data for vertex blended models) -

- https://bugs.thedarkmod.com/view.php?id=5717

I figured it would be a good idea if support for more than one bump map's could be added for vertex blended models to the core mod. As it is, the mapper can only choose one atm, so blended models will look odd if the mapper isn't careful.
Additional InformationHere is an example blend material I made for NHAT4, no matter what I tried only tecond bump-map was ever shown in-game -

textures/blend/cave_gravel_blend
{
    qer_editorimage textures/darkmod/stone/natural/grey_cracked_001_ed
    surftype15
    description "stone & gravel blend texture"

// Vertex colour stage

    {
        blend diffusemap
        map textures/darkmod/stone/natural/grey_cracked_001
        VertexColor
    }
    {
        blend bumpmap
        map textures/darkmod/stone/natural/grey_cracked_001_local (this bump-map 'is not' recognised by the engine)
        VertexColor
    }

// Inverse Vertex colour stage
    
    {
        blend diffusemap
        map textures/darkmod/nature/dirt/stones_sand01
        InverseVertexColor
        scale 3,3
    }
    {
        blend bumpmap
        map textures/darkmod/nature/dirt/stones_sand01_local (this bump-map 'IS' recognised by the engine)
        InverseVertexColor
        scale 3,3
    }
}
TagsNo tags attached.

Relationships

related to 0005717 closedgreebo DarkRadiant LWO2 Model Exporter doesn't write vertex colours 
related to 0005862 resolvedstgatilov The Dark Mod Backface lighting + bumpmapping broken 

Activities

nbohr1more

nbohr1more

21.08.2021 01:02

developer   ~0014308

Ah, I just noticed:

grey_cracked_001__local

has two underscores...

It should be:

grey_cracked_001_local
Bikerdude

Bikerdude

21.08.2021 09:49

reporter   ~0014309

Corrected typo above, but this doesn't fix/effect the issue. The game will only recognise one bump-map per blended material.
Bikerdude

Bikerdude

19.09.2023 15:35

reporter   ~0016068

All we need to do is have the bumpmap at the beginning of each vertex stage in the material def and only assign the 'vertex' and 'inversevertex' lines to the diffuse/specular stages. And on a side note we can add specular maps to the vertex stages aswell.
after.png (27,226 bytes)   
after.png (27,226 bytes)   
before.jpg (72,144 bytes)   
before.jpg (72,144 bytes)   
image.png (1,284,382 bytes)
Bikerdude

Bikerdude

22.09.2023 10:46

reporter   ~0016078

I have a attached a test map so the team can get users to test this on low end GPU's such as Intel Arc or ATi/Amd to make sure it looks and works ok.
before.png (544,670 bytes)
after-2.png (805,401 bytes)
BlendTest.7z (5,110,030 bytes)
Bikerdude

Bikerdude

22.12.2023 14:35

reporter   ~0016253

See note from 19.09.2023 15:35, 0005718:0016068 or fix. This can be closed, unless the team want to test further.
stgatilov

stgatilov

06.06.2024 06:13

administrator   ~0016726

I downloaded BlendTest.7z, and I see material with vertex color there, but it is not applied to anything.
Is there something with vertex color that it can be applied to?
Bikerdude

Bikerdude

06.06.2024 08:29

reporter   ~0016727

@Stgatilov

Ive created an updated version of the map for you, see attached.
blendtest.pk4 (1,820,005 bytes)
stgatilov

stgatilov

06.06.2024 16:39

administrator   ~0016728

Last edited: 06.06.2024 16:42

Thanks!
But how do I see that it does NOT work?

I mean: grass + road look fine with this pk4.
I can verify in debugger that proper normal map is combined with appropriate diffuse map.
It is also OK if I set vertexColor / inverseVertexColor in all 4 stages, not just in 2 of them.

UPDATE: I see that road gets grass bumpmap if I swap order of diffuse/bump stages.
Although I don't see much difference visually to be honest...
Is it the problem?
Is there any kind of specification anywhere on how such multiple interaction materials?
Bikerdude

Bikerdude

06.06.2024 16:58

reporter   ~0016729

Nothing need to be fixed, see my note from the 22.12.2023 @14:35.
nbohr1more

nbohr1more

06.06.2024 17:04

developer   ~0016730

According to OrbWeaver , there are still some problems:

https://forums.thedarkmod.com/index.php?/topic/22179-vertex-blending-not-working-with-bump-maps/#comment-495048

but the may be a red herring.

Additional refs:

https://wiki.thedarkmod.com/index.php?title=DrVertexBlend_(tutorial)

https://wiki.thedarkmod.com/index.php?title=Vertex_Painting_in_Lightwave
Bikerdude

Bikerdude

06.06.2024 18:27

reporter   ~0016731

Well Ive used VB in several maps since resolving the issue so I know its works now.

I cant speak to Orbweavers issue, as what is talking about is way above my head..
nbohr1more

nbohr1more

09.06.2024 05:16

developer   ~0016733

Last edited: 09.06.2024 05:17

It has been concluded that the only problem is on the DR side.

The correct material specification is:

1) Normal Map
2) Diffuse
3) Specular

See "Rendering Order":

https://iddevnet.dhewm3.org/doom3/index.html
stgatilov

stgatilov

09.06.2024 09:01

administrator   ~0016734

I agree this is not a bug to be fixed, but I believe issue should not be closed as is =)
I'd like to try implementing a console warning for the cases where stages seemingly go in wrong order.
stgatilov

stgatilov

09.06.2024 11:01

administrator   ~0016735

I added a check that each block detected in SortInteractionStages has at most one instance of each stage type.

Here is the list of warnings I get on all core materials:
WARNING:Material 'bc_flaskglass': duplicate interaction stages B:1 D:1 S:2
WARNING:Material 'bc_lanternglass_unlit_colorme': duplicate interaction stages B:1 D:2 S:0 (hint: bump must be first)
WARNING:Material 'hlantern': duplicate interaction stages B:1 D:2 S:1 (hint: bump must be first)
WARNING:Material 'large_green_leaf_normals_alpha': duplicate interaction stages B:1 D:2 S:0 (hint: bump must be first)
WARNING:Material 'sawblade': duplicate interaction stages B:1 D:2 S:1 (hint: bump must be first)
WARNING:Material 'steam_engine_glassreadouton': duplicate interaction stages B:1 D:2 S:0 (hint: bump must be first)
WARNING:Material 'tdm_grass_model_dense': duplicate interaction stages B:1 D:2 S:0 (hint: bump must be first)
WARNING:Material 'tdm_grass_model_dense_colored': duplicate interaction stages B:1 D:2 S:0 (hint: bump must be first)
WARNING:Material 'tdm_potglass2': duplicate interaction stages B:1 D:2 S:1 (hint: bump must be first)
WARNING:Material 'textures/darkmod/door/wood/french_door': duplicate interaction stages B:1 D:2 S:0
WARNING:Material 'textures/darkmod/metal/grate/girder_victorian': duplicate interaction stages B:1 D:2 S:1 (hint: bump must be first)
WARNING:Material 'textures/darkmod/metal/grate/girder_victorian_moss': duplicate interaction stages B:1 D:2 S:1 (hint: bump must be first)
WARNING:Material 'textures/darkmod/metal/grate/grate_rusted_flat_seethru': duplicate interaction stages B:1 D:2 S:0 (hint: bump must be first)
WARNING:Material 'textures/darkmod/weather/test_rain01': duplicate interaction stages B:1 D:2 S:0 (hint: bump must be first)
WARNING:Material 'textures/darkmod/weather/test_rain03': duplicate interaction stages B:1 D:2 S:1 (hint: bump must be first)
WARNING:Material 'textures/glass/dull_opaque01_moonlit': duplicate interaction stages B:1 D:2 S:1 (hint: bump must be first)
WARNING:Material 'textures/water_source/sea_wave_01': duplicate interaction stages B:1 D:2 S:0 (hint: bump must be first)
WARNING:Material 'utility_grate_001': duplicate interaction stages B:1 D:2 S:0 (hint: bump must be first)
WARNING:Material 'washboard_tin': duplicate interaction stages B:1 D:1 S:2 (hint: bump must be first)

Some materials have e.g. two diffuse stages with mutually exclusive conditions, which is supported by the engine.

The full behavior is this:
1) If specular or diffuse stage is present but bump stage is missing, then "bumpmap _flat" is added implicitly to the end.
2) Then stages are broken into contiguous blocks, and each block is stable-sorted in order: bump, diffuse, specular.
  If the first stage is bump, then stages are split in such a way that: every block has exactly one bump stage, and it is the first stage in block.
  If the first stage is not bump, then all stages constitute a single block and are sorted together.
3) Renderer backend goes through stages in their order after sorting.
  Stages disabled by "if" condition are skipped. It seems that nodiffuse/nospecular also force skipping respective stage after 0004292.
  A new interaction block when 1) we meet a bump stage, or 2) we meet a second diffuse or specular stage.
  If a block has no bump stage (happens on duplicate diffuse/specular), then _flat is implicitly used.
*) Ambient stages are completely irrelevant: while they are present and are reordered, you can assume the interaction behavior is the same is if they did not exist.

As you see, this is a huge mess.
Trying to fix anything here or add warnings will only make the situation worse.

I think the only path forward is to add "interaction separator" syntax to materials, which would force interaction block split at all levels, and ensure no reordering across it happens.
Also drop that stupid statically added implicit bump stage when at least one separator is present --- TDM already adds it in backend anyway.

Related Changesets

DarkRadiant: master 1704aeb7

11.06.2024 19:20

orbweaver


Details Diff
0005718: fix rendering of vertex blend between two materials

This required fixes in two places:

- Remove the sorting of material stages in OpenGLShader, which placed
ALL bump maps before ALL diffuse maps. This discarded vital
information about which pairs or triplets of maps needed to be bound
together in interaction passes. Sorting of bump maps before diffuse
maps is necessary, but this must be done by the artist in the MTR
decl, otherwise the engine will not render the blend correctly.
- When we assemble the maps into D/B/S triplets in the RegularLight
rendering code, treat bump maps as "delimiters" which start a new
interaction pass (via a new clear() method). If we don't do this we
end up with unwanted extra passes: a MTR which declares a sequence
{B1, D1, B2, D2} generates interaction passes {B1, D1}, {D1, B2},
{B2, D2} which gives the wrong result.

Note that 0005718 is actually a Dark Mod bug, but the investigation led to
the discovery of this incorrect rendering behaviour in DarkRadiant. The
actual engine renderer seems to produce correct results provided the
material stages are correctly sorted bumpmap-first in the decl.
Affected Issues
0005718
mod - include/ishaderlayer.h Diff File
mod - radiantcore/rendersystem/backend/OpenGLShader.cpp Diff File
mod - radiantcore/rendersystem/backend/RegularLight.cpp Diff File
mod - radiantcore/rendersystem/backend/RegularLight.h Diff File

Issue History

Date Modified Username Field Change
20.08.2021 20:00 Bikerdude New Issue
20.08.2021 20:10 Bikerdude Relationship added related to 0005717
20.08.2021 20:12 Bikerdude Description Updated
21.08.2021 01:02 nbohr1more Note Added: 0014308
21.08.2021 09:46 Bikerdude Additional Information Updated
21.08.2021 09:49 Bikerdude Note Added: 0014309
02.01.2022 12:36 nbohr1more Relationship added related to 0005862
06.08.2022 10:23 Bikerdude Product Version TDM 2.09 => TDM 2.10
19.09.2023 15:35 Bikerdude Note Added: 0016068
19.09.2023 15:35 Bikerdude File Added: after.png
19.09.2023 15:35 Bikerdude File Added: before.jpg
19.09.2023 15:35 Bikerdude File Added: image.png
22.09.2023 10:46 Bikerdude Note Added: 0016078
22.09.2023 10:46 Bikerdude File Added: before.png
22.09.2023 10:46 Bikerdude File Added: after-2.png
22.09.2023 10:46 Bikerdude File Added: BlendTest.7z
22.12.2023 14:35 Bikerdude Fixed in Version => TDM 2.11
22.12.2023 14:35 Bikerdude Note Added: 0016253
27.05.2024 17:07 stgatilov Fixed in Version TDM 2.11 =>
27.05.2024 17:07 stgatilov Target Version => TDM 2.13
06.06.2024 06:13 stgatilov Note Added: 0016726
06.06.2024 08:29 Bikerdude Note Added: 0016727
06.06.2024 08:29 Bikerdude File Added: blendtest.pk4
06.06.2024 16:39 stgatilov Note Added: 0016728
06.06.2024 16:39 stgatilov Note Edited: 0016728
06.06.2024 16:42 stgatilov Note Edited: 0016728
06.06.2024 16:58 Bikerdude Note Added: 0016729
06.06.2024 17:04 nbohr1more Note Added: 0016730
06.06.2024 17:04 nbohr1more Status new => feedback
06.06.2024 18:27 Bikerdude Note Added: 0016731
06.06.2024 18:27 Bikerdude Status feedback => new
09.06.2024 05:16 nbohr1more Note Added: 0016733
09.06.2024 05:17 nbohr1more Assigned To => orbweaver
09.06.2024 05:17 nbohr1more Status new => closed
09.06.2024 05:17 nbohr1more Resolution open => no change required
09.06.2024 05:17 nbohr1more Fixed in Version => TDM 2.10
09.06.2024 05:17 nbohr1more Target Version TDM 2.13 =>
09.06.2024 05:17 nbohr1more Note Edited: 0016733
09.06.2024 09:01 stgatilov Note Added: 0016734
09.06.2024 11:01 stgatilov Note Added: 0016735
09.06.2024 11:01 stgatilov Status closed => assigned
09.06.2024 11:01 stgatilov Assigned To orbweaver => stgatilov
09.06.2024 11:01 stgatilov Status assigned => new
15.06.2024 13:49 stgatilov Assigned To stgatilov => orbweaver
15.06.2024 13:49 stgatilov Status new => closed
23.07.2024 11:36 orbweaver Changeset attached => DarkRadiant master 1704aeb7