D3D9 Effects- variable parameters

  • D3D9 Effects- variable parameters DeadMG

    I've created some simple Phong shading code from a sample. The issue is that the sample only handles one light. If I wanted a variable number of lights set at the start of each frame, how could I specify in the effect file that I need to pass a variable number of e.g. light positions and etc to render from?

  • For each light do one render pass and use Additive blending. It is called forward rendering.

    Question is: Why to do it this way and not just send all of the light positions and params in few arrays? Answer is that this is much easier to handle once you start making some more complex effects. And there is one plus more. You can use your current shader.

    Edit: To prove my point, i added two renders, because this technique sometimes sounds weird. One is rendered with gpu renderer which using described technique. And second is same scene rendered with Maya. Scene is lighted with 3 lights. One emits red, one blue and one green color. Common shadow mapping is used.

    Realtime renderer:

    Rendered with maya


c++ directx9
Related questions and answers
  • I am setting an HLSL effect variable in the following way in a number of places. extern ID3D10EffectVectorVariable* pColour; pColour = pEffect->GetVariableByName("Colour")->AsVector(); pColour->SetFloatVector(temporaryLines[i].colour); In one of the places it is set in a loop, each line in the vector temporaryLines has a D3DXCOLOR variable associated with it. The most annoying thing... = temporaryLines.size(); for(int i = 0; i < allLines; i++) { pColour->SetFloatVector(temporaryLines[i].colour); // in the line loop too? // combine the matrices and render D3DXMATRIX

  • I was thinking about making smaller structures with the fTime variable each so I can have attribute keyframes, light keyframes and buffer keyframes, then make the node structure look like... something that will be default values in most of the scene objects (I believe the scene won't be built from skinned hierarchy meshes but mostly static and even in some cases the animation is purely... this variable in order to change the global alpha value for this frame LIGHT_TYPE nApplyLights; // Set the light types that will be processed for this node. If it's set to GLIGHTTYPE

  • . length Number of bytes you want to lock in the sample buffer. ptr1 Address of a pointer that will point to the first part of the locked data. ptr2 Address of a pointer..., void * ptr2, unsigned int len1, unsigned int len2 ); ptr1 Pointer to the 1st locked portion of sample data, from Sound::lock. ptr2 Pointer to the 2nd locked portion of sample data, from Sound::lock. len1 Length of data in bytes that was locked for ptr1 len2 Length of data in bytes that was locked for ptr2. This will be 0 if the data locked

  • I am trying to create a 2D platformer (Mario-type) game and I am some having some issues with handling collisions properly. I am writing this game in C++, using SDL for input, image loading, font... over-thinking it. If anyone thinks they can help, please take a look at the code below and help me try to improve on this if you can. I would like to refrain from using a library to handle this (as I...; } } if (de2dCheckCollision(ball,block[i],0.0f,0.0f)==false) { ball.gravity = -0.5f; } } } To explain what some of this code means: The blocks variable is basically an integer that is storing

  • I'm rendering to a depth map in order to use it as a shader resource view, but when I sample the depth map in my shader, the red component has a value of 1 while all other channels have a value of 0. The Texture2D I use to create the DepthStencilView is bound with the D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE flags, the DepthStencilView has the DXGI_FORMAT_D32_FLOAT format... errors from D3D, and no compile time warning or anything. I'm not sure what I'm missing here at all. I have the impression the depth value is always being set to 1. I have not set any depth/stencil

  • Posted this question on SO but got no answers. Maybe somebody can help me here. I recently had a well-working program which streamed WAV and Ogg sounds with OpenAL. I then decided to abstract the source and buffer objects into C++ classes. I got as far as the source class. My function which returns the number of processed buffers is not altering the integer passed to alGetSourcei. int ALSource...) return -1; return processed; } I checked that error is never anything but AL_NO_ERROR. I generate the source in the constructor: alGenSources(1, &source); This also never gives any error

  • I'd like to use Lua to write some scripts which should allow me, given the state of certain variables of a specific instance, to determine a number to be assigned to a variable of that instance. Let me explain: I have a class, which is called Monster. This class contains a boolean variable which is called "Slowed". My script should return a different number depending on Slowed's value. To do this, I have to push a lot of functions in Lua, for example getSlowed(), and this functions also depend on the kind of instance. So, I'd like to write a "LuaManager" class which can push the functions

  • I've come across a C++ Sample of from Programming Game AI by Example. For the most part it is fairly understandable, the only thing confusing me is the reference to "m_pVehicle->Heading()" I'm not sure what it means by heading. If anyone could clarify this, I would really appreciate it. Vector2D SteeringBehaviors::Pursuit(const Vehicle* evader) { //if the evader is ahead and facing the agent then we can just seek //for the evader's current position. Vector2D ToEvader = evader->Pos() - m_pVehicle->Pos(); double RelativeHeading = m_pVehicle->Heading

  • btDiscreteDynamicsWorld(Dispatcher, BroadPhase, Solver, CollisionConfiguration); ... createScene(); } In the createScene method I add a light and try to setup a "ground" plane to act as the ground for things...::createScene() { m_pSceneMgr->createLight("Light")->setPosition(75,75,75); // Physics // As a test we want a floor plane for things to collide with Ogre::Entity *ent; Ogre::Plane p; p.normal = Ogre... code shows the changes I made to get accurate physics. void GameState::createScene() { m_pSceneMgr->createLight("Light")->setPosition(75,75,75); // Physics // As a test we want a floor plane

Data information