-
Posts
7,936 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Downloads
Everything posted by Rick
-
Testing my game on my 7 inch Galaxy tab (first generation) and I'm noticing when I have a sound to play it's slightly delayed. On my PC the sound plays instantly when I would expect it.
-
http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/window/ KeyHit(), KeyDown()
-
small correction: In the Assets tab, right clicking on the model will give 'Generate Shape'. In the scene tab right clicking on a csg model gives 'save as shape' but can't do that with a custom 3rd party model. Also a bug here when right clicking on models in Assets tab sometimes the context menu keeps getting more and more of the same 3 options added until the menu is massive
-
Texture selection per model instance shader [shader included]
Rick replied to Rick's topic in Programming
I tried, but the website was giving me errors when I tried to attach anything. Will try again tomorrow maybe. -
I can't attach any files for some reason as I did try to put this in the asset store under shaders and even on this post but it kept giving me an error: https://dl.dropbox.c...iled-Shader.rar INSTALL: Place the .shader files into your projects Shaders/Dynamic folder. It won't overwrite anything as they are new files. THANKS: MASSIVE thanks to shadmar for the offsetting code and talking things out with me, and niosp for his LE2 original shader that gave the idea of using the color (he used alpha as an index but I think this required a different shader for different number of sub textures per row which this method doesn't require) for doing this as the color seems to be unique per model instance which is what we need and the reason we use the color variable to get this effect. DESCRIPTION: I don't really know what to call this shader, but it allows you to combine multiple textures into 1 big texture, and then allow you to pick which texture from that you want to show on a given model instance. This is "needed" because models are by default instanced, and so changing material on 1 instance changes it on all instances. You can create unique copies, but doing so at run-time is slower than using instancing so for mobile this will give a big savings I think.To be able to have 1 model instance, but apply different textures to it, you use this shader, and then you use entity:SetColor(row, col, 1.0 / 4.0, 1) to get the subtexture you want to actually apply. entity:SetColor(row, col, 1.0 / 4.0, 1) explained: 1) Your big texture will have rows & cols made up of your sub textures (see screenshot below) 2) When calling SetColor() the first parameter is the row, and the second is the column, the 3rd is 1 / how many texture per row fit on your big texture, and the last parameter is ignored so just put 1 NEGATIVES: You lose the functionality of SetColor(). This means you can't tint your model a certain color using SetColor() when using this shader. I rarely use SetColor() on models myself so this probably isn't a massive limitation. RANT: Ideally, we would be able to define use variables of certain types, per model instance dynamically, that then get exposed to the shaders by the engine automatically. Not sure if that's possible, but it would allow for way more functionality and not hacking around using things like color for something else. Maybe even a couple holders for each type would help if doing this dynamically isn't possible. EXTRA: Note below I only did 3 textures and left the rest blank. I will have more for my game, but did this as just an example of what I mean. In my case I'm using this for completely different textures, but you could also give a progression of your character getting beat up with blood and ripped clothes or something cool like that.
-
I just noticed that I created an int uniform that in the shader would change the tileset uniform (because for some reason the Vec3 isn't working) and when I created 2 models with the same shader in the App:Start() I always got the last one I set. Getting closer
-
@shadmar Yeah, I notice if I hardcode tileselect in the shader it works (or does the correct offset when the material is first created) but you can never change it in code then since the hardcode overwrites the code change each time. Need some way to get around that. Could probably do some check to init to 0,0 and set a flag and if flag is set (the first time it goes into main(), we don't init anymore). Not sure how you can do that in a shader though. Are you able to give a var a value when you declare it, otherwise not sure how you would init it once only, or tell that a variable hasn't been given a value yet? If I try to init on the declaration line I get (Pixel Shader: Line 10: Initialization of uniform variables requires #version 120 or later). What version are we working with?
-
I have a really simple scene with no moving parts but the memory usage that I display on screen keeps going up up up! I have 1 csg element as the ground, and 9 models with dynamic diffuse-normal shaders. They don't move, and I don't do anything in code with them, but the memory just keeps going up.
-
I have a project here and even though I deleted every material from the editor by right clicking on asset in Assets tab and selecting delete, then save the project, when I reopen they are all there again
-
hmm, couldn't get this to work. So you tested this and it worked for you? Here is what I did. 1) Opened diffuse+normal.shader and made the changes you have above 2) Made a tga file that was 1024x1024 and put in 3 of my 256x256 textures on this starting in top left corner and going right 3) Imported this texture into LE3 4) Generated normal map via LE3 menu option 5) Made dynamic material from texture and normal. The bg color of my 1024x1024 texture is white, so what I noticed visually on the material is that it was ALL white with the normal bumps in the shape of the actual texture, but again, the color was all white so something wrong at this point. 6) I do the code stuff you have but again it's all white because something is clearly wrong with the material. No clue why it's just all white (the bg of the texture) and doesn't show at all the 3 textures I have inside of it. If I take your code change out I see the 3 textures and the remaining white but then of course I don't get the functionality that you are trying to provide. Not sure what's up with the all white :/
-
Niosp (I think) did something like this in LE2. It worked great. I'm not a shader guy so I have no idea how this would be done but I know it can be done and has before.
-
Using just LoadModel() without the second param will make an instance of it and they all share the material. Using it with Asset.Unmanaged I'm guessing is what's causing the slowdown. This is why I think a shader that allows us to have multiple textures on 1 image file and offset which one we want would be the best fit in this siutation. Maybe I just have to make 1 of each as preloading and make prefabs :/ Hope that doesn't kill the memory usage on mobile.
-
I have a base model. I have 6 base materials that fit this model. I need to randomly create any of these variations at random times (so no way of knowing how many I'd need ahead of time). What would be the most efficient way to do this? Because of model instancing I can't just load the base model and apply different materials to it because it switches the models to the most current material. Having 6 different model files of the same model to get around the instancing issue is wasteful and on mobile I can't imagine is the way to go. Any ideas? [EDIT] What I'm doing now is I placed the base model in the scene (as a precache model so model instancing happens but my understanding is Model:Load() where the second parameter is Asset.Unmanaged means I get instancing of the model data, but a new material? I then created 6 csg models and put the 6 materials on them as a precache to the materials so when I call Material:Load() it should be instances of the already loaded materials right? With this I'm getting about 20 fps on my desktop. :/ I notice also it's like the scene takes 30 seconds to really load or finish doing whatever it's doing even though it shows and screen and runs. I get 30 some seconds of choppy 20 FPS before MOST times it gets to 60 and then stays. Every so often it won't get to 60 and stays in the 20's. This is very strange.
-
The hooks are generally all normal C functions. Looks like your Break() is part of the Stone class?
-
Has anyone figured out how to get all entities loaded in the map yet? Via Lua preferred.
-
Just wanted to update this. I was able to get this to work thanks to shadmar. I had to go into the model editor and calculate normals. Once I did that all lighting worked perfectly! Thanks shadmar!
-
They are normal models. So dynamic materials on these will treat the lights dynamically (like LE2?) instead of using the lightmap? I swear I selected dynamic when I made the materials. I'll have to try again I guess. I'll keep you updated.
-
What do you mean by dynamic shaders, and what does that do? Or how do you do it?
-
If I make a csg box it lights up, but not my model.
-
I'm putting lights into this scene and I see the difference in the perspective view, but when I calc lights it says it finished in like 22 ms, and when I run the game the lights don't see to be there. It's really dark. Is there a known bug or am I missing something? This seems pretty basic, and it was working. At one point I added 2 directional lights so not sure if that screwed it up. I make a new map and it just doesn't seem to matter. It's like the lights are broken or something.
-
LE3 : Tutorial make attachable weapon from Blender
Rick replied to YouGroove's topic in Game Artwork
Yeah, doing it in the Start() method would be better YouGroove. -
Did you ever figure out how to get entities by name? I haven't looked at it yet, but if you've figured it out it'll save me the time
-
So I see Asset::CreateNew and Asset::Unmanaged. What's the difference? My guess is Asset::CreateNew will actually create a new model and material and everything, where Asset::Unmanaged will create an instance of the model, but it's own material? If so that would be perfect!
-
A nice shader might be to allow for offsets in a texture so we can have multiple textures and switch between them on instanced model. If only someone knew shader programming... If it's possible for Leadwerks 3, I'd be willing to pay a little for it. I think I'm going to need it for this smaller little fun mobile game I'm going to make this next week.