Phong shading

This commit is contained in:
Crizomb 2025-09-26 21:43:08 +02:00
parent f5d4a5cb7e
commit 9e8028f904
2 changed files with 24 additions and 3 deletions

View file

@ -6,6 +6,7 @@ type Color interface {
// Ambre je te copie
type Material struct {
ambiantColor Color
diffuseColor Color
diffuseFac float64
specularColor Color
@ -17,9 +18,10 @@ type Material struct {
refractIndice float64
}
func DefaultMaterial(diffuseColor Color) Material {
func DefaultMaterial(ambiantColor Color) Material {
return Material{
diffuseColor: diffuseColor,
ambiantColor: ambiantColor,
diffuseColor: Vector3{255, 255, 255},
diffuseFac: 1.0,
specularColor: Vector3{1.0, 1.0, 1.0},
specularFac: 0.5,
@ -33,6 +35,7 @@ func DefaultMaterial(diffuseColor Color) Material {
func MixMat(mat1 Material, mat2 Material, t float64, p Vector3) Material {
return Material{
mat1.ambiantColor.GetColor(p).Scale(1 - t).Add((mat2.ambiantColor.GetColor(p)).Scale(t)),
mat1.diffuseColor.GetColor(p).Scale(1 - t).Add((mat2.diffuseColor.GetColor(p)).Scale(t)),
(mat1.diffuseFac*(1-t) + mat2.diffuseFac) * t,
mat1.specularColor.GetColor(p).Scale(1 - t).Add((mat2.specularColor.GetColor(p)).Scale(t)),