Jump to content

tjheldna

Members
  • Posts

    938
  • Joined

  • Last visited

Everything posted by tjheldna

  1. I took a leaf out of this book and tried a flame shader and to my surprise I managed to get it in... https://www.shadertoy.com/view/XsXSWS I created a material using that shader and assigned it to a billboard which works great. Only thing is the flame is pointing upside down and can't work out why? Any Ideas? Vert #version 400 #define MAX_INSTANCES 256 //Uniforms //uniform mat4 entitymatrix; uniform vec4 materialcolordiffuse; uniform mat4 projectioncameramatrix; uniform mat4 camerainversematrix; uniform instancematrices { mat4 matrix[MAX_INSTANCES];} entity; uniform vec4 clipplane0 = vec4(0.0); //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; out float clipdistance0; 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; vec4 modelvertexposition = entitymatrix_ * vec4(vertex_position,1.0); //Clip planes if (length(clipplane0.xyz)>0.0001) { clipdistance0 = modelvertexposition.x*clipplane0.x + modelvertexposition.y*clipplane0.y + modelvertexposition.z*clipplane0.z + clipplane0.w; } else { clipdistance0 = 0.0; } ex_VertexCameraPosition = vec3(camerainversematrix * modelvertexposition); gl_Position = projectioncameramatrix * modelvertexposition; mat3 nmat = mat3(camerainversematrix);//[0].xyz,camerainversematrix[1].xyz,camerainversematrix[2].xyz);//39 nmat = nmat * mat3(entitymatrix[0].xyz,entitymatrix[1].xyz,entitymatrix[2].xyz);//40 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; } Frag #version 400 #define BFN_ENABLED 1 uniform vec2 buffersize; uniform float currenttime; //Uniforms uniform sampler2D texture0;//diffuse map uniform samplerCube texture15;//BFN map uniform vec4 materialcolorspecular; uniform vec4 lighting_ambient; uniform float FLAME_SPEED = 2.0; uniform float flame_strength = 1.0; uniform float flame_length = .75; //Lighting uniform vec3 lightdirection[4]; uniform vec4 lightcolor[4]; uniform vec4 lightposition[4]; uniform float lightrange[4]; uniform vec3 lightingcenter[4]; uniform vec2 lightingconeanglescos[4]; uniform vec4 lightspecular[4]; uniform vec4 clipplane0 = vec4(0.0); //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; in float clipdistance0; out vec4 fragData0; out vec4 fragData1; out vec4 fragData2; out vec4 fragData3; // procedural noise from IQ vec2 hash( vec2 p ) { p = vec2( dot(p,vec2(127.1,311.7)), dot(p,vec2(269.5,183.3)) ); return -1.0 + 2.0*fract(sin(p)*43758.5453123); } float noise( in vec2 p ) { const float K1 = (sqrt(3)-1)/2; const float K2 = (3-sqrt(3))/6; vec2 i = floor( p + (p.x+p.y)*K1 ); vec2 a = p - i + (i.x+i.y)*K2; vec2 o = (a.x>a.y) ? vec2(1.0,0.0) : vec2(0.0,1.0); vec2 b = a - o + K2; vec2 c = a - 1.0 + 2.0*K2; vec3 h = max( 0.5-vec3(dot(a,a), dot(b,b), dot(c,c) ), 0.0 ); vec3 n = h*h*h*h*vec3( dot(a,hash(i+0.0)), dot(b,hash(i+o)), dot(c,hash(i+1.0))); return dot( n, vec3(70.0) ); } float fbm(vec2 uv) { float f; mat2 m = mat2( 1.6, 1.2, -1.2, 1.6 ); f = 0.5000*noise( uv ); uv = m*uv; f += 0.2500*noise( uv ); uv = m*uv; f += 0.1250*noise( uv ); uv = m*uv; f += 0.0625*noise( uv ); uv = m*uv; f = 0.5 + 0.5*f; return f; } // no defines, standard redish flames //#define BLUE_FLAME //#define GREEN_FLAME void main(void) { //Clip plane discard if (clipdistance0>0.0) discard; vec4 outcolor = ex_color; vec4 color_specular = materialcolorspecular; vec3 normal = ex_normal; vec2 uv = ex_texcoords0; vec2 q = uv; q.x *= 5.; q.y *= 2.; float strength = floor(q.x+1.3); float T3 = currenttime/1000.0 * FLAME_SPEED; q.x = mod(q.x,1.)-0.5; q.y -= 0.25; float n = fbm(strength*q - vec2(0,T3)); float c = 1. - 16. * pow( max( 0., length(q*vec2(1.8+q.y*1.5,.75) ) - n * max( 0., q.y+.25 ) ),1.2 ); // float c1 = n * c * (1.5-pow(1.25*uv.y,4.)); float c1 = n * c * (1.5-pow(2.50*uv.y,4.)); c1=clamp(c1,0.,1.); vec3 col = vec3(1.5*c1, 1.5*c1*c1*c1, c1*c1*c1*c1*c1*c1); #ifdef BLUE_FLAME col = col.zyx; #endif #ifdef GREEN_FLAME col = 0.85*col.yxz; #endif float a = c * (1.-pow(uv.y,0.9)); //fragColor = vec4( mix(vec3(0.),col,a), 1.0); if (a < 0.4) discard; //Modulate blend with diffuse map outcolor *= vec4( mix(vec3(0.0, 0.0, 0.0),col,a), a); //Blend with selection color if selected fragData0 = outcolor;// * (1.0-ex_selectionstate) + ex_selectionstate * (outcolor*0.5+vec4(0.5,0.0,0.0,0.0)); #if BFN_ENABLED==1 //Best-fit normals fragData1 = texture(texture15,normalize(vec3(normal.x,-normal.y,normal.z))); fragData1.a = fragData0.a; #else //Low-res normals fragData1 = vec4(normalize(normal)*0.5+0.5,fragData0.a); #endif fragData1.a = materialcolorspecular.r * 0.299 + materialcolorspecular.g * 0.587 + materialcolorspecular.b * 0.114; int materialflags=1; if (ex_selectionstate>0.0) materialflags += 2; fragData2 = vec4(0.0,0.0,0.0,materialflags/255.0); } You can get a single flame by playing with these values: q.x *= 5.; q.y *= 2.;
  2. Hmm the character controller does not conform to the tessellation of the terrain.
  3. I came across this a day or two ago and wish I researched into Modo's animation system a bit more thoroughly. I'm posting this as it may help someone out too. In Modo's 'Animate' I've become accustomed to creating all my animations in a single string well that's no more. If you create an 'Action' for each of your animations and create each animation in the specified action. For example a 'idle' action is been created and selected, I then created the idle animation, same for run, walk etc. See image. In Modos .fbx preferences have 'Export actions into separate takes' selected before exporting When imported into the animated model Leadwerks editor, each 'take' will be imported as a separate animation with the animation length being the start and end key frames of each 'action'/'take'. Doing it this way does away with some of the need to create the text file to define animations or creating them manually. Two major benefits are that at any stage I can increase/decrease the number of frames of any animation and LE will import it perfectly and it really is nice being able to isolate and work on one animation at a time. Now that I have delved deeper into Modo's animation's tab further, it really is great to use.
  4. Thanks Macklebee for pointing me in the right direction. I got it working in one line. //Decals outcolor = mix(ex_color, texture(texture0, ex_texcoords0), texture(texture0,ex_texcoords0).a) Summer Games Tournament Truck01 thanks you!
  5. Thanks macklebee, I'll try mix. I'll also put something together for testing. Just wondering where can a find a good list of functions available to me for shaders in LE?
  6. Hi All, I'm trying my hand at modifying the diffuse_normal shader to do a particular task. Basicly I want to texture cars using rgb values with a decal texture overlay. Doing this I can easily change the color of the cars paintwork using rgb values but keep things like lights, damage, interior the same. This does work but one thing I can't do is get a nice alpha fade off, blended by the alpha value on the texture with the rgb value. float textureAlpha = texture(texture0,ex_texcoords0).a; if(textureAlpha > 0.0) { outcolor = texture(texture0,ex_texcoords0); } else { outcolor = (ex_color * (1.0 - texture(texture0,ex_texcoords0).a)); } If I change the 0.0 value I get various results but always a hard line around the decals where I'm trying to blend with the texture alpha. Any insight into this would be great! Thanks
  7. Collision hull is now working again thanks. If you have a model with "collisionhull" already imported and you re-export the model overwriting it with a different/changed "collisionhull" the model wont update in the editor. The only way to get it to update is to update the .phy file first then re-export.
  8. Physics shape on the wheels? Try turning collision off.
  9. Hi commanderz, I'm a Modo user too (801). Skinned animations do work. To export an animated rig you need to "bind" the skeleton to the mesh under the setup tab after that it creates a vertex weight map and you can paint vertex weights for deformation. There is an import issue with the fbx export and Modo. Modo works in meters and LE works in cm. If you set the scale in Modo to export to 0.01 to convert meters to cm which this conversion dosen't work. Everything I export into LE I need to be scaled by 0.01 for correct size. I think Josh is looking into this. There are few little quirks but all in all it should work.
  10. Cheers, NB Also note the measurement conversion into LE dosen't work with Modo's fbx so I have to scale everything by 0.01 in the editor or 1% in the model editor.
  11. I was using collision hull a week or two ago and worked fine and exported a number of meshes. I've exported two models now with the child mesh named collisionhull and in the model viewer its coming up as polymesh where before it converted the collisionhull mesh by default. I also think the collisionhull mesh didn't appear in the scene view but it is now (can't remember exactly).
  12. Nice that does solve my problem, didnt think of that thanks! The features still would be nice though.
  13. If you have multiple items selected and rotate, the models rotate on their local axis with a gizmo appearing for each. Problem if i piece together a few things i.e bathroom cabinets, sink and bench, mirror and I want to rotate them all to another wall the only option is to rotate them on their local axis so if I do rotate I need to re-align them all which is proving quite painful. I have a few suggestions here: - Mutiple items to have only 1 gizmo at the centre of the selected items. - Another plug for a rotate and scale gizmo. - If you have the 'global coordinates' selected all models rotate about that centre axis else models rotate about their local axis like it is now. [edit] - Adjustable rotation angle snap
  14. Same here, all script fields are blank.
  15. Thanks Shadmar and Macklebee for your help it is really appreciated. Seems Josh was 1 step ahead of me with the collision and you can do it directly from the modeling program like I was wanting, I must have missed that memo or not understood something. I take back all the swear words I said to the editor when I was doing it the hard way. Thinking about it it's better looking stupid and finding now when I've 5 houses completed compared to 50 still I have some work to do. Thanks again
  16. Hi Josh, and thanks for your comments I appreciate it. Don't get me wrong, your phy shape implementation is fantastic. I believe the big difference here is creating a model pack and using the models in a level are two different things. Issues like navmesh generation, wasn't on my mind when modeling till I realised that the door frames was stopping the generation because it had collision on it (the fit is as tight as I can get it around doors). Also I don't want all the collision detail in window frames, house fixtures etc, but want the detail in the model so there are savings to be had. You can see the phy file sizes being decimated in my comparisons and sure this will make in game savings too. I do propose a solution: In your modeling program you can have a child mesh which needs to be named 'HINT' or something In the model viewer if you select 'PolyMesh' and you have the child named 'HINT' a shape is generated from the 'HINT' model else it uses the actual model as it does now. The 'HINT model is removed when the level is run similar to the method using Brushes. I recon that would keep everyone happy. I'm wary of becoming dependent on a feature that is labeled legacy No worries, this tool has saved me in the passed with rigs not exported properly. Being able to visually see it when the imports/exports don't line up is where this feature really shines. I took a look at the new way in an older project I have. In general I think it's now open to a lot of user error, some form of fool proof way of validating and assigning a uniquely named model has to be done imo. That being said because I was working off unique names anyway it didn't break anything. @Shadmar I mean with being able to create your own exported collision mesh and use that easily. With the house models I'm doing the collision has to be very tight. Cheers
  17. Lately using LE it feels like there are features being removed or changed with no real warning. One of the items is referring to the beta branch. Here are my examples: Custom collision meshes - This is the one I miss the most, I'm never going to stop on this one, so useful. I've decimated the file size of every .phy file I've optimised and no doubt making a difference in game. Resize and position collision shapes - key adjustment values for collision optimisation. The editor has no idea of where I want the shape or it's orientation, so why let it choose it for me? Skeleton View in model editor - great for debugging your exported rig Target entity field now a text box - I've used it now and if it wasn't intuitive before it's even more so now. I'm not sure why the way this field used to work is now the devil. Being a strict C++ user and no use for the game player etc it actually feels like features have not only ground to a halt, but going backwards. I'm not mad or anything, I just want to voice that these changes are effecting my LE workflow in a negative way. Cheers
  18. Yes with the latest update I downloaded an hour or two ago, the map loads in code now. Thanks
  19. No effect on the game, more the development of it. It was just easy to drag the entity that I wanted into the box. I took a quick look at the new method tonight, still not convinced its better. I've never been happy having to use the 'name' field to do lookups in code. I'd much rather having a unique value taken care of in the editor like an auto increment field in a database table assigned to each model and use that instead whether it be a new ID value or forcing the name to be unique in the editor don't care. I don't know about any difficulties your end of the implementation of something like that, I'm just giving my thoughts on it and at the end of the day it's up to you. An alternate method for drag n drop would possibly be the other way around.... A non editable text box a button next to it with a crosshair icon on it or something similar to before. Click on the crosshair button your cursor changes to the icon and you can then click on to select an entity in the perspective view port or in the scene graph to select your entity and your target field is populated. Also not sure if it's your end or mine, but after I compile I'm getting a 'Map file version 35 not supported' error. VS Project has been cleaned recompiled and updated in LE. Seems I run into that one regularly when I update the project. (when I load the game in code, it loads in the editor)
  20. I'm thinking in the space of my Mages game. I mainly use the target field so I can access the entity in C++. So I can have any number up to 10 targets as a max number I think it is. For example a door script assigned to the door mesh: slot 1 = pivot :closet orientation slot 2 = pivot :open orientation slot 3 = pivot: hinge orientation slot 4 = camera orientation when casting the spell on the door My C++ door wrapper then keeps a reference to those targeted entities using it's "name" field so I too need to keep the names unique. For this I just grab the entity I want and chuck it in the target field, very easy. As a 100% C++ user, this is the only way I know how to access an entity from the editor so I heavily use it. You know what, that old method of linking entities was a real good feature in 2.5.
  21. I'm trying to look at this with an open mind but this is what I keep getting back to these points.. - The user can change referenced name at anytime. - The user can make a spelling error. - The editor will add meshes with a duplicate name by default - Random things happen if there are duplicates and cause frustration. Honesty, intuitive is not the word I would use. I also really like Einlanders suggestion. I'm just going by what I've read, I'm not too keen on updating my projects if I can help it just yet.
  22. So what if your game is heavily dependent on Pivots like ours?
  23. Mental note to self, read posts properly. Removed it to avoid confusion
×
×
  • Create New...