Normals Shader -> terrific Toon Shader

Everything related to 3D programming
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 756
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: Normals Shader -> terrific Toon Shader

Post by Samuel »

Alexi wrote:The EnhancedCelShading Example actually isn't a Toon Shader.
Um, I'm pretty sure the EnhancedCelShading is considered to be a Toon Shader. A Toon Shader just makes the graphics look hand drawn nothing more.
Alexi wrote:If you move the camera arround, the darker scaled Cells have to align to the Camera - not to the light source.
Excluding the outline every Cel or Toon Shader that I've seen has worked off of the light position and not the camera position. With a little elbow grease I'm sure it can be done though.
Alexi wrote: This would be really simple using the already used default Shading to get the 3D deep feeling.
So, you want a Toon Shader that uses Ambient Occlusion or am I mistaken?

Alexi wrote: Maybe some shader expert can change Samuel's ported EnhancedCelShading to use normals? This would be nearly perfect if its aligned to the Camera.
Just to clarify what do you mean by normals? In graphics a normal is usually used to determine a surface's orientation toward a light source.
The EnhancedCelShading and any shader that uses light already uses normals for the calculations. So, your statements have me confused.


I know I didn't really help you with my post. I'm just trying to completely understand what it is your after.


EDIT:
You may have already looked through them, but here's a few links to past cel/toon shader topics. Maybe one of them will be more suited to your needs.
http://www.purebasic.fr/english/viewtop ... 36&t=51389
http://www.purebasic.fr/english/viewtop ... 16&t=40838
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 756
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: Normals Shader -> terrific Toon Shader

Post by Samuel »

Alexi wrote:With the EnhancedCelShading it would be like attaching a spot light to the Camera.
If you look around a mesh, the darker cells are always at the edges.
I would just attach a point light to my camera position like you said? Instead of altering the shader itself.
The shader should work fine with the light moving around.
To me this way would make the most sense. Because you still have the light advantages and it will always look like the light is coming from the camera position.
Making the edges of your mesh always have the darker cels.

Is there a reason why you wouldn't want to do it this way?
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 756
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: Normals Shader -> terrific Toon Shader

Post by Samuel »

The shader collects data from PureBasic's light system.

So, for example let's say you create a light in PureBasic using CreateLight(#Light, RGB(255,255,255)0,0,0,#PB_Light_Point). At the start up the shader will
display the graphics with the current light position.
Then if you use MoveLight(#Light, 0, 50, 50, #PB_Absolute) the shader automatically updates and displays the new lighting position.

So, all you will need to do is make sure the camera and light position are in the same spot. Using a node might be the simplest way of accomplishing this.
That or you could collect the camera X, Y, and Z locations. Then update the light position to those coordinates.

I could create an example if you need one.
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 756
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: Normals Shader -> terrific Toon Shader

Post by Samuel »

Yes, I see your problem now. I'll see what I need to change on the shader.
One quick question though. Do you want some of your toons to work off of the camera position and others to work off of the light position?
Or will all of them be using the camera position?
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 756
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: Normals Shader -> terrific Toon Shader

Post by Samuel »

I think I'm just about done with switching it to the camera position.

I'm going to go through the files to combine and edit some of them. That should make the shader easier to work with.
You'll end up with 3 or 4 files instead of the previous 7.

I should be able to post the new version sometime in the next day or two.
Post Reply