ModEnc is currently in Maintenance Mode: Changes could occur at any given moment, without advance warning.

VPL: Difference between revisions

From ModEnc
Jump to navigation Jump to search
Created page, added basic known info. Might need rephrasing/reformatting.
 
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
.vpls are used by [[Westwood]] to determine a voxels's actual color after the normal takes effect. They are one of the last things figured out within the TS/RA2 engine.
Voxels.vpl is a file used to determine the final in-game color of a [[voxel]], adjusted by its [[normals|surface normal]].
 
==Shading model==
Basically the VPL file stores the data needed to shade the voxels using specified shading parameters (or, one could say material parameters). It appears that the game's voxel drawing is based on Blinn-Phong shading model, which has three light level parameters:
 
- Ambient (non-direct lighting)
- Diffuse (direct soft reflection, like on matte plastic, cloth etc.)
- Specular (direct hard reflection, like on glass, metal etc.)


==Usage==
==Usage==
Voxels can be sectioned by the place where their normals are coming from. In TS, the normals could be divided into 16 sections, in RA2, 32. After these sections were determined, the actual color of the voxel is replaced with the used section's appropriate color. If no section is found (because there are not enough sections, see below) then the voxel become transparent.
VPL contains 32 sections, meaning 32 possible configurations for each of the 256 voxel color indexes (in [[PAL|unittem.pal]]). In {{ts}}, only the first 16 sections are actually used. The purpose of these configurations is to gradually change the brightness of the voxel's color when the voxel rotates. The first section is used when the normal is facing directly ''opposite'' to the imagined light source, therefore appearing the darkest. Conversely, the last section is used when the normal is pointing directly at the light source, thus appearing the brightest. Should the total amount of sections be anything less than 32 (see the VPL header below), the voxel will become transparent when its normal points to the missing section(s).


==Structure==
==Structure==
Header: 16 byte
The VPL file consists of a header, a redundant palette, and 32 sections. The header is 16 bytes long, composed of the following data, all DWORDs:
 
- first remap color index
- last remap color index
- total amount of sections (1–32)
- an unknown entry at the time of writing
 
The header is followed by a [[Westwood]]-standard 768-byte [[PAL|palette]] which is followed by 32 sections, each 256 bytes long. These sections are mere lookup tables, each byte representing the index of a color in the voxel color palette (unittem.pal). While there is a palette in the VPL, it's ignored by the engine.


The VPL header is composed of the following datas, all on DWORDs.
==See also==
[https://ppmforums.com/viewtopic.php?t=30026 Original research thread at PPM Forums]


- first remap entry
[https://bbs.ra2diy.com/forum.php?mod=viewthread&tid=22368 ThomasSneddon's shading model research thread at RA2DIY]
- last remap entry
- total amount of sectors (<=32)
- and an unknown entry at the time of writing


The header is followed by a WW-standard 768-byte palette which is followed by 32 256-byte sections. These sections are just mere lookup tables, containing the outputted palette color entry for the voxel in the section. While there is a palette in the VPL, it gets ignored by the engine overall.
[https://bbs.ra2diy.com/forum.php?mod=viewthread&tid=23475 Another ThomasSneddon's shading model research thread at RA2DIY]


This document is written based upon Gangster's research after VK published the components.
[https://github.com/ThomasSneddon/vxl-renderer ThomasSneddon's VXL Renderer and VPL Generator tool]

Latest revision as of 21:52, 10 August 2024

Voxels.vpl is a file used to determine the final in-game color of a voxel, adjusted by its surface normal.

Shading model

Basically the VPL file stores the data needed to shade the voxels using specified shading parameters (or, one could say material parameters). It appears that the game's voxel drawing is based on Blinn-Phong shading model, which has three light level parameters:

- Ambient (non-direct lighting)
- Diffuse (direct soft reflection, like on matte plastic, cloth etc.)
- Specular (direct hard reflection, like on glass, metal etc.)

Usage

VPL contains 32 sections, meaning 32 possible configurations for each of the 256 voxel color indexes (in unittem.pal). In Tiberian Sun, only the first 16 sections are actually used. The purpose of these configurations is to gradually change the brightness of the voxel's color when the voxel rotates. The first section is used when the normal is facing directly opposite to the imagined light source, therefore appearing the darkest. Conversely, the last section is used when the normal is pointing directly at the light source, thus appearing the brightest. Should the total amount of sections be anything less than 32 (see the VPL header below), the voxel will become transparent when its normal points to the missing section(s).

Structure

The VPL file consists of a header, a redundant palette, and 32 sections. The header is 16 bytes long, composed of the following data, all DWORDs:

- first remap color index
- last remap color index
- total amount of sections (1–32)
- an unknown entry at the time of writing

The header is followed by a Westwood-standard 768-byte palette which is followed by 32 sections, each 256 bytes long. These sections are mere lookup tables, each byte representing the index of a color in the voxel color palette (unittem.pal). While there is a palette in the VPL, it's ignored by the engine.

See also

Original research thread at PPM Forums

ThomasSneddon's shading model research thread at RA2DIY

Another ThomasSneddon's shading model research thread at RA2DIY

ThomasSneddon's VXL Renderer and VPL Generator tool