parent
40c0846029
commit
6fc7d7a4c3
1 changed files with 5 additions and 4 deletions
|
|
@ -8,7 +8,8 @@ import (
|
|||
"math"
|
||||
)
|
||||
|
||||
func phongShading(point Vector3, normal Vector3, lightVec Vector3, mat Material) Vector3 {
|
||||
func phongShading(point Vector3, normal Vector3, mat Material) Vector3 {
|
||||
lightVec := (lightPos.Sub(point)).Normalized()
|
||||
reflectLight := Reflect(lightVec, normal)
|
||||
eyeVec := (cameraPos.Sub(point)).Normalized()
|
||||
brutMat := mat.GetMaterialBrut()
|
||||
|
|
@ -23,7 +24,8 @@ func phongShading(point Vector3, normal Vector3, lightVec Vector3, mat Material)
|
|||
return ambiant.Add(diffuse).Add(specular)
|
||||
}
|
||||
|
||||
func shadow(point Vector3, direction Vector3) float64 {
|
||||
func shadow(point Vector3) float64 {
|
||||
direction := (lightPos.Sub(point)).Normalized()
|
||||
p := point.Add(direction.Scale(5 * EPS))
|
||||
res := 1.0
|
||||
dist_total := 0.0
|
||||
|
|
@ -48,8 +50,7 @@ func rayMarch(origin Vector3, direction Vector3) (bool, Vector3) {
|
|||
dist, mat := scene.Distance(p)
|
||||
if dist < EPS {
|
||||
normal := Gradient(scene, p, EPS).Normalized()
|
||||
lightVec := (lightPos.Sub(p)).Normalized()
|
||||
return true, phongShading(p, normal, lightVec, mat).Scale(max(shadow(p, lightVec), 0.3))
|
||||
return true, phongShading(p, normal, mat).Scale(max(shadow(p), 0.3))
|
||||
// return true, phongShading(p, normal, *mat)
|
||||
}
|
||||
if dist > MAX_DIST {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue