User:SirYodaJedi/Porting IdTech 3 maps to Source/Shader2VMT: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
Line 4: Line 4:
=== SurfaceParm commands ===
=== SurfaceParm commands ===
; alphashadow
; alphashadow
This uses the alpha channel of q3map_lightImage to cast [[texture shadows]].
This uses the alpha channel of q3map_lightImage to cast [[texture shadows]]. VRAD doesn't quite have as much control over texture shadows, so some creativity might be needed.
; detail
[[%CompileDetail]]
; metalsteps
Use a metallic [[$surfaceprop]]
; nolightmap
; nolightmap
Lightmaps are not generated for this material.
Lightmaps are not generated for this material.
This does '''not''' necessarily mean the surface is unlit; it still per-vertex lighting calculated for it unless q3map_noVertexLight is used (but whether they are actually used depends upon if rgbGen vertex is used, afaik)
This does '''not''' necessarily mean the surface is unlit; it still per-vertex lighting calculated for it unless q3map_noVertexLight is used (but whether they are actually used depends upon if rgbGen vertex is used, afaik)
; nomarks
[[$nodecal]]
; nosteps
Use the <tt>default_silent</tt> [[$surfaceprop]]


=== Q3Map_* commands ===
=== Q3Map_* commands ===

Revision as of 13:24, 9 June 2024

Some miscellanea for the User:SirYodaJedi/Porting IdTech 3 maps to Source#Converting materials section that would bloat the page if put there.

Per material

SurfaceParm commands

alphashadow

This uses the alpha channel of q3map_lightImage to cast texture shadows. VRAD doesn't quite have as much control over texture shadows, so some creativity might be needed.

detail

%CompileDetail

metalsteps

Use a metallic $surfaceprop

nolightmap

Lightmaps are not generated for this material. This does not necessarily mean the surface is unlit; it still per-vertex lighting calculated for it unless q3map_noVertexLight is used (but whether they are actually used depends upon if rgbGen vertex is used, afaik)

nomarks

$nodecal

nosteps

Use the default_silent $surfaceprop

Q3Map_* commands

q3map_alphaGen const <norm>

$alpha <norm>

q3map_colorGen const ( <red> <green> <blue> )

Constant vertex color. Use $color or $color2, depending upon the shader.

q3map_lightImage <texturepath>

This is used for texlight color, bounced light reflectivity, and texture shadows (both opaque and color-tinted). If the lightImage texture is a JPG, then <texturename>_alpha.jpg should be treated as the alpha channel, if present. If absent, qer_editorImage is used instead. If that is also absent, then the first non-$lightmap texture map is used.

q3map_lightRGB <red> <green> <blue>

Texlight color, used instead of the average color of the texture. The values are normalized to 0-1 and will need to be converted to the 0-255 range. This is as simple as multiplying each value by 255 and rounding to the nearest whole integer.

q3map_noFog

$nofog

q3map_normalImage <texturepath>

This is a normal map, which is used to create shadows when baking lightmaps, simulating bumpmapping. Source supports real bumpmapping (which looks a lot better when interacting with dynamic lights), so go ahead and use this as a $bumpmap.

q3map_rgbGen const ( <red> <green> <blue> )

Same as q3map_colorGen

q3map_surfaceLight <intensity>

Put the texture in a RAD file. By default, the emission color is the average color of the q3map_lightImage, unless q3map_lightRGB is defined.
The easiest way to determine the average color of an image is to generate a 1x1 box mipmap. Using Gimp or Paint.NET, set the image scaling mode to "bilinear", then repeatedly rescale both axes by 50% until the canvas is 1x1 (we don't want to do a direct downscale, as this results in some strong approximations), then use the color picker to determine the 0-255 RGB values.

q3map_surfaceModel <modelpath> <density> <odds> <minscale> <maxscale> <minangle> <maxangle> <oriented>

Like detail props. Annoyingly, VBSP has a bug that makes %detailtype not work correctly on brushes 99.9% of the time, so you might want to either take the time to convert the geometry to displacements (which it might need to be anyway for blended textures), or place prop_static or prop_detail entities manually.

Texture-related stuff

noMipMaps

Set the "no mipmaps" flag in the applicable VTFs

noPicMip

Set the "No LoD" flag in the applicable VTFs

noTC (in JK2, JA)
noCompress (in WolfET)

Don't use DXTn texture compression when creating the applicable VTFs (use BGR565, BGR888, or BGRA8888)

allowcompress (in WolfET)

Use DXT1 or DXT5 texture compression when creating the applicable VTFs, even if you are making most of the VTFs uncompressed

WolfET "implicit" materials

Wolfenstein Enemy Territory has some parameters that can be used as a shorthand for materials with only a diffuse map and lightmap, instead of defining all the texture stages for a material. These either contain a texture path, or use -, which uses the name of the material as the texture path. If you're curious how these work in WolfET, see this pastebin.

implicitMap <texturepath>

Material is opaque; no additional VMT parameters necessary.

implicitMask <texturepath>

Material is alpha-tested and backface culling is disabled; use $alphatest, $alphatestreference 0.5, and $nocull.

implicitBlend <texturepath>

Material is alpha-blended and backface culling is disabled; use $translucent and $nocull


Other

qer_editorImage <texturepath>

This is roughly equivalent to %tooltexture, although it differs slightly in that it can also be used in the 3D view for alignment purposes.

cull none
cull disable

$nocull

deformVertexes autoSprite

$spriteorientation VP_PARALLEL

deformVertexes autoSprite2

$spriteorientation VP_PARALLEL_ORIENTED

Per texture stage

map <texturepath>

This is the texture. It may be any sort of texture, not necessarily just a diffuse texture.

clampMap <texturepath>

Like `map`, but clamps the UV coordinates to prevent usage as a tiled texture. Set these in the VTF.

animMap <texturepath>

Like `map`, but animated. The number before the texture list indicates the frame rate. Combine these into a single VTF and use a material proxy to set the animation. Up to 8 frames in vanilla Quake III. Up to 16 frames in vanilla RTCW and WolfET. Up to 32 frames in vanilla Jedi Academy.

clampAnimMap <texturepath>

Like clampMap and animMap combined. Not in vanilla Quake 3.

videoMap <videopath>

Like `animMap`, but uses a ROQ video file instead of defining a set of individual image files. This allows for much longer animations, but lacks an alpha channel. Use ffmpeg -i input.roq out%03d.png to extract all the frames from the ROQ, and ffprobe input.roq to determine the original framerate.

blendFunc <func>

Can blend textures together (detail textures, glowing textures, etc.), be used for translucency, or even do specular lighting, depending upon parameters and stage position. These directly line up with OpenGL's glBlendFunc values, but also have three shorthand options:

alphaFunc <func>

Alphatesting. Unlike Source, Quake III supports alpha-clipping translucent textures. Any textures with translucency will need to not have alpha-testing when ported to Source, and may need to be edited (to sharpen the alpha channel). It takes one parameter:

Func Description VMT equivalent and additional setup
GT0 Greater Than 0.

Usually used in conjunction with a translucent blendFunc, to avoid rendering the surface where completely transparent.

If not translucent (rare):
LT128 Less Than 128.

This designates an inverted alpha channel.

If not translucent:

First invert the alpha channel in an image editor (linear invert).

GE128 Greater than or Equal to 128.

Standard alpha testing; anything less than 127 will be transparent, and anything greater than or equal to 128 will be opaque.

If not translucent:
GE192 Greater than or Equal to 192.

Added in Jedi Academy. Like GE128, but with the clipping threshold set to 192

If not translucent:
tcGen environment

Stage is an environment map; use as a $envmap. Subsequent stages use the alpha channel of the textures of the texture as a specular mask. If the blendFunc is blend or GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA, then invert the mask before using it as a $envmapmask. If the blendFunc is GL_ONE_MINUS_SRC_ALPHA GL_SRC_ALPHA, then the alpha channel can be used as an $envmapmask as-is.