Jump to content
  • Advertisement

MD Forhad Reja

  • Content Count

  • Joined

  • Last visited

Community Reputation

137 Neutral

About MD Forhad Reja

  • Rank

Personal Information

  • Interests
  1. MD Forhad Reja

    [dx9] setting a shader constant?

    It should be 16 in the last parameters of SetVertexShaderConstantF, not 4. A matrix is made of 16 floats. So your're just passing the only 4 elements, not the whole matrix. 
  2. Wish to make a good FPS game.
  3. Many thanks for your kind information. Can you give me the link of Nividia paper?   Thanks again.
  4. Isn't there anybody to help me?  :unsure:
  5. Yes, I have. In fact my posted codes work just fine as a basic shadow map.   Here is the screenshot -    http://postimg.org/image/wlo7nircr/be298c65/   Note that the above screenshot is also showing split colors. I think they are just fine?
  6. Of course I did look at those resources but the fact is I'm struggling to understand how I can implement them practically and that is why I need help.. I really need help.
  7. After being success in implementing a decent shadow map for my game engine ( with a great help of this community ), I'm very very keen to jump into some advance shadow map techniques like Cascaded Shadow Map(CSM), Parallel-Split Shadow Map(PSSM), Variance Shadow Map(VSM) etc. Cause I want a shadow technique that will be able to cover big area in game very efficiently. After doing a lots of search in Internet, I found CSM most useful. I may be wrong but this technique has really impressed me. And I really want to implement it.   First looked into the Cascaded Shadow Map sample of Microsoft DirectX SDK(June 2010) called CascadedShadowMaps11 to get the basic idea. But what I actually understand is nothing. Uff! This sample is really really complex ( for me ). What actually bother me is the DX11 and XNA stuffs.    So I started doing something simpler in that way -    I render ( only depth ) all the shadow casting object three times into three different render target texture. Every RT texture has its own View and Projection matrix ( Actually a shadow camera ). three times means I just simply render them inside a for loop and I call the following function inside the loop to update the shadow camera for every RT texture -  void SceneManager::UpdateShadowCamera(Camera* cam, Light* light, Camera* texCam, size_t cascadeIndex) { // Build View Matrix D3DXVECTOR3 dir = -light->mSunDirection; ::T3DNormalize(&dir); D3DXVECTOR3 pos(-3, 30, -57); //------------------------------- D3DXVECTOR3 up(0, 1, 0); // Check it's not coincident with dir if (abs(DotProduct(&up, &dir)) >= 1.0f) { // Use camera up up = D3DXVECTOR3(0, 0, 1); } // cross twice to rederive, only direction is unaltered D3DXVECTOR3 left = CrossProduct(&dir, &up); Normalize(&left); up = CrossProduct(&dir, &left); Normalize(&up); // Derive quaternion from axes Quaternion q; q.FromAxes(left, up, dir); q.Normalize(); texCam->matView = MakeViewMatrix(pos, q, NULL); ViewFrustum* frustum = cam->mFrustum; D3DXVECTOR3 camPos = cam->GetPosition(); float mSplitPoints[4] = { 1.0f, 20.0f, 80.0f, 300.0f }; // Apply the right clip distance. float nearSplit = mSplitPoints[cascadeIndex]; float farSplit = mSplitPoints[cascadeIndex + 1]; // Build Projection Matrix texCam->matProjection = MakeProjectionOrtho( 100, 100, // width and height 1.0f, 100.0f // near and far ); // Now I'm stuck here! }  So basically, this function has got four parameters. The cam is the main view camera, the light is carrying only a direction. texCam is the light/shadow camera. cascadeIndex is the for loop current index. Inside this function, I just did some basic calculation what I do for a simple shadow map.   And also,  my shadow receiver pixel shader uses following code to determine which shadow map to use now -  float shadow = 1.0f; if ( pixelDepth < 20 ) { shadow = tex2Dproj(gDepthMap, SMPos); splitCol = float4(0.1, 0.0, 0.0, 1.0); } else if ( pixelDepth < 80 ) { shadow = tex2Dproj(gDepthMap2, SMPos2); splitCol = float4(0.0, 0.1, 0.0, 1.0); } else if ( pixelDepth < 300 ) { shadow = tex2Dproj(gDepthMap3, SMPos3); splitCol = float4(0.0, 0.0, 0.1, 1.0); } pixelDepth is screenSpace Z value passed by vertex shader. Both in main code and pixel shader, split distances are hand-coded for the testing purpose. Those codes are working perfectly. I mean split colors are showing perfectly according to their distance.    That's it! I could not go anymore. I don't know how to calculate proper projection and view matrix for Cascaded shadow map. I think that my view matrix calculation is just fine. Or maybe not?   All the samples in Internet are very tough for me to understand. Some of them only calculates different projection matrix for each texture and the view matrix is same. and some of them recalculates both! Things are getting horrible. So I really need help.   Please help.  
  8. MD Forhad Reja

    What is this artifact in my shadow map?

    Actually, the final hlsl shader code isn't much different than the code that I posted.    I just changed the following line -  float cDiffuse = dot(vWorldNormal, normalize(gLightDir)); to -  float cDiffuse = max(dot(vWorldNormal, normalize(gLightDir)), 0); Now you got it? Sorry for late reply. 
  9. MD Forhad Reja

    What is this artifact in my shadow map?

    Many thanks to everyone. :)
  10. MD Forhad Reja

    What is this artifact in my shadow map?

      Oh, that actually make sense. I could think about it before.   so using max 0, the result is just fine -    http://postimg.org/image/g6m6xbl6p/583628cc/   Thanks a lot. :)
  11. MD Forhad Reja

    What is this artifact in my shadow map?

    Now I'm here to show my updated shadow map results.    Camping the dot product -    http://postimg.org/image/x2lcsoq69/b82333a9/   So artifacts are gone ( and the self shadow! ) but the shading looks flat.    And using Half lambert -    http://postimg.org/image/nsh3i1rwh/bdb273d1/   Artifacts are still present but looks better than before.    Now I'm thinking what to do next...
  12. MD Forhad Reja

    What is this artifact in my shadow map?

    No, the ground and the teapot are rendered in same way. Both receive and cast shadow ( though the ground plane should not cast shadow ). And also they use same shader.    If you need more information, let me know.   Thanks.
  13. MD Forhad Reja

    What is this artifact in my shadow map?

    Well, This is a good solution. But... actually the back side of the teapot looks very flat.    Thanks.     Yes, but remember that you are using a "flat" color as your ambient term.   You could use "half Lambert" for the diffuse term (instead of clamping, multiply by 0.5 and add 0.5), this will remap the [-1,1] range to [0, 1] giving you that backside gradient you are looking for.   Anyway... Its not really related to your shadow issue.   Thanks. I really like the idea of "half Lambert".  Let me check it out...
  14. MD Forhad Reja

    What is this artifact in my shadow map?

      OK, I will change the bias value and see what happen. And yes, I'm using D3DTADDRESS_CLAMP for D3DSAMP_ADDRESSU and D3DSAMP_ADDRESSV.   Never mind, what is nullified Sampler State?
  15. MD Forhad Reja

    What is this artifact in my shadow map?

    Well, This is a good solution. But... actually the back side of the teapot looks very flat.    Thanks.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!