Armikron Posted June 9, 2023 Share Posted June 9, 2023 Windows 10, Unigine Community 2.16.1, C# I'm banging my head trying to make UI elements that work with Anti-Aliasing. Also have problems with Opacity flickering (it's not highlighting in the video). Mesh UI is using ObjectMeshDynamic with shown unlit material. https://youtu.be/q94RO0bRR5k Link to comment
silent Posted June 13, 2023 Share Posted June 13, 2023 Armikron Is it possible to get the project with all material graphs and source code for testing? Maybe we can come up with some extra idea. Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Armikron Posted June 13, 2023 Author Share Posted June 13, 2023 Well I don't envy the person who'll have to see my horror prototype code, but sure. Uploaded as "tiny_hearts [armikron] [topic-8554].zip". The only relevant code used is hud_mesh.cs, material is unlit_mat.mgraph. By the way, is there a way to make Transparent PBR material unlit? That material option has controlled emission parameter, as opposed to Unlit option that has forced emission. 1 Link to comment
silent Posted June 14, 2023 Share Posted June 14, 2023 Quote By the way, is there a way to make Transparent PBR material unlit? That material option has controlled emission parameter, as opposed to Unlit option that has forced emission. The main purpose of unlit materials is that you need to implement your lightning on our own. Quote Uploaded as "tiny_hearts [armikron] [topic-8554].zip". Thanks, we would check this as soon as our team will more spare time (maybe only after 2.17 release). How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Armikron Posted July 2, 2023 Author Share Posted July 2, 2023 (edited) Any development on this? Basically I need to have FXAA on UI and no TAA. I thought of having a post material and add FXAA shader to it. One way is to render to 2 viewports and combine them as textures in material, but this is laughably slow. Using material on WidgetSpriteShader is useless since Texture Screen Buffer Color returns black, so I can't blend. It does work if I use material in settings, but then I have other issues with a texture instead. Just madness. Also Function node is very undercooked. I don't see texture() function in order to sample texture (required for FXAA) among other things (no Undo/Redo, else block, etc) Strange that this problem exists, your Weapon Clipping demo shows no anti-aliasing on weapon as well. P.S. Могу по русски, по английски пишу только для того чтобы иностранцы легче находили решения в гугле. --- Think I found the solution: Render to texture and use it in post material. Post material must be in settings, NOT on WidgetSpriteShader (this makes Texture Buffer Screen Color return black). Set Render Sequence Order in post material to Before Post Materials. This gets rid of TAA artifacts and ghosting and leaves FXAA. This makes WidgetSprite useless, so it goes in to garbage bin. Now I have this transparency flickering thing to worry about. Edited July 2, 2023 by Armikron Link to comment
silent Posted July 3, 2023 Share Posted July 3, 2023 Armikron Render to texture is indeed a more flexible solution. If you already have a final code, perhaps you could publish it here to assist future researchers? :) Currently, most of the development team is on summer vacation, which is causing this significant delay. Sorry for that. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Armikron Posted July 3, 2023 Author Share Posted July 3, 2023 Well deserved, congrats on 2.17 release. Final code, you mean UI? Didn't progress barely at all, didn't have much time and I was dealing with anti-aliasing issue (it was a deal breaker). If you mean change that fixed aliasing, then in Init(): player = projectionCamera; ivec2 winsize = WindowManager.MainWindow.Size; proj = new(); proj.camera = projectionCamera; proj.camera.ViewportMask = 2; proj.viewport = new Viewport(); proj.viewport.SkipFlags |= Viewport.SKIP_VELOCITY_BUFFER; // this will disable TAA proj.viewport.SkipFlags |= Viewport.SKIP_POSTEFFECTS; // glitch output if used on post processing material proj.viewport.SkipFlags |= Viewport.SKIP_AUTO_WHITE_BALANCE; //proj.viewport.SkipFlags |= Viewport.SKIP_TRANSPARENT; proj.texture = new Texture(); proj.texture.Create2D(winsize.x, winsize.y, Texture.FORMAT_RGBA8, Texture.SAMPLER_FILTER_LINEAR | Texture.SAMPLER_ANISOTROPY_16 | Texture.FORMAT_USAGE_RENDER); Material spriteMat = Materials.FindMaterialByPath("ui/post_mat.mgraph"); spriteMat.SetParameterInt("enable", 1); spriteMat.SetTexture(spriteMat.FindTexture("albedo"), proj.texture); The only change is WidgetSprite is removed entirely. Added post material lines. Update() is the same: RenderState.SaveState(); RenderState.ClearStates(); proj.viewport.RenderTexture2D(proj.camera.Camera, proj.texture); RenderState.RestoreState(); Post process material itself: Added it to Settings of course. FXAA enabled in Settings. Function Final is just a Lerp with condition: void Final(in float4 a, in float4 b, in int enable, out float4 c) { c = a; if (enable > 0) { c = lerp(a, b, b.w); } } By the way, is there a way to enable/disable post process materials from code? I might have missed that in docs. Link to comment
silent Posted July 3, 2023 Share Posted July 3, 2023 If you are talking about enabling / disabling specific scriptable material you can use Render.SetScriptableMaterialEnabled(int num, bool enabled) and find your material first via Render.FindScriptableMaterial(Material mat). 1 How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Recommended Posts