Skip to content

Shaders: Slice A — GLSL stylized shader assets + headless compile harness #744

Description

@fernandotonon

Part of #743 (Epic: Shaders — preset stylized shaders). Do this slice first — it de-risks the whole epic.

Goal

Author the custom GLSL programs + .material scripts for the stylized looks, and a headless compile harness that proves they compile on CI before any UI is built. The single riskiest part of the epic is "do these GLSL programs compile across platforms" — prove it here.

Shader assets

Add GLSL #version 150 programs under media/materials/programs/stylized/ (or reuse GLSL150/), using OgreUnifiedShader.h macros for cross-RS safety. A shared lighting/normal helper plus per-look vert/frag:

  • toon.frag — N·L → quantized ramp (band count uniform; optional ramp texture)
  • outline — prefer the cheap, robust 2-pass inverted-hull (back-face pass, front culling, scale-along-normal or depth_bias) per media/materials/scripts/QBuild.material BaseOutlined; no fragile geometry shader
  • rim.frag — Fresnel pow(1 - N·V, power)
  • matcap.frag — view-space normal → sphere-map UV lookup (needs a bundled matcap texture)
  • hologram.frag — Fresnel + scanline + additive blend
  • xray.frag — depth-tested additive Fresnel
  • gooch.frag — warm/cool interpolation
  • flat.vert/.frag — face normal via dFdx/dFdy (faceted)
  • vcolor.frag — unlit vertex color

Declare them in media/materials/programs/stylized/Stylized.program (mirror media/Main/ShadowVolumeExtude.program syntax: vertex_program … glsl { source … }). Author base .material scripts in media/materials/scripts/Stylized.material with vertex_program_ref/fragment_program_ref, named so Slice B can look them up / clone().

If a new programs dir is used, register it in cfg/resources.cfg.in.

Compile harness (load-bearing)

New src/StylizedShaders_test.cpp: in a headless RTT (reuse ModelTurntableRenderer or a minimal RTT like MeshDepthRenderer), apply each stylized material to a primitive and render one frame — a GLSL compile failure surfaces as an Ogre exception / blank frame. Skip gracefully when tryInitOgre() can't get a context (macOS local); runs for real on Linux CI (Xvfb + Mesa, MESA_GL_VERSION_OVERRIDE=3.3). Wire the test file into CMakeLists.txt.

Fallback

If a specific shader misbehaves on Mesa, fall that one look back to FFP/multipass — the preset surface (Slice B+) is identical either way.

Acceptance

  • All stylized GLSL programs declared and loadable.
  • Headless compile harness renders each look without GLSL compile errors on Linux CI.
  • 2-pass inverted-hull outline renders a silhouette on a test mesh.
  • Test skips gracefully without a GL context.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions