wowserhq / wowser

World of Warcraft in the browser using JavaScript and WebGL
MIT License
240 stars 63 forks source link

Fix: Texture settings #113

Closed fallenoak closed 8 years ago

fallenoak commented 8 years ago

This fixes a few issues with how textures are handled in Wowser. See issue #106 for an example of what's fixed.

M2Material should have flipY set to false on its textures WMOMaterial disables flipY, but M2Material doesn't disable it. Instead, M2Material is doing this in its shader:

texture1Coord = vec2(uv[0], -uv[1]);
texture2Coord = vec2(uv[0], -uv[1]);

This is fairly pointless, since just setting flipY to false a la WMOMaterial prevents the need to do the negation in the shader.

This is now fixed, and flipY is set to false for M2Material (matching WMOMaterial).

Textures should be cached and loaded based on texture settings Currently, the TextureLoader assumes that, for a given texture path, it will always be used with the same settings (wrapS, wrapT, flipY, etc). This isn't necessarily true, since texture settings are defined in the WMO and M2 data files, and some (probably many) textures are reused between various models.

This is now fixed, and differing settings for wrapS, wrapT, and flipY result in unique textures being loaded and cached.

fallenoak commented 8 years ago

I've given this PR a whirl in several places, but it'd probably be a good idea to test some on your end, too, before merging.

timkurvers commented 8 years ago

Floated through a bunch of different zones, awesome stuff! :tada:

fallenoak commented 8 years ago

Huzzah!