• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

100 Neutral

About brega

  • Rank
  1. Thanks for reply. I have switched to "pure" HLSL: D3DXCompileShaderFromFile(...) dev->CreateVertexShader(...) dev->CreatePixelShader(...) ... and use pragma directive: #pragma pack_matrix(row_major)//as D3DXMATRIX ... void VS(...) { OUT.Position = mul(float4(IN.Position.xyz, 1.0f), WorldViewProjection); // for column-major (default) // but this works for both using "effect framework" //OUT.Position = mul(WorldViewProjection, float4(IN.Position.xyz, 1.0f)); } and now shader work as expected. One more question: any particular reason why is that coulmn-major (matrices packing) are set as default for HLSL shaders?
  2. If i assume it correctly default packing for (constant reg.) matrices are column-major? But aren't column-major just transpose of row-major? Then i am confused as how does transforming vertices works with both ways?: OUT.Position = mul(float4(IN.Position.xyz, 1.0f), WorldViewProjection); I thought that for row-major it should be: OUT.Position = mul(WorldViewProjection, float4(IN.Position.xyz, 1.0f));
  3. I have a mesh with this vertex data (examined mesh->DrawSubset() with PIX): type: usage: FLOAT3 POSITION FLOAT3 NORMAL D3DCOLOR COLOR and from dxsdk docs about D3DCOLOR type: Quote: 4-D packed unsigned bytes mapped to 0 to 1 range. Input is in D3DCOLOR format (ARGB) expanded to (R, G, B, A). so its 32 bit color value? and in my shader i must set it as float4 for it to work: float4x4 WorldViewProjection; struct VertexData { float3 Position : POSITION; float3 Normal : NORMAL; float4 Color : COLOR; }; struct VertexOutput { float4 Position : POSITION; float4 Color : TEXCOORD0; }; struct PixelOutput { float4 Color : COLOR0; }; void VS(in VertexData IN, out VertexOutput OUT) { OUT.Position = mul(float4(IN.Position.xyz, 1.0f), WorldViewProjection); OUT.Color = IN.Color; } void PS(in VertexOutput IN, out PixelOutput OUT) { OUT.Color = IN.Color; } technique Tech { pass p0 { VertexShader = compile vs_3_0 VS(); PixelShader = compile ps_3_0 PS(); } } but its 4 x 32 bit??? Is there some conversation behind scene that i am not aware of? EDIT: i have another question on same shader: if i set: row_major float4x4 WorldViewProjection;//like D3DXMATRIX //column_major float4x4 WorldViewProjection; row-major packing matrices has 5 instruction slots used and column-major has 6 instruction slots used but in dxsdk they say that column-major is efficient then row-major.
  4. world*proj for normals

    Thanks for the link. bookmarked.
  5. world*proj for normals

    Sorry for intrusion but i have a similar question. Suppose that i don't need any scaling (since i scale all meshes in modeling prg.) and i keep "default" scale of xyz.scale = 1.0 and have mesh with this vertex data: struct VertexData { float3 Position : POSITION; float2 TexCoord : TEXCOORD0; float3 Normal : NORMAL; float3 Tangent : TANGENT; float3 Binormal : Binormal; }; and want to "apply" normalmap/parallax effect do i need to transform these with "transpose of the inverse of the world matrix" or just mul it with world?
  6. confused

    Ahhh, i have missed right vector upDir = cross(lookDir, rightDir)
  7. confused

    Quote: For a 3D matrix, you have 3 axes - X, Y and Z. You can calculate one of the axes if you know the other two, by using the cross product Sorry, but we already know two axes (cam position & target) how to calculate up direction? D3DXVECTOR3 upDir; D3DXVECTOR3 position = D3DXVECTOR3(0.0f, 50.0f, 0.0f); D3DXVECTOR3 lookAtPoint = D3DXVECTOR3(0.0f, 0.0f, 0.0f); D3DXVec3Cross(&upDir, &position, &lookAtPoint); // this gives me { 0, 0, 0 } Or i misunderstood your response.
  8. confused

    Then how do you calculate up vector? is this correct?: lookat vector = normalize(lookat - camera pos) up vector = cross (lookat vector)
  9. [C++] typedef keyword

    Quote: ...you're using www.functionx.com as a C++ reference... yes i was reading from there. thanks for clarification. is this better resource for learning Cplusplus www.cprogramming.com
  10. [C++] typedef keyword

    I need help to better understand typedef keyword. Reading from various sources typedef is used to make name alias for existing data type, this example i can understand: typedef vector<int> vint; ... vint vOfInt;// same as vector<int> vOfInt vOfInt.push_back(3); vOfInt.push_back(4); vOfInt.push_back(5); confusion 1 I was lurking thru "d3d9types.h" header witch is full of typedef's for example this piece of code: typedef struct _D3DVECTOR { float x; float y; float z; } D3DVECTOR; why would they use typedef keyword here? isn't this same as: struct D3DXVECTOR { float x; float y; float z; }; or there is something else "behind scene" going on that i am not aware of? confusion 2 "The typedef keyword can be followed by an attribute before the data type" // global variables typedef public short SmallNumber; typedef private unsigned int Positive; // WTF?! typedef protected double* PDouble; // WTF?! i don't get this one??? when would you use this?
  11. [C++] Help me choose container

    @Antheus Quote: ...std::partition YEESSSS. This is the thing that i was looking for. Thanks greatly for hint and clear explanation. There is only one thing that i don't understand. What "TBB" stands for? Is it something about multithreading? Since i am still beginner i'll stick to just one until i learn more about it.
  12. I think that is appropriate to continue conversation on my problem in For Beginners forum
  13. I am continuing "pursuit" to solve my problem that i have started here. Here is what am i doing and what i need: I am trying to create scene manager class and manage resources that it holds. I need some type of container that can hold just pointers to data/resources that does not allocate/deallocate nothing since i am doing it by hand. Here is some half pseudo (inserting into container): LightSceneElement* SceneManager::AddLightSceneElement(SceneElement* parent, ELightType type) { LightSceneElement* pLight = new LightSceneElement(); pLight->Init(this, parent, type);// intit basic properties conatainerLights.insert(pLight);// this should be my imagenary container return pLight;// return pLight so i can take control elswhere and manipulate it } then when finished delete all data: void SceneManager::Close() { ... foreach element in containerLights { LightSceneElement* pLight = *containerLights.iter;//obtain pointer delete pLight; //delete data that it points to pLight = 0; } } It should have fast function to sort my elements (that i have talked about in linked thread) and it should be fast at inserting elements: void SceneManager::Draw() { ... // for example render static meshes container<SceneElement*> containerNotCulledStaticMeshes;// name shoud be obvious foreach static mesh in containerAllStaticMeshes // container that holds all static meshes { if seen by camera { SceneElement* pCurrentMesh = *containerAllStaticMeshes.iter;//obtain pointer containerNotCulledStaticMeshes.insert(pCurrentMesh);//just insert pointer } } ... containerNotCulledStaticMeshes.sort(SceneElement::BackToFront());//sort meshes foreach static mesh in containerNotCulledStaticMeshes { SceneElement* pElement = *containerNotCulledStaticMeshes.iter;//obtain pointer SetShader(); pElement->Draw(); } } Is there some kind of "container" for this?
  14. no need for the first link, i have already got that basic knowledge about pointers. i have never tried to make my own linked list container but instead i use std::list one so i have no idea how this "system" manipulates elements. To me its just a "black box". i will try to make my own tomorrow based on your second link (and ill try to find some others for reference) and your "ideas". if i stuck i hope you don't mind continue helping me? thanks greatly.
  15. Dawoodoz, you make my brain melt down. Since i am a beginner i need to chew this one step a time so please try and explain it to me. 1. Are you talking about some custom linked list container that you've made? 2. Quote: For fixed size allocation... known number of elements in front? something like vector::reserve but for list? Quote: reuse chunks of memory by inserting garbage memory into a linked list of pointers. what is chunk? single element in a list? what is garbage memory? list filled with (for example) same dummy element? 3. Quote: The pointer to the next chunk will have a special place in each allocation... i don't get this, what this means? And rest of text also is confusing for me.
  • Advertisement