Esempio n. 1
0
void CSMFReadMap::CreateSplatDetailTextures()
{
	if (!haveSplatDetailDistribTexture)
		return;

	CBitmap splatDistrTexBM;
	CBitmap splatDetailTexBM;

	// if the map supplies an intensity- AND a distribution-texture for
	// detail-splat blending, the regular detail-texture is not used
	if (!splatDetailTexBM.Load(mapInfo->smf.splatDetailTexName)) {
		// default detail-texture should be all-grey
		splatDetailTexBM.channels = 4;
		splatDetailTexBM.AllocDummy(SColor(127,127,127,127));
	}

	if (!splatDistrTexBM.Load(mapInfo->smf.splatDistrTexName)) {
		splatDistrTexBM.channels = 4;
		splatDistrTexBM.AllocDummy(SColor(255,0,0,0));
	}

	splatDetailTex.SetRawTexID(splatDetailTexBM.CreateTexture(texAnisotropyLevels[true], true));
	splatDetailTex.SetRawSize(int2(splatDetailTexBM.xsize, splatDetailTexBM.ysize));

	splatDistrTex.SetRawTexID(splatDistrTexBM.CreateTexture(texAnisotropyLevels[true], true));
	splatDistrTex.SetRawSize(int2(splatDistrTexBM.xsize, splatDistrTexBM.ysize));

	// only load the splat detail normals if any of them are defined and present
	if (!haveSplatNormalDistribTexture)
		return;

	for (size_t i = 0; i < mapInfo->smf.splatDetailNormalTexNames.size(); i++) {
		if (i == NUM_SPLAT_DETAIL_NORMALS)
			break;

		CBitmap splatDetailNormalTextureBM;

		if (!splatDetailNormalTextureBM.Load(mapInfo->smf.splatDetailNormalTexNames[i])) {
			splatDetailNormalTextureBM.channels = 4;
			splatDetailNormalTextureBM.Alloc(1, 1);
			splatDetailNormalTextureBM.mem[0] = 127; // RGB is packed standard normal map
			splatDetailNormalTextureBM.mem[1] = 127;
			splatDetailNormalTextureBM.mem[2] = 255; // With a single upward (+Z) pointing vector
			splatDetailNormalTextureBM.mem[3] = 127; // Alpha is diffuse as in old-style detail textures
		}

		splatNormalTextures[i].SetRawTexID(splatDetailNormalTextureBM.CreateTexture(texAnisotropyLevels[true], true));
		splatNormalTextures[i].SetRawSize(int2(splatDetailNormalTextureBM.xsize, splatDetailNormalTextureBM.ysize));
	}

}
Esempio n. 2
0
static inline void GetFallbacks(std::unordered_map<std::string, STex>& textures)
{
	auto CREATE_SINGLE_COLOR = [](SColor c) -> STex {
		CBitmap bm;
		bm.AllocDummy(c);
		bm = bm.CreateRescaled(32, 32);
		return { bm.CreateTexture(), int2(bm.xsize, bm.ysize) };
	};

	textures["%FALLBACK_TEXTURE%"] = CREATE_SINGLE_COLOR(SColor(255, 0, 0, 255));
	textures["%FALLBACK_TEXTURE_NORMAL%"] = CREATE_SINGLE_COLOR(SColor(0, 255, 0, 255));
}
Esempio n. 3
0
CBasicWater::CBasicWater()
{
	CBitmap waterTexBM;
	if (!waterTexBM.Load(mapInfo->water.texture)) {
		LOG_L(L_WARNING, "[%s] could not read water texture from file \"%s\"", __FUNCTION__, mapInfo->water.texture.c_str());

		// fallback
		waterTexBM.AllocDummy(SColor(0,0,255,255));
	}

	// create mipmapped texture
	textureID = waterTexBM.CreateMipMapTexture();
	displistID = GenWaterQuadsList(waterTexBM.xsize, waterTexBM.ysize);
}
Esempio n. 4
0
void CSMFReadMap::CreateSpecularTex()
{
	if (!haveSpecularTexture)
		return;

	CBitmap specularTexBM;
	CBitmap skyReflectModTexBM;
	CBitmap blendNormalsTexBM;
	CBitmap lightEmissionTexBM;
	CBitmap parallaxHeightTexBM;

	if (!specularTexBM.Load(mapInfo->smf.specularTexName)) {
		// maps wants specular lighting, but no moderation
		specularTexBM.channels = 4;
		specularTexBM.AllocDummy(SColor(255, 255, 255, 255));
	}

	specularTex.SetRawTexID(specularTexBM.CreateTexture());
	specularTex.SetRawSize(int2(specularTexBM.xsize, specularTexBM.ysize));

	// no default 1x1 textures for these
	if (skyReflectModTexBM.Load(mapInfo->smf.skyReflectModTexName)) {
		skyReflectModTex.SetRawTexID(skyReflectModTexBM.CreateTexture());
		skyReflectModTex.SetRawSize(int2(skyReflectModTexBM.xsize, skyReflectModTexBM.ysize));
	}

	if (blendNormalsTexBM.Load(mapInfo->smf.blendNormalsTexName)) {
		blendNormalsTex.SetRawTexID(blendNormalsTexBM.CreateTexture());
		blendNormalsTex.SetRawSize(int2(blendNormalsTexBM.xsize, blendNormalsTexBM.ysize));
	}

	if (lightEmissionTexBM.Load(mapInfo->smf.lightEmissionTexName)) {
		lightEmissionTex.SetRawTexID(lightEmissionTexBM.CreateTexture());
		lightEmissionTex.SetRawSize(int2(lightEmissionTexBM.xsize, lightEmissionTexBM.ysize));
	}

	if (parallaxHeightTexBM.Load(mapInfo->smf.parallaxHeightTexName)) {
		parallaxHeightTex.SetRawTexID(parallaxHeightTexBM.CreateTexture());
		parallaxHeightTex.SetRawSize(int2(parallaxHeightTexBM.xsize, parallaxHeightTexBM.ysize));
	}
}