示例#1
0
/*
	this loader applies only textures for stage 1 & 2
*/
s32 CQ3LevelMesh::setShaderFogMaterial( video::SMaterial &material, const tBSPFace * face ) const
{
	material.MaterialType = video::EMT_SOLID;
	material.Wireframe = false;
	material.Lighting = false;
	material.BackfaceCulling = false;
	material.setTexture(0, 0);
	material.setTexture(1, 0);
	material.setTexture(2, 0);
	material.setTexture(3, 0);
	material.ZBuffer = video::ECFN_LESSEQUAL;
	material.ZWriteEnable = false;
	material.MaterialTypeParam = 0.f;

	s32 shaderState = -1;

	if ( (u32) face->fogNum < FogMap.size() )
	{
		material.setTexture(0, FogMap [ face->fogNum ].Texture);
		shaderState = FogMap [ face->fogNum ].ShaderID;
	}

	return shaderState;

}
示例#2
0
/*
	this loader applies only textures for stage 1 & 2
*/
s32 CQ3LevelMesh::setShaderMaterial( video::SMaterial &material, const tBSPFace * face ) const
{
	material.MaterialType = video::EMT_SOLID;
	material.Wireframe = false;
	material.Lighting = false;
	material.BackfaceCulling = true;
	material.setTexture(0, 0);
	material.setTexture(1, 0);
	material.setTexture(2, 0);
	material.setTexture(3, 0);
	material.ZBuffer = video::ECFN_LESSEQUAL;
	material.ZWriteEnable = true;
	material.MaterialTypeParam = 0.f;

	s32 shaderState = -1;

	if ( face->textureID >= 0 && face->textureID < (s32)Tex.size() )
	{
		material.setTexture(0, Tex [ face->textureID ].Texture);
		shaderState = Tex [ face->textureID ].ShaderID;
	}

	if ( face->lightmapID >= 0 && face->lightmapID < (s32)Lightmap.size() )
	{
		material.setTexture(1, Lightmap [ face->lightmapID ]);
		material.MaterialType = LoadParam.defaultLightMapMaterial;
	}

	// store shader ID
	material.MaterialTypeParam2 = (f32) shaderState;

	const IShader *shader = getShader(shaderState);
	if ( 0 == shader )
		return shaderState;

	return shaderState;

#if 0
	const SVarGroup *group;


	// generic
	group = shader->getGroup( 1 );
	if ( group )
	{
		material.BackfaceCulling = getCullingFunction( group->get( "cull" ) );

		if ( group->isDefined( "surfaceparm", "nolightmap" ) )
		{
			material.MaterialType = video::EMT_SOLID;
			material.setTexture(1, 0);
		}

	}

	// try to get the best of the 8 texture stages..

	// texture 1, texture 2
	u32 startPos;
	for ( s32 g = 2; g <= 3; ++g )
	{
		group = shader->getGroup( g );
		if ( 0 == group )
			continue;

		startPos = 0;

		if ( group->isDefined( "depthwrite" ) )
		{
			material.ZWriteEnable = true;
		}

		SBlendFunc blendfunc ( LoadParam.defaultModulate );
		getBlendFunc( group->get( "blendfunc" ), blendfunc );
		getBlendFunc( group->get( "alphafunc" ), blendfunc );

		if ( 0 == LoadParam.alpharef &&
			(	blendfunc.type == video::EMT_TRANSPARENT_ALPHA_CHANNEL ||
				blendfunc.type == video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF
			)
			)
		{
			blendfunc.type = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
			blendfunc.param0 = 0.f;
		}

		material.MaterialType = blendfunc.type;
		material.MaterialTypeParam = blendfunc.param0;

		// try if we can match better
		shaderState |= (material.MaterialType == video::EMT_SOLID ) ? 0x00020000 : 0;
	}

	//material.BackfaceCulling = false;

	if ( shader->VarGroup->VariableGroup.size() <= 4 )
	{
		shaderState |= 0x00010000;
	}

	material.MaterialTypeParam2 = (f32) shaderState;
	return shaderState;
#endif
}