I have been trying to load one of the maps from Alien Arena, dm-turbo2k8, into the Windows SVN build of Quake2World for performance testing purposes, and I am experiencing some issues trying to get the shaders and the normal and parallax mapping to work correctly. I checked out your shader guide at http://quake2world.net/books/documentation/creating-levels/materials-system, but since Alien Arena uses rscript for its shader system, the commands and syntax are different. How compatible is Q2W's shader system with Quake 3's? Rscript appears to be more compatible with Quake 3 from a syntax standpoint although it has some commands which don't appear to have corresponding functions in Quake 3' shader system. Do you have any suggestions on how to translate from rscript to Q2W's shader system?
Regarding Q2W's normal and parallax mapping implementation, does every texture which will use normal and/or parallax mapping need to be defined in a map's materials file (materials\map.mat) or does Quake2World automatically apply normal and parallax mapping for any texture which has a corresponding *_nm suffix? I ask because while Quake2World's official maps like "trial.bsp" loads properly and shows such mapping, AA's dm-turbo2K8 does not. Dm-turbo2K8's textures which also have normalmap versions aren't rendered at all (as all black). The only way to have these textures rendered is to set "r_deluxemaps" to 1 which turns off normal and parallax mapping. However, if I first load Quake2World's trial.bsp map and then subsequently load AA's dm-turbo2k8, the AA map's textures are rendered properly with the normalmap and parallax effects applied (with r_deluxemaps 0). So, do you know why I have to load a Q2W map before those effects work? Is it because I don't have any of AA's textures which use normal maps defined in its materials file (materials\dm-turbo2k8.mat)?
Finally what does Q2W use for specular maps? I don't see any texture files with an "*_sm" suffix on them.
Hi SA. Porting an AA map to Q2W (properly) will require recompiling it. AA fudges the per-pixel lighting input, i.e. it does not provide proper directional lighting information to its shaders. Quake2World, on the other hand, bakes this directional information into a separate chunk of light data called the deluxemap during the static lighting compile. Because dm-turbo2k8.bsp does not contain a deluxemap lump, Quake2World disables per-pixel lighting on world surfaces. That is why you don't see any fancy effects on the map.
As for specular maps, they are not yet supported. My per-pixel lighting implementation requires 4 texture units as it is (diffuse, lightmap, deluxemap, normalmap). Kevlarman is exploring a way to merge specular map information into the blue channel of the normalmap image, but this isn't quite ready yet. Still, Q2W's materials system allows you to control specularity per-material, so you can have high specularity on metal, moderate on rocks, and low on wood, etc..
The last thing you asked about, rscripts, are for the most part available in Q2W. But you're right, the syntax of the materials file stages is significantly different than rscripts or Q3A shader scripts. But porting over most animations should be relatively straightforward.
Hope this helps. Come find me on IRC if you have further questions.
"Quake2World, on the other hand, bakes this directional information into a separate chunk of light data called the deluxemap during the static lighting compile. Because dm-turbo2k8.bsp does not contain a deluxemap lump, Quake2World disables per-pixel lighting on world surfaces. That is why you don't see any fancy effects on the map."
So, when I do see normal and parallax mapping on an AA map after first loading one of Q2W's native maps like trial.bsp, is Q2W simply using the deluxemap lump information from the previous map (trial.bsp) since the AA map has no such information and did not replace it?
Here is a screenshot of dm-turbo2k8 under Q2W with normal and parallax mapping applied after loading it after trial.bsp. It doesn't look too bad, but I don't know what those black patches are in the textures unless they are specular maps that aren't getting applied or lighting information from trial.bsp which is being incorrectly applied to dm-turbo2k8. When I turn off deluxe maps (r_deluxemaps 0), the textures render normally without the black spots but they are flat of course.
Regarding Q2W's parallax mapping does it use separate *_hm.ext" texture files if they are present? I ask because AA does, and Q2W appears to be using those textures for the dm-turbo2k8 map. When I change the "r_parallax" CVAR to enable and disable parallax, I can see the difference so it is obviously using either the *_hm.ext files or the alpha channel of the AA *_nm.ext files.
As you can also see in that screenshot, the shaders for some things are broken like the grating and the water below it. And ideas on what to do about the water? Q2W doesn't appear to be applying a default water shader to it, and AA's rscript shader for it simply uses a "distort" command which I don't know how to translate to Q2W's shader system.
"Kevlarman is exploring a way to merge specular map information into the blue channel of the normalmap image"
I do not understand Why are you not using a separate image file for this rather than merging it with the existing normal map?
"But porting over most animations should be relatively straightforward."
I am having one hell of a time trying to do this because first I am not that familiar with Quake 3's shaders and second because rscript has some commands which don't appear to correspond with anything in stock Quake 3. Finally I keep having to search back through Q2W's source to see what its shader syntax is, and even then Q2W doesn't generate any error messages on the common shaders in the scripts subdirectory so I can't tell if my converted shaders aren't working because of syntax, improper texture paths, or for some other reason.
I'm not entirely sure why Q2W is loading any per-pixel lighting information on dm-turbo2k8.bsp. It really should not be. Unless Irritant also changed his BSP_VERSION constant to what the Q2W format value is. Previously, AA has used the stock Quake2 BSP_VERSION. You would have to verify with him. If AA maps still use the stock Q2 version constant, and Q2W is in fact loading per-pixel lighting stuff, that's a bug.
r_deluxemap 0 does not do what you think it does. Use one of r_bumpmap 0, r_lighting 0, and finally r_programs 0 to reduce GLSL functionality (in that order to increasingly reduce GLSL usage).
Q2W does not use separate heightmap textures. The normalmap format is clearly specified in the documentation. The materials file syntax is also pretty well documented there, too. You should probably have a read over the entire mapping guide. You're not supposed to have to read the source code to figure out how to map for this engine.
As for not using a separate texture for specular maps, I mentioned this explanation in my previous reply. Because I use deluxemaps for per-pixel lighting, I'm already employing 4 texture units (diffuse, lightmap, deluxemap, normalmap). Very few systems support > 4 texunits. However, kevlarman has identified an opportunity to steal the blue channel in the normalmap for including specular information. We're working out the practicality of that approach now.
"If AA maps still use the stock Q2 version constant, and Q2W is in fact loading per-pixel lighting stuff, that's a bug."
I believe that AA still uses the stock Quake 2 BSP format as its map compiler hasn't changed. Well it's not a bad bug because even incorrect lighting information is better than none as it does allow normal maps to work on old maps even if it does result in some black patches in the textures. This is only possible if a previously loaded map has that information. I also noticed that older Q2W maps from the "pre-per-pixel" subdirectory of your SVN such as "resurrection" don't suffer from that texture problem with normal maps enabled. Do they have deluxemap information?
"r_deluxemap 0 does not do what you think it does. Use one of r_bumpmap 0, r_lighting 0, and finally r_programs 0 to reduce GLSL functionality (in that order to increasingly reduce GLSL usage)."
Yes, after I posted that I discovered that setting r_bumpmap to 0 has the same effect in removing the black spots and rendering the map textures flat and does so without restarting the renderer.
"Q2W does not use separate heightmap textures. The normalmap format is clearly specified in the documentation."
I read the documentation, but I was and still am trying to figure out why parallax maps still worked on that AA map even though its normal map textures don't have height map information in the alpha channel. I was wondering if Q2W was using the *_hm texture files instead.
"The materials file syntax is also pretty well documented there, too."
I disagree as it doesn't appear to contain all of the available shader commands. For example Q2W's scripts\common.shader uses commands and syntax which differ from that guide.
"As for not using a separate texture for specular maps, I mentioned this explanation in my previous reply."
The problem was that I didn't understand the difference between the deluxemap and the normalmap units nor did I know about the 4 unit limit.
scripts/common.shader is for Gtk/NetRadiant. The engine never reads this file. Our materials file syntax is documented on this site as mentioned above.
Thanks for that clarification. I was pulling my hair out trying to figure out why the shaders I added to that directory and shaderlist.txt weren't working.