Toon shading without shaders?

BlitzMax Forums/MiniB3D Module/Toon shading without shaders?

Hezkore(Posted 2008) [#1]
Using latest MiniB3B version, is it possible to get a good toon effect without shaders?

(I'm not speaking about the black lines around a model, I'm on about the shades/lightning)

Something like this:


There are lots of tutorials about this, but since I'm new to 3D AND BlitzMax/MiniB3D I find them very hard to follow. >_>

Here's one for example:
http://www.gamedev.net/reference/programming/features/celshading/

So does anyone have any example of this and is it even possible? :S


JustLuke(Posted 2008) [#2]
I've never used MiniB3d, but cubemaps can give you the effect that you're looking for in Blitz3d.


Hezkore(Posted 2008) [#3]
You got any examples of that?
I might be able to convert it to MiniB3D/BlitzMax.


JA2(Posted 2008) [#4]
Try this:



This is a more advanced version of something I used for my Bongo game. It's based on some code by sswift.

Call the CelShader() function to setup cel shading (or change the number of shades your using) then use CelShade() or AnimatedCelShade() functions to apply it to your models.

For debugging, just call the LinearGradient() function after RenderWorld to see the texture used in the Cel Shading functions. Hope that all makes sense, been awhile since I used it :)


Hezkore(Posted 2008) [#5]
Cheers mate!
Now I just have to convert it to BlitzMax and I'm terrible at Blitz3D code lol -_-


plash(Posted 2008) [#6]
Note: that's Blitz3D code.


JA2(Posted 2008) [#7]
Yep should have mentioned that it is Blitz3D code. It shouldn't be too hard to convert over to BlitzMax/MiniB3D tho...


Hezkore(Posted 2008) [#8]
Yeah I got it working, thanks a lot mate! :D


JA2(Posted 2008) [#9]
You're welcome :)


The r0nin(Posted 2008) [#10]
Would you care to post the ported code? I could convert it to BMax as well, but if you've already done it...


The r0nin(Posted 2008) [#11]
I guess that's a "no." Share the wealth...


JetFireDX(Posted 2008) [#12]
I started converting it too. I've gotten the outlining bit of the code to work, but not the shading effect. (Everything compiles and works but the texture that is created and mapped to my objects doesn't seem to work right yet.) If I get it working fully I will post it but since it didn't take long to get this much going you might be able to get it all going yourself faster than waiting.


Hezkore(Posted 2008) [#13]
Sorry I've been having computer problems lately...
I didn't convert the texture generating code, I made it simple for me and just loaded a premade texture instead.
Also I didn't need it for animated objects, so I simplified the code a lot.


The r0nin(Posted 2008) [#14]
No prob... looks like I'll be diving in then....


The r0nin(Posted 2008) [#15]
Huh... I can't get it to work on B3D, much less MiniB3D. I must be doing something wrong. Do I need to call CelShader() outside the main loop, then AnimatedCelShade(model) in the loop before RenderWorld?


JA2(Posted 2008) [#16]
Only call AnimatedCelShade() before the main loop (after CelShader() is used) or when you have changed the number of shades used in CelShader(). AnimatedCelShade() is used for models loaded with LoadAnimMesh but don't use models with bone animation (play my Bongo game and watch closely to see why).


siread(Posted 2008) [#17]
I have done some very basic looking toon shading in NSS4 using cube maps...

http://www.blitzbasic.com/Community/posts.php?topic=77969