AsherOS
|
 |
Posted on: August 05, 2013, 02:22:07 am |
|
|
 Joined: Jul 2013
Posts: 19
|
Hello, as the title says, I am trying to create a shadow casting effect much like that of Teleglitch for my stealth game.  (Teleglitch) I was able to get something working in Game Maker Studio, but it was rather glitchy. Once I moved to Enigma, I tried to remake the system from scratch, but I didn't get anywhere alone. I'm just wondering if anyone can point me the right way on making this. I realize the Teleglitch creators use 3D shapes to make the shadows, but if a 2D system is simpler (my game is 2D), that's great. Cheers, Asher
|
|
|
Logged
|
|
|
|
Goombert
|
 |
Reply #1 Posted on: August 05, 2013, 02:36:47 am |
|
|
 Location: Cappuccino, CA Joined: Jan 2013
Posts: 2991
|
My suggestion is to take a look at this example... http://enigma-dev.org/edc/games.php?game=28Provided it has not been broken recently XD And whatever the hell you are making, it looks cool. The right way to do it though is using shaders, which are not quite completed yet.
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect. 
|
|
|
TheExDeus
|
 |
Reply #2 Posted on: August 05, 2013, 06:45:10 am |
|
|
 Joined: Apr 2008
Posts: 1860
|
There are many ways to draw shadows. Like using surfaces (geargod style), polar coordinates (xot's style) and others. The thing about Teleglitch is that it actually created shadows just by extending the geometry upwards. So no need for any real computation, it just a model which creates that effect. Like in this animation:  So it shouldn't be hard to replicate. Now some things could be broken in ENIGMA (surfaces specifically) and I am trying to fix them, so I won't be able to create an example for you. Maybe Robert can as he likes 3D stuff. The negative side is that only one "light" can be in the scene. In teleglitch there was no lights at all and it just symbolized visibility, so it worked there quite well. If you really want a shadow casting by multiple color and blended lights, then other techniques must be used. And whatever the hell you are making, it looks cool. The right way to do it though is using shaders, which are not quite completed yet. That screenshot is from a quite popular rogue style game Teleglitch. And there is rarely a "right way" to do anything. If you can get the same performance otherwise (like in this case just using geometry), then it is the right way as well.
|
|
|
Logged
|
|
|
|
Goombert
|
 |
Reply #3 Posted on: August 05, 2013, 06:55:38 am |
|
|
 Location: Cappuccino, CA Joined: Jan 2013
Posts: 2991
|
Maybe Robert can as he likes 3D stuff. Sure, if he doesn't want it for lighting and just occlusion like in his screen, but if he needs perpixel lighting like in your animation, I need hold off and do some other things and then shaders. That screenshot is from a quite popular rogue style game Teleglitch. And there is rarely a "right way" to do anything. If you can get the same performance otherwise (like in this case just using geometry), then it is the right way as well. Agreed, but if you want it like you say for lighting, that still requires a perpixel fragment shader unless you want to bump up the geometry.
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect. 
|
|
|
|
|
TheExDeus
|
 |
Reply #6 Posted on: August 05, 2013, 02:42:52 pm |
|
|
 Joined: Apr 2008
Posts: 1860
|
The guy who created the lightning engine posted in EDC actually created a new which is a lot easier to use and allows colored lights. Here is a video: http://www.youtube.com/watch?v=MaDPr2Z1-lMI will upload it to EDC when I fix up GL3. I will commit a fix for GL1 and GL3 so the example works without changes (though the variable_exists() will be removed). And the 3D was cool. It did shift around a little, but it is not a lightning engine or a shadow engine. That means you will have only one caster. If it suits your needs, then anything more complex might not be needed.
|
|
|
Logged
|
|
|
|
|
AsherOS
|
 |
Reply #8 Posted on: August 06, 2013, 03:11:31 pm |
|
|
 Joined: Jul 2013
Posts: 19
|
I've been able to create cameras, objects, etc. in 3D, however I need help figuring something out. The camera direction commands don't entirely make sense to me, but I know I need to to point along the z-axis, in order to see the 2D room. This is the example code I'm using (from http://enigma-dev.org/forums/index.php?topic=1169.0) //DRAW WHAT CAMERA SEES
xf=x; //x to look from yf=y; //y to look from zf=z; //z to look from
xt=xf+cos(degtorad(direction)); //x to look to (with direction) yt=yf-sin(degtorad(direction)); //y to look to (with direction) zt=zf-sin(degtorad(zdirection)); //z to look to (with z direction)
d3d_set_projection(xf,yf,zf, xt,yt,zt, 0,0,1); //look from & to I know this code points the camera along the x-axis, looking east in the room editor. Could someone explain how I would need to change this for what I need? I hope this isn't too much trouble. Cheers, Asher
|
|
|
Logged
|
|
|
|
Goombert
|
 |
Reply #9 Posted on: August 06, 2013, 03:26:04 pm |
|
|
 Location: Cappuccino, CA Joined: Jan 2013
Posts: 2991
|
Ohhh no you silly goose, you don't need those projection commands for what you are doing, just use d3d_set_projection_perspective, it will give a 2D view except have a 3D FOV.
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect. 
|
|
|
AsherOS
|
 |
Reply #10 Posted on: August 06, 2013, 04:46:45 pm |
|
|
 Joined: Jul 2013
Posts: 19
|
When I was writing this question, I kinda knew on the inside that the answer was going to be painfully simple. Thanks 
|
|
|
Logged
|
|
|
|
TheExDeus
|
 |
Reply #11 Posted on: August 06, 2013, 04:47:28 pm |
|
|
 Joined: Apr 2008
Posts: 1860
|
And didn't that code work? It should be as simple as d3d_set_projection(x,y,z, x,y,z+1, 0,0,1) or something like it. Also, I uploaded a working version of the easy to use light and shadow engine here: http://enigma-dev.org/edc/games.php?game=62That is if you think that will suit better (although its idea is totally different from what you are doing here).
|
|
|
Logged
|
|
|
|
|
Goombert
|
 |
Reply #13 Posted on: August 06, 2013, 10:06:28 pm |
|
|
 Location: Cappuccino, CA Joined: Jan 2013
Posts: 2991
|
d3d_set_projection(x,y,z, x,y,z+1, 0,0,1) Why would you use that? Just use the perspective function....
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect. 
|
|
|
|
|