SpiderPig Posted April 10 Share Posted April 10 DynamicLine.zip I've only noticed these things since the OpenGL build. It could be because now there are compile times involved. If you edit the attached frag file, it loads it twice and the changes are not applied. This is the console output after a single edit of DynamicLine.frag. If you change the color in the attached frag shader you'll see this in the console but the box will not change color. Loading shader module "Materials/DynamicLine/DynamicLine.frag" Loading shader module "Materials/DynamicLine/DynamicLine.frag" If you edit the material, all changes are applied but it still loads it twice. Deleting shader family "Materials/DynamicLine/DynamicLine.fam" Loading shader family "Materials/DynamicLine/DynamicLine.fam" Deleting shader family "Materials/DynamicLine/DynamicLine.fam" Loading shader family "Materials/DynamicLine/DynamicLine.fam" With some shaders I've seen it do it 4 times. It's annoying because as the files get bigger it takes longer to compile. #include "Engine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); auto framebuffer = CreateFramebuffer(window); auto world = CreateWorld(); world->SetGravity(0.0f, -2.0f, 0.0f); auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetPosition(0, 0, -2); auto light = CreateDirectionalLight(world); light->SetRotation(35, 35, 0); auto box = CreateBox(world); box->SetColor(0, 1, 0); auto mat = LoadMaterial("Materials\\DynamicLine\\DynamicLine.mat"); box->SetMaterial(mat); auto watcher = CreateFileSystemWatcher("Materials"); while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { while (PeekEvent()) { auto ev = WaitEvent(); if (ev.id == EVENT_FILECHANGE or ev.id == EVENT_FILECREATE) { //Look for a loaded asset with this file path auto asset = FindCachedAsset(ev.text); if (asset) { asset->Reload(); } } } box->Turn(0.0f, 0.1f, 0.0f); world->Update(); world->Render(framebuffer); } return 0; } Quote Link to comment Share on other sites More sharing options...
Josh Posted April 10 Share Posted April 10 What program are you editing it in, VSCode? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted April 10 Author Share Posted April 10 That frag shader file? Just a text editor. Quote Link to comment Share on other sites More sharing options...
Josh Posted April 10 Share Posted April 10 1 minute ago, SpiderPig said: That frag shader file? Just a text editor. Which one? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted April 10 Author Share Posted April 10 Notepad++. Do you think that matters? 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted April 10 Share Posted April 10 Yes. Some programs do saving a little differently. They'll do things like write the file somewhere else, and then copy it over once writing is finished, to prevent a file from getting corrupted. Some of these actions can trigger the file system watcher multiple times, and I do my best to prevent it. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted April 10 Author Share Posted April 10 Oh, I did not know that. Quote Link to comment Share on other sites More sharing options...
Josh Posted April 12 Share Posted April 12 I added a weak pointer in the shader module (the asset) to all shaders they get attached to, and it will reattach them and update the shader automatically when the module is reloaded. Tested shader editing in VSCode and Notepad and with both those programs the asset only gets reloaded once... Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted April 12 Share Posted April 12 Just installed Notepad++ and had no problems with multiple reloads when saving a post-processing fragment shader file. Let's see what happens when the next build of the editor goes up. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted April 12 Share Posted April 12 Editing a .fam file in VS Code, I do see two FILE_CHANGED events being emitted by the file system watcher. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted April 12 Share Posted April 12 From MS: https://learn.microsoft.com/en-us/dotnet/api/system.io.filesystemwatcher.created?view=net-8.0 Quote Common file system operations might raise more than one event. For example, when a file is moved from one directory to another, several OnChanged and some OnCreated and OnDeleted events might be raised. Moving a file is a complex operation that consists of multiple simple operations, therefore raising multiple events. Likewise, some applications (for example, antivirus software) might cause additional file system events that are detected by FileSystemWatcher. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Solution Josh Posted April 12 Solution Share Posted April 12 It may be possible to improve this in the future but I am wary of trying to mask this behavior, since it might lead to other problems. For now I am going to consider this "not a bug". 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.