Skip to content

Updates for procedural scenes: geometry, materials, instancing, transparency, point lights#227

Open
fbriggs wants to merge 8 commits intotweakoz:developfrom
fbriggs:fb-apr10-lightandmaterial
Open

Updates for procedural scenes: geometry, materials, instancing, transparency, point lights#227
fbriggs wants to merge 8 commits intotweakoz:developfrom
fbriggs:fb-apr10-lightandmaterial

Conversation

@fbriggs
Copy link
Copy Markdown

@fbriggs fbriggs commented Apr 13, 2026

  • fwdtools.i2 (bug fix) — The vertex-color technique was hardcoding metallic=1, roughness=1, and double-applying vertex color. Point lights and envmaps had no effect on procedural geometry.

    • forward_lighting_ntex: albedo changed from vec3(1,1,1)modcolor (vertex color becomes PBR albedo)
    • ambrufmtl changed from vec3(1,1,1)vec3(1, RoughnessFactor, MetallicFactor) (reads material uniforms instead of hardcoded values)
    • Removed double * modcolor multiply — was squaring vertex color, killing envmap reflections
    • Passes vec3(1) as modcolor to _forward_lightingZ since the color is already in the albedo
  • pbr.fxv2 (new features) — Transparency support for procedural geometry. Instanced rendering with vertex colors.

    • Added sb_cullcw_alpha state block (alpha blending + no depth writes)
    • Added FWD_CV_NM_RI_NI_MO_ALPHA technique (transparent vertex-color, non-instanced)
    • Added FWD_CV_NM_RI_IN_MO technique (opaque vertex-color, instanced)
    • Added FWD_CV_NM_RI_IN_MO_ALPHA technique (transparent vertex-color, instanced)
  • pbrtools.i2 (new features) — Transparency, tint/opacity per object, instanced rendering with vertex colors.

    • ps_forward_test_vtxcol: output changed from (lit, 1)(lit * ModColor.rgb, frg_clr.a * ModColor.a) — enables per-object tint and opacity via ModColor
    • Added ps_forward_test_vtxcol_alpha — transparent fragment shader with luminance-based alpha boost for glass-like specular
    • Added ps_forward_instanced_vtxcol_alpha — instanced transparent fragment shader (no luminance boost, instance alpha = final opacity)
    • Added vs_forward_instanced_vc — instanced vertex shader that reads per-vertex colors AND per-instance colors, multiplies them
  • stdtools.i2 (new feature) — Instanced rendering needs to combine per-vertex colors with per-instance colors.

    • Added lib_pbr_vtx_instanced_vc — vertex-color-aware instanced vertex transform lib block
  • fx_pipeline.h — Pipeline cache needs to distinguish opaque vs transparent permutations.

    • Added bool _is_alpha = false to FxPipelinePermutation
  • material_pbr.inl — PBRMaterial needs new technique pointers and alpha blending flag.

    • Added technique pointers: _tek_FWD_CV_NM_RI_IN_MO, _tek_FWD_CV_NM_RI_IN_MO_ALPHA, _tek_FWD_CV_NM_RI_NI_MO_ALPHA
    • Added bool _alphaBlend = false
  • rigid_primitive.inl — Alpha blending support and instanced rendering for procedural geometry.

    • Added #include <ork/lev2/gfx/material_pbr.inl> for PBRMaterial access
    • installInCallbackDrawable: checks _alphaBlend to set permu._is_alpha
    • Added renderInstancedEML() — instanced draw call
    • Added InstancedRigidPrimitiveDrawable — full instanced rendering drawable for procedural geometry
  • pyext_gfx_lighting.cpp — Missing properties needed to create and configure dynamic lights from Python.

    • Added LightData.intensity and LightData.shadowCaster properties
    • Added PointLightData.radius and PointLightData.falloff properties
    • Added DynamicPointLight() constructor and .data property
    • Added SpotLightData.createNode() method
  • pyext_gfx_pbr.cpp — Python needs to set alpha blending on materials.

    • Added PBRMaterial.alphaBlend property
  • pyext_gfx_primitives_rigid.cpp — Direct GPU buffer upload and instanced rendering from Python.

    • Added RigidPrimitive.fromArrays() — direct GPU vertex/index buffer upload from numpy arrays
    • Added RigidPrimitive.createInstancedNode() — creates instanced drawable node
  • pyext_gfx_scenegraph.cpp (bug fix) — Instance data bindings were hardcoded to InstancedModelDrawable.

    • Changed dynamic_pointer_cast<InstancedModelDrawable>dynamic_pointer_cast<InstancedDrawable> in instanceData, setInstanceMatrix,
      setInstanceColor
  • fx_pipeline.cpp — Pipeline cache index needs the alpha bit.

    • Added _is_alpha to genIndex(): index += (uint64_t(_is_alpha) << 6)
  • material_pbr.cpp — gpuInit needs to load new technique pointers.

    • Added technique lookups for FWD_CV_NM_RI_NI_MO_ALPHA, FWD_CV_NM_RI_IN_MO, FWD_CV_NM_RI_IN_MO_ALPHA
  • fwdnode_pipeline.cpp — Forward pipeline technique selection for new permutations.

    • Updated pipeline selection to handle instanced + vertex-color combinations
    • Handles _is_alpha flag for both instanced and non-instanced vertex-color paths

Tests

# Procedural PBR materials (gold, chrome, chalk, obsidian, copper, plastic, glass)
ork.lev2/pyext/tests/renderer/primitives/procedural_pbr/vtxcolor_materials.py

# Transparency (fixed alpha, animated opacity, animated tint, opaque-inside-transparent)
ork.lev2/pyext/tests/renderer/primitives/procedural_pbr/transparency.py

# Point lights (3 colored lights orbiting matte/metallic/mirror spheres)
ork.lev2/pyext/tests/renderer/primitives/procedural_pbr/point_lights.py

# GPU instancing (500 opaque + 200 transparent instances with animated transforms)
ork.lev2/pyext/tests/renderer/primitives/procedural_pbr/instancing.py

# Basic cube + sphere + light - are all 4 sides of the cube getting point light OK?
# Is the environment map's lighting contribution upside down?
ork.lev2/pyext/tests/renderer/primitives/procedural_pbr/basic_cube_sphere_light.py
# Same test with gold material instead of chalk:
ork.lev2/pyext/tests/renderer/primitives/procedural_pbr/basic_cube_sphere_light.py --gold

@fbriggs fbriggs changed the title Fb apr10 lightandmaterial Updates for procedural scenes: geometry, materials, instancing, transparency, point lights Apr 13, 2026
});
})
.def(
"fromArrays",
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might not be necessary, was an attempt to fix seams and nodes on spheres which may come from HDRI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant