vblack Posted May 24, 2017 Share Posted May 24, 2017 I'm doing a fps game and for optimisation (entering into a building), I need to hide the terrain entirely with a script. How to do that ? Can't find a 'terrain' object I can manipulate. Quote Link to comment Share on other sites More sharing options...
Josh Posted May 24, 2017 Share Posted May 24, 2017 The renderer will automatically hide parts of terrain that are not visible. 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...
vblack Posted May 24, 2017 Author Share Posted May 24, 2017 The problem is that we have a basement in that building and the terrain is sometimes visible (overlapping walls), we try to extrude, but hiding the whole would be better. Quote Link to comment Share on other sites More sharing options...
Josh Posted May 24, 2017 Share Posted May 24, 2017 Ah, that makes sense. Do this once after your map is loaded to get the terrain entity: local n for n=0,world:CountEntities()-1 do local entity = world:GetEntity(n) if entity:GetClassName()=="Terrain" then terrain = entity break end end 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...
Genebris Posted May 24, 2017 Share Posted May 24, 2017 1 hour ago, Josh said: Ah, that makes sense. Do this once after your map is loaded to get the terrain entity: local n for n=0,world:CountEntities()-1 do local entity = world:GetEntity(n) if entity:GetClassName()=="Terrain" then terrain = entity break end end terrain:Hide() removes collision from terrain, but it remains visible. Quote Link to comment Share on other sites More sharing options...
Josh Posted May 24, 2017 Share Posted May 24, 2017 4 minutes ago, Genebris said: terrain:Hide() removes collision from terrain, but it remains visible. That's actually going to be a problem, even if I fix that. You don't want all your objects outside to fall out of the level. The reason this occurs is that technically each terrain patch is its own entity, and is not parented to the terrain entity itself. 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...
Genebris Posted May 24, 2017 Share Posted May 24, 2017 5 minutes ago, Josh said: That's actually going to be a problem, even if I fix that. You don't want all your objects outside to fall out of the level. The reason this occurs is that technically each terrain patch is its own entity, and is not parented to the terrain entity itself. But how do you disable rendering of terrain then? You can do this, but I guess it won't help performance-wise. Quote Link to comment Share on other sites More sharing options...
Josh Posted May 24, 2017 Share Posted May 24, 2017 4 minutes ago, Genebris said: But how do you disable rendering of terrain then? You can do this, but I guess it won't help performance-wise. Well, at this point you don't. What the user needs is for me to add another terrain tool to remove patches of the terrain. 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...
gamecreator Posted May 24, 2017 Share Posted May 24, 2017 Which relates to a previous need to remove navmesh patches/triangles. Kinda Quote Link to comment Share on other sites More sharing options...
Rick Posted May 24, 2017 Share Posted May 24, 2017 Couldn't a shader just not draw the terrain while still having it physically in place? Quote Link to comment Share on other sites More sharing options...
Crazycarpet Posted May 24, 2017 Share Posted May 24, 2017 Couldn't you set the entities alpha to 0? It' be nice if the renderer didn't even try to draw entities with an alpha color of 0. Quote Link to comment Share on other sites More sharing options...
nick.ace Posted May 31, 2017 Share Posted May 31, 2017 @Rick This won't help much with performance (and can actually worsen performance). You aren't saving CPU processing due to draw calls/state changes being made, and you still have to go through vertex shading, tessellation, geometry shading (unless you discard here, but you get geometry shader overhead), and rasterization. If you discard in the fragment shader (because the terrain quads are too large or something), then you compromise early-z discard, which is a GPU hardware optimization that prevents fragment shaders from running. In fact, if you are rendering terrain and drawing it last, it can be faster allowing it to render normally than trying to discard it in a shader. 1 Quote Link to comment Share on other sites More sharing options...
Jazz Posted June 5, 2017 Share Posted June 5, 2017 Was playing with terrain the other day for fun so I put it in the workshop. It's too bad not all the terrain commands are working/exposed to lua. " terrainCutter.lua Lowers terrain the size of the model/CSG it's attached to. terrainRemove.lua lowers it when you enter the model's AABB then restores it when not in it's AABB. " https://www.leadwerks.com/workshopitem?tags=&queryType=1&fileType=0&fileid=938356115 1 Quote --- Scott Using Windows 7 Ultimate 64 bit/Core I7-2700K @ 4312mhz/24G RAM/Nvidia GTX 1060 Link to comment Share on other sites More sharing options...
vblack Posted June 12, 2017 Author Share Posted June 12, 2017 On 6/5/2017 at 11:53 AM, SGB said: Was playing with terrain the other day for fun so I put it in the workshop. It's too bad not all the terrain commands are working/exposed to lua. " terrainCutter.lua Lowers terrain the size of the model/CSG it's attached to. terrainRemove.lua lowers it when you enter the model's AABB then restores it when not in it's AABB. " https://www.leadwerks.com/workshopitem?tags=&queryType=1&fileType=0&fileid=938356115 The workshop is not working for this page (got 4.3 version). Can you put the script ? I can find the entity "Terrain" as explained, but cannot control it (Hide(), Move() doesn't work) Quote Link to comment Share on other sites More sharing options...
Jazz Posted June 12, 2017 Share Posted June 12, 2017 TerrainCutter.zip Quote --- Scott Using Windows 7 Ultimate 64 bit/Core I7-2700K @ 4312mhz/24G RAM/Nvidia GTX 1060 Link to comment Share on other sites More sharing options...
vblack Posted June 18, 2017 Author Share Posted June 18, 2017 Hi; In TerrainRemove.lua, tSize and terrain are undefined ? Quote Link to comment Share on other sites More sharing options...
Jazz Posted June 18, 2017 Share Posted June 18, 2017 1 minute ago, vblack said: Hi; In TerrainRemove.lua, tSize and terrain are undefined ? They are defined in Main.lua Quote --- Scott Using Windows 7 Ultimate 64 bit/Core I7-2700K @ 4312mhz/24G RAM/Nvidia GTX 1060 Link to comment Share on other sites More sharing options...
vblack Posted June 18, 2017 Author Share Posted June 18, 2017 OK, tried the code, but it doesn't work, when I go inside, it just flicker and the terrain is still visible Quote Link to comment Share on other sites More sharing options...
Jazz Posted June 18, 2017 Share Posted June 18, 2017 53 minutes ago, vblack said: OK, tried the code, but it doesn't work, when I go inside, it just flicker and the terrain is still visible Here's a compiled version to try. terraintest.rar · 23.58 MB https://www.dropbox.com/s/0wbgdtz1huytp4d/terraintest.rar?dl=0 Quote --- Scott Using Windows 7 Ultimate 64 bit/Core I7-2700K @ 4312mhz/24G RAM/Nvidia GTX 1060 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.