Leider ist der Eintrag nur auf English verfügbar.
Leider ist der Eintrag nur auf English verfügbar.
YES! I did it… finally I got all the OpenGL fun stuff together and managed to dynamically (as in through OpenGL) blend all the textures of a tile.
First I had to write my own GLSL Fragment Shader (WotLK version):
uniform sampler2D Layer0;
uniform sampler2D Layer1;
uniform sampler2D Layer2;")
uniform sampler2D Layer3;")
uniform sampler2D Alpha1;")
uniform sampler2D Alpha2;")
uniform sampler2D Alpha3;")
varying vec4 texCoord;")
void main (void)
{
vec4 l0 = texture2D( Layer0, texCoord.xy * 8);
vec4 l1 = texture2D( Layer1, texCoord.xy * 8);
vec4 l2 = texture2D( Layer2, texCoord.xy * 8);
vec4 l3 = texture2D( Layer3, texCoord.xy * 8);
vec4 a1 = texture2D( Alpha1, texCoord.xy);
vec4 a2 = texture2D( Alpha2, texCoord.xy);
vec4 a3 = texture2D( Alpha3, texCoord.xy);
gl_FragColor = l0 * (1 - a1.a - a2.a - a3.a) + l1 * a1.a + l2 * a2.a + l3 * a3.a;
}
Then I had to convince my program to use it:
Gl.glShaderSource(Shader, 1, New String() {FragShad}, FragShad.Length - 1)
Gl.glCompileShader(Shader)
Progra = Gl.glCreateProgram()
Gl.glAttachShader(Progra, Shader)
Gl.glLinkProgram(Progra)
Figuring out how to pass the parameters to the shader was a major pain in the butt… here’s how it works:
1. You create your textures as you normally would:
Dim Layer0 As Bitmap
Layer0 = Bitmap.FromFile("d:\temp\test\n2525\WinterspringSnowSolid_orig.png")
Gl.glGenTextures(1, LayerID0)
Dim LayerData As Imaging.BitmapData = Layer(i).LockBits(New Rectangle(0, 0, Layer(i).Width, Layer(i).Height), Imaging.ImageLockMode.ReadOnly, Imaging.PixelFormat.Format32bppArgb)
Gl.glBindTexture(Gl.GL_TEXTURE_2D, LayerID0)
Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA, Layer(i).Width, Layer(i).Height, 0, Gl.GL_BGRA, Gl.GL_UNSIGNED_BYTE, LayerData.Scan0)
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR)
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR)
Layer0.UnlockBits(LayerData)
2. Then you have to “tell” the program to use this texture (assuming it will be bound to GL_TEXTURE0):
Gl.glUseProgram(Progra)
Dim loc As Integer = Gl.glGetUniformLocation(Progra, "Layer0")
Gl.glUniform1i(loc, 0)
3. Now in the draw routine, you need to assign the texture to the selected texture slot:
Gl.glUseProgram(Progra)
Gl.glEnable(Gl.GL_TEXTURE_2D)
Gl.glActiveTexture(Gl.GL_TEXTURE0)
Gl.glBindTexture(Gl.GL_TEXTURE_2D, LayerID0)
Voila… it works… here’s the “proof” (this tile is from around the eastern end of the borean tundra):
I’ve yet to copy this code over from my test project to the wow2collada code (including all the texture fun associated with it, i.e. undoing all the precalculations I thought necessary at the time).
Cheers
Hamu
Hiho
Ok, I got busy (thanks to some very helpful posters on some forums…
I can now completely combine a layer in 10 seconds using a bicubically enlarged alphamap in order to get rid of any hard borders.
Here are some pics:
Layer 0:
Layer 1:
Layer 2:
Combined result:
Now, it still takes 10 seconds per tile, so generating the textures for one ADT region will still take around 10s x 256 = 2560s = ~ 45minutes… *sigh*. I think I’ll have to consider two things:
1. render it using several threads (I’ve got an 8 core system, so a speedup of around 6 should be realistic -> still 8minutes, but already much better)
2. get rendering done using something (a lot) faster than vb.net, i.e. C++ or so… however I’m too stupid to know how to do that
So much for now, more to follow…
Cheers
Hamu
Ok, so I tried to recreate the texture splatting of WoW in Blender…
Here’s what I came up with (besides precalculating the complete texture):
Basically, I recreated the overlay formula from the previous posts… it kind of works, however, it looks way too complicated to really be the right solution, I hope…
Cheers
Hamu
I have a fun problem to solve…
Terrain data from Wow files contains a heightmap and texture-layers.
There is a base map with height information:
Each map is comprised of 16×16 chunks:
Which are themselves made out of 8×8 tiles:
Here’s where the fun start…
Each of these 256 tiles has 1 base texture, for example:
This texture is of course repeated in X and Y 8 times in order to fill the whole chunk.
The result looks like this:
As you can imagine, this would look pretty bad in the game, so there are more textures layered above this base layer.
There are up to 3 additional layer each with
If I combine the first layer with the second layer, something like this comes out:
Unfortunately, my combination of these layers is quite wrong… hopefully some OpenGL wizzard can help me out here…
The code currently looks like this:
Gl.glEnable(Gl.GL_BLEND)
Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA)
Gl.glEnable(Gl.GL_ALPHA_TEST)
Gl.glAlphaFunc(Gl.GL_LESS, 0.9F)
Gl.glBindTexture(Gl.GL_TEXTURE_2D, Texture(TileN))
Gl.glColor4f(1.0F, 1.0F, 1.0F, 1.0F)
Gl.glCallList(Mesh(n))
Gl.glBindTexture(Gl.GL_TEXTURE_2D, Alphamap(TileN))
// The Alphamap has previously been split into 8x8 pieces in order
// to make it the same size as the Textures, so it can be drawn with the same vertexlist
Gl.glColor4f(1.0F, 1.0F, 1.0F, 1.0F)
Gl.glCallList(Mesh(n))
Cheers
Hamu
After being fed up with having to guess where each ADT tile belonged, I enhanced wow2collada to include a ADT explorer that can export tilesets.
Here’s the main grids for your reference (so you won’t have to go through the same hoops):
| Azeroth |
Kalimdor |
Outland |
Northrend |
![]() |
![]() |
![]() |
![]() |
You can download the high-res pictures either above (by clicking each of the images).
Cheers
Hamu
I revamped the UI to make it more responsive (render is in it’s own window) and moved away from DirectX9 in favor of OpenGL. Seams somewhat easier to manage…
Here’s a screenshot of the new UI with some submeshes untextured (a new debug function to make it easier to see invisible and/or ocluded stuff.
I have some funky challenges with transparency (the texture is transparent but if you look ingame, the result is NOT… weird…). I’ll do some digging around that…
The next big chunk is to add the whole animation stuff to the M2s (still excluding characters for now).
Life is good.
Hamu
Today’s a great day… first of all, I’m still stuffed from yesterday’s excellent curry (home made), on the other hand, I managed to get my preliminary exporter (OBJ format) to work with textures…
Finally I can actually get a model INTO Blender…
And the render in Blender:
As always, there remains a lot to still be done, but we’re getting there…
One thing I really don’t like yet is that all triangles are completely independent of each other, which is to say that there is massive duplication of vertices when rendering/exporting/manipulating. While this might be necessary for Direct3D (the primitive there is a triangle, have to look into mesh support), Blender can deal with meshes quite well. To get the above image, I removed doubles (around 10’000 vertices with identical coordinates) and added a smooth modifier + ambient occlusion (otherwise the picture would have been black on blue *grin*).
I learned more about .OBJ support in Blender and other programs than I really ever wanted… while according to the standard, the sequence of vertices, normals, vertexcoordinates and triangles doesn’t really matter, I only got it to work by adhering to a strict order of:
Next test will be to open and export Stormwind (around 6000 doodads, 254 buildings/meshes, plenty of textures). I expect this to either
(a) blow up my computer (unlikely, as I have a dual-quad-core with 16GB of memory)
(b) take a really long time (as in 30 minutes or so)
(c) crash the 3D subsystem
(d) generate an OBJ file that is unreadable due to its size
(e) all of the above
Well, dear reader, you’ll read all about it tomorrow or so.
Cheers
Hamu
Ah… I love Easter… a few days free to do as I please *grin*.
And of course, I worked on wow2collada… here’s the latest and greatest:
As you can see, full MPQ-support has been added (browseable tree) and on the picture, you see the smithy in Goldshire including all doodads and stuff… Of course there are still some (lots) of issues and missing features, but I’m slowly getting somewhere.
Happy egg-hunting
Hamu
Ok, I got some nice process over the weekend on my wow2collada program:
As you can see, I can now load multiple textures (BLPs)…
I had to write a BLP importer for vb.net (doesn’t support DXT5 yet).
Looking up a model’s textures from the model itself is annoying, you have to first look at some DBC files to get the right file… ah.. well..
Two annoying things remain: 1. I have to implement DXT5 as many models use that and 2. as you can see above, my Direct3D doesn’t support transparent textures too well (look at the eyes). The guy DOESN’T have funky sunglasses…
BTW: The program is at http://code.google.com/p/wow2collada/
If you use it for something, let me know… if you want to participate in working on it, let me know as well… if you find errors or have input… well, you know… let me know *grin*.
So much for now
Cheers
Hamu