i’m totally new here, so apologize any errors.
I’m thinking about making ARBs vertex & fragment programs (!!ARBvp1.0) for Doom3.
What i got in mind would be a Cell/Toon shader for a personnal project.
So, i should:
Posterize(good word?) colors:
to do so, i’d like to use an 1d (1x16) texture to define models’ colors’ hard edges positions and gradients, to have a total control over each models’ materials.
Draw object/model “blacklines”:
tricky&easy choice should be to go for an inverted & scaled up black model, but it would mean render 2 times the same model, and blacklines should grow when coming from far to near the player view.
So i’d prefer to go for a vertex program that keep blacklines at a given thickness (plus only 1 model to render).
I’d also like this Cell shading effect to be only 60-75% over the original textures and lightning, like this:
that’s the hardest part for me to figure, i’d like to use a greyscaled texture (let’s take a clouds texture for exemple) and use it for dark areas and shadows, but, use it only as a mask.
Let’s take the red donut image as example:
-the red part should have no “cloud” at all.
-the brown part should have everything that as a brightness inferior to 50 (rgb value between 0 and 255) on the cloud texture, applied on black over the donut, not on object textures coordinates, but rather on screen coordinates.
-the very dark brown, plus the black donut part, should have everything as a brightness inferior to 150 on the cloud texture, applied on black over the donut. (still in screen coord.)
(i replaced clouds by lines, look more cartoonish)
Ok, so, finally…
A) Is that effect(s) possible with only ARBs?
B) Should i go for a screen post process effect over everything, including sprites, decals, etc (may cause some problems for edges on sprites for example), or should i go for individuals shaders on selected models/materials? or combination of the both?
C) Where could i start to learn more specific fonctions about ARB to achieve this?
Any tips, help, piece of code would be very appreciated!
I finally got the simple cell-shading effect pass through the interaction.vfp, it’s the “vertex & fragment program” file that calculate materials interactions (diffuse+specular+normal+lights).
so i don’t need another shader over the screen, or over the rendered model, for this.
Now, i’ll look for the “blacklined edges” effect and look how i can achieve this, and where…
It’s something like that, but how must i go for that, in ARB 1.0 vertex program?
Plus, is the line-width=3 in pixel size, or in “world space” size?
(cause i don’t want big black lines when the model is near the camera)
I was thinking about a pixel depth approach, but still learning how to do so…
I’d like to insert it in the “common” vertex&fragment program that Doom3 use for each material that use a diffuse+specular+normalmap+light (98% of objects).
Too bad, so the black edges will not be so great.
Could it be possible to know the normal of a polygon, or compare any polygon that is facing between 85°-95° from the view, and draw black pixels next to it?
Doable, normally the normal is already available in the fragment program. But this method is not really great, I tryied it : you can tweak the threshold angle for the black, but the best results depends heavily of the curvature. Thin tubes will need a very diffrent threshold than wide tubes, for example.
But sure, it is better than nothing.
Or even using a pixel depth comparison shader as a post process?
If doom3 has such a pass, it is possible… but unlikely.
-Cell/Toon Shading effect in the main vertex/fragment program:
I injected it right after the normal+tangent+light algorithm
so the diffuse and (potential) specular are added over it.
(not color limited)
-Edge Blacklines effect in an objects optionnal pass:
by calculate normal+tangent+view angle, and using 1d external
texture for line thickness/color.
Currently, i’m doing the postprocess vfp:
-Dark zones “brush effect”,
-Light zones “paper effect” (something like “Okami”),
-Screen color hue filter.
The hardest part for the moment is to figure out how to modulate screen dark areas with a scaled brush/stroke texture,