Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

126 Neutral

About AntiMoron

  • Rank
  1. AntiMoron

    Problem about loading TGA files.

    I've already fixed this.   After reading documentation carefully. I found that it's using RLE(run - length encoding) for compression. I didn't know that at first.   it's working for now.
  2. AntiMoron

    Skin binding problem.

            Are you testing a simple model, perhaps just two cubes with a bone connecting them, perhaps with an animation that doesn't move the bone at all, or moves the bone just a very little bit?   If so, and if you have concluded that those routines are where problems may be, step through the code in debug mode (as suggested in the link) and check if the values are calculated correctly. With such a model, checking the matrix calcs will be very straight forward.   Yes! I should make my test case as simple as possible. 
  3. AntiMoron

    Skin binding problem.

      Sorry for my forgetting pasting the shader url : https://github.com/AntiMoron/aMazing/blob/master/aMazing/Shader/skinAnim/skinAnim.fx This is included in the project's github url pasted above too.   for InputLayout for this shader :  //this is the data structure that used to save vertex data for skeleton animation. class SkinVertex { public: SkinVertex() { memset(boneIndices, 0, sizeof(boneIndices)); weights = { 0, 0, 0, 0 }; } XMFLOAT4 position; //vertex in binding space XMFLOAT4 normal; //normals XMFLOAT4 texture; //textureCoord (just use the first two element) XMFLOAT4 weights; //weights unsigned int boneIndices[4]; //bone indices which indicate the bones that influenced the vertex }; //the layout used for the shader above D3D11_INPUT_ELEMENT_DESC animLayout[] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, offsetof(SkinVertex,position), D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "NORMAL", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, offsetof(SkinVertex,normal), D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, offsetof(SkinVertex,texture), D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "WEIGHTS", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, offsetof(SkinVertex,wegights), D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "BONEINDICES", 0, DXGI_FORMAT_R32G32B32A32_UINT, 0, offsetof(SkinVertex,boneIndices), D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; A lot of comments has been made in my cpp code to ensure that anybody else can read this code.    for tips #2-#4 you gave me:   I know that there're more than 4 weights (I've printed debug message before.I thought that those familiar with assimp may know this better than me.) I've already made it processed like:(save all the weights & sort'em ,cut for the top4 weights & indices,if not enough for 4 couples of index & weight,I made weights all zero for this case) //the index and weight for each vertex pair<boneIndex,weight> std::unordered_map<std::size_t, std::vector<std::pair<unsigned char,float> > > vindex2Weight; //pre-process bone datas for (std::size_t cur = 0; cur < bones->size(); ++cur) { auto& weights = (*bones)[cur]->weights; for (std::size_t r = 0; r < weights.size(); ++r) { std::size_t id = weights[r]->mVertexId; if (vindex2Weight.find(id) == vindex2Weight.end()) { vindex2Weight.insert(std::pair<size_t, std::vector<std::pair<unsigned char, float> > >(id, {})); } //insert weight count vindex2Weight[id].push_back(std::pair<unsigned char,float>(cur,weights[r]->mWeight)); } } //sort weight data for each vertex.the top4 will be used for (auto& entry : vindex2Weight) { auto& indexAndWeight = entry.second; std::sort(indexAndWeight.begin(), indexAndWeight.end(), [](const std::pair<unsigned char, float>& a, const std::pair<unsigned char, float>& b) { return a.second > b.second; }); } For tip #1.  I really need to give it a try. Thank you for your advise. I would reduce pasting code in my future questions.
  4. AntiMoron

    Data moving between GPU and CPU

    well if you want to move datas from CPU to GPU. constant buffer seems to be a good choice for you.   If you are using C++. you can do it template way.   Why not check my util :   https://github.com/AntiMoron/aMazing/blob/master/aMazing/GPUConstantBuffer.hpp   when using it ,you can just code : //xxx.cpp typedef struct { float[4][4] matrix; }DataToSlot1; GPUConstantBuffer<DataToSlot1> cb; //deivce : ID3D11Device* device,ID3D11DeviceContext* context, //a number to set binding slot in hlsl. cb.Initialize(device,context,1); DataToSlot1 cbData; //set cbData members' values. ... ... //update data in CPU. cb.UpdateData(&cbData); //update data in GPU cb.UpdateGPU(device,context); //bind data to shader. cb.BindVertexShader(device,context); then in your vertex shader.you can have : cbuffer xxx : register(b1) //binding slot 1 { matrix data; } to access your data from CPU.
  5. AntiMoron

    Skin binding problem.

      What have you done to find the problem?   Regarding your code: TL;DR as the problem could be any one of several things: bad import technique, wrong winding order, incorrect matrix calcs, bad shader code, incorrect loading of shader resources, etc., all things you can check.   Is your FBX file correct? Do you use assimp correctly to import it? Have you loaded a static model using the same import techniques? I.e., using FBX and assimp, have you created a simple box, imported it, and rendered it sucessfully?   You may want to follow the data to see where the data or the code is incorrect. In particular, note the suggestion to use the simplest data and code possible. Then add another code routine and test it.   Have you read this article on the FBX SDK? You also need to be familiar with the principles of skinned mesh animation.   well,thanks for you advise first... Before starting this thread,I just though that I shouldn't tell what I thought and did for the problem cuz this may effect what others think.   first I though I was setting wrong layout.  After rechecking it ,using 'offsetof' instead of calculating offset manualy seems fixed that error. But I still see artifacts. Broken meshes everywhere.   Sure,I've already rendered a static model.It goes perfectly, really nice. But I'm not using FBX SDK but assimp 3.0.   Assimp  support lots of kinds of models.And users should only consider those interfaces assimp gives. while importing FBX models,Assimp uses FBX SDK to implement its interfaces. So FBX SDK is not what I should consider.   According to Introduction to 3D game programming   let Pos be position of each vertex,P be the position of this vertex in binding space,M[] be the matrices in world space each bone have,Ind[] be  the indices of bones that effect this vertex. W[] be the weights which showing how much is the affect is. The formula is what I need at last: Pos =  sum(W[Ind] * P * M[Ind])   where i is usually range [0,4)   thus the output of rendering model in static mode(not including skeleton animation) is perfect,the only places where could cause my problem are as follow: calculation of matrices of each bone. calculation of vertex positions in binding space. calculation of indices and weights.   But after checking as what I said still not fixed my problem(Maybe a tiny place but I just can't find).  So I was thinking that anybody experienced could find the bugs to help me.    
  6. hello guys .I need your help. I'v been trying to do skin animation during last 36 hours.but vertices data seems broken. Using assimp 3.0 to load fbx model. view the result here http://pasteboard.co/2zixWwMK.png (for some reason I can't find a good paste image website.) my project can be download at herel: https://github.com/AntiMoron/aMazing the critical code of my problem can be viewd from : https://github.com/AntiMoron/aMazing/blob/master/aMazing/ModelClass.cpp https://github.com/AntiMoron/aMazing/blob/master/aMazing/ModelClass.h my IDE is vs2013 following c++11 standard what am I doing wrong ?
  7. Hello guys.I'm writing a util about loading tga files.   my reop at github :   https://github.com/AntiMoron/TgaLoader   The file format specification I'm referencing is https://github.com/AntiMoron/TgaLoader/blob/master/tgafileformat.pdf You can down load that with my repo.   My IDE is codeblocks 13.12 OS : win7.   When I follow the manual of tga file format reading the 'image data' part. Something went wrong. I'm so confused that can anybody help me?   The picture I got is :   The correct pic is as follows :
  8. AntiMoron

    problem about `Shadow Map`

    Well, thank you guys! I've almost fixed this problem. Code is already update to github. The problem shown at #5 is wrong depth-bias set.  Almost every common error about shadow map could be found from MSDN:  http://msdn.microsoft.com/en-us/library/windows/desktop/ee416324(v=vs.85).aspx This is really a good article.   Here is an url to view my shadow map currently. https://lh4.googleusercontent.com/-QBwhBNd0Q_o/VCaqJS-bRMI/AAAAAAAAABU/wzo-5-hlpSY/w674-h542-no/success.png           as you can see from picture.There is still much space to improve. Wish you can succeed too if you have similar questions as mine about shadow mapping!!!!! :)
  9. AntiMoron

    problem about `Shadow Map`

    this is how it failed...The depthvalue must have some problem.
  10. AntiMoron

    problem about `Shadow Map`

    Well It's about shadows. The depthColor of cameraDepth and lightDepth seems wired. And won't do right occlusion.  In my project Projection Texture is well working . The problem must be the depthValue of lightView or cameraView of both of them. But I'm just confused.. I've been thinking this for hours just won't figure this out..Really driving me crazy.   (BTW,sorry for not showing you a picture. I'll post one picture later.)
  11. After my last question.Here comes the second.   It 's about shadow map.   I've known the math of it. Here's the shader I used. Texture2D txDiffuse : register(t0); Texture2D ProTexutre : register(t1); SamplerState samLinear : register( s0 ); cbuffer cameraMatrices : register( b0 ) { matrix World; matrix View; matrix Projection; }; cbuffer PRS : register(b1) { matrix Pos; matrix Rot; matrix Sca; } cbuffer LightMatrices : register(b2) { matrix LightView; matrix LightProjection; } struct VS_INPUT { float4 Pos : POSITION; float2 Tex : TEXCOORD0; }; struct PS_INPUT { float4 Pos : SV_POSITION; float2 Tex : TEXCOORD0; float4 viewPosition : TEXCOORED1; }; PS_INPUT VSEntry( VS_INPUT input ) { PS_INPUT output = (PS_INPUT)0; output.Pos = float4(input.Pos.xyz,1.0f); output.Pos = mul( output.Pos, Rot); output.Pos = mul( output.Pos, Sca); output.Pos = mul( output.Pos, Pos); output.Pos = mul( output.Pos, World ); output.viewPosition = output.Pos; output.viewPosition = mul(output.viewPosition, LightView); output.viewPosition = mul(output.viewPosition, LightProjection); output.Pos = mul(output.Pos, View); output.Pos = mul(output.Pos, Projection); output.Tex = input.Tex; return output; } float4 PSEntry(PS_INPUT input) : SV_Target { float bias = 0.0000001f; float4 color = txDiffuse.Sample(samLinear, input.Tex); clip(color.a == 0.0f ? -1 : 1); float2 projectTexCoord; projectTexCoord.x = input.viewPosition.x / input.viewPosition.w / 2.0f + 0.5f; projectTexCoord.y = -input.viewPosition.y / input.viewPosition.w / 2.0f + 0.5f; if((saturate(projectTexCoord.x) == projectTexCoord.x) && (saturate(projectTexCoord.y) == projectTexCoord.y)) { float lightdepth = input.viewPosition.z / input.viewPosition.w; lightdepth = lightdepth - bias; float cameradepth = input.Pos.z / input.Pos.w; float4 depthColor = float4(lightdepth, lightdepth, lightdepth, 1.0f); if (lightdepth < cameradepth) color = depthColor; } return color; }   1.Do a projection texturing(which I've implemented) from light position. 2.Compare the depth value from camera position and depth value from light position view.     if  cameraDepthValue is larger than lightDepthValue which means the scene at that pixel is lighted then return lighted color.     Otherwise return shadow color..      But in my project it's not working at all. I don't know what am I doing wrong.   Some ideas please? The whole project is here : https://github.com/AntiMoron/aMazing  . Really Iooking forward to your help.
  12. thanks to migi0027 ,too!   Wow gamedev's forum is awesome! People here are soooo kind. I love you ppl!!!!
  13.   Which is the result of trying to bind the framebuffer.cpp render-to-texture buffer's SRV to the PS, while it's RTV is still bound on the OM.  It's trying to set it to read while it's still bound for writing.  So the runtime is simply ignoring your request to bind it to the PS, meaning basic2D.fx can't sample from it.  That's why your app only displays the cleared color of your backbuffer, it never attempts to read from the render-to-texture.  You can fix this warning by re-ordering your Render() function in aMazing.cpp:   ... blur.setRenderTarget(DEVICE, CONTEXT); blur.clearRenderTarget(DEVICE, CONTEXT);   TEXTURE.getTexture(1)->bindPS(DEVICE, CONTEXT, 0); SHADERS.getPair("Basic3D").bindShader(DEVICE, CONTEXT); mz->Render(DEVICE, CONTEXT);   d3d.setRenderTarget(); //bind the backbuffer RTV to the OM -before- binding the render-to-texture SRV to the PS  blur.bindPS(DEVICE, CONTEXT,0);   d3d.clearDepthStencil(); SHADERS.getPair("Basic2D").bindShader(DEVICE, CONTEXT); GRAPHICS.RenderRectangle(0, 0, WINWIDTH, WINHEIGHT); ... That solves the immediate problem of why you don't get anything onscreen.  Run your project again and hold down S to back the camera away, you'll see your boxes appear after a second or two. So it's working now, that's great right?!  However...   If you go look at the debug output in VS, it now gives 2 new warnings and 1 ouright error in the VS output window:     Lets deal with the warnings first.  The two warnings happen at the start of the frame, because the render-to-texture SRV from framebuffer.cpp is still bound to the PS from the end of previous frame.  When it tries to bind the RTV of the same resource to the OM it complains in the first warning and then forces the SRV to be unbound from the PS in the second warning.  Unlike the earlier warning these ones don't outright break your rendering, but you should probably fix them.  Once again it can be fixed by re-ordering the calls in your render function:   TEXTURE.getTexture(1)->bindPS(DEVICE, CONTEXT, 0); //replace the SRV bound to slot 0 in the PS -before- binding the render-to-texture RTV to the OM blur.setRenderTarget(DEVICE, CONTEXT); blur.clearRenderTarget(DEVICE, CONTEXT);   SHADERS.getPair("Basic3D").bindShader(DEVICE, CONTEXT); mz->Render(DEVICE, CONTEXT);   d3d.setRenderTarget(); //bind the backbuffer RTV to the OM -before- binding the render-to-texture SRV to the PS  blur.bindPS(DEVICE, CONTEXT,0);   d3d.clearDepthStencil(); SHADERS.getPair("Basic2D").bindShader(DEVICE, CONTEXT); GRAPHICS.RenderRectangle(0, 0, WINWIDTH, WINHEIGHT); Attempt to run the project now and only the error message remains.  The error is happening because you've created your render-to-texture resource and it's associated views with multiplesampling enabled (SampleDesc.Count =4 on the resource, and _TEXTURE2DMS on both of the views), while your basic2D.fx shader declares it as a plain TEXTURE2D.  The quickest fix is to go into FrameBuffer.cpp and change your sample counts to 1 instead of 4, and the view descriptions to _TEXTURE2D.  Note you need to do this for the associated depth buffer in FrameBuffer.cpp also.  That's all the per-frame D3D11 runtime warnings/errors corrected.   If you did want to render the box geometry with multisampling, then you need resolve the render-to-texture TEXTURE2DMS buffer into a seperate TEXTURE2D buffer and sample from that instead in your shader.  You'd do this by using context->ResolveSubResource().  So basically you'd no longer create the SRV for the render-to-texture buffer, but instead create a second buffer of the same format (you're currently using DXGI_FORMAT_R32G32B32A32_FLOAT which is a bit overkill btw) with a sample count of 1 instead of 4, and create an SRV with a viewdimension of _TEXTURE2D for that new 1-sample buffer.  Then once you'd finished rendering to your multisample buffer, unbind it's RTV from the OM, and call ResolveSubResource with the multisample buffer as the src, and the 1-sample buffer as the dst.  Then bind your 1-sample buffer's SRV to the PS when you render with basic2D.fx.   On a seperate note, when you application exits the debug output from the D3D11 runtime is complaining about a lot of resources still alive.  There are a lot of threads here about how to fix those errors (some resources aren't being released). Good luck!   Wow,your answer is really terrific!!!! I appreciate your patience,really. I learn a lot from you!  I've read your answer carefully and can draw a conclusion that I really need to care the binding order of SRVs and RTVs. Maybe I should make a limitation of binding orders with syntax of c++. 
  14. well...Actually everything seems to work fine.....But Just Nothing Rendered.   No error message is printed..   I'm so confused..........  8-(
  15. Hello guys,I was getting started to write a simple maze game one month ago. And I really want to add some effect using Render to texture. But some unknown problem occured. The screen won't render anything...!!! I've done render to texture before.But this time,It failed...I don't know what am I doing wrong. Here's the RenderToTexture class.. (Which I use FrameBuffer Instead) for class declaration : https://github.com/AntiMoron/aMazing/blob/master/aMazing/FrameBuffer.h for class defination &amp;nbsp; : https://github.com/AntiMoron/aMazing/blob/master/aMazing/FrameBuffer.cpp &amp;nbsp; for test Code : https://github.com/AntiMoron/aMazing/blob/master/aMazing/aMazing.cpp or you can download the whole project to help me check out how could it be ! https://github.com/AntiMoron/aMazing
  • 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!