Retera / WarsmashModEngine

An emulation engine to improve Warcraft III modding
GNU Affero General Public License v3.0
192 stars 37 forks source link

error: Too many fragment shader texture samplers #44

Open iodream opened 11 months ago

iodream commented 11 months ago

Hello. Warsmash is crashing for me when i try to load any map or campaign with this error on Linux.

It's an intel hd 3000 sandy bridge graphics card. A webGl test says it has Max Vertex Texture Image Units: 16

I also have a hybrid graphics laptop and the discrete Nvidia gt 520m card does run the game without problems. Max Vertex Texture Image Units: 32

Is this a bug or do i not meet Warmash's technical requirements? Thanks and awesome project.

Log file: 1689266279681.err.log

Retera commented 11 months ago

I have a computer that also has this issue. In order to solve the general case of the rendering of Warcraft 3 style terrain with only 16 texture units, a different algorithm or processing needs to be designed for rendering that. The manner in which I render the terrain was originally based on HiveWE per the notes and credits, and the HiveWE project is targeting fairly "new" hardware (probably newer than 2014 or something like that).

When I want to play Warsmash on my laptop that has only 16 texture image units, typically I go into the TerrainShaders file and delete the line of code that handles the 15/16 indices for the terrain tiles so that maps are restricted to about 14 different terrain tiles instead of the original Warcraft 3 limit that allows 16 per map. (Warsmash is using some extra texture slots for blight and some other things and so it goes past 16 on the hardware normally.)

In my case, once I delete the line of code for supporting those higher indices, a majority of maps still work fine and then the game runs on the older hardware. Maybe a toggle for this could be added, at least until a later date when I invent some different way of rendering terrain on the ground that is optimized to only use 16 texture units.

For what it's worth, it appears that my attempted fix for this on my other machine is actually currently in the code already, which is weird and should probably be made optional: https://github.com/Retera/WarsmashModEngine/blob/main/core/src/com/etheller/warsmash/viewer5/handlers/w3x/environment/TerrainShaders.java#L201

But when I added Fog of War a few months ago, I used another sampler so now it was back up to 17 instead of 16 and I didn't notice because I was on newer hardware recently.

tl;dr Your machine is not meeting the technical requirements of the Warsmash code exactly as it is written, but it's open source and possible to change the code. So for example if you deleted out fog of war, or deleted sample13 (one of the terrain tile slots used by maps) you could get it back to 16 texture units for your hardware with a very small code change.

linsmod commented 11 months ago

when on my phone using gles3.2, reports the same error. kept 13 then works.