Solved

dx9 shader / sdk sample question

Posted on 2004-08-01
3
742 Views
Last Modified: 2013-12-26
in the DolphinVS sample that comes with directX 9 sdk, there is some setvertexshaderConstant() functions in the FrameMove function that look like this...

            Device.SetVertexShaderConstant(0, New Vector4() {vZero})
            Device.SetVertexShaderConstant(1, New Vector4() {vOne})
            Device.SetVertexShaderConstant(2, New Vector4() {vWeight})
            Device.SetVertexShaderConstant(4, New Matrix() {matTranspose})
            Device.SetVertexShaderConstant(8, New Matrix() {matCameraTranspose})
            Device.SetVertexShaderConstant(12, New Matrix() {matViewTranspose})
            Device.SetVertexShaderConstant(19, New Vector4() {fLightDolphinSpace})
            Device.SetVertexShaderConstant(20, New Vector4() {fLight})
            Device.SetVertexShaderConstant(21, fDiffuse)
            Device.SetVertexShaderConstant(22, fAmbient)
            Device.SetVertexShaderConstant(23, fFog)
            Device.SetVertexShaderConstant(24, fCaustics)
            Device.SetVertexShaderConstant(28, New Matrix() {matProjTranspose})

I dont understand why constants would have dolphinspace information, and what i would do with these lines of code if i have a second dolphin in a different position.


thanks for any input, i know its vague but im just tryin to understand how to maniuplate multiple objects using shader technology.  most books i read on shaders use directX8 and c++ and im having trouble getting the understnad.
0
Comment
Question by:joshmiller
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 17

Accepted Solution

by:
davebytes earned 500 total points
ID: 11726709
Many times, constants are used for more specific information for a given model instance in the world.  I've used this to add coloring/tinting to different players, but do it inside the shader -- or to do time-offset specific stuff, but allow models to have their own 'time clock'.

You can call the SetVertexShaderConstant calls every frame, for every object, and it won't tank performance -- you'll hit MANY other bottlenecks before it even hits the radar screen.  Just modify your code so that anything 'dolphin specific' is stored in a structure per-dolphin, then SVSC should reference the per-dolphin variable as it does setup (or pass a ptr to the dolphin struct for each setup call, making it more abstracted).

There's a ton of new books on the market dealing with DX9, and with DX9 shaders -- worth checking out amazon/borders/etc. and picking up one or two.

-d
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question