scimesh 0.3.4
Headless CPU-only 3D software renderer for scientific mesh visualization
Loading...
Searching...
No Matches
scimesh::RenderOptions Struct Reference

All settings that control rendering output. More...

#include <render_options.h>

Collaboration diagram for scimesh::RenderOptions:

Public Attributes

Output size
int width = 800
 Image width in pixels (default: 800).
 
int height = 600
 Image height in pixels (default: 600).
 
Shading
ShadingMode shading = ShadingMode::SMOOTH
 Shading mode (default: SMOOTH).
 
bool backface_culling = true
 Enable backface culling (default: true).
 
bool invert_normals = false
 Flip all surface normals (default: false).
 
Colors
Color background_color = WHITE
 Background color (default: opaque white).
 
Color default_color = DEFAULT_COLOR
 Default color for meshes without explicit vertex/face colors.
 
Wireframe
bool wireframe = false
 Draw triangle edges as lines (default: false).
 
Color wireframe_color = Color(0.0f, 0.0f, 0.0f, 1.0f)
 Color of the wireframe lines (default: black).
 
Anti-aliasing
int aa_samples = 1
 Anti-aliasing sample count (default: 1 = no AA).
 
Specular highlights
Color specular_color = Color(0.0f, 0.0f, 0.0f, 0.0f)
 Specular highlight color (default: transparent = no specular).
 
float shininess = 0.0f
 Shininess exponent (default: 0.0 = no specular).
 
Projection
ProjectionType projection = ProjectionType::PERSPECTIVE
 Projection type (default: PERSPECTIVE).
 
Lighting
std::vector< Light > lights
 List of light sources.
 
float ambient = 0.3f
 Ambient light level (default: 0.3).
 
Post-processing
float contrast = 1.0f
 Contrast adjustment (default: 1.0 = no change).
 
Clipping planes
std::vector< ClipPlane > clip_planes
 Optional clip planes for cross-section views.
 
Fog
bool fog_enabled = false
 Enable depth fog (default: false).
 
float fog_start = 0.0f
 Distance at which fog begins (default: 0).
 
float fog_end = 1.0f
 Distance at which fog is fully opaque (default: 1).
 
Color fog_color = TRANSPARENT_BLACK
 The color that distant objects fade into.
 
FogSpace fog_space = FogSpace::WORLD
 The space and unit in which fog_start / fog_end are given.
 
Threading
int threads = 0
 Number of render threads (default: 0 = auto-detect).
 
Screen-space ambient occlusion (SSAO)
bool ssao_enabled = false
 Enable SSAO (default: false).
 
float ssao_radius = 16.0f
 SSAO sample radius in pixels (default: 16).
 
float ssao_intensity = 0.8f
 SSAO darkening intensity (default: 0.8).
 
Clipping distances
float near_plane = 0.1f
 Near clipping plane distance (default: 0.1).
 
float far_plane = 10000.0f
 Far clipping plane distance (default: 10000.0).
 

Detailed Description

All settings that control rendering output.

Quick start

The defaults produce a reasonable result for most cases:

RenderOptions opts; // all defaults
opts.width = 1920;
opts.height = 1080; // Full HD output
All settings that control rendering output.
int width
Image width in pixels (default: 800).
int x
Left edge of the bitmap, in image pixels.
Definition text.cpp:223

Adding lights

opts.lights.push_back(Light{Vec3(0,0,1), Color(1,1,1), 1.0f, true});
opts.ambient = 0.4f; // brighter ambient light
glm::vec3 Vec3
3-component floating-point vector (xyz).
Definition types.h:46
An RGBA color with floating-point components.
Definition types.h:88
A light source for the Blinn-Phong shading model.
Definition types.h:179

Anti-aliasing

opts.aa_samples = 4; // 4Ɨ supersampling for smooth edges

Wireframe overlay

opts.wireframe = true;
opts.wireframe_color = Color(0,0,0); // black edges
See also
Renderer, Light, ClipPlane, ShadingMode

Definition at line 74 of file render_options.h.

Member Data Documentation

◆ aa_samples

int scimesh::RenderOptions::aa_samples = 1

Anti-aliasing sample count (default: 1 = no AA).

Super-sampling anti-aliasing: each pixel is sampled aa_samples times in each direction, then averaged. A value of 4 means 16 samples per pixel total. Higher values produce smoother edges but are slower and use more memory.

Definition at line 157 of file render_options.h.

◆ ambient

float scimesh::RenderOptions::ambient = 0.3f

Ambient light level (default: 0.3).

Ambient light is uniform "fill" light that illuminates all surfaces equally, preventing shadowed areas from being completely black. Range: 0.0 (no ambient) to 1.0 (fully lit). Typical: 0.2–0.4.

Definition at line 201 of file render_options.h.

◆ backface_culling

bool scimesh::RenderOptions::backface_culling = true

Enable backface culling (default: true).

When enabled, triangles facing away from the camera are not drawn. This is an optimization and is almost always what you want. Disable only if you need to see both sides of single-sided geometry.

Rendering is two-sided in that case: a visible back side is lit with the normal flipped towards the camera, so single-sided geometry (a plane, a surface patch) looks the same from both sides, and the exactly coplanar face pairs generated by e.g. generate_plane() shade identically no matter which of the two wins the depth test.

Definition at line 108 of file render_options.h.

◆ background_color

Color scimesh::RenderOptions::background_color = WHITE

Background color (default: opaque white).

Pixels not covered by any triangle get this color.

See also
WHITE

Definition at line 124 of file render_options.h.

◆ clip_planes

std::vector<ClipPlane> scimesh::RenderOptions::clip_planes

Optional clip planes for cross-section views.

Each plane removes the geometry on its negative side; planes are combined with a logical AND. By default a plane is defined in world space (see ClipPlane::space), so the cut is a fixed feature of the scene and does not move when the camera moves. Pass PlaneSpace::EYE for the legacy camera-relative behaviour.

Example
// World-space slice at x = 0 (keeps x <= 0).
opts.clip_planes.push_back(ClipPlane{Vec3(-1, 0, 0), 0.0f});
// Additionally drop everything closer than 3 units to the camera.
opts.clip_planes.push_back(
ClipPlane{Vec3(0, 0, -1), -3.0f, PlaneSpace::EYE});
@ EYE
Eye (view/camera) space: the plane is anchored to the camera and therefore travels and rotates with i...
A clipping plane that can hide parts of the scene.
Definition types.h:263
std::vector< ClipPlane > clip_planes
Optional clip planes for cross-section views.
See also
ClipPlane, PlaneSpace

Definition at line 237 of file render_options.h.

◆ contrast

float scimesh::RenderOptions::contrast = 1.0f

Contrast adjustment (default: 1.0 = no change).

‍1.0 increases contrast, < 1.0 reduces it.

Definition at line 211 of file render_options.h.

◆ default_color

Color scimesh::RenderOptions::default_color = DEFAULT_COLOR

Default color for meshes without explicit vertex/face colors.

Overridden by per-mesh Mesh::default_color.

See also
DEFAULT_COLOR

Definition at line 130 of file render_options.h.

◆ far_plane

float scimesh::RenderOptions::far_plane = 10000.0f

Far clipping plane distance (default: 10000.0).

Geometry farther than this is not rendered. Increase for massive scenes; decrease to improve depth precision.

Definition at line 337 of file render_options.h.

◆ fog_color

Color scimesh::RenderOptions::fog_color = TRANSPARENT_BLACK

The color that distant objects fade into.

Definition at line 267 of file render_options.h.

◆ fog_enabled

bool scimesh::RenderOptions::fog_enabled = false

Enable depth fog (default: false).

When enabled, objects fade toward fog_color with their distance from the camera, between fog_start and fog_end.

Definition at line 248 of file render_options.h.

◆ fog_end

float scimesh::RenderOptions::fog_end = 1.0f

Distance at which fog is fully opaque (default: 1).

Must be greater than fog_start. Same space/unit as fog_start.

See also
FogSpace, RenderOptions::fog_space

Definition at line 264 of file render_options.h.

◆ fog_space

FogSpace scimesh::RenderOptions::fog_space = FogSpace::WORLD

The space and unit in which fog_start / fog_end are given.

Default: FogSpace::WORLD, i.e. the fog distances are distances in world units from the camera. Use FogSpace::NDC for the legacy normalized-device-depth interpretation.

Example: world units (default)
opts.fog_enabled = true;
opts.fog_start = 20.0f; // 20 world units in front of the camera
opts.fog_end = 60.0f; // fully fogged 60 units away
Example: legacy normalized device depth
opts.fog_enabled = true;
opts.fog_space = FogSpace::NDC;
opts.fog_start = 0.5f; // half way into the depth range
opts.fog_end = 1.0f; // at the far plane
@ NDC
Normalized device depth: the raw values of the depth buffer, in [-1, 1], where -1 is the near plane,...
See also
FogSpace

Definition at line 291 of file render_options.h.

◆ fog_start

float scimesh::RenderOptions::fog_start = 0.0f

Distance at which fog begins (default: 0).

Interpreted according to fog_space: world units from the camera by default, or raw normalized device depth when fog_space == FogSpace::NDC.

See also
FogSpace, RenderOptions::fog_space

Definition at line 257 of file render_options.h.

◆ height

int scimesh::RenderOptions::height = 600

Image height in pixels (default: 600).

Definition at line 82 of file render_options.h.

◆ invert_normals

bool scimesh::RenderOptions::invert_normals = false

Flip all surface normals (default: false).

Useful when normals from a file point inward instead of outward.

Definition at line 113 of file render_options.h.

◆ lights

std::vector<Light> scimesh::RenderOptions::lights

List of light sources.

If empty, a default single directional light from +Z is used.

See also
Light

Definition at line 194 of file render_options.h.

◆ near_plane

float scimesh::RenderOptions::near_plane = 0.1f

Near clipping plane distance (default: 0.1).

Geometry closer than this is not rendered. Reduce if you need to see very close objects; increase if you have z-fighting issues.

Definition at line 331 of file render_options.h.

◆ projection

ProjectionType scimesh::RenderOptions::projection = ProjectionType::PERSPECTIVE

Projection type (default: PERSPECTIVE).

See also
ProjectionType

Definition at line 183 of file render_options.h.

◆ shading

ShadingMode scimesh::RenderOptions::shading = ShadingMode::SMOOTH

Shading mode (default: SMOOTH).

SMOOTH interpolates normals across triangles for a rounded look. FLAT uses one normal per triangle for a faceted look.

See also
ShadingMode

Definition at line 95 of file render_options.h.

◆ shininess

float scimesh::RenderOptions::shininess = 0.0f

Shininess exponent (default: 0.0 = no specular).

Higher values produce sharper, more focused highlights. Typical range: 16–128. Only used when specular_color.a > 0.

Definition at line 173 of file render_options.h.

◆ specular_color

Color scimesh::RenderOptions::specular_color = Color(0.0f, 0.0f, 0.0f, 0.0f)

Specular highlight color (default: transparent = no specular).

Set to white or a tinted color to add shiny highlights.

Definition at line 167 of file render_options.h.

◆ ssao_enabled

bool scimesh::RenderOptions::ssao_enabled = false

Enable SSAO (default: false).

SSAO darkens crevices and corners to add depth and realism.

Definition at line 312 of file render_options.h.

◆ ssao_intensity

float scimesh::RenderOptions::ssao_intensity = 0.8f

SSAO darkening intensity (default: 0.8).

0.0 = no effect, 1.0 = full effect.

Definition at line 320 of file render_options.h.

◆ ssao_radius

float scimesh::RenderOptions::ssao_radius = 16.0f

SSAO sample radius in pixels (default: 16).

Definition at line 315 of file render_options.h.

◆ threads

int scimesh::RenderOptions::threads = 0

Number of render threads (default: 0 = auto-detect).

The renderer can use multiple threads for triangle rasterization. Set to 1 to force single-threaded rendering.

Definition at line 302 of file render_options.h.

◆ width

int scimesh::RenderOptions::width = 800

Image width in pixels (default: 800).

Definition at line 79 of file render_options.h.

◆ wireframe

bool scimesh::RenderOptions::wireframe = false

Draw triangle edges as lines (default: false).

When enabled, each triangle edge is drawn on top of the filled triangle. Wireframe thickness is 1 pixel.

Definition at line 141 of file render_options.h.

◆ wireframe_color

Color scimesh::RenderOptions::wireframe_color = Color(0.0f, 0.0f, 0.0f, 1.0f)

Color of the wireframe lines (default: black).

Definition at line 144 of file render_options.h.


The documentation for this struct was generated from the following file: