Jump to content

Haydenmango

Members
  • Posts

    434
  • Joined

  • Last visited

Everything posted by Haydenmango

  1. That is not what I am saying at all. What I am saying is that the Lua Garbage Collector is sometimes not fast enough for games that are using lots of memory so this function helps if you are creating games with big worlds. The bugs I found were simple issues that weren't causing memory leaks. My game runs exactly the same now that I have fixed them and tested it again with and without collectgarbage('setpause",100). If you must know the bugs were simple things like bees not doing damage because a condition wasn't see to true as well as my respawntimes for certain creatures were way to quick. Oh and -- The issue that crashed the game was a rare condition that only would happen if the bees were not doing damage(it was a physics issue the bees normally turn their physics off and start following the object while doing damage but the physics never turned off). .... think about it; does one general setting for a garbage collection system work for every single program ever created?
  2. I have been reading a lot about Lua and specifically the garbage collector recently and learned a few things. Such as - source- http://www.lua.org/manual/5.1/manual.html I have been testing my game for memory issues for weeks now and I am starting to think that the garbage collector just isn't fast enough to keep up with the amount of things I have going on. I noticed that since my memory usage rises to quick that the collector waits for my total memory to double before starting the next cycle and things start to get out of hand from there. I know that in most cases the garbage collector should be able to handle by itself but in my case it is not. I do not have any memory leaks in my code. I know this because if I run the garbage collector every frame my memory usage stays consistent. So could it be a better option to control the Lua Garbage Collector manually in my case? Edit ---- I have tested using collectgarbage('setpause',100) in my App Start() function. My game lasted about 2 hours longer than usual!! I normally test my games memory usage by going into release mode and standing completely still until my game crashes(It used to crash after about an hour); this time, well after I reached my normal 'crash point' I started running around doing crazy things to see if I would run out of memory but my game crashed due to an unknown error (I wasn't in debug mode) which I believe to be an issue in my script(not memory related)!!! I found multiple bugs I haven't noticed in my game before as well which I will fix and then I will test this more thoroughly. Also when tested in debug mode I noticed that my memory usage stayed consistent when before it used to constantly increase!
  3. To see particle emitters in the editor you have to go to View - Realtime Render
  4. Ok well I have just been using collectgarbage() not collectgarbage(collect). Once I changed that I think I started getting more accurate results. It is good to know that some of the small memory bumps are possibly structures in the terrain class getting initialized and it is not a leak. P.S. Knowing about the third parameter for DrawStats() is really helping me test my other projects! Also, I couldn't find the DrawStats() function in the documentation; did I miss it or is it yet to be created?
  5. At least it isn't just me. Thanks for testing that out. !!!!!!!!!!!!!!! I didn't know you could even do that! That changes everything!I also noticed that just the memory usage rises for me too while the script memory usage stays the same. edit-- What do "batches" stand for? I get 6 batches when using my basic testing map but when I use my Hunt for Food map I get anywhere from 50-100ish batches which I am guessing isn't good. haha
  6. Yes I have done this and it does reach a limit. In theory you could make a character run around the entire terrain and the memory will reach a limit once you have been everywhere. I haven't tested that because it would take forever but I have tested it on a small csg box and after I ran around the entire box the memory usage did reach a limit and I could continue running without the memory increasing. This probably isn't a bug then but it is kind of limiting and makes memory usage testing quite difficult.
  7. Yeah that seems like a reasonable cause for the 'issue'. I was starting to come to a similar conclusion myself but you put it into words perfectly. That would be cool if you could do a test, let me know about the results! The terrain in my test map didn't have any textures on it. So I am now wondering if having multiple terrain texture layers could increase the amount of memory allocated... I am guessing yes but then again I am only guessing at this point....
  8. Yes I recall reading that. The memory never gets cleaned up. I've waited a lonnnnnggggg time and it will never go down. By placing collectgarbage() in my main App loop I believe that stops lua from building up memory. --Josh Edit--- After testing more I found that when using the same setup but with a csg box instead of terrain the memory usage reaches a limit. Also when using just a camera to move around the memory usage increases if I have a terrain but the memory usage reaches a limit if it is a csg box.
  9. Good job, it is working fine for me. This will definitely speed things up!
  10. It would be nice if someone else could test this to see if they get similar results. I am up to date and am in the beta.
  11. No problem, glad you figured it out!
  12. Sorry I gave you the wrong information initially. Look back at my first post, I edited it with the correct info.
  13. edit - I looked at the script and that line should actually look like this - local bob=0; local speed = math.max(0.1,self.player.entity:GetVelocity():xz():Length())
  14. Has this been looked at? I would like to know if this is a problem or not so that I can start working on my game again. I can't accurately test my memory usage if this is a bug.
  15. When I walk on terrain with a Character Controller my memory usage consistently goes up. I tested this by using the Terrain map in the MyGame project with a Character Controller using the FPSplayer.script. I also put a check for memory usage and collectgarbage() in my main App Loop. Further details can be found in the video I made-- https://www.youtube.com/watch?v=Bj0brR8_7eQ&feature=youtu.be
  16. Go to View - Show Physics and un-check it. The orange boxes represent the objects physics shapes.
  17. Hi everyone. I was wondering if someone could take a look at these modified versions of Shadmars Vegetation+Diffuse+Shadowmask and Shadow+Vegetation shaders to check for any errors. Also I was wondering if there is a way I can make the vegetation sway only when it is visible and/or within a certain distance from the camera. That could be really useful (especially if it increases my fps). Anyways here they are. They compile without any errors and seem to work fine. Feel free to use them in any of your own projects at your own risk until they get a stamp of approval. Vegetation+Diffuse+Shadowmask Shader-- Fragment- #version 400 #define BFN_ENABLED 1 //Uniforms uniform sampler2D texture0;//diffuse map uniform sampler2D texture1;//normal map uniform vec4 materialcolorspecular; uniform vec4 lighting_ambient; uniform samplerCube texture15; uniform vec2 camerarange; uniform vec2 buffersize; uniform float camerazoom; //Inputs in vec2 ex_texcoords0; in vec4 ex_color; in float ex_selectionstate; in vec3 ex_VertexCameraPosition; in vec3 ex_normal; in vec3 ex_tangent; in vec3 ex_binormal; //Outputs out vec4 fragData0; out vec4 fragData1; out vec4 fragData2; out vec4 fragData3; float DepthToZPosition(in float depth) { return camerarange.x / (camerarange.y - depth * (camerarange.y - camerarange.x)) * camerarange.y; } void main(void) { vec4 outcolor = ex_color; outcolor *= texture(texture0,ex_texcoords0); if (outcolor.a < .63) discard; vec4 color_specular = materialcolorspecular; vec3 screencoord = vec3(((gl_FragCoord.x/buffersize.x)-0.5) * 2.0 * (buffersize.x/buffersize.y),((-gl_FragCoord.y/buffersize.y)+0.5) * 2.0,DepthToZPosition( gl_FragCoord.z )); screencoord.x *= screencoord.z / camerazoom; screencoord.y *= -screencoord.z / camerazoom; vec3 nscreencoord = normalize(screencoord); vec3 normal = ex_normal; normal = texture(texture1,ex_texcoords0).xyz * 2.0 - 1.0; float ao = normal.z; normal = ex_tangent*normal.x + ex_binormal*normal.y + ex_normal*normal.z; normal=normalize(normal); vec4 lighting_diffuse = vec4(0); vec4 lighting_specular = vec4(0); float attenuation=1.0; vec3 lightdir; vec3 lightreflection; int i; float anglecos; float diffspotangle; float denom; fragData0 = outcolor; #if BFN_ENABLED==1 fragData1 = texture(texture15,normalize(vec3(normal.x,-normal.y,normal.z))); #else fragData1 = vec4(normalize(normal)*0.5+0.5,fragData0.a); #endif fragData1.a = color_specular.r * 0.299 + color_specular.g * 0.587 + color_specular.b * 0.114; int materialflags=1; if (ex_selectionstate>0.0) materialflags += 2; fragData2 = vec4(0.0,0.0,0.0,materialflags/255.0); } -Vertex #version 400 #define MAX_INSTANCES 256 //Uniforms uniform vec4 materialcolordiffuse; uniform mat4 projectioncameramatrix; uniform mat4 camerainversematrix; uniform instancematrices { mat4 matrix[MAX_INSTANCES];} entity; uniform float currenttime;//Attributes in vec3 vertex_position; in vec4 vertex_color; in vec2 vertex_texcoords0; in vec3 vertex_normal; in vec3 vertex_binormal; in vec3 vertex_tangent; //Outputs out vec4 ex_color; out vec2 ex_texcoords0; out float ex_selectionstate; out vec3 ex_VertexCameraPosition; out vec3 ex_normal; out vec3 ex_tangent; out vec3 ex_binormal;void main() { mat4 entitymatrix = entity.matrix[gl_InstanceID]; mat4 entitymatrix_=entitymatrix; entitymatrix_[0][3]=0.0; entitymatrix_[1][3]=0.0; entitymatrix_[2][3]=0.0; entitymatrix_[3][3]=1.0; //SWAY float seed = mod(currenttime / 100.0 * 0.25,360.0); seed += entitymatrix_[3].x*33.0 + entitymatrix_[3].y*67.8 + entitymatrix_[3].z*123.5; seed += vertex_position.x + vertex_position.y + vertex_position.z; vec4 movement = vec4( vec3( 0.02 * (sin(seed)+0.025*cos(seed*5.2+3.2)) ),0.0); vec4 modelvertexposition = entitymatrix_ * vec4(vertex_position+movement.xyz,1.0); ex_VertexCameraPosition = vec3(camerainversematrix * modelvertexposition); gl_Position = projectioncameramatrix * modelvertexposition; mat3 nmat = mat3(camerainversematrix[0].xyz,camerainversematrix[1].xyz,camerainversematrix[2].xyz); nmat = nmat * mat3(entitymatrix[0].xyz,entitymatrix[1].xyz,entitymatrix[2].xyz); ex_normal = normalize(nmat * vertex_normal); ex_tangent = normalize(nmat * vertex_tangent); ex_binormal = normalize(nmat * vertex_binormal); ex_texcoords0 = vertex_texcoords0; ex_color = vec4(entitymatrix[0][3],entitymatrix[1][3],entitymatrix[2][3],entitymatrix[3][3]); //If an object is selected, 10 is subtracted from the alpha color. //This is a bit of a hack that packs a per-object boolean into the alpha value. ex_selectionstate = 0.0; if (ex_color.a<-5.0) { ex_color.a += 10.0; ex_selectionstate = 1.0; } ex_color *= vec4(1.0-vertex_color.r,1.0-vertex_color.g,1.0-vertex_color.b,vertex_color.a) * materialcolordiffuse; } Shadow+Vegetation Shader-- Fragment- #version 400 uniform sampler2D texture4;in vec2 ex_texcoords0; void main() { if (texture(texture4,ex_texcoords0).a < 0.8) discard; } Vertex- #version 400 #define MAX_INSTANCES 256 //Uniforms //uniform mat4 entitymatrix; uniform mat4 projectioncameramatrix; uniform instancematrices { mat4 matrix[MAX_INSTANCES];} entity; uniform float currenttime; //Attributes in vec3 vertex_position; in vec2 vertex_texcoords0; out vec2 ex_texcoords0; void main() { mat4 entitymatrix = entity.matrix[gl_InstanceID]; mat4 entitymatrix_=entitymatrix; entitymatrix_[0][3]=0.0; entitymatrix_[1][3]=0.0; entitymatrix_[2][3]=0.0; entitymatrix_[3][3]=1.0; //SWAY float seed = mod(currenttime / 100.0 * 0.25,360.0); seed += entitymatrix_[3].x*33.0 + entitymatrix_[3].y*67.8 + entitymatrix_[3].z*123.5; seed += vertex_position.x + vertex_position.y + vertex_position.z; vec4 movement = vec4( vec3( 0.01 * (sin(seed)+0.025*cos(seed*5.2+3.2)) ),0.0); ex_texcoords0 = vertex_texcoords0; vec4 modelvertexposition = entitymatrix_ * vec4(vertex_position+movement.xyz,1.0); gl_Position = projectioncameramatrix * modelvertexposition; }
  18. I would like an Entity:LookAt() function. Would save me some lines of messy math code. Also you could use SetInput(rot.y) for a character controller instead of switching its physics mode temporarily to use SetRotation(0,rot.y,0). At least I think that should work.
  19. To create a .phy file for your .mdl navigate to your model in the Assets Tab of the Leadwerks Editor then Right-Click the models thumbnail. An option near the bottom will say Generate Shape - Convex Hull or Polymesh. For editing models you want the .fbx of the model. I believe the .mdl is Leadwerks imported version of the model while the .fbx is the origin. You can import a .fbx model into Blender easily and then edit it however you would like. Then when you are finished editing you can export the .fbx model right into your Leadwerks Model folder and it will import into a .mdl file. You can also create a model in Blender and export it as a .fbx into your Leadwerks Model folder and it will import into a .mdl file. Hope this helps!
  20. The rivers and waterfalls are looking good! Also the dancing was quite funny.
  21. Well I have noticed in the past that parenting does more than just move the object in some cases. Moving the Trigger entity using SetPosition() and SetRotation() should work. It can be tedious though.
  22. I just noticed this same problem today when trying to increase my resource respawn time. It will stop at 100000 if the value is a script float as well. Like if you did -- Script.health=80 --float "Health" In the entites Script Tab the "Health" float will max out at 100000.
  23. Yeah I wasn't sure if this was intended or not so I just posted this here. If this is indeed a bug then this can be moved to the bug reports.
  24. Looks good! Gotta love those easy imports. As far as glass goes there should be a glass texture that comes with the tutorial project. The glass material has the proper shaders/other settings for glass. For trees I would check out some of the packs made by Nobiax. -- http://nobiax.deviantart.com/gallery/24853853/Packs
  25. Yeah it will generate the Character Controller cylinder physics which is unwanted in many cases including this one most likely. A work around is to move your entity and then make an invisible entity with character physics that will follow it (using SetPosition() and SetRotation()). Give your entity Debris collisiontype to avoid collisions with the invisible entity(with Character Controller physics) following it. Might not be perfect but that is what I am doing until I can make custom collision responses and it works pretty good.
×
×
  • Create New...