Re: Adding normal matrix to CSS Shaders

On Mon, Dec 19, 2011 at 2:12 PM, Chris Marrin <cmarrin@apple.com> wrote:

>
> On Dec 16, 2011, at 10:51 PM, Fabrice Robinet wrote:
>
> > Hi group,
> >
> > One great outcome of CSS Shader could be the ability to add
> custom/simple lighting to DOM elements.
> > The simple addition of the normal matrix to be passed to the shader (as
> optional),
> > would allow simple cases without impacting the SPEC too much.
>

What is a "normal matrix"?

If you feel like going crazy, there's something nvidia defined, "Standard
Annotations and Semantics" that many shader editors use. They define the
following 24 matrices

WORLD
VIEW
PROJECTION
WORLDVIEW
VIEWPROJECTION
WORLDVIEWPROJECTION
WORLDINVERSE
VIEWINVERSE
PROJECTIONINVERSE
WORLDVIEWINVERSE
VIEWPROJECTIONINVERSE
WORLDVIEWPROJECTIONINVERSE
WORLDTRANSPOSE
VIEWTRANSPOSE
PROJECTIONTRANSPOSE
WORLDVIEWTRANSPOSE
VIEWPROJECTIONTRANSPOSE
WORLDVIEWPROJECTIONTRANSPOSE
WORLDINVERSETRANSPOSE
VIEWINVERSETRANSPOSE
PROJECTIONINVERSETRANSPOSE
WORLDVIEWINVERSETRANSPOSE
VIEWPROJECTIONINVERSETRANSPOSE
WORLDVIEWPROJECTIONINVERSETRANSPOSE




>
> This brings up a question I have about matrices and the shaders. The
> shader doesn't get a model-view matrix, so what would the normal matrix be?
> The only matrix passed in is the projection matrix and I'm not sure what
> value it has. Does it include some perspective value or is it just a
> mapping between NDC and the pixel space in which the element is rendered?
>
> I like the idea of making it possible to do lighting in CSS shaders. But
> to do that we'd need to pass in a model-view matrix, which would probably
> be the cumulative transform property from the element to the root, not
> including perspective, and add the perspective property to the projection
> matrix. Add a normal matrix to that and you can do complete lighting
> calculations. These would all be based on a viewer looking down at the page.
>
> But it's slightly more complicated than that. A web page can have multiple
> CSS perspective properties. But when an element has perspective, you can
> think of it as the viewing frustum for all its children. So I think we can
> safely make the model-view matrix the cumulative transform from that
> perspective element to the element with the CSS shader.
>
> All of these matrices have a cost associated with them. So if we want to
> make the complete set available, we might want to make it opt in, so we're
> not computing them unnecessarily.
>
> Does this make sense?
>
>

Received on Monday, 19 December 2011 23:42:04 UTC