New shader features?

Posted By: jcl

New shader features? - 10/06/03 18:41

I would like to know which variables, vectors, matrices and other features you want to have implemented for effect files.

We'll add the inverse view matrix, and a tangent vector instead of the second texture coordinate set - both are required for certain shader effects. Then we'll have basically the same set of shader variables that programs like RenderMonkey or EffectEdit offer, so I guess that's all what's needed for all kind of effects. After implementation of the new light management, we'll also add vectors for the properties of the 8 lights.

If you need anything else, please post it here, and also mention for which kind of shader effect you'd need it (or mention the sample in one of the shader programming books).

It was requested to add C-Script access to the transformation matrices. However the world matrix is different for every rendered entity, so this would not make much sense, or would at least slow down the rendering due to the fixed<->float conversion. So I'd prefer to calculate all required matrices by the engine.
Posted By: ventilator

Re: New shader features? - 10/06/03 18:48

but won't the second texture coordinate set be important once shaders can be used with level geometry?
Posted By: jcl

Re: New shader features? - 10/06/03 18:51

Yes. The tangent space conversion can not be used for shaded surfaces. But it can be used for models, sprites, and flat surfaces, so I guess it's not much of a restriction.
Posted By: ello

Re: New shader features? - 10/06/03 19:54

as i see we have those so far.
v0[3] - position
v3[3] - normal
v7[2] - tex coord1
v8[2] - tex coord2

what about getting color-vectors and vertex_weight. this one crossed my way many times when i was looking at some sources i found.

in a description i found there are the following ones:
v0[3] - position x,y,z,w
v1[3] - vertex weight w,0,0,1
v2[3] - normal x,y,z,1
v3[3] - primary color r,g,b,a
v4[3] - secondary color r,g,b,a
v5[3] - fog coefficient fc,0,0,1
v6[3] - tex coord1 s,t,r,q
v7[3] - tex coord2 s,t,r,q




Posted By: ventilator

Re: New shader features? - 10/06/03 20:16

i guess the vertex weight is only needed if you want to use the vertex shader for skeletal animation or something like that and the colors would only be useful if a6 geometry would support vertex colors.
Posted By: jcl

Re: New shader features? - 10/06/03 20:24

Those input parameters are mostly legacy for software T&L. Hardware T&L vertex formats normally don't use colors, fog coefficients and so on. So, those values are normally always zero. The only thing we'll change in that regard in the next beta is 3 dimensions for the texture coordinates, instead of 2.
Posted By: ello

Re: New shader features? - 10/06/03 20:25

but if i can set the colors (oD0 and oD1) then i'd like to be able to request them, too.
Posted By: jcl

Re: New shader features? - 10/06/03 20:29

What for?
Posted By: ello

Re: New shader features? - 10/06/03 20:46

for example, i'd like to swap the red and blue amount of oD0 to have it flicker
Posted By: jcl

Re: New shader features? - 10/06/03 23:53

I'm a little confused now. It's pretty easy to swap the read and blue values in a vertex shader. What has this to do with the input registers?

The v3 and v4 registers pass the diffuse and specular vertex colors to the shader. In T&L mode, vertices do not have any diffuse and specular colors. Those colors are calculated by the hardware from the material and the entity color and environment lights. So those registers are always zero in A6 mode. They are only used in A5 mode.
Posted By: ello

Re: New shader features? - 10/07/03 03:08

hmm, ok..dont pay any attention on this.. seems to be siilly words i spoke, just saw that thing at an example and got confused, too.
Posted By: ventilator

Re: New shader features? - 10/07/03 07:43

i am not completely sure but i think wolfgang engel's per pixel lighting examples use a transposed world matrix. maybe this would be useful?
Posted By: mss

Re: New shader features? - 10/07/03 09:02

I think access to the transformation matrices could make sense in some situations. As game developer I know which objects are fixed and which are not. For a fixed object I need only one time the inverse worldmatrix, in a loop I would transform the eyepositon to objectspace and set them in the entity or material skills which are used as constant values (one calculation per model). In vertexshader the transformation would be calculated for each vertex, which could be expensive depending on the number of vertices.
Posted By: mss

Re: New shader features? - 10/07/03 09:20

As you set the worldmatrix in constants which are vectors of four floats the worldmatrix we get from the engine is already transposed.
Posted By: ventilator

Re: New shader features? - 10/07/03 09:27

oh! i see! some of this matrices stuff still confuses me...
Posted By: mss

Re: New shader features? - 10/07/03 17:09

Maybe the following try to explain it could help you.

Code:
  .


Multiply a vector with a Matrix:

M11 M12 M13
[x’ y’ z’] =[x y z] * M21 M22 M23
M31 M32 M33

/////////////////////////////////////////////////////
x’=(x*M11)+(y*M21)+(z*M31)
y’=(x*M12)+(y*M22)+(z*M32)
z’=(x*M13)+(y*M23)+(z*M33)
/////////////////////////////////////////////////////
the Matrix set as it is in constants:

c0=(M11,M12,M13)
c1=(M21,M22,M23)
c3=(M31,M32,M33)
/////////////////////////////////////////////////////////
would not lead to the expected solution in the dot product:

x’=(x*M11)+(y*M12)+(z*M13)
y’=(x*M21)+(y*M22)+(z*M23)
z’=(x*M31)+(y*M32)+(z*M33)
/////////////////////////////////////////////////////
Transposing a Matrix means to exchange the rows with the columns:

M11 M12 M13 M11 M21 M31
A = M21 M22 M23 A transposed = M12 M22 M32
M31 M32 M33 M13 M23 M33
//////////////////////////////////////////////////////////////////////////////////
Set the transposed Matrix in constants:

c0=(M11,M21,M31)
c1=(M12,M22,M32)
c2=(M13,M23,M33)
//////////////////////////////////////////////////////////////////////////////////
Now we have the same result as multiplication a vector with a matrix.

x’=(x*M11)+(y*M21)+(z*M31)
y’=(x*M12)+(y*M22)+(z*M32)
z’=(x*M13)+(y*M23)+(z*M33)



This explanation is not perfect, but I think it could be helpful.

The stuff is more confusing, if you don’t know how Direct3D deals with those matrices and in a tutorial this is required like in the tuts from Wolfgang Engel.


Posted By: mss

Re: New shader features? - 10/07/03 18:24

Some information from the D3DCaps8 structure would be useful, like the shader versions and max simultaneous texture.
Posted By: ello

Re: New shader features? - 10/08/03 15:48

its me again. i found the use of a cv_color(maybe that is a colorvector) in the toonshading example of the NVeffectsbrowser.

and i came across many times the "eyepoint" - what vector is that?
Posted By: ventilator

Re: New shader features? - 10/08/03 16:15

mss, thanks for the explanation!

...
i guess the eyepoint is the view position. you can get it from the worldview matrix.

VertexShaderConstant[8]=<matWorldView>;
c10 is the view position then. (i guess in modelspace)
© 2024 lite-C Forums