Questions on ARB assembly-level by a newbie

Hi everyone,
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:

  1. 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.

  2. 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).

  3. I’d also like this Cell shading effect to be only 60-75% over the original textures and lightning, like this:

  4. 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.)

example:

(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!

Thank you for reading,
Greg.

A) Yes, ARB_vertex_program ARB_fragment_program are sufficient for doing toon shading. These extensions are for SM 2.0 hw like the Gf 5800 and Radeon 9700 and others.

B) This effect is not a post-processing effect.

C) Rendermonkey has exampe in GLSL which you can convert to
ARB_vertex_program ARB_fragment_program and I ve seen demoes in the ATI SDK

Oki, thank you V-man.
I’ll check out Rendermonkey and the ATI SDK.

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…

any idea, or, a good link?

For blacklines, how about: make line-width=3, set polygon-fill=line, invert the backface culling, draw your model.

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…

Fortunately in your case, the line width unit is pixel, so it stays the same when the object in close to or far from the camera.

you don’t need to use a shader for that, just redraw your object (in a second pass) in wireframe mode using glPolygonMode glLineWidth and inverse the culling mode with:

glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);

thanks for the tip, but i can’t use those gl fonctions…
i use an ARB 1.0 shader language (doom3) only.
:frowning:

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).

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?

Or even using a pixel depth comparison shader as a post process?

:confused:

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.

So what method do you preconize? (recommand?)

Ok, for the moment i managed to have:

-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,

any links/tips on this subject?

thanks.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.