PbrShaderGenerator

class PbrShaderGenerator

Bases: ShaderGenerator

A ShaderGenerator that writes PBR shaders: install it on a GSG and turn the shader generator on for a subtree, and every state under it gets the shader for its PbrFeatureKey:

gsg.set_shader_generator(PbrShaderGenerator(gsg)) render.set_shader_auto()

Shaders are cached by key; materials, lights and textures change uniforms only. The GLSL is 4.50 where the driver offers it and 4.10 otherwise (macOS, for development).

Inheritance diagram

digraph inheritancec21c1e5f90 { bgcolor=transparent; rankdir=BT; size="8.0, 12.0"; "DTOOL_SUPER_BASE" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style=""]; "PbrShaderGenerator" [URL="acron.shading.PbrShaderGenerator.html#acron.shading.PbrShaderGenerator",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "ShaderGenerator" -> "PbrShaderGenerator" [arrowsize=0.75,style=""]; "ReferenceCount" [URL="acron.core.ReferenceCount.html#acron.core.ReferenceCount",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "DTOOL_SUPER_BASE" -> "ReferenceCount" [arrowsize=0.75,style=""]; "ShaderGenerator" [URL="acron.core.ShaderGenerator.html#acron.core.ShaderGenerator",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "TypedReferenceCount" -> "ShaderGenerator" [arrowsize=0.75,style=""]; "TypedObject" [URL="acron.core.TypedObject.html#acron.core.TypedObject",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "DTOOL_SUPER_BASE" -> "TypedObject" [arrowsize=0.75,style=""]; "TypedReferenceCount" [URL="acron.core.TypedReferenceCount.html#acron.core.TypedReferenceCount",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "TypedObject" -> "TypedReferenceCount" [arrowsize=0.75,style=""]; "ReferenceCount" -> "TypedReferenceCount" [arrowsize=0.75,style=""]; }
PbrShaderGenerator.__init__()

The GLSL version follows the GSG’s driver: 4.50 if it has it, else 4.10.

PbrShaderGenerator.clear_cache()

Forgets the cached shaders (and makes every state ask again).

PbrShaderGenerator.get_builder()

The builder whose options the generator uses. Changing an option affects states synthesised afterwards; call rehash_all() to redo the rest.

static PbrShaderGenerator.get_class_type()
PbrShaderGenerator.get_num_cached_shaders()

The number of distinct shaders made so far.

PbrShaderGenerator.precompile()

Makes the shaders of every auto-shaded state below root (as it would be drawn: root’s net state composed down to each Geom) and queues them on the GSG, which compiles and links them at the start of the next frame, instead of in the middle of the frame that first draws them. Call it after loading a level, with its lights and environment on. Returns the number of distinct shaders queued.

prepare_scene() also makes the shaders but does not queue them. Skinned meshes drawn with hardware-animated-vertices are linked once more, with the back end’s skinning, when first drawn.

static PbrShaderGenerator.rehash_all()

Makes every state ask its generator for its shader again (after a builder option changed).