Appearance
Environment & Retro Effects
VEX provides a global Environment system that controls the rendering pipeline's aesthetic. This system allows you to toggle specific "retro" features, such as vertex jitter, affine texture warping, and color quantization, to achieve an authentic PS1-era look.
These settings are stored in the vex::environment struct and are applied globally to the active scene.
WARNING
Overwriting them in code persists as long as new scene isnt loaded. When new scene is loaded it loads its own environment settings.
Accessing Settings
The environment settings are managed directly by the Engine class. You can retrieve the current configuration, modify specific flags, and push the changes back to the engine.
cpp
// 1. Get current settings
vex::environment env = GetEngine().getEnvironmentSettings();
// 2. Modify settings (e.g., disable texture warping)
env.affineWarping = false;
// 3. Apply changes
GetEngine().setEnvironmentSettings(env);Retro Aesthetics
These settings control the geometry and pixel-processing stages to mimic early 3D hardware limitations.
| Property | Type | Description |
|---|---|---|
| passiveVertexJitter | bool | Enables vertex jitter even when the camera is static. Useful for a constantly ""alive"" unstable look. |
| vertexSnapping | bool | Snaps vertices to a lower-precision grid during movement. This causes the classic ""wobble"" effect seen in PS1 games. |
| affineWarping | bool | Disables perspective-correct texture mapping. Textures will appear to warp or distort at extreme angles. |
| screenQuantization | bool | Reduces color precision across the entire screen, creating banding artifacts typical of lower bit-depth displays. |
| screenDither | bool | Applies a dithering pattern to smooth out the banding caused by quantization. |
| ntfsArtifacts | bool | Enables CRT/NTSC-style signal artifacts (composite video noise/bleeding). |
Example: "Ultra Retro" Mode
This example enables every retro feature to maximize the nostalgic aesthetic.
cpp
void Game::EnableRetroMode() {
vex::environment env = GetEngine().getEnvironmentSettings();
// Geometry Instability
env.vertexSnapping = true;
env.affineWarping = true;
// Color/Video Artifacts
env.screenQuantization = true;
env.screenDither = true;
env.ntfsArtifacts = true; // Enables composite signal artifacts
GetEngine().setEnvironmentSettings(env);
}Lighting & Shading
In addition to retro artifacts, the environment struct controls the global lighting model.
| Property | Description |
|---|---|
| gourardShading | When true, lighting is calculated per-vertex (Gouraud). When false, it may default to flat shading depending on the shader. |
| ambientLight | The base color vec3 of the scene's shadows/darkest areas. |
| sunLight | The color vec3 of the main directional light. |
| sunDirection | A vec3 defining the direction of the ""sun"" light source. |
| clearColor | The background color used if no skybox is present. |
Example: Day/Night Cycle
You can animate these values in your Update() loop to create dynamic environmental effects.
cpp
void MyGame::Update(float deltaTime) {
vex::environment env = GetEngine().getEnvironmentSettings();
// Simple Day/Night cycle based on time
float time = GetEngine().GetCurrentFrame() * 0.001f;
float brightness = (sin(time) + 1.0f) / 2.0f; // Oscillate 0.0 to 1.0
// Update ambient light strength
env.ambientLightStrength = 0.1f + (brightness * 0.4f);
// Change background from Black (Night) to Blue (Day)
env.clearColor = glm::vec3(0.0f, 0.0f, brightness * 0.5f);
GetEngine().setEnvironmentSettings(env);
}