Toon shader.. yeah the #521231

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Toon shader.. yeah the #521231

Post by B@z »

Hi
Sorry for the new topic...
But i was searching around the forum and the net for a week, and didn't find any good one..
Actually found a lot of toon shader, but nothing had outline.
I need outline, but dont wanna make it in the model (it would duplicate the vertex number, so not too good for fps ;) )
but i dont know shader, dont understand at all xD
could somebody show me a good one? (what works)
Oh and yeah, i need directx shader (hlsl maybe?)

thanks
Image
Image
Pyritie
Posts: 120
Joined: Fri Jan 16, 2009 12:59 pm
Contact:

Post by Pyritie »

Hive Workshop | deviantART

I've moved to Ogre.
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

yeah it looks cool, but there isn't any source code there... xD
Image
Image
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

any ideas?
Image
Image
Pyritie
Posts: 120
Joined: Fri Jan 16, 2009 12:59 pm
Contact:

Post by Pyritie »

Do you want the outline to change depending on the viewing angle?

If not, then just put it in the texture.
Hive Workshop | deviantART

I've moved to Ogre.
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

well it will be a 3d game, so of course i need to change depending on the viewing angle xD
it looks bad if not...
Image
Image
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

nobody? :(

i found some shaders what does something like that, but it needs multiple pass shader.
does irrlicht support that?
Image
Image
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

pls?
Image
Image
Image
Frank Dodd
Posts: 208
Joined: Sun Apr 02, 2006 9:20 pm

Post by Frank Dodd »

Perhaps you could try some of these shaders out

http://www.lighthouse3d.com/opengl/glsl/index.php?toon1

I'm not shader capable myself yet :oops: but this looks like an interesting resource to start out with.

I did find a link where someone had created a toon shader with a very simple ARB program that I have almost got running at least to create the posterised shading but not the outline.

http://www.paulsprojects.net/direct3d/c ... ading.html

I don't think either of these are really suitable for a beginner forum but ... its a start
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

hi
thanks for the links
but i saw both of them before, the first one doesn't have outline, and the second one... i dunno why did i dropped out :O

anyway, im going to check it out, thanks ^^

but still need sollution, im not sure i can do it ><;

edit:
i tried the second one, and thats what i want! (maybe a little stronger outline, but thats not the problem)
but... i can't get it work with irrlicht...
if i put it into dx9 it doesnt work (keeps telling something wrong with v0 and so on), but it compiles with dx8.
but so, its invisible...

passing variables with this:

Code: Select all

		core::matrix4 worldViewProj;
		worldViewProj = driver->getTransform(video::ETS_PROJECTION);			
		worldViewProj *= driver->getTransform(video::ETS_VIEW);
		worldViewProj *= driver->getTransform(video::ETS_WORLD);

		services->setVertexShaderConstant(worldViewProj.pointer(), 4, 4);		
		video::SColorf col(0.75f, 0.95f, 1.0f, 1.0f);
		services->setVertexShaderConstant(reinterpret_cast<f32*>(&col), 4, 1);		

		core::vector3df pos = device->getSceneManager()->
			getActiveCamera()->getAbsolutePosition();

		invWorld.transformVect(pos);
		services->setVertexShaderConstant(reinterpret_cast<f32*>(&pos), 8, 1);
		services->setVertexShaderConstant(reinterpret_cast<f32*>(&pos), 8, 1);
whats the problem? :(

edit2:
tried with this:

Code: Select all

		core::matrix4 worldViewProj;
		worldViewProj = driver->getTransform(video::ETS_PROJECTION);			
		worldViewProj *= driver->getTransform(video::ETS_VIEW);
		worldViewProj *= driver->getTransform(video::ETS_WORLD);
                worldViewProj = worldViewProj.getTransposed();

		services->setVertexShaderConstant(worldViewProj.pointer(), 0, 4);		
		video::SColorf col(0.75f, 0.95f, 1.0f, 1.0f);
		services->setVertexShaderConstant(reinterpret_cast<f32*>(&col), 4, 1);		

		core::vector3df pos = device->getSceneManager()->
			getActiveCamera()->getAbsolutePosition();

		invWorld.transformVect(pos,core::vector3df(0.0f, 0.0f, 20.0f));
		services->setVertexShaderConstant(reinterpret_cast<f32*>(&pos), 5, 1);
		core::vector3df objspacepos;
		invWorld.transformVect(objspacepos,core::vector3df(5.0f, 5.0f, 5.0f));
		services->setVertexShaderConstant(reinterpret_cast<f32*>(&objspacepos), 6, 1);
and it pops up, but well... it appears to be a box, and has some toon shader, but no outline, and the texture is screwed up...did i wrong something?
Image
Image
Post Reply