Forge Blinn Phong Materials logo

Forge Blinn Phong Materials

Community
Nebulavenus
forge-blinn-phong-materials

Add per-material Blinn-Phong lighting with ambient, diffuse, specular colors and shininess. Use when someone needs to render multiple objects with distinct material appearances, add material property systems, or extend basic lighting with per-object parameters in SDL3 GPU.

Overview

PublisherNebulavenus
Repositoryforge-gpu
Skill nameforge-blinn-phong-materials
Stars
46
Forks
7
Bundled files
Instructions only
LicenseZlib
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by Nebulavenus on GitHub. Read the source before you install it.

Installation

Install the Forge Blinn Phong Materials AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/Nebulavenus/forge-gpu/tree/main/.claude/skills/forge-blinn-phong-materials
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Nebulavenus/forge-gpu.git /tmp/forge-gpu
mkdir -p .claude/skills
cp -r /tmp/forge-gpu/.claude/skills/forge-blinn-phong-materials .claude/skills/forge-blinn-phong-materials
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Forge Blinn Phong Materials in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Forge Blinn Phong Materials on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Forge Blinn Phong Materials is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Add per-material Blinn-Phong lighting to an SDL GPU project. Extends the basic lighting pattern from the forge-basic-lighting skill with full material properties.

When to use

  • Rendering multiple objects that need to look different (metal vs plastic vs stone)
  • Adding a material property system to a 3D scene
  • Extending Lesson 10-style Blinn-Phong with per-object material colors
  • Foundation for PBR-style material workflows

Key concepts

Material struct

c
typedef struct Material {
    float ambient[4];    /* ambient reflectance (rgb, w unused)       */
    float diffuse[4];    /* diffuse reflectance (rgb, w unused)       */
    float specular[4];   /* specular reflectance (rgb), shininess (w) */
} Material;

Pack shininess into specular[3] — saves a uniform slot and aligns naturally to 16 bytes per row.

Predefined materials (OpenGL Programming Guide / Devernay tables)

c
/* Metallic — colored specular highlights */
static const Material MATERIAL_GOLD = {
    { 0.24725f, 0.1995f,  0.0745f,  0.0f },  /* ambient  */
    { 0.75164f, 0.60648f, 0.22648f, 0.0f },  /* diffuse  */
    { 0.628281f, 0.555802f, 0.366065f, 51.2f } /* specular + shininess */
};

/* Dielectric — near-white specular */
static const Material MATERIAL_RED_PLASTIC = {
    { 0.0f, 0.0f, 0.0f, 0.0f },
    { 0.5f, 0.0f, 0.0f, 0.0f },
    { 0.7f, 0.6f, 0.6f, 32.0f }
};

Fragment uniform layout (96 bytes)

c
typedef struct FragUniforms {
    float mat_ambient[4];   /* 16 bytes */
    float mat_diffuse[4];   /* 16 bytes */
    float mat_specular[4];  /* 16 bytes — rgb + shininess in w */
    float light_dir[4];     /* 16 bytes */
    float eye_pos[4];       /* 16 bytes */
    Uint32 has_texture;     /*  4 bytes */
    float _pad[3];          /* 12 bytes — total: 96 bytes */
} FragUniforms;

HLSL fragment shader

hlsl
cbuffer FragUniforms : register(b0, space3)
{
    float4 mat_ambient;
    float4 mat_diffuse;
    float4 mat_specular;   /* rgb + shininess in w */
    float4 light_dir;
    float4 eye_pos;
    uint   has_texture;
};

float4 main(PSInput input) : SV_Target
{
    float3 diffuse_color = mat_diffuse.rgb;
    if (has_texture)
        diffuse_color *= diffuse_tex.Sample(smp, input.uv).rgb;

    float3 N = normalize(input.world_norm);
    float3 L = normalize(light_dir.xyz);
    float3 V = normalize(eye_pos.xyz - input.world_pos);

    /* Ambient */
    float3 ambient_term = mat_ambient.rgb;

    /* Diffuse (Lambert) */
    float NdotL = max(dot(N, L), 0.0);
    float3 diffuse_term = NdotL * diffuse_color;

    /* Specular (Blinn) — full RGB, not always white */
    float3 H = normalize(L + V);
    float NdotH = max(dot(N, H), 0.0);
    float shininess = mat_specular.w;
    float3 specular_term = pow(NdotH, shininess) * mat_specular.rgb;

    return float4(ambient_term + diffuse_term + specular_term, 1.0);
}

Per-object rendering pattern

c
for (int i = 0; i < num_objects; i++) {
    const Material *mat = objects[i].material;

    /* Position each object */
    mat4 model = mat4_translate(objects[i].position);
    mat4 mvp = mat4_multiply(vp, model);

    /* Push vertex uniforms */
    VertUniforms vu = { .mvp = mvp, .model = model };
    SDL_PushGPUVertexUniformData(cmd, 0, &vu, sizeof(vu));

    /* Push material + lighting uniforms */
    FragUniforms fu;
    SDL_memcpy(fu.mat_ambient,  mat->ambient,  sizeof(fu.mat_ambient));
    SDL_memcpy(fu.mat_diffuse,  mat->diffuse,  sizeof(fu.mat_diffuse));
    SDL_memcpy(fu.mat_specular, mat->specular, sizeof(fu.mat_specular));
    /* ... set light_dir, eye_pos, has_texture ... */
    SDL_PushGPUFragmentUniformData(cmd, 0, &fu, sizeof(fu));

    /* Draw */
    SDL_DrawGPUIndexedPrimitives(pass, index_count, 1, 0, 0, 0);
}

Common mistakes

  1. Always-white specular. Lesson 10 uses float3(1,1,1) for specular. Metals need colored specular — use mat_specular.rgb instead.

  2. Forgetting to push uniforms per object. SDL_PushGPUFragmentUniformData must be called before each draw call, not once for the whole scene.

  3. Mismatched cbuffer layout. The C struct and HLSL cbuffer must have identical sizes and alignment. Use float4 (16 bytes) per row in HLSL to avoid packing surprises.

  4. Shininess of zero. pow(x, 0) = 1.0 for all x, producing a flat white overlay. Use shininess >= 1.0.

Metallic vs dielectric guide

TypeAmbientDiffuseSpecularShininess
MetalDark, tintedMedium, tintedBright, same tint30–80
PlasticVery darkSaturated colorNear-white (0.6–0.8)20–50
Stone/gemDark, slightly tintedMuted colorGray (0.2–0.4)10–20
PearlWarm darkOff-white/creamGray (0.2–0.3)8–15

Dependencies

  • Extends: forge-basic-lighting skill (Lesson 10 patterns)
  • Uses: math/forge_math.h for vectors and matrices
  • Uses: gltf/forge_gltf.h for model loading
  • Reference: Lesson 18 — Blinn-Phong with Materials

Frequently asked questions

What does the Forge Blinn Phong Materials AI skill do?

Add per-material Blinn-Phong lighting with ambient, diffuse, specular colors and shininess. Use when someone needs to render multiple objects with distinct material appearances, add material property systems, or extend basic lighting with per-object parameters in SDL3 GPU.

Why use Forge Blinn Phong Materials on TypingMind?

Because you install it once and use it with any model. Forge Blinn Phong Materials is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Forge Blinn Phong Materials in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Nebulavenus/forge-gpu/tree/main/.claude/skills/forge-blinn-phong-materials. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Forge Blinn Phong Materials?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Forge Blinn Phong Materials?

As many as you like. As long as a model supports skills, you can use Forge Blinn Phong Materials with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Forge Blinn Phong Materials AI skill free?

Yes. It is published on GitHub by Nebulavenus under the Zlib license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇