Sign in to follow this  
cozzie

How does this look?

Recommended Posts

Looks very cool.

Have you implemented skeletal animation yet? If so, what models format are you using for this?

Share this post


Link to post
Share on other sites

Good start!  If you remove some of the sharp edges on your buildings and objects then things will look even better.

Share this post


Link to post
Share on other sites

@anddos: When i create the projection matrix, I also create and save a identity view * projection matrix. As soon as I need to render the weapon, I send the viewIdentityProjection matrix to the shader (shader constant).

@guardianX: no animations yet, will dig into that probably in a few weeks. I've added a nice flexible class with the FMOD audio api yesterday. So much things to do, so little time.
Things on my list: space positioning, mesh animation, hud class, particle system, level editor (although I love going wild with notepad, editing my own scene file format smile.png)

@meddo337: currently point lights don't affect the weapon, because I set the identityViewProjection matrix to the projectionMatrix shader constant. But I think I know how to solve it:
- have 2 uniform inputs in my (lighting) shader, one for regular viewProjection matrix and one for the identity one. Then add a new technique specifically for weapon rendering, where the 1st matrix is used for passing worldpos to the pixelshader and the 2nd is used for calculating the VS output pixel position. This means I would need to keep track and update a world matrix for the camera position though. If it works out I'll post another screenshot.

 

Update: too bad it's not that simple, the problem isn't the viewIdentityProjection matrix, but the world matrix. For positioning I need the camera oriented world matrix, but for the point lights I need the world positon world matrix.... I'll think about it.

Edited by cozzie

Share this post


Link to post
Share on other sites

@anddos: When i create the projection matrix, I also create and save a identity view * projection matrix. As soon as I need to render the weapon, I send the viewIdentityProjection matrix to the shader (shader constant).

@guardianX: no animations yet, will dig into that probably in a few weeks. I've added a nice flexible class with the FMOD audio api yesterday. So much things to do, so little time.
Things on my list: space positioning, mesh animation, hud class, particle system, level editor (although I love going wild with notepad, editing my own scene file format smile.png)

@meddo337: currently point lights don't affect the weapon, because I set the identityViewProjection matrix to the projectionMatrix shader constant. But I think I know how to solve it:
- have 2 uniform inputs in my (lighting) shader, one for regular viewProjection matrix and one for the identity one. Then add a new technique specifically for weapon rendering, where the 1st matrix is used for passing worldpos to the pixelshader and the 2nd is used for calculating the VS output pixel position. This means I would need to keep track and update a world matrix for the camera position though. If it works out I'll post another screenshot.

 

Update: too bad it's not that simple, the problem isn't the viewIdentityProjection matrix, but the world matrix. For positioning I need the camera oriented world matrix, but for the point lights I need the world positon world matrix.... I'll think about it.

Would it be possible to see that code?, i could never understand what people ment by rendering with an identity matrix for fps weapons,if i set a model to the identity and pass it to the shader,it just apears in 0,0,0 world cordinates.

Share this post


Link to post
Share on other sites

Anddos, no problem.

Below I've pasted the current/ working situation, with the remark that my point lights are not affecting the weapon.

 

I'm trying to solve this by using the regulier viewProjection matrix and the camera view matrix inverse as world matrix.

 

The code:

bool CD3d::RenderWeapon(const CD3dscene &pD3dscene, const CD3dcam &pCam, const char *pTechnique)
{
	int mInst	= pD3dscene.GetCurrentWeapon();
	int mesh	= pD3dscene.mWeaponMeshInst[mInst].GetMeshId();
	int fxIndex = 0;				
	// = pD3dscene.mWeaponMeshInst[mInst].GetEffectIndex();		NOT POSSIBLE/ TRICKY, BECAUSE OF LIGHTING SHADER

	// Set the ViewProjection (Camera) matrix to 'identity view matrix' version
	if(FAILED(pD3dscene.mShaders[fxIndex].mEffect->SetMatrix(pD3dscene.mShaders[fxIndex].mHViewProjMatrix, &pCam.GetViewIdentProjMatrix()))) return false;	

	if(!pD3dscene.mMeshes[mesh].SetBuffers()) return false;					
	if(!pD3dscene.ShaderSelectWeaponMeshInst(mInst)) return false;

	if(!ShaderSetTechnique(pD3dscene, fxIndex, pTechnique)) return false;	
	pD3dscene.mShaders[fxIndex].Begin(); 

	for(unsigned int p=0;p<pD3dscene.mShaders[fxIndex].GetNumPasses();++p)
	{
		pD3dscene.mShaders[fxIndex].BeginPass(p); 

		for(int mat=0;mat<pD3dscene.mNrMaterials;++mat)			// OPTIMIZE; only go through materials of specific mesh
		{
			if(!pD3dscene.ShaderSelectMaterial(mat, fxIndex)) return false;
			
			pD3dscene.mShaders[fxIndex].Commit(); 

			for(DWORD sub=0;sub<pD3dscene.mMeshes[mesh].GetSubMeshSize();++sub)
			{
				if(pD3dscene.mMeshes[mesh].mMatIdPerSubMesh[sub] == mat)
				{
					pD3dscene.mMeshes[mesh].RenderSubMesh(sub, LIST);
				}
			}
		}
		pD3dscene.mShaders[fxIndex].EndPass(); 
	}
	pD3dscene.mShaders[fxIndex].End();
	return true;
}

You might need some thinking on it, but basically it's a 'regular' shader, but with 2 differences:

- viewProjection = identityViewProjection (calculated @cpu)

- worldMatrix = local space instead of world space (which I have for all mesh instances in the scene)

Share this post


Link to post
Share on other sites

Point lights on the selected weapon also fixed smile.png

 

testscene-weapon-plight.jpg

 

Not using the identity view * projection matrix anymore, just normal viewProjection.

But as world matrix for the weapon I send the inverse of the camera viewmatrix to the shader.

 

Only problem is that I haven't figured out yet how to 'add' the local space world matrix of the weapon to the inverse viewmatrix of the camera, before sending it to the shader. Just adding them up doesn't work (D3DXMATRIXA16 inverseview + D3DXMATRIXA16 localworld);

Edited by cozzie

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this