Rick Posted September 29, 2013 Share Posted September 29, 2013 So there is an invisible material, but since instances share materials I need another way to not draw a certain instance of a given model. Is there any way a shader could provide this ability? I would want it to still have collision but just not be drawn. Quote Link to comment Share on other sites More sharing options...
Admin Posted September 29, 2013 Share Posted September 29, 2013 Set the alpha to zero and do this in the fragment shader: if (color.a<0.5) discard; 1 Quote Link to comment Share on other sites More sharing options...
Flexman Posted September 29, 2013 Share Posted September 29, 2013 For the benefit of others who might overlook this little feature. This is actually pretty good for doing basic stuff in 3D games. A common example, when you have a player vehicle or an animated character viewed from first person. In these situations you don't want the mesh intruding into the camera view (the inside of someone's head can be disturbing) but you want all the benefits of collision detection and shadows. If you simply Hide() the model you loose those. Another scenario; when you have a detailed vehicle interior, but when viewed from the drivers position you might still see parts of the exterior model (it may be a different scale or the mesh doesn't quite match up etc). You can make different meshes visible/invisible depending on the viewpoint. In some situations you can simply use Hide() and Show() We've found this really useful in LE2. Quote 6600 2.4G / GTX 460 280.26 / 4GB Windows 7 Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT Tricubic Studios Ltd. ~ Combat Helo Link to comment Share on other sites More sharing options...
Rick Posted September 29, 2013 Author Share Posted September 29, 2013 Good examples flexman. In my situation I'm making a prototype with a top/down style game where you can enter buildings that have more than 1 level/floor. The higher levels need to not be shown so as to not obstruct your view of your player, but there will be NPC's/enemies on levels that still need to update their logic and move around. Like you mentioned if I simply hide the floor the floor models and physics would be lost making the NPC's/enemies fall down. If I hide the NPC's/enemies I'm sure I lose the controller functionality of moving them around and such, which they still need to update their logic when not shown. Nothing like being able to avoid an enemy simply by just going back down the stairs and making their logic stop updating so they stop chasing you. Not very realistic. So I figured running the logic all the time but simply not drawing them via a shader, so I can turn it on/off at run-time, would be the way to go for my given situation. The NPC's and floor stuff will all be instanced so I wouldn't be able to simply set their materials to invisible as that would make other instances invisible as well which isn't what I want. Combining this functionality with my instance texture shader should allow me to have a ton variety of NPC's on screen and a very detailed world in terms of buildings, which I plan too have, without any major frame drop Quote Link to comment Share on other sites More sharing options...
YouGroove Posted September 29, 2013 Share Posted September 29, 2013 Some sort of camera layers in fact or scene nodes system. Depending on your game needs you could put a bunch of stuff in one layer, other stuff in another layer and just display the layer you need with some functions like Show/hide layer or node. For the player and car example, you would just hide some "player" layer , when entering the car. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted September 29, 2013 Author Share Posted September 29, 2013 A layering system in my situation would have to be per building which might defeat the purpose of a layer system? It would have to be this way because you could be inside the 5th floor of 1 building but see other buildings around it, and I wouldn't want to see inside those buildings so it's not a global layer system. I'm going to use area triggers to determine per building what to draw or not. I don't like using show/hide because those methods cause certain things to happen in LE. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted September 29, 2013 Share Posted September 29, 2013 @Rick : Solutions sometimes are "make it simple" Look at Skyrim, outdoor performance need and detailled indoor : keep indoor and outdoor as different maps, you load when entering them. But you can keep characters moving in and out indoor houses, if you are in exterior, you just see the character disappear when entering the house. For the character and car system, some games just put the camera in front of character head , outside, so you can see your character without needing to make it invisible. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted September 29, 2013 Author Share Posted September 29, 2013 Nope, I want instant visual transition. When you are outside a house you see it's roof. When you open the door the roof and any upper floors goes invisible and you now see the inside and can walk around by clicking on the floor. That style of walking through a neighborhood is what I'm going for. I don't like the idea of loading a new map for each interior at all for this game. I would question having the "outside" still updating with NPC's too. Are you sure Skyrim had this? Did enemies that were chasing you outside a building chase you inside a building after the interior was loaded? I didn't play Skyrim all that much. Quote Link to comment Share on other sites More sharing options...
shadmar Posted September 29, 2013 Share Posted September 29, 2013 By using that shader trick instead of show/hide it will still consume rendering power. 1 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
YouGroove Posted September 29, 2013 Share Posted September 29, 2013 For skyrim, yes this is loading interior map, i mean you never see opened doors or througt windows. Enemies won't chase you inside indoor houses, but NPC will go inside and just disappear , when you enter you see the NPC inside for example. It seems there is some loading time indeed. Ok i understand your need is different then, more like the game EA Sims. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Rick Posted September 29, 2013 Author Share Posted September 29, 2013 @shadmar, Yeah, I'm thinking no matter what, if I want the NPC's to continue working as normal no matter what floor they are on, ie they could "hear" me and come running down to my floor, or be doing actions on other non-visible floors, I would have to deal with that. I do want the non drawn floors to exist and function as normal, but just not draw them in certain situations so they don't block the players view. I think I'll have billboards by stairs that you click and it'll move the player to a spot up or down the stairs on the next level, and be how determining what floor to draw happens. @YouGroove Yeah, The Sims is a good way to think of my needs. It's almost exactly like that. 1 Quote Link to comment Share on other sites More sharing options...
Flexman Posted September 30, 2013 Share Posted September 30, 2013 If anything, it highlights that you might need to de-couple your game logic from renderable entities. Split them into two states; renderables and logical entities. Not saying you should do that Rick, just something to consider in general. As always it depends on the scale of the game, small games/demos can get away with it. Quote 6600 2.4G / GTX 460 280.26 / 4GB Windows 7 Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT Tricubic Studios Ltd. ~ Combat Helo Link to comment Share on other sites More sharing options...
paramecij Posted September 30, 2013 Share Posted September 30, 2013 A "layer" system might not be such a bad idea. Seems like you already have your buildings separated by floors, right? Each floor is a layer, if you have parented floors from ground to top, you can set alpha=0 to all meshes above the player in one go.. additionally you'd need to have an array (floor layers) of linked lists for enemies and/or other objects. You could build these lists on entering the building or have them prebuilt for each building on level load, of course, for NPCs you'd need to dynamically insert and remove them from the lists as they go up and down each floor. Quote Link to comment Share on other sites More sharing options...
Rick Posted October 1, 2013 Author Share Posted October 1, 2013 I'm going 100% editor/lua scripts with this. You enter a building by clicking it's door. This makes your character walk over to the door (it's click to move at this time), open it, and then after the door opens the script attached to the door was configured to accept all the different floors that should be hidden. This is filled in at design time from the editor. All items on a floor were parented to that floor and will also be hidden. Stairs will have billboard like icons by them. 1 for up 1 for down if both directions are capable. Click the up icon for example will walk over to the stairs and go up to a defined point on top of the stairs. Once the player hits a trigger on the stairs, that trigger will define what floor should be shown. It knows the direction (higher floor shown for going up, higher floor hidden for going down) based on the billboard icon you clicked. The only thing at this time will be the NPC's and handling what floor they are on. These aren't really predefined as the NPC's are somewhat randomly moving around the map the entire time. They will also use a style of the billboards to move up and down the stairs. If one exists in a given AABB around them they'll have an x% chance to go up and/or down. This is if idle mind you. If in chase mode they'll follow the character. The up/down stairs logic or entering building can "attach" them as a child of that floor, and maybe if I do start with them in a building I can assign them the floor they are on. So we make a variety of buildings configured as prefabs and just plop them down. Combined with my shader that allows for multiple textures for the same material I should be able to get a good variety of styles/colors at a cheap cost. This is all prototype at the moment of course. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.