Jump to content

Haydenmango

Members
  • Posts

    438
  • Joined

  • Last visited

Everything posted by Haydenmango

  1. I do not believe there is an area like this yet but I agree that it would be a good addition. Welcome to the Leadwerks community!
  2. This is something I have been testing a lot recently. Once my memory doubles the GC will cut it down but then it waits till my memory doubles the amount that it was at when it was cut down. Meaning if it collects memory at something like 800 then it will do its next memory collect at 1600 and the next at 3200 and then 6400 and then etc. Obviously the number gets to high eventually and then the game crashes due to being out of memory. This is what I have observed and is why I looked into this at all. If I call collectgarbage() every frame there are no leaks my memory stays the same(without using collectgarbage('setpause',100) in my App Start() function). I wonder, why are there even controls for the GC if it supposedly runs perfectly on its own? I haven't given up just yet. This project is a learning experience for me so I would rather not just give out my project and have all the answers given to me by other people. Also I tested my game (with collectgarbage('setpause',100) in my App Start() function) all night without a crash or any other weird behaviour. It ran for 10 hours(8-9 hours longer than usual), I exited out because I wanted to read this forum post. I saw no bugs the whole time I was playing and everything was working great.
  3. I haven't and I am getting to the point where I may begin giving out my source code since I do agree with you on the point that I may be completely wrong about everything/some of the things I've done; after all I haven't been doing this for to long. Also I have like 15 or so scripts and at least 4 of them are 600-1000 lines long so it wouldn't really help to just post snippets in this case but again I will think about giving out the source code if I give up. I need to do more tests though still since I just started using this function and now each test run is 3+ hours. No I know he is busy. If he wanted to adopt the game for the workshop or something that would be cool but I am not holding my breath.
  4. That's what I have been doing and I can't narrow it down to anything other than I have just to many things happening. I have done memory tests on everything for hours everyday on every line of every script and haven't added anything but simple bug fixes to my game for the past 2-3 weeks now. There aren't any problems I can find at this point. It is a powerful line of code if you haven't read into what it does. Also I am not blaming Leadwerks for doing anything I was asking if it is possible that the Lua Garbage Collector isn't fast enough for some situations. My entities have no physics being applied to them, don't animate, don't move, aren't visible, and their scripts return end unless they are within a certain range so everything is as optimized as I can get it to be. When my entities are nearby some of them have sightly complex scripts that they use so even if I stand still the environment still generates decent amounts of memory. Yes it would crash because of Lua Error:Out of Memory 6 GB RAM (5.89GB usable) on my system.
  5. 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?
  6. 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!
  7. To see particle emitters in the editor you have to go to View - Realtime Render
  8. 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?
  9. 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
  10. 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.
  11. 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....
  12. 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.
  13. Good job, it is working fine for me. This will definitely speed things up!
  14. 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.
  15. No problem, glad you figured it out!
  16. Sorry I gave you the wrong information initially. Look back at my first post, I edited it with the correct info.
  17. 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())
  18. 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.
  19. 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
  20. Go to View - Show Physics and un-check it. The orange boxes represent the objects physics shapes.
  21. 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; }
  22. 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.
  23. 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!
  24. The rivers and waterfalls are looking good! Also the dancing was quite funny.
  25. 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.
×
×
  • Create New...