pbr_shaders¶
Algan’s built-in vertex shaders.
A shader here is a plain torch function: it receives per-vertex geometry, normals and material parameters along with the Scene’s lights, and returns per-vertex color. It runs before upload, once per vertex, which is cheap – the trade-off is that highlights are interpolated across a triangle rather than evaluated at each pixel.
A Mob that sets no material of its own does not come here: it is shaded by
DiffuseMaterial, Algan’s default
material, whose lighting shaders live in
algan.rendering.shaders.material_shaders.
null_shader() skips lighting entirely, leaving a Mob its own flat color.
basic_pbr_shader() is the metallic/roughness model the
MeshStandardMaterial family builds on.
Each has an in-kernel counterpart in
algan.rendering.shaders.fragment_shaders; passing one of these functions
to set_fragment_shader()
resolves it to the matching per-fragment stage.
Functions
- basic_pbr_shader(memory, vertex_location, vertex_normal, albedo_color, camera_location, light_origin, light_color, light_intensity, ambient_light_intensity, smoothness=0.5, metallicness=0.5)[source]¶
Implements a simplified physics-based rendering shader, using smoothness and metallicness to define diffuse and specular lighting.
- Parameters:
vertex_location ((np.ndarray)) – The 3D location of the vertex to be shaded.
vertex_normal ((np.ndarray)) – The surface normal vector at the vertex point (need not be normalized).
albedo_color ((np.ndarray)) – The albedo/base RGBG color of the material.
camera_location ((np.ndarray)) – The 3D location of the camera/viewer.
light_origin ((np.ndarray)) – The 3D location of the point light source.
light_color ((np.ndarray)) – The RGB color of the light.
light_intensity (float) – The intensity/brightness of the light source.
ambient_light_intensity (float) – The intensity of ambient scene lighting, ranges from 0 (no light) to 1.
smoothness ((float)) – The smoothness of the material [0, 1]. 0=rough, 1=smooth.
metallicness ((float)) – The metallicness property of the material [0, 1]. 0=dielectric, 1=metal.
- Returns:
The final computed RGB color for the vertex.
- Return type:
np.ndarray