Hi.
I am trying to get Wind Waker shading by manipulating the normals on a mesh, but the transition in light levels is far too rough. I have attemped to fix it, but one side still has rough transitions.
for i = 1, #vertices do
local position = editable_mesh:GetPosition(vertices[i])
local normal = (position * sun).Unit
if sun.X >=0 then
if normal:Dot(Vector3.new(-sun.X,sun.Y,sun.Z)) >=0.5 then
normal = dl:Lerp(direction, normal:Dot(direction))
elseif normal:Dot(Vector3.new(-sun.X,sun.Y,sun.Z)) >-0.5 then
-- normal = direction:Cross(Vector3.new(1,0,0)):Lerp(-direction, normal:Dot(direction))
else
-- normal = direction:Cross(Vector3.new(1,0,0)):Lerp(-direction,math.abs(normal:Dot(Vector3.new(-sun.X,sun.y,sun.Z))))
-- normal = direction:Cross(Vector3.new(1,0,0)):Lerp(-direction, normal:Dot(direction))
normal = dl:Lerp(-direction, math.abs(normal:Dot(direction)))
end
else
local dp = normal:Dot(Vector3.new(sun.X, sun.Y, sun.Z))
if dp >=0.5 then
normal = dr:Lerp(direction, dp)
elseif dp >-0.5 then
-- normal = direction:Cross(Vector3.new(1,0,0)):Lerp(-direction, normal:Dot(direction))
-- normal = dr:Lerp(-direction, math.abs(normal:Dot(direction)))
normal = dr:Lerp(-direction,math.abs(dp))
else
-- normal = direction:Cross(Vector3.new(1,0,0)):Lerp(-direction,math.abs(normal:Dot(Vector3.new(-sun.X,sun.y,sun.Z))))
-- normal = direction:Cross(Vector3.new(1,0,0)):Lerp(-direction, normal:Dot(direction))
normal = dr:Lerp(-direction, math.abs(dp))
end
end
editable_mesh:SetNormal(normals[i], normal)
end
To clarify, this only happens when sun.X is not >=0