Example #1
0
void CompositorLoader::ParseStageConnections(CompositeStageConnections& connections, const json::Value& stageJson)
{
	if (stageJson.HasKey("input") && stageJson["input"].GetType() == ArrayVal)
	{
		Array inputArray = stageJson["input"].ToArray();

		for (auto it = inputArray.begin(); it != inputArray.end(); ++it)
		{
			connections.AddRenderTargetInput(it->ToString(""));
		}
	}
	
	if (stageJson.HasKey("output") && stageJson["output"].GetType() == ArrayVal)
	{
		Array inputArray = stageJson["output"].ToArray();

		for (auto it = inputArray.begin(); it != inputArray.end(); ++it)
		{
			connections.AddRenderTarget(it->ToString(""));
		}
	}
	
	if (stageJson.HasKey("depthBuffer") && stageJson["depthBuffer"].GetType() == StringVal)
	{
		connections.SetDepthBuffer(stageJson["depthBuffer"].ToString());
	}
}
Example #2
0
void CompositorLoader::ParseStage(ResourceManager& resourceManager, Compositor::Ptr& compositor, const json::Value& stageJson)
{
	if (stageJson.HasKey("disabled") && stageJson["disabled"].ToBool(false))
	{
		return;
	}

	if (!stageJson.HasKey("stage") || stageJson["stage"].GetType() != StringVal)
	{
		throw FormatException("stages[].stage needs to be a string containing the relvative path to a CompositeStage");
	}

	CompositeStageConnections connections;

	ParseStageConnections(connections, stageJson);

	std::string stageFilename = stageJson["stage"].ToString();
	CompositeStage::Ptr stage = resourceManager.LoadResource<CompositeStage>(stageFilename);

	if (stageJson.HasKey("shaderValues"))
	{
		Array defaultValues = stageJson["shaderValues"].ToArray();

		for (auto it = defaultValues.begin(); it != defaultValues.end(); ++it)
		{
			JsonTypeHelper::ParseValueIntoParameters(stage->GetStateParameters(), *it);
		}
	}

	compositor->AddCompositeStage(stage, connections);
}
Example #3
0
Sampler::Ptr SamplerLoader::ParseSampler(ResourceManager& resourceManager, const json::Value& root)
{
	if (root.GetType() == StringVal)
	{
		return resourceManager.LoadResource<Sampler>(root.ToString());
	}

	SamplerDescription description;

	description.samplingMode = ParseSamplingMode(root["sampling"].ToString("basic"));
	description.anisotropicEnabled = root["anisotropicEnabled"].ToBool(false);

	description.minFilter = ParseInterpolatioMode(root["minFilter"].ToString("linear"));
	description.magFilter = ParseInterpolatioMode(root["magFilter"].ToString("linear"));
	description.mipFilter = ParseInterpolatioMode(root["mipFilter"].ToString("linear"));
	
	description.uWrap = ParseEdgeSampling(root["uWrap"].ToString("clamp"));
	description.vWrap = ParseEdgeSampling(root["vWrap"].ToString("clamp"));
	description.wWrap = ParseEdgeSampling(root["wWrap"].ToString("clamp"));

	description.useMipMap = root["useMipMap"].ToBool(description.useMipMap);

	description.mipBias = root["mipBias"].ToFloat(description.mipBias);
	description.minLOD = root["minLOD"].ToFloat(description.minLOD);
	description.maxLOD = root["maxLOD"].ToFloat(description.maxLOD);

	description.compareFunction = JsonTypeHelper::ParseCompareFunction(root["compareFunction"].ToString("never"));

	description.maxAnisotropy = root["maxAnisotropy"].ToInt(description.maxAnisotropy);

	if (root.HasKey("borderColor"))
	{
		description.borderColor = JsonTypeHelper::ParseColor(root["borderColor"]);
	}

	return resourceManager.GetGraphics()->CreateSampler(description);
}