2

I am trying to make a Gouraud shader, but I can't get the right result.

shader gouraud(
    color base_color = color(1,1,1)[[
        string label = "Base Color",
        ]],
    color spec_color = color(1,1,1)[[
        string label = "Specular Color",
        ]],
    float spec_hardness = 50.0[[
        string label = "Specular Hardness",
        ]],
    output color gouraud_color = color(0,0,0)[[
        string label = "Color",
        ]],
    )
{
    // Gouraud calculations
    normal Nf = faceforward(normalize(N), I);
    float gouraud_diffuse = max(0, dot(Nf, normalize(I)));
    float gouraud_specular = pow(max(0, dot(Nf, normalize(I + normalize(-I + 2 * Nf * dot(-I, Nf))))), spec_hardness);
// output
gouraud_color = base_color * gouraud_diffuse + spec_color * gouraud_specular;

}

Result:

result image

Test file:

L0Lock
  • 15,965
  • 1
  • 20
  • 44

0 Answers0