IndyJones

Member

179

298 Neutral

• Rank
Member
1. Photon Mapping problems

I'm trying to add photon mapping to my ray tracer and got stuck with the calculation of the radiance estimate. The problem is that my estimation function always returns 0/0/0 and therefore all I see is a black image. Here is how I implemented my photon tracing/radiance estimate function: - First I calculate the photon power for a photon like this: Color photonPower = curLight->GetColor() / numPhotons; Where Color is a type containing 3 floats for RGB values, numPhotons is the number of photons emitted from the current light source and GetColor returns the light color/intensity. - When the photon hits an object I determine what to do next using Russian Roulette. Let's assume we are doing a diffuse reflection - then this is what I currently do in my code: Ray reflRay = GetDiffuseReflection(); Color newPower = p_Power * DiffuseBRDF(hitPoint, hitNormal, p_Ray.m_Direction, reflRay.m_Direction, curMat); AddPhoton(hitPoint, p_Ray.m_Direction, newPower); PhotonTrace(p_Scene, p_Light, reflRay, newPower, p_TraceDepth + 1, p_RefrIndex); First I calculate the diffuse reflection ray. Then I multiply the current photon power by the BRDF of the surface where the photon hit was detected (in the case of the diffuse BRDF all I do is (Normal * -reflRay.dir) * curMat->GetColor()) and store the photon (because we hit a diffuse surface). Then I recursively continue photon tracing with the new calculated photon power. - Finally my radiance estimate locates the n closest photons and performs the following calculation. Color output(0,0,0); for(int i = 0; i < PhotonsFound; ++i) { const Photon* p = m_Photons; Vector3 dir = GetPhotonDir(p->m_Theta, p->m_Phi); output += (hitNormal * -dir) * p->m_Power; } const float tmp = (1.0f / PI) / (MaxSqDistance); output = output * tmp; The problem that I have with my photon mapping implementation is that output is always very small (0.000xxxx values) and therefore my scene is just black. I'm not sure what parts of Photon Mapping I've misunderstood that my implementation is not working correctly. I hope someone can help and enlighten me!

If you'r using C++ you might want to check out TinyXML HTH
3. Calculating the Tangent Space in FarCry!!!

The only thing I found that is freely available is a presentation here. Don't know if it goes as deep into detail as the article in ShaderX does ...
4. Calculating the Tangent Space in FarCry!!!

You maybe want to check out the article "Triangle Mesh Tangent Space Calculation" by Martin Mittring (Lead Graphics Programmer at Crytek) in ShaderX 4. IIRC he exactly describes how they did it in the CryEngine.
5. DirectX and VS 2008

I don't have VS 2008 installed here but maybe it works the same as with VS 2005: - Search in the help index for "collection manager" and choose help - Select Visual Studio Combined Help Collection Manager from the shown topics There you have a list with available help collections. Choose the ones you want to integrate and press the "Update VSCC" button. Hope this helps
6. How Can I get the Path of My Documents Folder

You can use the SHGetFolderPath function using CSIDL_PERSONAL for the nFolder parameter.
7. dll current directory

Just a guess: if you'r running from the debugger the current directory won't be the output directory (Debug or Release) but the one that contains your project file (usually one directory level lower).
8. Unit testing output in .Net

I don't know if you have access to the Team Edition of Visual Studio 2005 but this one has an integrated Unit Testing Framework for managed code. It works quite good and is nicely integrated with Visual Studio. It also has some nice features like code coverage and automatic test case generation. More information can be found here
9. [VC++ 2005] Template Class problem (kind of solved)

You have to put the implementation of your template class into the header file (except your compiler supports the export keyword which afaik only the Comeau C++ compiler currently does).
10. Cleaining Up After a DirectX Application

Quote:Original post by TheAdmiral Quote:ii)Im sure the answer to this is yes, but...is an parent classes deconstructor called by it's children when they deconstruct?IndyJones seems to have answered a different question (regarding inheritance). But the answer is no. A child class won't (and can't) destroy its parents, as it may have many such or even none. However, a parent class will destroy its children. Right - have misread the question - thanks for clearing things up Admiral
11. Cleaining Up After a DirectX Application

This misleading information is produced because all resources you create (i.e. IDrect3DDevice9::CreateTexture) are coupled with the D3D9 device instance. Check out the DirectX FAQ here for a more precise explanation.
12. Cleaining Up After a DirectX Application

i) Destructors are called if an instance of a class is going to be deleted so any cleanup work can be done (releasing memory, free locks to events, etc.). See here for more information. To solve your unfreed memory problem I suggest you use the "Break on alloc" option from the DirectX control panel. The leaks reported by Direct3D will all have an allocation ID assigned to them - just insert that ID in the edit field and the debugger will hit a breakpoint when you run you application and the allocation of this D3D resource is done. ii) yes - the following sample class A { public: virtual ~A() { std::cout << "~A called" << std::endl; } }; class B : public A { public: ~B() { std::cout << "~B called" << std::endl; } }; int main(int argc, char* argv[]) { { B b; } return 0; } will result in the output ~B called ~A called Note: ~A should be made virtual so that ~B is called if you reference an instance of B via a pointer to A i.e.: A* a = new B; delete a; // will only call ~B if class A's destructor was declared virtual iii) You should keep track of the current FVF yourself and just call SetFVF if the FVF changes (also - GetFVF will not work if you use a pure device for instance). HTH
13. UML diagram software...

Enterprise Architect is another good - but not free - one.
14. visual studio 2005 projects

You can create a custom application wizard: File / New / Project, then choose General / Custom Wizard