2025-07-31 21:42 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0005136Spring engineGeneralpublic2016-03-07 19:37
ReporterBeherith 
Assigned ToKloot 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version101.0 
Target VersionFixed in Version101.0+git 
Summary0005136: CustomUnitShaders graphical glitches - loss of tex1 and tex2
DescriptionAfter a few different units, using different texture sets, CustomUnitShaders starts assigning bogus texture1 and texture2 to units, some of which seem like random other textures, some are just blank ones with all teamcolor.

Ive been trying to locate wether the source of this bug is Lua or engine side, but have come up short so I'll post it here.
Steps To ReproduceCheckout bar:test, hit f11 to make sure you have "Extra Model Shading" enabled in the graphical settings, then '/give all'. Most of the units will have glitched textures, where the normal maps are fine and correct, but tex1 and tex2 are not the ones they should be.

You can validate that customunitshaders is on by looking at units with emissive textures, as those should flash on and off.

Oddly, toggling and untoggling customunitshaders fixes this bug, but toggling and untoggleing results in units losing self-shadowing.
Additional InformationI apologize if this is a purely customunitshaders bug, and not an engine bug.
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files

-Relationships
+Relationships

-Notes

~0015968

Beherith (reporter)

On screen00149, a different set of random tex1 and tex2 is bound to the large chickens in the center.

~0015969

gajop (developer)

I think I might have had a similar issue with it: http://i.imgur.com/TFpMP2T.jpg
using the updated version of the shader framework. To me it seemed as if too many different unit textures were accessed causing the old ones to be dropped from the cache and be invalid when used again.

Wasn't able to make a decent bug report out of it though.

~0015970

silentwings (reporter)

For completeness - this bug doesn't appear in 100.

~0015971

Kloot (developer)

Pretty sure it's an engine bug related to texture preloading.

On the framework side you'll probably want to fix:

  api_custom_unit_shaders.lua:
    normalmapping = (Spring.GetConfigInt("NormalMapping", 1) > 0)

  versus

  bgu_mainMenu.lua:
    Settings['NormalMapping'] = Spring.GetConfigInt('NormalMapping') == 1

(note the different default values passed to GetConfigInt)

~0015974

Anonymous (viewer)

Fix 1edab82e8aa55244fe14a64134752a9d10d421bb committed to develop branch: fix 0005136

a bad case of data-localification without checking for pointer
leakage; this means custom object materials are FUBAR in 101.0, repo: spring changeset id: 6726

~0016014

Kloot (developer)

NB: in the absence of 102.0, a workaround for this bug is to force all model textures to be loaded before the CUS framework by accessing any key of the model subtable:

[code]
for udid, ud in pairs(UnitDefs) do
    ud.model.midx
end
for fdid, fd in pairs(FeatureDefs) do
    fd.model.midx
end
[/code]

For BAR this won't hurt much because its textures are atlased. (Insert into e.g. http://imolarpg.dyndns.org/trac/balatest/browser/branches/BAR/luaui/widgets/api_unit_texture_preloader.lua)
+Notes

-Issue History
Date Modified Username Field Change
2016-03-04 13:59 Beherith New Issue
2016-03-04 13:59 Beherith File Added: screen00148.jpg
2016-03-04 14:02 Beherith Note Added: 0015968
2016-03-04 14:02 Beherith File Added: screen00149.jpg
2016-03-04 15:26 gajop Note Added: 0015969
2016-03-04 19:24 silentwings Note Added: 0015970
2016-03-04 19:38 Kloot Note Added: 0015971
2016-03-05 01:14 Kloot Assigned To => Kloot
2016-03-05 01:14 Kloot Status new => assigned
2016-03-05 02:19 Changeset attached => spring develop 1edab82e
2016-03-05 02:19 Anonymous Note Added: 0015974
2016-03-05 02:19 Anonymous Status assigned => resolved
2016-03-05 02:19 Anonymous Resolution open => fixed
2016-03-07 19:37 Kloot Note Added: 0016014
2016-03-07 19:37 Kloot Status resolved => feedback
2016-03-07 19:37 Kloot Resolution fixed => reopened
2016-03-07 19:37 Kloot Status feedback => resolved
2016-03-07 19:37 Kloot Fixed in Version => 101.0+git
2016-03-07 19:37 Kloot Resolution reopened => fixed
+Issue History