CortexDragon

Members
  • Content count

    16
  • Joined

  • Last visited

Community Reputation

2 Neutral

1 Follower

About CortexDragon

  • Rank
    Member

Personal Information

  • Industry Role
    Programmer
  • Interests
    Art
    Design
    Programming
  1. I dont think there is a "right" way to do it, just do what is most convenient for you. If you have a large number of textures, a texture array (which is different from an array of textures) is good as it means your hlsl code can easily access whichever texture it wants by using a texture number. But thats really only useful if you have lots of textures, far more than 4. Texturearrays also have the restriction that each texture in that array must have the same x and y dimensions. (you would have to have a different texture array object for each different texture size, but you can obviously have an array of them to do this) To make a texturearray - in your D3D11_TEXTURE2D_DESC object, set textureDesc.ArraySize to be the number of textures. To make your srv you use D3D11_SRV_DIMENSION_TEXTURE2DARRAY instead of D3D11_SRV_DIMENSION_TEXTURE2D ie srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY; srvDesc.Texture2DArray.MostDetailedMip = 0; srvDesc.Texture2DArray.MipLevels = desc.MipLevels; srvDesc.Texture2DArray.FirstArraySlice = 0; srvDesc.Texture2DArray.ArraySize = texturearrayelements; // number of texture array elements In the hlsl you would use Texture2DArray instead of Texture2D. Also remember its a single object not an array of objects when you define its slot in hlsl. When copying into a texture array you do it by the subresources. So the texture array is layed out by having a subresource for each mip of the 1st texture, then a subresource for each mip of the second texture etc.
  2. A good way to avoid extermination in RTS?

    In rome total war, troops have a morale rating which causes troops to run away so battles dont often lead to a total anihalation. They run away when they have taken too many loses in a short period of time. Getting surrounded also lowers moral so some can break while others on the side are still okay. Seeing nearby friendly units die or running can also effect moral. Being near the general increases moral as does him blowing his horn.
  3. The "world" part of a WorldViewProj describes the objects position, rotation and size. To make different objects not be all in the same place, instead of a single gWorldViewProj in the shaders, you would need a seperate "world" for each object (or a seperate gWorldViewProj if you wish to do the combining of world,view,projection in the cpu like you are at the moment) You could either have an array of them inside a constantbuffer, or have a structurebuffer. If you are using executeindirect you dont need an array of them as seen by the vertexshader as you can use it to change the start of your constant buffer view to a different piece of data in a single larger buffer which is an array of all of them. Your vertex could store its objectnumber so it can choose the correct array element in the vertexshader, but thats not ideal if you wanted to draw multiple of the same object in different positions in the world. As this is DX12 you could solve the problem of transmitting the objectnumber to the gpu without imbedding it in a vertex by using a executeindirect instead of a drawindexed as it is tailor made to draw multiple different objects in a single draw Executeindirect can change values in the rootsignature with each draw it issues so it could either be used to pass the objectnumber as a rootconstant or even better can change a single gWorldViewProj constantbufferview and not need an array in the vertexshader and this would be faster. See the D3D12ExecuteIndirect sample https://msdn.microsoft.com/en-us/library/windows/desktop/mt186624(v=vs.85).aspx That sample does this very thing by having a different position for each object by changing the constantbufferview to start at a different element in a bigger buffer which is basically an array of them.
  4. Did your change in LightShaderClass.cpp fix the problem ? (you have a comment about it)
  5. Texture compression / DDS files

    Do the higher BC modes like BC7 render faster in the gpu than the lower equivalent modes like BC3 ? The documentation seems to imply it, but I haven't timed it.
  6. Dynamic world framework

    Skyrim has a radiant AI. Their npcs have factions which like each other and other factions which hate each other so you can get "emergent behavoir" happening For example their are some totally unscripted mods ("Populated lands road paths" and "immersive patrols") that all they do is spawn npcs and set them walking along roads to certain map points across the map. Due to the faction preferences these npcs may decide to attack bandit camps they walk by and other npcs will then get involved if they see their friends being attacked. Big battles occur when stormcloaks and imperials meet. Bandits attack merchants and their body guards help defend them and may wipe out the bandits. All of these events are totally unscripted. Skyrim also has something called radiant quests. These are repeatable quests that randomly pick who is involved and what location it occurs. For example a rescue kidnapped person radiant quest can randomly decide any town or village npc has been kidnapped, and place them in a random place with enemies for you to rescue.
  7. Texture compression / DDS files

    You can compress to BC3 quite fast, but in my experience compressing to BC7 is extremely slow, although I haven't tried the compute shader texture compression functions from directxTex/directXTK so maybe they are faster. So its possible those developers are using BC7 ? Block compression modes - https://msdn.microsoft.com/en-us/library/windows/desktop/hh308955(v=vs.85).aspx
  8. Thankyou everyone - the FXC.exe worked perfectly to make the assembly code. Previously I had just been using the D3DCompileFromFile function to compile my hlsl.
  9. Thankyou I will check it out. Is this peoples prefered way of viewing the hlsl assembly code ?
  10. Any assembly that can help me optimise my hlsl code, I dont mind which. I believe its described here - https://msdn.microsoft.com/en-us/library/windows/desktop/hh447232(v=vs.85).aspx
  11. Designing the optimum skilltree system

    I remember a tiered system. I think it was in "forsaken world", but it may have been a different game. Basically each skilltree has a set of tiers, and you need to spend a certain amount of points in a tree before you have access to the higher tiers. The high level skills are in the high tiers, the low level skill sare in the low tiers. Its up to you where you put your points in the low tiers but you have to put them somewhere. A vertical bar would show on the side showing how many skillpoints had been spent on the tree and once it reached the height of a higher level skill tier you were allowed to buy skills from that higher tier in that skilltree that you met the prerequisites for.
  12. I dont know the "official" way of doing it (as I am just a hobbyist), however I do it in several different ways depending on the situation: 1. From the pixel shader if you are writing to another texture you can use the standard depth stencil mechanics to ensure the closest "wins". 2. When writing to a RWStructuredBuffer from a compute shader, I make different threads write to different elements in the buffer. The easy way is to use the threadnumber as the element number. A slightly more complex way is to have a thread "grab" an element number by interlocked incrementing a counter and having that thread use the previous value of the counter. 3. From the pixel shader I send back to the cpu the object number of the object i clicked on. Basically I need the closest texel at a certain screen position (eg where i clicked the mouse) write information to element one of a RWStructuredBuffer. After checking the pixel is at the correct position, I construct a uint value where the high 16 bits are the depth ( ((uint)(input.Pos.z * 65535.0)) << 16 ) and the low 16 bits are my information eg my object number. Then use the InterlockedMin function to send the uint value to the buffer. This causes the texel with the lowest depth to "win" which means it comes from the object which was closest to the camera at that point on the screen. So in summary - you either write to different elements or use the interlocked functions to give you better control.
  13. How do you view the assembly code of your hlsl code? I am using visual studio 2017 and an nvidia graphics card. I tried looking in the visual studio graphics analyzer ("debug - graphics - start graphics debugging" from visual studio opens that) but where I would expect it to be it says "Enable GPU disassembly via View->Options->Graphics Diagnostics->Enable gather of GPU Disassembly. The vsglog must be re-opened for this change to take effect." However that isnt an option you can select. I would actually prefer a way to view the asm without having to capture a frame, as my program doesnt do well in the visual studio graphics analyzer When I try to playback a captured frame I get "An error has occured. Playback of your application may be incomplete (HRESULT = 0x00630000)" However I am able to play back captured frames of the microsoft samples, but I am still not able to see asm code with them.
  14. I dont know anything about that book, but you can learn dx11 directly from MSDN and their dx11 samples work on windows 10 (I just checked them) Direct3D Tutorial Win32 Sample - https://code.msdn.microsoft.com/Direct3D-Tutorial-Win32-829979ef This is the classic tutorials 1-7 that take you from setting up a window to displaying a rotating textured cube. The download button is at the top of that page. The zip file contains: 1. description.html this has links for all 7 tutorial step by step descriptions. You should read all of these 2. A folder called c++ You can open this "Tutorials.sln" solution in visual studio (I use visual studio 2017), and let it update them all to the latest version of visual studio. Or you can open the projects in the folders which seems to also open all of them. The sample contains all 7 tutorials. Compile them. To run a particular sample (as the solution contains all), in the solution explorer of visual studio right click on the one you want eg "Tutorial07" and select "set as startup project". Then from the top menu select debug - start debugging. I just checked it and it does work on windows 10, with visual studio 2017 ******** After these 7 tutorials I recommend MSDN: Direct3D 11 Graphics - https://msdn.microsoft.com/en-us/library/windows/desktop/ff476080(v=vs.85).aspx Read each of those sections links HLSL - https://msdn.microsoft.com/en-us/library/windows/desktop/bb509561(v=vs.85).aspx Read each of those sections links
  15. Use a static_cast if you want to cast a base class to a derived class without loss of speed. You should only do that if you can guarantee as the programmer it really is that type (which in your case you can because you had it store an enum value so it knows its type).