Phong shading
This commit is contained in:
parent
f5d4a5cb7e
commit
9e8028f904
2 changed files with 24 additions and 3 deletions
|
|
@ -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)),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue