Skip to content

Instantly share code, notes, and snippets.

@ghiboz
Created August 5, 2014 13:59
Show Gist options
  • Save ghiboz/16f1ee159fe7e6dfc835 to your computer and use it in GitHub Desktop.
Save ghiboz/16f1ee159fe7e6dfc835 to your computer and use it in GitHub Desktop.
void Render::initShiny()
{
/// material factory setup
sh::OgrePlatform* platform = new sh::OgrePlatform("General", sBasePath + "data/common");
platform->setCacheFolder(PATHMANAGER::GetCacheDir());
mFactory = new sh::Factory(platform);
sh::Factory& fct = sh::Factory::getInstance();
fct.setReadSourceCache (true);
fct.setWriteSourceCache (true);
fct.setReadMicrocodeCache (true);
fct.setWriteMicrocodeCache (true);
fct.setGlobalSetting("fog", "true");
fct.setGlobalSetting("num_lights", "2");
fct.setGlobalSetting("wind", "true");
fct.setGlobalSetting("mrt_output", "false");
fct.setGlobalSetting("shadows", "false");
fct.setGlobalSetting("shadows_pssm", "false");
fct.setGlobalSetting("shadows_depth", "false");
fct.setGlobalSetting("lighting", "true");
fct.setGlobalSetting("terrain_composite_map", "false");
fct.setGlobalSetting("soft_particles", "false");
fct.setGlobalSetting("editor", "false");
fct.setSharedParameter("fogColorSun", sh::makeProperty<sh::Vector4>(new sh::Vector4(0,0,0,0)));
fct.setSharedParameter("fogColorAway", sh::makeProperty<sh::Vector4>(new sh::Vector4(0,0,0,0)));
fct.setSharedParameter("fogColorH", sh::makeProperty<sh::Vector4>(new sh::Vector4(0,0,0,0)));
fct.setSharedParameter("fogParamsH", sh::makeProperty<sh::Vector4>(new sh::Vector4(0,0,0,0)));
fct.setSharedParameter("pssmSplitPoints", sh::makeProperty<sh::Vector3>(new sh::Vector3(0,0,0)));
fct.setSharedParameter("shadowFar_fadeStart", sh::makeProperty<sh::Vector4>(new sh::Vector4(0,0,0,0)));
//fct.setSharedParameter("arrowColour1", sh::makeProperty <sh::Vector3>(new sh::Vector3(0,0,0)));
//fct.setSharedParameter("arrowColour2", sh::makeProperty <sh::Vector3>(new sh::Vector3(0,0,0)));
fct.setSharedParameter("windTimer", sh::makeProperty <sh::FloatValue>(new sh::FloatValue(0)));
fct.setSharedParameter("posSph0", sh::makeProperty <sh::Vector4>(new sh::Vector4(0,500,0,-1)));
fct.setSharedParameter("posSph1", sh::makeProperty <sh::Vector4>(new sh::Vector4(0,500,0,-1)));
fct.setSharedParameter("terrainWorldSize", sh::makeProperty <sh::FloatValue>(new sh::FloatValue(1024)));
fct.setSharedParameter("waterDepth", sh::makeProperty<sh::FloatValue>(new sh::FloatValue(1.0)));
fct.setGlobalSetting("terrain_specular", "false");
fct.setGlobalSetting("terrain_normal", "false");
fct.setGlobalSetting("terrain_parallax", "false");
//fct.setGlobalSetting("terrain_triplanarType", toStr(pSet->ter_tripl));
//fct.setGlobalSetting("terrain_triplanarLayer", toStr(sc->td.triplanar1Layer));
fct.setGlobalSetting("water_reflect", "true");
fct.setGlobalSetting("water_refract", "true");
fct.setSharedParameter("waterEnabled", sh::makeProperty<sh::FloatValue> (new sh::FloatValue(0.0)));
fct.setSharedParameter("waterLevel", sh::makeProperty<sh::FloatValue>(new sh::FloatValue(0)));
fct.setSharedParameter("waterTimer", sh::makeProperty<sh::FloatValue>(new sh::FloatValue(0)));
fct.setSharedParameter("waterSunFade_sunHeight", sh::makeProperty<sh::Vector2>(new sh::Vector2(1, 0.6)));
fct.setSharedParameter("windDir_windSpeed", sh::makeProperty<sh::Vector3>(new sh::Vector3(0.5, -0.8, 0.2)));
// per lod
fct.setGlobalSetting ("enable_normal_map", "true");
fct.setGlobalSetting ("enable_spec_map", "true");
fct.setGlobalSetting ("refraction", "true");
fct.setGlobalSetting ("viewproj_fix", "false");
fct.setSharedParameter ("vpRow2Fix", sh::makeProperty<sh::Vector4> (new sh::Vector4(0,0,0,0)));
/// uncomment to enable shader output to files
//mFactory->setShaderDebugOutputEnabled(true);
sh::Language lang;
if (pSet->shader_mode == "")
{
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
lang = sh::Language_HLSL;
#else
lang = sh::Language_GLSL;
#endif
}else
{
if (pSet->shader_mode == "glsl") lang = sh::Language_GLSL;
else if (pSet->shader_mode == "cg") lang = sh::Language_CG;
else if (pSet->shader_mode == "hlsl") lang = sh::Language_HLSL;
else assert(0);
}
mFactory->setCurrentLanguage(lang);
mFactory->parseResources();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment