Jump to content

  • Log In with Google      Sign In   
  • Create Account


Tispe

Member Since 02 Oct 2010
Offline Last Active Jul 01 2014 07:14 AM
-----

#5127393 Has any of the veterans tried to feed animation data into an animation contro...

Posted by Tispe on 30 January 2014 - 12:55 AM

I think it is best to just roll your own animation controller. It is not that hard to do. Animation Tracks has a set of keys for each bone. Just figure out between which two keys you are by using a time variable 0-1, then interpolate those keys for each bone.

 

Blending animations is just as easy.




#5123587 C++ DirectX Renderer Design

Posted by Tispe on 14 January 2014 - 09:31 AM

What functionality do you want from a renderer? Well you want to give it a Scene and render it to the screen right? You also want it to handle the game window so that you can change resolution and toggle windowed mode and fullscreen mode.

 

Another thing you want from the renderer (atleast DX9) is to create textures/surfaces and buffers for you.

 

Here is some of my Dx9Device class:

class Dx9Device
{
public:
	Dx9Device(void);
	~Dx9Device(void);

	bool CreateGameWindowAndInit(HINSTANCE hInstance, int nCmdShow, LPVOID *pInput);
	void ChangeDisplaySettings(DisplaySettings &NewSettings);
	void BuildManagedResources(std::shared_ptr<GameResource> &spResource);
	void Render(GameScene &Scene);
	void GetSettings(DisplaySettings &Settings);

.
.
.
}

The Scene data structure contain all the information necessary to draw one frame to the screen.




#5122311 error C2061: syntax error : identifier 'HINSTANCE'

Posted by Tispe on 09 January 2014 - 12:33 AM

Well, I like it simple. Even if it creates un-needed dependency. I have enough with forward declarations already.




#5122310 Impossible to use instancing with DirectX 9 when D3DCREATE_HARDWARE_VERTEXPRO...

Posted by Tispe on 09 January 2014 - 12:24 AM

Do you SetVertexShader() and SetPixelShader()?

 

 

 


pD3dDevice_->SetFVF(simpleKnobMesh_.Mesh->GetFVF());

 

Do you need this?

 

 

 


simpleKnobMesh_.Mesh->GetVertexBuffer(&g_vertexBufferGeometry);
simpleKnobMesh_.Mesh->GetIndexBuffer(&g_indexBuffer);

Remember to release(), as the internal reference count increases everytime you call Get*.




#5122207 error C2061: syntax error : identifier 'HINSTANCE'

Posted by Tispe on 08 January 2014 - 12:23 PM

Right, the problem was that I did not #include Main.h where all my includes are in Dx9Device.cpp as I did in my original source. Fixed now. Thx.




#5117301 Rectilinear Texture Warping - Building Warp Maps

Posted by Tispe on 16 December 2013 - 06:17 AM

Unfortunatly those articles are not helping. But with some creative use of pen and paper i've cooked up something from what I got out of Rosens paper. I will see if I can implement this. I'm trying to do this on SM3.0 in DX9. All maps will have the same length.

 

1. First the importance map is collapsed into two 1D maps, the vertical and the horizontal. This is done by setting each corresponding pixel to the maximum value in the row or column.

 

2. These 1D maps are then blurred.

 

3. Calculate the sum of all pixels in each blurred map to get the total importance. Perhaps this can be done on the GPU by rendering to a 1x1 texture using a quad. Since the pixel shader is only run once for each 1D map it will sample the entire 1D blurred map and spit out the sum. Which can be read back to the CPU and set as a constant on the GPU. I don't know if there is a faster method to find the total importance.

 

4. The warping map is constructed by rendering to a 1D texture. The first pixel in the warp map will recieve half the value of the first pixel in the blurred 1D map divided by total importance. The second pixel in the warp map will recieve the full value of the first pixel, plus half the value of the second pixel divided by total importance. The third pixel in the warp map will recieve half the value of the third pixel in the blurred map, plus the sum of the first and second pixel  divided by total importance. The algorithm here is the sum up all the pixels before the current pixel, plus half of the current pixel and divide by total importance. Each pixel in the warp map is a pointer that maps to a new coordinate. This is a list of pixels with values between 0 and 1.

 

5. Render the shadow map; in the vertex shader transform all vertices to screen space to have a value between -1 and 1 as normal. Then add 1 and divide by 2 to scale it to the range between 0 and 1. We now sample pixels in the warp maps where our value is between. A linear interpolation of the two pixel values gives us a new mapped coordinate in the range 0 to 1. We scale it back to be in the range -1 and 1 and output the result. Perhaps we can fiddle the warp map to have values between -1 and 1 to avoid back and forth scaling.

 

6. Render the scene to a texture.

 

7. Render full screen quad using the texture from step 6. In the pixel shader convert UV's to shadow map space and run them through the warp maps, using the new UV's sample the shadow map and do the depth test.

 

 

Hope there aren't any flaws in what I just said.




#5108136 DirectX 9.0c: Handling "Lost Device"?

Posted by Tispe on 09 November 2013 - 01:10 PM

Normally no, but it's not that hard to implement it. I posted basically all the code you need.




#5108090 DirectX 9.0c: Handling "Lost Device"?

Posted by Tispe on 09 November 2013 - 08:39 AM

This is what I use: 

hr = device->Present(NULL, NULL, NULL, NULL);

	if (hr == D3DERR_DEVICELOST){
		LostDevice = true;
	}
if(LostDevice){
		RecoverDevice();
	} else {
		Render();
	}
RecoverDevice()
{
	HRESULT hr = NULL;

	hr = device->TestCooperativeLevel();
	switch (hr)
	{
	case D3D_OK:
		// device is no longer lost and reset has completed successfully; recover resources here
		LostDevice = false;
		return;  // note: this assumes that this test is the last thing in the function it's being called from
	case D3DERR_DEVICELOST:
		Sleep(5);
		// device is still lost; can't do anything so do nothing
		break;
	case D3DERR_DEVICENOTRESET:
		// device is ready to be reset; Release resources here and then Reset it
		// (be sure to test the hr from your Reset call too!)
		//ReleaseResources();
		ResetDevice();
		break;
	default:
		MessageBox(NULL, L"TestCooperativeLevel() failed", L"Error", MB_OK);
		PostQuitMessage(0);
		return;
	}
}



#5108061 Help Understanding Instancing

Posted by Tispe on 09 November 2013 - 03:57 AM

You should not draw the same mesh with more then one draw call. Use instancing for every mesh you plan on drawing more then once. If you use the same mesh with different textures you can build a texture atlas or use more samplers.




#5107866 Cost of a freelance games programmer?

Posted by Tispe on 08 November 2013 - 06:57 AM

About 100$/hour for skilled professional I would assume. Big companies that need extra help for a short time period I would guess 200$/hr.

Anything below 50$/hr would be a good deal if he/she can deliver the goods.




#5107619 Computing view matrix to create shadow map

Posted by Tispe on 07 November 2013 - 01:52 AM

You need one view matrix for each light, and 6 for point lights.

 

Use D3DXMatrixLookAtLH, D3DXMatrixOrthoLH for directional lights for projection.




#5106330 Shadow mapping: D3DUSAGE_DEPTHSTENCIL or D3DUSAGE_RENDERTARGET?

Posted by Tispe on 01 November 2013 - 02:43 PM

Thanks guys. I think I will go for the D3DUSAGE_RENDERTARGET, D3DFMT_R32F, surface since I am targeting DX9 hardware and I need to most compatibility, and I don't want to complicate things by writing hardware specific code at this stage.




#5106174 c++, is a std::map's value ever copied?

Posted by Tispe on 01 November 2013 - 12:59 AM

Yes. But if the map erases entry 5 then int_ptr will be dangling.

 

You can use a shared_ptr inside the map, such that if map erases entry 5 then int_ptr will still point to the valid int. Only when the last shared pointer is destoryed the int is automatically deallocated.

std::map<int, std::shared_ptr<int> > my_map;
.
.
.

my_map[5] = std::shared_ptr<int>(new int(SomeValue));

.
.
.

std::map<int, std::shared_ptr<int> >::iterator it = my_map::find(5);

if(it != my_map.end()){
std::shared_ptr<int> int_ptr = (*it).second;
int SomeValue = *int_ptr.get();
}




#5106173 DirectX 9: Best Method To Limit FPS?

Posted by Tispe on 01 November 2013 - 12:33 AM

You should decouple FPS from game logic so that the game behave the same way regardless of FPS. For each frame you find the fElapsedTime and pass it down to all your logic. Every parameter you want to move/rotate/scale/advance you multiply with fElapsedTime.

void Logic(float fElapsedTime){
.
.
.
.
.
PlayerPosition += PlayerVelocity*fElapsedTime;
.
.
.
.
.
}



#5099703 Next step after learning C++ basics

Posted by Tispe on 08 October 2013 - 02:43 PM

I think you should just dive into a Directx Tutorial, there are many of them around. Just google it.






PARTNERS