Questions, questions, questions..

Posted By: Excessus

Questions, questions, questions.. - 07/17/06 13:21

Hello,

I have recently started learning about writing shaders and while I must say it's not as hard as it looks at first I have come across a few things I can't find an answer to. I'd really apreciate it if you guys could answer any or all of these questions.

1) Why do I (sometimes) have to initialise an output struct like VS_OUT Out = (VS_OUT)0;? (I guess this is not HLSL specific but I'd still like to know.

2) When I convert a vertex position to clipspace (SomeFloat4 = mul(InPos, matWorldViewProj)), what is in SomeFloat4.z and SomeFloat4.w?

3) How can a vertex have a normal? Is it that:
-each vertice is rendered multiple times, once for each triangle it is part of. It then gets the normal of the triangle that is currently being rendered.
-the vertex normals are just interpolated normals between all triangles that are connected to that vertex.

4) Can it be beneficial to include a technique that compiles a shader at 2_0 even if the exact same shader can be compiled at 1_1? Ofcourse I would also include a technique that compiles it at 1_1, but is a shader compiled at 2_0 faster for 2_0 cards?

5) Is it possible to imlement a shadowmapping shader without using a plugin? (If not, why not?)

6) Is it possible to implement a bloom shader without using a plugin? (If not, why not?)
Posted By: mk_1

Re: Questions, questions, questions.. - 07/17/06 14:17

1) dunno, never used a structure
2) z is depth in clipspace. You can use the z value to render a depth map for example.
3) Normal is interpolated if you use soft edges (smooth) and the triangle's normal if use hard edges (flat mode). Hopefully the mdl format will support that soon.
4) Don't think so but I don't know it.
5) I think it's possible with pro. You need to render a depth map from the lightsource and then use render to texture to use it on your screen.
6) again you need pro

5/6 buy Sphere
Posted By: ello

Re: Questions, questions, questions.. - 07/17/06 14:34

[quote1) Why do I (sometimes) have to initialise an output struct like VS_OUT Out = (VS_OUT)0;? (I guess this is not HLSL specific but I'd still like to know.




you aint forced to do so, but if you like to use the same input or output more often you will find it usseful to do so.
Posted By: Matt_Aufderheide

Re: Questions, questions, questions.. - 07/17/06 15:25

Quote:

Can it be beneficial to include a technique that compiles a shader at 2_0 even if the exact same shader can be compiled at 1_1?




No. The rule of thumb is, always use the lowest version that works.. however, most modern cards perform well on 2.0 so its really not a problem (GeForce FX cards were terrible at 2.0, but if you dont care about them...)

Quote:

How can a vertex have a normal?




How can it not? Triangles dont really exist in direct 3d, only vertices. That is, there is no real polygon normal.. only the vertex normal, and the polygon that is eventually drawn has the normal interpolated fomr each vertex.

Think of a vertex as a vector, not a point.
Posted By: Excessus

Re: Questions, questions, questions.. - 07/18/06 11:12

Thanks alot guys.

I have some more questions:
7) How do I define where the pixelshader output gets written? For example if I want to render a depthmap from a lightsource position, I don't want the output to be written to the backbuffer(and appear onscreen) but rather be written to some bitmap/texture. I think this is called a render target, how do I set it?
8) I often see people complain about limitations of the 3dgs shader system, but it's not exactly clear what these are. I've heard people say you can't access a depthmap and that there are only 2 render targets. What exactly are the implications of this and what other limitations are there? This is especialy important information for converting shaders I find on the net or in books.
Posted By: mk_1

Re: Questions, questions, questions.. - 07/18/06 13:51

You can certainly render a depth map (and I wrote that in the thread you're talking about).
afaik you need a render target for each light source you're using but I'm not sure about that since I don't own pro and haven't tried shadow mapping.
Posted By: Matt_Aufderheide

Re: Questions, questions, questions.. - 07/18/06 17:13

I think doing shadow mapping is not currently possible in Pro because of many factors, such as no floating point render targets, and so on. Certainly you could make a hack that could sort of work, but quality would be not good. Also there is littel chance you could do omni directional lights like in SPhere.

Basically not worth trying I think.
© 2024 lite-C Forums