Rick Posted February 16, 2015 Share Posted February 16, 2015 Someone posted about a Thief like game and I recall I tried messing around with being detected in light before and found it sort of a pain to try and match up csg cone with a spotlight so was thinking for those types of games it might be handy to have a way to easily have something in the editor where if you have csg as a child to a light and check a button it could exactly become the shape of the light cone or sphere in the case of point light. Just remember I forgot to make a request like this. I had a hard time manually shaping the csg to the point light and it wasn't matched up perfectly. 2 Quote Link to comment Share on other sites More sharing options...
Ma-Shell Posted February 16, 2015 Share Posted February 16, 2015 Actually such a collision wouldn't necessarily mean that the player is really exposed to the light source, as there might be walls or anything else between the player and the light. Also I assume pointlights should have some kind of falloff (the nearer the brighter), so it would be hard to determine which size the sphere should be. Instead you should iterate through all the lights and 1. perform a raytrace to determine if you are exposed to the lightsource. 2. for lights that have a falloff (pointlights and spotlights?) check the distance 3. for lights with an angle (directional lights and spotlights) calculate the angle. The only part of that you could make easier by these proposed csg-shapes would be the third one, but that is also easily achievable by using the acos of the dot product of the normalized light's viewing vector and the normalized vector from the player towards the light. Quote Link to comment Share on other sites More sharing options...
Rick Posted February 16, 2015 Author Share Posted February 16, 2015 I wouldn't think you'd need to iterate over all the lights. You should be able to do the raycast from inside the csg light collision function the player is colliding with. The csg matching should handle the falloff then too with good enough precision so nothing to do there as the shape itself is the falloff distance I would think. I haven't played much of thief so don't recall the different light intensities it had. But yes, a raycast then is needed once the player collides with the light csg shape. Either this OR just give lights a Collision function! Easier for us Quote Link to comment Share on other sites More sharing options...
Rick Posted February 16, 2015 Author Share Posted February 16, 2015 In a modeler it would be a matter of minutes and scaling it you could resuse it on other spot lights. This is what I'm saying. I found it painful (for pointlights anyway as there was different sizes and you'd have to scale it manually for all various sizes) to get it just right in LE myself. Maybe I'm just an idiot but would be nice to have a collision function called for spot and point lights. Quote Link to comment Share on other sites More sharing options...
Ma-Shell Posted February 16, 2015 Share Posted February 16, 2015 I wouldn't think you'd need to iterate over all the lights. You should be able to do the raycast from inside the csg light collision function the player is colliding with. OK, you're right with that one. The csg matching should handle the falloff then too with good enough precision so nothing to do there as the shape itself is the falloff distance I would think. Not really sure, how to interprete that one. Do you only want to distinguish two states ("dark enough to be considered outside the light" and "bright enough to be considered inside the light")? Quote Link to comment Share on other sites More sharing options...
Rick Posted February 16, 2015 Author Share Posted February 16, 2015 OK, you're right with that one. Not really sure, how to interprete that one. Do you only want to distinguish two states ("dark enough to be considered outside the light" and "bright enough to be considered inside the light")? I personally don't want anything with this . I just did a test some months ago and now there is this new person who made a post about trying to do this same thing and it made me think about my test. For my test I just did a simple (in the dark or in the light). I can see if you wanted to do shades of gray in there how you'd have to think of another approach, but for something simple it would be cool to make this csg matching easier to lights, specifically spot. Quote Link to comment Share on other sites More sharing options...
beo6 Posted February 16, 2015 Share Posted February 16, 2015 Since Lights are extended from the Camera class i found the method "DetermineVisibleEntities". Not sure what it does exactly since it is undocumented but maybe it helps? But you will need C++ for it to use. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted February 16, 2015 Share Posted February 16, 2015 If you have directionnal lights also, it won't work and you'll need a method using render ot texture and checking player luminosity. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
shadmar Posted February 16, 2015 Share Posted February 16, 2015 In theory you can sample one/several pixels of the gun (or just a tiny geometry) or something checking it's luminosity in a pp-shader, then check against that on how visible you are in any light to your enemy. 1 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Rick Posted February 16, 2015 Author Share Posted February 16, 2015 If you have directionnal lights also, it won't work and you'll need a method using render ot texture and checking player luminosity. I guess I left off directional light as I don't think thief type games generally use that kind of light. @shadmar, Yeah, I would think a shader would be ideal but we all rely on you for that . Quote Link to comment Share on other sites More sharing options...
shadmar Posted February 16, 2015 Share Posted February 16, 2015 @shadmar, Yeah, I would think a shader would be ideal but we all rely on you for that . ..and now I had to try. It works, sample 8 points from 2 spheres where one is inverted to get eventual backlight in a pp-shader. The spheres have to be visible to sample them, but I think you can have some gui element drawn over them with no problem. You can even have degrees of visibilty. Like 50% visible if half dark or in shadows etc.. 1 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
AnthonyPython Posted February 16, 2015 Share Posted February 16, 2015 this is certainly a interesting subject rick. ..and now I had to try. It works, sample 8 points from 2 spheres where one is inverted to get eventual backlight in a pp-shader. The spheres have to be visible to sample them, but I think you can have some gui element drawn over them with no problem. You can even have degrees of visibilty. Like 50% visible if half dark or in shadows etc.. neat Quote OS: Windows 10 Pro CPU: i3-10100 CPU @ 3.60GHz GPU: NVIDIA 2060 Super - 8 GB RAM: 32 GB Link to comment Share on other sites More sharing options...
Rick Posted February 16, 2015 Author Share Posted February 16, 2015 ..and now I had to try. It works, sample 8 points from 2 spheres where one is inverted to get eventual backlight in a pp-shader. The spheres have to be visible to sample them, but I think you can have some gui element drawn over them with no problem. You can even have degrees of visibilty. Like 50% visible if half dark or in shadows etc.. Yeah, I don't understand what any of this means Quote Link to comment Share on other sites More sharing options...
shadmar Posted February 16, 2015 Share Posted February 16, 2015 Well it was good in theory, I have no methods of reading a pixel value in lua from a texture or buffer in lua. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
AnthonyPython Posted February 17, 2015 Share Posted February 17, 2015 Well it was good in theory, I have no methods of reading a pixel value in lua from a texture or buffer in lua. eh, well the effort is what matter's, so you can't say you haven't tried. Quote OS: Windows 10 Pro CPU: i3-10100 CPU @ 3.60GHz GPU: NVIDIA 2060 Super - 8 GB RAM: 32 GB Link to comment Share on other sites More sharing options...
shadmar Posted February 17, 2015 Share Posted February 17, 2015 If you have std edition you can add this hack for a lua project to read a pixel-value from a texture. So yes it works now but very hacky stuff. (don't yell I know the static cast will make nightmares in the cpp-camp ) So here is my shadow detector: 1. pp effect which reads player lumnosity (lua+.shader) 2. Modified lua exe, added this to support GetPixles() //GetPixels lua port (for 1 pixel) static int GetPix(lua_State *L){ int argc = Interpreter::GetStackSize(); Texture* t; t = static_cast<Leadwerks::Texture*>(Interpreter::ToObject(1)); //texture sent from lua int datasize = t->GetMipmapSize(0); char* pixels = (char*)malloc(datasize); t->GetPixels(pixels); char r; memcpy(&r, pixels+0, 1); delete(pixels); Interpreter::PushFloat(r); //value pushed to lua return 1; } And now we can sneak in the shadows 2 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
shadmar Posted February 17, 2015 Share Posted February 17, 2015 I'll post a little demo with my sources. 2 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
ocean Posted February 18, 2015 Share Posted February 18, 2015 And now we can sneak in the shadows Brilliant! Quote Ubuntu 14.04 / 64bit. Dell XPS430, Intel Core 2 Quad Q8300 @ 2.50GHz, 4Gb Ram, Radeon HD 6670, Leadwerks Pro edition (Steam). Link to comment Share on other sites More sharing options...
shadmar Posted February 18, 2015 Share Posted February 18, 2015 Ok here is my test project: How to use : 1. Make a lua project. 2. unzip this into your root 3. delete the original <project>.exe 4. rename the rename_to_projectname.exe to <project>.exe (buildt in VS2013 using LE beta) 5. load sneak.map and run it from the editor, F6 If you have Std ed, App.cpp with the lua bind for GetPixles() is added so you can update whenever you want or build for linux yourself. Player's lumnosity you can fetch from anywhere using camera:GetKeyValue("playerlight") https://dl.dropboxusercontent.com/u/11319604/lumdetector.zip 3 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Rick Posted February 18, 2015 Author Share Posted February 18, 2015 Very cool. Sort of a shame Lua only users don't have this functionality as whenever a new update happens for them they have to pick either get no new exe updates or this exe Quote Link to comment Share on other sites More sharing options...
beo6 Posted February 18, 2015 Share Posted February 18, 2015 its not working for me. it gives the error: Failed to load shader "G:/Projekte/Games/Leadwerks/sneakTest//Shaders/PostEffects/00_shaders/_passthrough.shader" when i run it and it is indeed not included in the zip Quote Link to comment Share on other sites More sharing options...
Ma-Shell Posted February 18, 2015 Share Posted February 18, 2015 its not working for me. it gives the error: Failed to load shader "G:/Projekte/Games/Leadwerks/sneakTest//Shaders/PostEffects/00_shaders/_passthrough.shader" when i run it and it is indeed not included in the zip I would assume, that one is one from shadmars PostProcessing shaders from the workshop: http://steamcommunity.com/workshop/browse?appid=251810 Quote Link to comment Share on other sites More sharing options...
beo6 Posted February 18, 2015 Share Posted February 18, 2015 indeed it is. sorry didn´t knew. Works nicely Quote Link to comment Share on other sites More sharing options...
shadmar Posted February 19, 2015 Share Posted February 19, 2015 Ah sorry forgot to include that passthrough shader, but yes you can fetch it in the workshop anyway. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
klanphear Posted February 19, 2015 Share Posted February 19, 2015 work's great but I get a warning. Lua sandboxing disabled. Does anyone else? is this normal? 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.