WarsmashPreviewApplication has a member field named "viewer". That's the java-based port of the viewer originally written in javascript that I was copying from (
GitHub - flowtsohg/mdx-m3-viewer: A WebGL viewer for MDX and M3 files used by the games Warcraft 3 and Starcraft 2 respectively.)
After I copied it I had to add the lighting system since his original work did not have that system. So, for a world view (w3x/ map) I use the War3MapViewer class, but you may notice that when WarsmashPreviewApplication initializes his member field named "viewer" he creates an instance of "MdxViewer" and not an instance of "War3MapViewer" like the overworld gameplay stuff that I most often show videos of on Warsmash.
When using "MdxViewer", the lighting is then getting set based on a light direction passed to the
constructor of that class (it's exact value is controllabe
here, currently the vector {0.3f, 0.3f, -0.25f} with a negative Z so that it's light coming down from above), which is then
given to the light manager that gets created later. Currently it reuses the same light manager that the overworld gameplay view uses for Unit Portraits at the bottom of the screen in the UI. The "portrait light manager" class then uses this direction given to fill the
light data buffer with a hardcoded light who generally is formatted onto that buffer in the same format as what we see in
LightInstance.bind. If you wanted to refactor the code to be more readable, maybe the hardcoded light could be setup using a call to LightInstance.bind so that there is only one place in the code that turns the meaningful variable names into buffer contents in this format. Looks like I did not bother to set it up that way.
The formatted data in that buffer is then read from GLSL code on the GPU stuff
here if you're interested in the math of what those numbers get used for. Not sure if that's relevant to your problem. As you have probably seen, the math itself should support brighter lights and we just need to configure it to be brighter. Honestly I'm forgetting what causes the issue with models being dark that you are facing.
Have you tried changing this line
CURRENT_SHADER_TYPE = MENU
to instead assign
CURRENT_SHADER_TYPE = GAME
:
WarsmashModEngine/MdxViewer.java at ba2eb05207e8a7543076c6c48b3fbe2f296f8c00 · Retera/WarsmashModEngine
I'm not certain but something like that might be what you're looking for. Although the Portrait Light Manager stuff is shared between the ingame portrait and the general MDX viewer, I put in this static boolean as a hack to make the lighting on the menu screens match more closely to the War3 experience. I don't exactly understand why, but it's as though the srgb conversion is accidentally run 2x on the menus in Warcraft III but only 1x correctly in game or something like that. A lot of this is a fairly inexact science and I'm pretty sure the original game War3 is probably hacked together around the edges anyway. I just sometimes get inspired to put in hacks to increase how much mine reminds me of the experience that I want visually.
Edit:
Here is an example screenshot comparing why I did this:
Obviously in both cases I am not yet previewing the fog effects, but I assume that if I ever add those, then it would probably become as similar as I am ever going to get it, I assume.
Edit 2:
Did you try
git checkout experimental
for the experimental branch, also? In that version, the
main
method for WarsmashPreviewApplication is already setting it to
GAME
shader type, actually. But if you are building the main/master branch then it's probably not fixed.