Skip to main content
gamedev.net
🔒 Locked

Cel-shading

Started by siberianstar 2 replies 750+ views
Original Post
siberianstar
siberianstar
Hello i'm trying to implementing cel shading but i don't get the effect i want, http://85.25.18.122/snap0058.bmp actually i'm doing for each vertex: vector ldir = light_position - vtx_position ldir.normalize() coord = vtx_normal.dotProduct ( ldir ) what i'm doing wrong ? Thanks
CyberSlag5k
CyberSlag5k
Post a little more code if you can, but a few questions.

First, what is the effect you're going for? The picture you provided looks decently cel-shaded, with a few anomalies in its head and right arm. Is that what you're looking to correct?

Second, are you normalizing the vertex normal before dotting it with the light direction?

Third, how are you using coord?
Without order nothing can exist - without chaos nothing can evolve.
siberianstar
siberianstar
This is the effect that i would like to get

http://85.25.18.122/snap0059.bmp

I Get this effect using this set of normals

http://85.25.18.122/normals.txt

But if try to recalculate normals of the mesh using this algorithm

core::vector3df a, b;
a = vtx[idx[i+0]].Pos - vtx[idx[i+1]].Pos;
b = vtx[idx[i+0]].Pos - vtx[idx[i+2]].Pos;

core::vector3df c;
c.X = a.Y * b.Z - b.Y * a.Z;
c.Y = b.X * a.Z - a.X * b.Z;
c.Z = a.X * b.Y - b.X * a.Y;
c.normalize();

i get that effect i shown you before (http://85.25.18.122/snap0058.bmp)

So i suppose the problem is on calculating normals.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.