Jump to content

Hide Terrain by code


vblack
 Share

Recommended Posts

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

 

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

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.

Link to comment
Share on other sites

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.

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

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.

 

Link to comment
Share on other sites

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.

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

@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.

  • Upvote 1
Link to comment
Share on other sites

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

  • Upvote 1

---

Scott

 

Using Windows 7 Ultimate 64 bit/Core I7-2700K @ 4312mhz/24G RAM/Nvidia GTX 1060

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

1 minute ago, vblack said:

Hi;

In  TerrainRemove.lua, tSize and terrain are undefined ?

They are defined in Main.lua

---

Scott

 

Using Windows 7 Ultimate 64 bit/Core I7-2700K @ 4312mhz/24G RAM/Nvidia GTX 1060

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...