Jump to content

  • Log In with Google      Sign In   
  • Create Account


We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.

Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!

SIC Games

Member Since 22 Jun 2012
Offline Last Active Oct 03 2014 09:17 AM

Topics I've Started

Why does my static mesh drop FPS from 60 to 4?

25 September 2014 - 11:14 AM

At first thought my graphics card was puking chips. The static mesh I created is a cup that has 18,000 total polygons. I noticed the FPS to drop from 60 to 4-8. The cup is being rendered in the deferred renderer.


I also wanted to see how Unreal Engine 4 handle it - so I loaded it inside Unreal Engine 4 and it was just fine. I'm not the expert level as in Epic Games but my game rendering is suffering a bunch of frame drops.


I loaded a game character from another game that is about 12K total of polygon - I loaded three of them inside my level editor - frame dropped from 60 to 10 frames per second. In the game Amnesia they have multiple of those creatures chasing the player - so obviously my renderering system blows. 


I disabled the deferred shading and lowered down the shadow map resolution to 1024 x 1024 which was 2048 x 2048. Didn't really help much.


I use std::vectors to store the mesh data and such.


Each rendering scene object and I will get around to changing it:

void SceneObject::RenderSceneMesh(GraphicsDevice *device, MaterialShader &mShader, XMMATRIX &world, XMMATRIX &view, XMMATRIX &proj) {

		if (isCulled) {

			UINT stride = sizeof(ObjectVertexData);
			UINT offset = 0;

			device->devcon->IASetVertexBuffers(0, 1, &vertexBuffer, &stride, &offset);
			device->devcon->IASetIndexBuffer(indexBuffer, DXGI_FORMAT_R32_UINT, 0);


			cameraConstantBuff *cameraCBuffer;
			MESHES_CB_BUFFER *sceneCBuffer;

			XMMATRIX mWorld;
			mWorld = XMMatrixIdentity();
			XMMATRIX invView;

		//	ZeroMemory(&map, sizeof(D3D11_MAPPED_SUBRESOURCE));
			device->devcon->Map(PrimaryConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);

			sceneCBuffer = (MESHES_CB_BUFFER*)map.pData;

			world = scaleMatrix * rotationMatrix * translationMatrix;
			XMMATRIX wvp = world * view * proj;

			sceneCBuffer->WVP = XMMatrixTranspose(wvp);
			sceneCBuffer->WorldMatrix = XMMatrixTranspose(world);
			sceneCBuffer->viewMatrix = XMMatrixTranspose(view);
			sceneCBuffer->projectionMatrix = XMMatrixTranspose(proj);
			sceneCBuffer->modelWorld = XMMatrixTranspose(world);

			XMVECTOR det;
			XMMATRIX invWorld = XMMatrixInverse(&det, world);
			sceneCBuffer->invWorldMatrix = invWorld;

			sceneCBuffer->UVTile.x = gMaterial.TextureTile.x;
			sceneCBuffer->UVTile.y = gMaterial.TextureTile.y;

			if (!isPlaced) {
				sceneCBuffer->ghostModeEnabled = XMFLOAT2(1.0f,0.0f);
			else {
				sceneCBuffer->ghostModeEnabled = XMFLOAT2(0.0f,0.0f);
				isPlaced = true;
			sceneCBuffer->isSelected = XMFLOAT2(isSelected, 0.0f);
			sceneCBuffer->padding = XMFLOAT2(0, 0);

			device->devcon->Unmap(PrimaryConstantBuffer, 0);

			//ZeroMemory(&camMap, sizeof(D3D11_MAPPED_SUBRESOURCE));
			device->devcon->Map(cameraConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &camMap);

			cameraCBuffer = (cameraConstantBuff*)camMap.pData;

			//cameraCBuffer->reflectionMatrix = XMMatrixLookAtLH(reflectionPosition, reflectionLookAt, reflectionAim);

			cameraCBuffer->cameraPosition = cameraPosition;
			cameraCBuffer->padding = XMFLOAT4(0, 0, 0, 0);

			device->devcon->Unmap(cameraConstantBuffer, 0);

			D3D11_MAPPED_SUBRESOURCE lightMapped;
			//ZeroMemory(&lightMapped, sizeof(D3D11_MAPPED_SUBRESOURCE));

			device->getDeviceContext()->Map(lightCB, 0, D3D11_MAP_WRITE_DISCARD, 0, &lightMapped);

			lightConstantBuffer *lightCBuff;
			lightCBuff = (lightConstantBuffer*)lightMapped.pData;
			XMMATRIX lightProjWS = XMLoadFloat4x4(&ShadowProjWS);
			XMMATRIX ShadowWS = world * lightProjWS;
			lightCBuff->lightViewMatrix = XMMatrixTranspose(ShadowWS);
			lightCBuff->lightProjMatrix = XMLoadFloat4x4(&ShadowProjWS);

			device->getDeviceContext()->Unmap(lightCB, 0);

			device->devcon->VSSetShader(mShader.eVertexShader, 0, 0);
			device->devcon->PSSetShader(mShader.ePixelShader, 0, 0);

			ID3D11Buffer *constantbuffers[3] = { PrimaryConstantBuffer, cameraConstantBuffer, lightCB };

			device->devcon->VSSetConstantBuffers(0, 3, constantbuffers);
			device->devcon->PSSetConstantBuffers(0, 3, constantbuffers);
			ID3D11ShaderResourceView* srvs[7] = { diffuseSRV, normalSRV, specularSRV, ambientOccSRV, displacementSRV, ShadowMapSRV , SRV3D};
			device->devcon->PSSetShaderResources(0, 7, srvs);

			ID3D11SamplerState *samplers[2] = { device->pointTextureSampleState, device->clampTextureSampleState };
			device->devcon->PSSetSamplers(0, 2, samplers);


			device->devcon->DrawIndexed(renderObject.numIndices(), 0, 0);

			aabb.isBuilt = true;
			ID3D11ShaderResourceView *nullSRVS[7] = { 0 };
			device->getDeviceContext()->PSSetShaderResources(0, 7, nullSRVS);


Could it be the dyanmic constant buffers that are hurting performance? Thanks for chiming in.


3D Vertex Painting DirectX 11

09 September 2014 - 12:32 AM

I was curious about how I would go about vertex painting or terrain building with mouse picking. My idea was to have a off screen black render target. When the mouse clicks on a position of the terrain - it would load a round soft white texture onto the render target.  WHen the Terrain Editing is off - it will save the height map created by the off screen render target.


Vice Versa goes with perhaps blending in different textures using the same technique.


Just a rough idea but I wondered if anyone that has experience in this type would know how it's normally done.


Kind of like this



What are these showing in my normal map (Forward Rendering)

01 September 2014 - 05:36 PM

When I output the normal map this shows up:


Attached File  Snapshot1.jpg   122.23KB   1 downloads


Would this be a normal issue inside the mesh? Funny how Brazynsoft checks to see if the parameter of cumpute normals is true or false. If not then it uses the normals from the mesh. I'm using the normals from the mesh.


The shader:

output.normal = mul(input.normal, (float3x3)worldMatrix); //-- worldMatrix is the model's world matrix.
output.tangent = mul(input.tangent, (float3x3)worldMatrix);


float3 normalmap = Textures[1].Sample(ss, input.texcoord);
normalmap = 2.0f * normalmap - 1.0f;

input.normal  = normalize(input.normal);
input.tangent = normalize(input.tangent - dot(input.tangent, input.normal) * input.normal);
float3 biTangent  = cross(input.tangent, input.normal);
float3x3 texSpace = float3x3(biTangent, input.Tangent, input.normal);

input.normal = normalize(mul(normalmap, texSpace));

Or possibly this could be a result of the normal map its self.

Why are their bumps in my shadow mapping?

28 August 2014 - 12:33 AM

I just started implemending Shadow Mapping in my engine and I see inside the editor there's bumps inside the shadow map. I'm wondering what they are?


The current set up I have is an orthographic Left Handed view for rendering depth. The depth stencil is rendered as DXGI_FORMAT_D24_UNORM_S8_UINT and is bounded both as depth stencil and shader resource. The texture format for the depth stencil is DXGI_FORMAT_R24G8_TYPELESS The shader resource view is formated as DXGI_FORMAT_R24_UNORM_X8_TYPELESS.


Is it a format issue?


Attached File  Snapshot1.jpg   96.68KB   1 downloads


If anyone needs to see sniplets of code I'll share.

What you think of my Depth Pass AA?

25 August 2014 - 04:00 PM

I'm wanting to implemend Nvidia's FXAA and TXAA inside my game - however, I figure I create my own AA. Perhaps, someone already has already came up with the type of AA and there's more work to do to enhance the blurring. I want your feedback and let me know what you think. It's rough demonstration not perfect quite yet.


The firest picture is when it's just using the 8x MSAA on high setting possible. The second image is the 8x MSAA and my Depth Pass AA implematation.


I'm still working on how to make it better. Was just fascinated on the descripton in Nvidia's website how FXAA works - this is when I started to think about trying out my own. I have a simple blur but I am thinking about making it box blur with two passes or possibly gaussian blur.