-
Posts
3,618 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Downloads
Everything posted by shadmar
-
The index is used to access next surface if your model have 2 surfaces, the second one would be surface[1]
-
I did something like this in 3.0 for the model shaders vertex: out vec3 clip_pos; .. clip_pos = (entitymatrix*vec4(vertex_position, 1.0)).xyz; frag: in vec3 clip_pos; uniform float water_height; .. if (clip_pos.y < water_height) discard; The thing is that you have to change all shaders that are in play or has the chance of being clipped, so making clipped workshop items etc will be a nightmare.
-
It only bugs/freezes in list view, using grid view works ok. (you can choose next to "BIG PICTURE") Now I can start it within steam again.
-
You can fade alpha on most shaders, just not the alphamasked one. just use SetColor(1,1,1,fadeamount); Material has to be alpha blended.
-
262000 trees at 15 fps. Using grid for the close ones and geometry shader for the 261500 billboards. Edit: not sure how this got into this thread..
-
Yes you can use discard like that, but then you need to change all object shader in use (the ones that are supposed to be clipped), which makes water making with plane reflection difficult for general easy usage.
-
There are exmaples on the description.
-
Would be nice to have for lua, now I do a picking loop to place the entities, but picking is expensive.
- 1 reply
-
- 4
-
Easy to use lua based grid for massive 3d entity management
shadmar replied to shadmar's topic in Programming
Thanks, if I edit posts with code, all tabs are collapsed wich makes it impossible to correct it since it won't be readable after. -
Easy to use lua based grid for massive 3d entity management
shadmar replied to shadmar's topic in Programming
Yes you should have a system for hiding aswell. You could do a simple loop every second and just hide everything before getcell is called. And I like your idea -
Based on : https://github.com/ING1337/CellGrid 1. Create a script called Scripts/class.lua function class(base) local c = {} if type(base) == "table" then for key,value in pairs(base) do c[key] = value end c._base = base end c.__index = c local mt = {} mt.__call = function(class_table, ...) local self = {} setmetatable(self, c) if class_table.init then class_table.init(self, ...) else if base and base.init then base.init(self, ...) end end return self end c.is_a = function(self, klass) local m = getmetatable(self) while m do if m == klass then return true end m = m._base end return false end setmetatable(c, mt) return c end 2. Create a script called Scripts/grid.lua require "Scripts/class" -- LUA CellGrid by ING -- allows massive 3d entity management CellGrid = class() function CellGrid:init(cellSize, offsetX, offsetY) self.grid = {} self.size = cellSize or 100 self.offsetX = offsetX or -15000 self.offsetY = offsetY or -15000 end -- ################################################################################################################################# function CellGrid:AddEntity(entity, position, radius) range = radius and (math.ceil(radius / self.size)) or 0 x = math.max(1, math.floor((position.x - self.offsetX) / self.size - range)) y = math.max(1, math.floor((position.z - self.offsetY) / self.size - range)) for i = x, range * 2 + x, 1 do if self.grid == nil then self.grid = {} end for j = y, range * 2 + y, 1 do if self.grid[j] == nil then self.grid[j] = {} end table.insert(self.grid[j], entity) end end end function CellGrid:RemoveEntity(entity, position, radius) range = radius and (math.ceil(radius / self.size)) or 0 x = math.max(1, math.floor((position.x - self.offsetX) / self.size - range)) y = math.max(1, math.floor((position.z - self.offsetY) / self.size - range)) for i = x, range * 2 + x, 1 do for j = y, range * 2 + y, 1 do for k, comp in ipairs(self.grid[j]) do if comp == entity then table.remove(self.grid[j], k) break end end end end end -- ################################################################################################################################# function CellGrid:GetCell(position) x = math.max(1, math.floor((position.x - self.offsetX) / self.size)) y = math.max(1, math.floor((position.z - self.offsetY) / self.size)) if not self.grid[x] then return nil end return self.grid[x][y] end 3. Example usage for putting in entities : Make a camara/player/etc attached script : require "Scripts/grid" function Script:Start() --init the grid self.cell = CellGrid() self.cell:init(50) -- sets size of one grid cell -- place some entities around the xz plane entities = { } for x=0,20000,1 do entities[x] = some.loaded.entity:Instance() entities[x]:SetPosition(Math:Random(-500,500),0,SetPosition(Math:Random(-500,500)) entities[x]:Hide() end --add entities to the grid for i,j in pairs(entities) local position = { x = j:GetPosition().x, z = j:GetPosition().z } self.cell:AddEntity(j, position, 1) end end function Script:UpdateWorld() -- get player/camera position local position = { x = self.entity:GetParent():GetPosition().x, --assuming parent is player or camera z = self.entity:GetParent():GetPosition().z --assuming parent is player or camera } -- fetch entites and show them within cell size of position local grid = self.cell:GetCell(position) if grid ~=nil then for k,v in pairs(grid) do if v~=nil then v:Show() end end end end
-
Look in bloom.lua --Called each time the camera is rendered function Script:Render(camera,context,buffer,depth,diffuse,normals,emission)
-
Win8.1 You can also just hit Windows+X, choose Run type : steam://rungameid/251810
-
It should look like this (if mats are correctly configured)
-
Yes this works very well, no need to click inside steam api then.
-
http://www.leadwerks.com/werkspace/files/file/471-animated-vegetation-shader/
-
Good point I havent tested, but I think you dependant on the in-house octree, and have predefined ranges like NEAR,FAR etc.. Edit: viewrange works quite ok, but MediumRange is really to close and FarRange is.. well too far. If we could have custom ranges it would be perfect.
-
Yes. Abit, using camera distance would force me to check all 80000 objects every frame. Now I just check cells within my radius wich contains about 1000 objects, so number of checks would be about 80 instead of 80000.
-
@rick It's no shader, just lua. the objects displayed will steal fps, but search of wich objects to display is almost free. @ygroove If you have tens of thousands of objects placed in a map it will search .placed objects surrounding you in a radius R very fast and do entity:Show(). In that shot it displays all times around 1100 objects of 80000, so I will always have rocks and trees surrounding me, even if I walk for miles However if you look from above you will see that objects visible is just surrounding the player in a defined radius.
-
A grid based scenemanager to handle a large number objects, this one holds 80.000 objects, trees and rocks, for a huge ground level.
-
It's a wonder that still works. I have a plan to make it easier to use. But just need time. Also ping klepto, he have some pp-water that looks very good, but I dont know when it's available.
-
I exit leadwerks, exit steam (all th way) unplugged network and started steam in offline mode, then launched leadwerks. Seems to be working allright at my end here.
-
If no internet, just start Steam in offline mode, then launch Leadwerks. Works fine.