UnrealEngineSkyAtmosphere
// Listen to CTRL+S for shader live update in a very simple fashion (from http://www.lofibucket.com/articles/64k_intro.html)
static ULONGLONG lastLoadTime = GetTickCount64();
if (GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState('S'))
{
const ULONGLONG tickCount = GetTickCount64();
if (tickCount - lastLoadTime > 200)
{
Sleep(100); // Wait for a while to let the file system finish the file write.
loadShaders(false); // Reload (all) the shaders
}
lastLoadTime = tickCount;
}
该代码片段展示了在UnrealEngine中如何通过监听CTRL+S快捷键实现着色器的即时更新。当按下CTRL+S时,程序会等待一小段时间以确保文件写入完成,然后重新加载所有着色器,实现简单的着色器热重载功能。
2863

被折叠的 条评论
为什么被折叠?



