Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

117 Neutral

About PolGraphic

  • Rank
  1. I am not very experienced with shadow mapping / global illumination / ray-casting. But I do know C++, a bit of HLSL/CG and I work with DirectX 11.   I want to add an optimal light/shadows solution to my game engine (it can depend on pre-calculated maps). The engine usually works on closed scenes (e.g. room), with the camera behind the person (limited range of view, but good details). Most of the objects are static, but there are some skinned meshes too.   Which technique or combination of techniques (I know that some of them cannot be mixed together) will give me the "full" (complete) solution?   For now I have implemented the phong shading, but the result is far from "good enough":   I was thinking about shadow-mapping and/or SSAO (it's possible to combine them somehow?). Will that be "enough"?   I consider the radiosity as too expensive. The game engine supposed to works fine (60fps) on most of present graphic cards and the games target is not AAA productions. But I do have to improve the shading.   I guess that effects like bloom, HDR or even motion-blur etc. can improve the result, but are not really related to light & shadows (which don't look convincing in my engine now). So I don't consider them in that question.   I do know that those are just approximations and will never give me the quality level comparable to non real-time rendering (e.g. in 3ds max with GI). I look for the direction and not for detailed step-by-step how-to. I know that the details are complicated and can be found elsewhere without the need to expand this thread to enormous size ;) I just need to decide which one to use and which can be combined.    Thank you for your patience. ?
  2. I was trying to load a mesh from file in my DirectX 11 application. As the base I took my own code (that renders some Primitives now) and I wanted to add to it code of mesh creating/rendering from "Basic HLSL" Project from DirectX 11 SDK Samples (which uses e.g. SDKmesh.h and DXUT.h from samples. The mesh code is: I was trying to load a mesh from file in my DirectX 11 application. As the base I took my own code (that renders some Primitives now) and I wanted to add to it code of mesh creating/rendering from "Basic HLSL" Project from DirectX 11 SDK Samples (which uses e.g. SDKmesh.h and DXUT.h from samples. The mesh code is: [source lang="cpp"] class FeyModel : public Graphic::Model, public FeyGraphicElement{ protected: CDXUTSDKMesh mesh; public: FeyModel(ID3D11Device * device, std::string filename, const Common::Point3D center){ mesh.Create( device, L"tiny\\tiny.sdkmesh", false ); //for now tiny.sdkmesh } void render(FeyShader * shader, FeyCamera * camera, ID3D11DeviceContext* context, float t ){ UINT Strides[1]; UINT Offsets[1]; ID3D11Buffer* pVB[1]; pVB[0] = mesh.GetVB11( 0, 0 ); Strides[0] = ( UINT )mesh.GetVertexStride( 0, 0 ); Offsets[0] = 0; context->IASetVertexBuffers( 0, 1, pVB, Strides, Offsets ); context->IASetIndexBuffer( mesh.GetIB11( 0 ), mesh.GetIBFormat11( 0 ), 0 ); SDKMESH_SUBSET* pSubset = NULL; D3D11_PRIMITIVE_TOPOLOGY PrimType; //! context->PSSetSamplers( 0, 1, &samLinear ); for( UINT subset = 0; subset < mesh.GetNumSubsets( 0 ); ++subset ) { // Get the subset pSubset = mesh.GetSubset( 0, subset ); PrimType = CDXUTSDKMesh::GetPrimitiveType11( ( SDKMESH_PRIMITIVE_TYPE )pSubset->PrimitiveType ); context->IASetPrimitiveTopology( PrimType ); // TODO: D3D11 - material loading ID3D11ShaderResourceView* pDiffuseRV = mesh.GetMaterial( pSubset->MaterialID )->pDiffuseRV11; context->PSSetShaderResources( 0, 1, &pDiffuseRV ); context->DrawIndexed( ( UINT )pSubset->IndexCount, 0, ( UINT )pSubset->VertexStart ); } } };[/source] I have also noticed that in the sample, there was a different vertex layout, so I have changed my shader's class code to (the code will be executed once, in shader's class constructor, before mesh creating): [source lang="cpp"] ... const D3D11_INPUT_ELEMENT_DESC layout[] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; UINT numElements = ARRAYSIZE( layout ); // Create the input layout hr = device->CreateInputLayout( layout, numElements, pVSBlob->GetBufferPointer(), pVSBlob->GetBufferSize(), &*vertexLayout ); pVSBlob->Release(); // Set the input layout context->IASetInputLayout( *vertexLayout ); ... [/source] The compilation works. But during the execution of code I get error: Access violation reading location 0x00000000 In SDKmish.h near: [source lang="cpp"]if (bSRGB) { // This is a workaround so that we can load linearly, but sample in SRGB. Right now, we can't load // as linear since D3DX will try to do conversion on load. Loading as TYPELESS doesn't work either, and // loading as typed _UNORM doesn't allow us to create an SRGB view. // on d3d11 featuer levels this is just a copy, but on 10L9 we must use a cpu side copy with 2 staging resources. ID3D11Texture2D* unormStaging = NULL; ID3D11Texture2D* srgbStaging = NULL; D3D11_TEXTURE2D_DESC CopyDesc; pRes->GetDesc( &CopyDesc ); pLoadInfo->BindFlags = 0; pLoadInfo->CpuAccessFlags = D3D11_CPU_ACCESS_WRITE | D3D11_CPU_ACCESS_READ; pLoadInfo->Depth = 0; pLoadInfo->Filter = D3DX11_FILTER_LINEAR; pLoadInfo->FirstMipLevel = 0; pLoadInfo->Format = CopyDesc.Format; pLoadInfo->Height = CopyDesc.Height; pLoadInfo->MipFilter = D3DX11_FILTER_LINEAR; pLoadInfo->MiscFlags = CopyDesc.MiscFlags; pLoadInfo->Usage = D3D11_USAGE_STAGING; pLoadInfo->Width = CopyDesc.Width; CopyDesc.BindFlags = 0; CopyDesc.Usage = D3D11_USAGE_STAGING; CopyDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE | D3D11_CPU_ACCESS_READ; CopyDesc.Format = MAKE_SRGB(CopyDesc.Format); hr = D3DX11CreateTextureFromFile( pDevice, pSrcFile, pLoadInfo, pPump, ( ID3D11Resource** )&unormStaging, NULL ); DXUT_SetDebugName( unormStaging, "CDXUTResourceCache" ); hr = pDevice->CreateTexture2D(&CopyDesc, NULL, &srgbStaging); DXUT_SetDebugName( srgbStaging, "CDXUTResourceCache" ); pContext->CopyResource( srgbStaging, unormStaging ); ID3D11Texture2D* srgbGPU; pRes->GetDesc( &CopyDesc ); CopyDesc.Format = MAKE_SRGB(CopyDesc.Format); hr = pDevice->CreateTexture2D(&CopyDesc, NULL, &srgbGPU); pContext->CopyResource( srgbGPU, srgbStaging ); SAFE_RELEASE(pRes); SAFE_RELEASE(srgbStaging); SAFE_RELEASE(unormStaging); pRes = srgbGPU; }[/source] Precisely in the line: [source lang="cpp"] pContext->CopyResource( srgbStaging, unormStaging );[/source] When I comment few lines of that function and something in my code (I now can't remember what line were that) I get the mesh in the window, but without textures. So I guess it's something with textures? I have the tiny model and texture in the proper folder, I have also set vertex layout like I have posted above. What else should I do?
  3. Hi. I have a problem - how to show that there is an relation between two classes in such an example. Class1 can get as an parameter (or returned value) Class2 type. But Class1 does NOT contains any attributes of Class2 type. It just gets/returns it as a parameter (e.g. in function of Class1, we take come attributes from Class2 or pack few variables in new Class2 just before return) - no variable, container etc. of Class2 type exist in Class1. Here's the illustration to my problem (on that image it looks like there is absolutely no relations between that two classes):
  4. Hello. I have put few effects from Fx Composer 2.5 (by nVidia) into my project just by copying .fx file I've created or modified in that great program and setting all sharer's parameters in my code. Now I want to create fire effect in my project (C++, DirectX 9.0c, HLSL if sb is asking). For first, just the same like in Fx Composer: . The problem is, how to copy the particles emitter? I can create my own one, but I can't find precisely information about particles' amount, size, movement, life, variations etc. in that sample. And I think the effect require the similar emitter - so how to copy it, or maybe it can be downloaded from somewhere?
  5. I have calculated tangent after loading mesh and I think I have done that part correctly (D3DXComputeTangentFrameEx() inside FAILED() which returns false). I'm trying with params, light, other objects/textures etc. (changing the normal map texture makes render a little different but it's still just the variation about the same image - 'colour lines similar to the annual rings on the completely black surface) but I'm still at the same point - with the same error, without knowing what have caused that error :/
  6. Hello. I have put the "Parallax occlusion mapping" shader into my engine. The .fx file can be found in the DirectX 9 SDK, I haven't modified the original file I have downloaded: http://msdn.microsoft.com/en-us/library/ee418710%28VS.85%29.aspx. I have load my shader, set initial data, loaded object and textures, rendered and... got that: (link) I have no idea what may cause that strange render (some colour lines similar to the annual rings on the completely black surface). Has somebody met with similar problem? Or know what may cause it? Here's the part of my engine's code for loading the shader and set values (the object was loaded previously): ShaderNeeds * shNeeds = new ShaderNeeds(true,true,false,true,"g_mWorld","g_mView","","g_mWorldViewProjection"); //defines what matrix will be need and what are their names shaderID = engine3D->createShader("ParallaxOcclusionMapping.fx", shNeeds, "RenderSceneWithPOM"); if(shaderID<0) MessageBox(NULL,ToString(shaderID).c_str(), "Shader creating error! Code:", MB_OK); //material's variables COLOR vWhite = COLOR( 1, 1, 1, 1 ); COLOR ambient = COLOR( 0.35f, 0.35f, 0.35f, 0 ); COLOR diffuse = COLOR( 1.0f, 1.0f, 1.0f, 1.0f ); COLOR specular = COLOR( 0.1f, 0.1f, 0.1f, 1.0f ); float specularExponent = 60.0f; bool addSpecular = true; if(!(engine3D->setShaderParam(shaderID, "g_materialDiffuseColor", &vWhite) && engine3D->setShaderParam(shaderID, "g_materialAmbientColor", &ambient) && engine3D->setShaderParam(shaderID, "g_materialDiffuseColor", &diffuse) && engine3D->setShaderParam(shaderID, "g_materialSpecularColor", &specular) && engine3D->setShaderParam(shaderID, "g_fSpecularExponent", &specularExponent) && engine3D->setShaderParam(shaderID, "g_bAddSpecular", &addSpecular) )) MessageBox(NULL, "Could not set shader's parameter(s).", "Error!", MB_OK); float g_fLightScale = 1.0f; COLOR vLightDiffuse = COLOR( g_fLightScale *1, g_fLightScale *1, g_fLightScale *1, g_fLightScale *1 ); if(!engine3D->setShaderParam(shaderID, "g_LightDiffuse", &vLightDiffuse)) MessageBox(NULL, "Could not set shader's parameter.", "Error!", MB_OK); float textureRepeat = 1.0f; int LODThreshold = 3; int minSamples = 8; int maxSamples = 50; float shadowSoftening = 0.58f; float heightScale = 0.01f; if(!(engine3D->setShaderParam(shaderID, "g_fBaseTextureRepeat", &textureRepeat) && engine3D->setShaderParam(shaderID, "g_nLODThreshold", &LODThreshold) && engine3D->setShaderParam(shaderID, "g_nMinSamples", &minSamples) && engine3D->setShaderParam(shaderID, "g_nMaxSamples", &maxSamples) && engine3D->setShaderParam(shaderID, "g_fShadowSoftening", &shadowSoftening) && engine3D->setShaderParam(shaderID, "g_fHeightMapScale", &heightScale) )) MessageBox(NULL, "Could not set shader's parameter(s).", "Error!", MB_OK); int textureID = engine3D->createTexture("general-diffuse.png"); if(textureID<0) MessageBox(NULL,ToString(textureID).c_str(), "Texture creating error! Code:", MB_OK); if(!engine3D->setShaderParam(shaderID, "g_baseTexture", textureID)) MessageBox(NULL, "Could not set shader's parameter.", "Error!", MB_OK); int normalTextureID = engine3D->createTexture("general-normals.tga"); if(normalTextureID<0) MessageBox(NULL,ToString(normalTextureID).c_str(), "Texture creating error! Code:", MB_OK); if(!engine3D->setShaderParam(shaderID, "g_nmhTexture", normalTextureID)) MessageBox(NULL, "Could not set shader's parameter.", "Error!", MB_OK); Ofc I haven't seen any error window after running it. I have tested my engine with other shaders and they are working property, so I think there is an error with some values/etc. I have put to that shader, not the general problem with my engine's functions. [Edited by - PolGraphic on August 19, 2010 5:20:09 PM]
  7. About 'new()' - 'first think, then do' - I'm too tired today ;p Thx about lib :) I have checked the settings, both seem to be the same (btw I'm using Code::Blocks). But I have cleaned and recompiled everything 20th time after that and everything work... To conclusion: I must have made some errors because of not compatible settings of lib, which I have fixed after your advice and doesn't even noticed that differences ;p (evidently, too less alcohol...). Or... the Martians caused the crash. THANK a lot once more for quick and brilliant advices :) --edit: I didn't want to create a 'spam' post so I've decided just to edit that one to answer Madhed's last post and to ensure that I have just rated him ;]
  8. It's the question for me now ;p I don't see the difference. But it's obvious there is sth, because as you said - one works and the other doesn't :/ The size of class, number of functions, included data etc. shouldn't have influence on it. The using of that list which cause a problem was exactly the same - in my 'real' code I have also just declared it and once wanted to use push_back. Moreover, all other functions (that don't depend on lists/vectors/etc. declared in implementation class) from my real code work without errors and I'm sure of it. The only difference I see is that in 'real' code the equivalents for header.h/.cpp aren't compiling with others, but are just in .lib (my static lib, note that everything worked without that list). And the equivalent for h1.cpp is in two, not one source file. Also, in the real code, elements.empty() returns false in all methods, even when the list was only declared in .h and hasn't been used (and I'm sure I have never added anything there, I have even deleted all lines of code that do anything to that list before that check). --edit Hm, that a little interesting: When instead of list I have put sample struct: struct STH { int e; } and in .h (inside my equivalent to A class) declared STH * sh, then in .cpp used it (sh->e=5) I have got a crash. But when I used it as: STH sh (in .h) and sh.e=5 there were no errors. Sth with pointers/memory? [Edited by - PolGraphic on August 15, 2010 1:48:08 PM]
  9. Quote:Original post by Madhed The problem is here: *** Source Snippet Removed *** You call createInterface on an uninitialized pointer to SampleInterface. (Wrong!) createInterface returns your pointer to class A but you keep using "ex" (Wrong!) As soon as you start calling a function (pubF1) on the uninitialized object which tries to access a property of the class (elements) (Crash!!) About 'ex->createInterface()' instead of 'SampleInterface * ex = SampleInterface ::createIterface();' - it was just my mistake during writing the code from sample (the real source code was ok in that case, I have improved it now) ;p Ofc I have always used 'SampleInterface * ex = SampleInterface ::createIterface()' but still have an error. Beside, if I would use it the way I have wrote for the first time (sorry for confusion, now the source is ok) even when I would call pubF1 function I should have got the Crash - not only in privF2. So once more sorry for mistake during copy out, unfortunately the problem is still in the same place as before.
  10. Hello. I have created interface and implementation of it. Unfortunately I have program crash when I want to use std::list (or std::vector and maybe other structures, but not the e.g. integer) in my implementation (class). The list was declared in .h (inside class, as a private) and I wanted to use it in .cpp, in one of the class's methods. Hardly speaking, I think I have done some stupid mistake and it's not the problem of std::list but about construction of my class or sth like that. Program crush not only with push_back(), also with some other std::list functions. I decided to write the example-code which cause the same problem, but doesn't have not important, for that discussion, lines and files. What is strange, in that sample my method of using std::list seems to work, not crush :/ I don't quite now what to do, I don't see any difference (as far as the using of that list and structure/relations of code's elements is concerned) between that code and my program that always crush. But I publish here that example (unfortunately working ;p ) code, hoping that somebody will catch the error I could make which doesn't cause problem here but can cause with more files/variables etc. I really don't know what can be the source of error :/ main.cpp #include <iostream> #include "header.h" ; using namespace std; int main() { SampleInterface * ex = SampleInterface ::createIterface(); ex->pubF1(15); //here we have an error, real program crush (pubF1 calls privF2), the sample not even when there aren't any different in that part of code... XD cout << "Hello world!" << endl; return 0; } header.h #ifndef HEADER_H_INCLUDED #define HEADER_H_INCLUDED struct SampleInterface { virtual void pubF1(int code)=0; static SampleInterface * createIterface(); }; #endif // HEADER_H_INCLUDED header.cpp #include "header.h" #include "h1.h" SampleInterface * SampleInterface::createIterface() { return new A(); } h1.h #ifndef H1_H_INCLUDED #define H1_H_INCLUDED #include <list> #include "header.h" class A : public SampleInterface { std::list <int> elements; bool privF2(int code); public: void pubF1(int code); }; #endif // H1_H_INCLUDED h1.cpp #include "h1.h" bool A::privF2(int code) { elements.push_back(code); //here is the error, real program crash } void A::pubF1(int code) { privF2(code); } [Edited by - PolGraphic on August 15, 2010 12:37:09 PM]
  11. Indeed ;] Nice to hear that own structures and conversions are 'normal' and won't make somebody to scream... Thx once again, now everything it's clear, but firstly I wasn't sure how to deal with that :) One more thing - about HWND structure. Should I cast it to sth (long? not pretty nice when sb want to use 64-bit code...), or just include windows.h inside #ifdef WINDOWS?
  12. The conversions happen about few times in each game loop. It's not the extremely high amount, but also not too small to think about some optimizations. Ofc more important is the independence of interface. Now it looks like the best way is (according to rasnjo) to declare own structures that will be converted to/from current API any time the few functions from engine (the functions that use that specified types for attributes/returned value) will be call. In the modules from 'higher' level (modules that use my interface) I can also use structures I will declare for this interface. So the conversion will have to be done only at the level of chosen engine implementation. Thx for quick help.
  13. Hello. I have written some interface for my module. Let's say it's a interface of 3d engine. I have a few functions that returns/need to get some parameters like vector in 3d space. The structures from DirectX (like D3DXVECTOR) and windows.h (RECT, POINT) suit me well, but the engine should be independent of system and API (I will want to create engine based on DirectX and also the other based on OGL - on the same interface). And I don't know what's the best way to achieve it. For now I have done sth like that: #ifdef WINDOWS #include <windows.h> #include <d3dx9.h> typedef D3DXVECTOR3 VECTOR3D; #else struct RECT { long left; long top; long right; long bottom; }; struct POINT { long x; long y; }; struct VECTOR3D { float x; float y; float z; }; #endif // WINDOWS But I really don't like that way. Moreover it's not 'nice' when OGL programmers will have to use the structures from DirectX to represent OGL structures (one more conversion...). On the other hand, creating my own structure for vector 3d, rect etc. will make me to make conversions to that type both in DirectX and OGL versions of engine :/
  14. Hello. I have started to learn UML. I want to ask you how to put on scheme few things that are in my C++ code (I will be glad if some of you would answer to part of them, I have put them together not to make to many similar topics): 1. The pointer I want to signalize that the attribute of my class is a pointer (I want to be compatible with new UML standard). As far as I know I can do it by that: I don't know if it's a good notation. And how to draw it in the class 'box', just like other attributes? I don't think writing '*' like this will be ok with standards: 2. The structure declared in another structure/class. The example c++ code: struct class1{ struct class2{ int value; }; class2 structures2; }; For now I have made sth like this from the first image, but it not contains additional information that class2 was declared inside class1 and cannot be used anywhere else. Btw, is there any difference when I will change classes with structures in that example? 3. Can I use both methods: put attribute in the class 'box' and draw the second class 'box' and connect that two boxes? I'm thinking of sth like that: For that code: class class2; class class1{ class2 * Attribute1; };
  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!