michaelmk86

Members
  • Content count

    44
  • Joined

  • Last visited

Community Reputation

189 Neutral

About michaelmk86

  • Rank
    Member
  1. The simplest way i can think of is this   ID3D11ShaderResourceView* textures[10]; for(int i=0; i<10; i++) D3DX11CreateShaderResourceViewFromFile(device, fileName[i], NULL, NULL, &textures[i], NULL); ID3D11DeviceContext* deviceContext; deviceContext->PSSetShaderResources(0, 10, textures); not sure if this is what you are asking.
  2. Texture Arrays

    it is possible to pass to the shader a Texture Array and at the same time 2 or more Textures that are not in an arrey? I have try like that but it doesn't work deviceContext->PSSetShaderResources(0, 1, &ShadowMapTexture);//contains 1 Texture deviceContext->PSSetShaderResources(1, 1, &ReflectionTexture);//contains 1 Texture deviceContext->PSSetShaderResources(2, 4, modelTexturesArray);//contains 4 Textures //HLSL Texture2D Textures[6] : register(t0); Textures[0].Sample(.....// it is the ShadowMapTexture Textures[1].Sample(.....// it is the ReflectionTexture Textures[2].Sample(.....// it is the modelTexturesArray 0 Textures[3].Sample(.....// it is the modelTexturesArray 1 Textures[4].Sample(.....// it is the modelTexturesArray 2 Textures[5].Sample(.....// it is the modelTexturesArray 3 ... the weird thing is that if i do the following it works but not with the hadowMapTexture and ReflectionTexture at the same time deviceContext->PSSetShaderResources(0, 1, &ShadowMapTexture);//contains 1 Texture deviceContext->PSSetShaderResources(1, 4, modelTexturesArray);//contains 4 Textures //HLSL Texture2D Textures[5] : register(t0); Textures[0].Sample(.....// it is the ShadowMapTexture Textures[1].Sample(.....// it is the modelTexturesArray 0 Textures[2].Sample(.....// it is the modelTexturesArray 1 Textures[3].Sample(.....// it is the modelTexturesArray 2 Textures[4].Sample(.....// it is the modelTexturesArray 3 ...
  3. reuse 3d primitives

    2500 draw calls and 11fps looks reasonable if you have a very weak and old cpu.   just to give you an idea, if you have a good cpu you can make 40K draw calls with 60fps (but in DX11 not dx9)
  4. something weird that i notice struct VertexInputType { float4 position : POSITION; float2 tex : TEXCOORD0; float3 normal : NORMAL; uint material : BLENDINDICES; uint InstanceId : SV_InstanceID; };   in this line in the VertexShader   output.material = input.material;   have around 10% performance impact, I mean all it dose is to pass the an int to the Pixel Shader
  5. it works now.   with the "uint material : BLENDINDICES;" as input in the vertex shader   thanks
  6. that is exactly what I need, but can you give a bit more info on how to make this input to the shader?   //currently have this struct VertexInputType { float4 position : POSITION; float2 tex : TEXCOORD0; float3 normal : NORMAL; uint material; // what i need to put here? uint InstanceId : SV_InstanceID; };
  7. Convert std::string to WCHAR ?

    I solve my problem by doing the following:   std::wstring s2ws(const std::string& s) { int len; int slength = (int)s.length() + 1; len = MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, 0, 0); wchar_t* buf = new wchar_t[len]; MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, buf, len); std::wstring r(buf); delete[] buf; return r; } #ifdef UNICODE std::wstring stemp = s2ws(filename); // Temporary buffer is required LPCTSTR L_filename = stemp.c_str(); #else LPCTSTR L_filename = s.c_str(); #endif D3DX11CreateShaderResourceViewFromFile(device, L_filename, NULL, NULL, &texture, NULL); i just couldn't imagine such a simple thing to be that complicated.  
  8. Convert std::string to WCHAR ?

    to pass a string  in the second parameter here  WCHAR* filename = L"file path..."; D3DX11CreateShaderResourceViewFromFile(device, filename, NULL, NULL, &texture, NULL);
  9. Convert std::string to WCHAR ?

    I don't understand, the above code it giving me an error.   basically what i want is something like this WCHAR convert(std::string s) { WCHAR w; //do whatever needs to be done return w; } std::string s = "something"; WCHAR w = convert(s);
  10. Convert std::string to WCHAR ?

    I am trying to do this: std::string s; WCHAR w = s; Also what do you mean what platform i am using?
  11. Hi, how to get multiple textures on a model without the need to use separate draw calls for each texture that is on the model?   SamplerState SampleTypeWrap : register(s0); Texture2D mTexture0 : register(t0); Texture2D mTexture1 : register(t1); Texture2D mTexture2 : register(t2); struct PixelInputType { float4 position : SV_POSITION; float2 tex : TEXCOORD0; // contains texture coordinates for all 3 Textures that are on the model float3 normal : NORMAL; }; float4 PPixelShader(PixelInputType input) : SV_TARGET { //need to fine how to determine what Textures(mTexture0, mTexture1, mTexture2) corresponds to the input.tex (that contains all the texture coordinates) float4 output; //if(this pixel have Texture mTexture0) output = mTexture0.Sample(SampleTypeWrap, input.tex); //if(this pixel have Texture mTexture1) output = mTexture1.Sample(SampleTypeWrap, input.tex); //if(this pixel have Texture mTexture2) output = mTexture2.Sample(SampleTypeWrap, input.tex); return output; }   I hope i make myself clear.
  12. DX11 DX11 Instancing question

    looks like  passing the rotation with TEXCOORD is not possible. using an  array of matrices (inside constant buffer) and index it using SV_InstanceID works with rotation, but it can only pass 1024 matrix meaning i can only have 1024 instances of the same model. looking at the DirectX SDK(Direct3D10 folder, Instancing10) i find that is doing Instancing with this  "row_major float4x4 mTransform : mTransform;" but i have idea how to use this in dx11, in order to get  Instance with rotation and in large numbers like 10k not just 1024.   any ideals?
  13. DX11 DX11 Instancing question

    you mean like that ? struct VertexInputType { float4 position : POSITION; float2 tex : TEXCOORD0; matrix instancePosition; }; and in what way should I modify the D3D11_INPUT_ELEMENT_DESC ? polygonLayout[2].SemanticName = "TEXCOORD"; polygonLayout[2].SemanticIndex = 1; polygonLayout[2].Format = DXGI_FORMAT_R32G32B32_FLOAT; polygonLayout[2].InputSlot = 1; polygonLayout[2].AlignedByteOffset = 0; polygonLayout[2].InputSlotClass = D3D11_INPUT_PER_INSTANCE_DATA; polygonLayout[2].InstanceDataStepRate = 1;