• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

318 Neutral

About BlinksTale

  • Rank
  1. All great posts, thank you!   Echo17's stroke based implementation best matches the slightly-modified idea mentioned above, it can easily recognize shapes being drawn from any combination of directions, so I'll probably use that. It is the first library linked in my original post, Drawing Engine.   The other engine, HyperGlyph, also still stands out - but hasn't been updated in over two years. Drawing Engine was updated two weeks ago, so it makes it a much easier choice.   Thanks again!
  2. Follow up from my own research: ends up there's no simple solution, should have figured. My options are either to go through the full learned state idea where a library is taught what to look for with examples, or you program it to compare against the sizes of a few basic shapes and nothing more.   http://citeseerx.ist.psu.edu/viewdoc/download?doi=   This article was the most helpful, and it looks like there's no easy or intuitive solution to this. The closest is...   1. Get convex hull for current shape (like putting a rubber band around it) 2. Compare convex hull to smallest of X shape that would fit around it (circle, then square, then triangle, etc) 3. If areas are almost one to one, they are probably the same shape.   It's pretty good for what it sets out to achieve, but it can't handle interesting shapes that are different, but have similar convex shapes (so ellipses and diamonds are tricky for it).   If I find any better options, I'll report back here, but for now it looks like this isn't a good enough approach, so a library is probably necessary.
  3. tl;dr: I want simple hand drawn shapes (boxes, lines, circles) to be identified by my code when the user makes that pattern with their cursor.   Example video   I want to go from mouse input to solid objects based on the (rough) shape that is drawn. This is not edge or blob detection, nor vector art as far as I'm aware, but some sort of path direction/line segment detection. There are X preset shapes, and drawing something similar to one of them will create that shape at that size.   In Trine, this includes a square for a box and a line for a plank (not sure if there are others, but I don't mind that being spoiled for me if there are). So far I'm getting *way* more complex stuff than I need with my Google searches, I think, so turning here for more practical applications at my needs level. "Evolutionary visual learning" was described in one document I found, and that's far beyond anything I want.   Working in C#/Unity, in case there are any relevant libraries I should look at.     EDIT: These two assets in Unity seem to do what I want, but I'm looking to understand how it's done in case I can implement it more cheaply/effectively/simply myself for my own purposes (rather than adopting a new engine to what I already have)   Drawing Engine   HyperGlyph
  4. Alright, final product is a combination of the partial solution and a workaround. When you touch a block, it immediately switches to 50% opacity and disables itself as a shadow surface, but also doesn't render before shadows again until after it's back at 100%. The shadows disappear when the crumbling blocks are touched then, but appear as soon as they're whole again, and all transparencies look good.   So it's about 80% of what I hoped for, and it looks good. :) Thanks guys!
  5. Transparent objects shouldn't render depth. Won't the problem go away if you disable depth writes for the crumbling blocks?     This is a lot better, but doesn't solve everything:     So, no depth test on crumbling blocks = awesome shadows passing through!   Heck, they go so far through it's like the crumbling blocks aren't even there!   ...ah shoot, it's like the crumbling blocks aren't even there. Now there are no shadows on top. As you can see, I've added some crumbling blocks above the other crumbling blocks. With the old way, the shadow recognizes the blocks and lands on it.     But the new way makes that shadow invisible.   So what can I do to address that? Multiple passes won't work because if it goes...   noDepth crumblingBlocks allShadows depth crumblingBlocks allShadows   ...well, for one: it does this funky shadow thing:     That's because the shadow is applied twice to everything at the bottom (I could probably clean that up by finding the difference of the two stencils though and not drawing anything twice) but two:     If I look through transparent crumbling blocks at the shadow of other blocks on TOP of crumbling blocks... nothing appears. I would have to do one of these passes for every single vertical layer of my game world. :|   So more dilemma! I want both to use the blocks with depth test, so I can draw shadows on top of them, but also without so I can draw shadows beneath them. Ah... any tips on this?
  6. Disclaimer: this is older OpenGL, and while I would love to switch to all shaders (not sure if that would be appropriate here even), I'd rather complete what I have instead of switching the whole engine over at this point. It is an older project, but I'd still like to see it wrapped up in its current form.     My project is a 3d platformer, you have cubes jumping around on other cubes and they use shadow volumes to show where they are in relation to the ground. Recently I added crumbling blocks, the kind that disappear a few seconds after you touch them. That's great! I have them set so their alpha is reduced based on how long it's been since you've touched them so they fade away after a few seconds. The problem is: even at alpha zero, they're affecting the depth test for my stencil buffer.   The white/grey blocks are the crumbling ones:     (Don't mind the missing face, it's part of an efficiency measure to remove unused faces that doesn't consider disappearing blocks yet)   The problem you see here is that the shadows, while drawn fine on the left and right, are not appearing in the middle behind the player. That's because there are crumbling blocks there, though they have 0% opacity/alpha. You can even see the outline of the cube just above and to the right of the player because that's the shape cut out of the shadows.   Also: the player automatically gets a silhouette when behind another object, same stencil style test as the shadows, so that's why the player is mostly yellow and shadowed yellow but then turns green at the top. It's explained here.   I don't want to leave anything out I might be missing, so here's the whole code chunk (you can see my comments trying to remember what I wrote... I've gotten better at this since 2012... ): // Give shadows to everything! void drawAllShadows(int player) { // Blend function not causing any differences if enabled/disabled? glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // GL_BLEND is the difference between black shadows and dark versions of the colors underneath glEnable( GL_BLEND ); // Not sure GL_ALPHA is doing anything, nor ALPHA_TEST glEnable( GL_ALPHA ); glEnable( GL_ALPHA_TEST ); // Color Mask with everything disabled means it doesn't use this data to draw real shapes/objects // instead, we're going to use it for a stencil test later glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); // No Depth Test lets shadows overlap instead of their not-drawn sections deleting shadows behind them glDepthMask(GL_FALSE); // GL_STENCIL_TEST limits the shadows to being drawn in the stencils, which are the levelShadows glEnable(GL_STENCIL_TEST); // Just draw the level shadows as regular polygons, but with the stencil option if (levelShadows) { glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); // specify pointer to vertex array glColorPointer(3, GL_FLOAT, 0, shadowColors); glVertexPointer(3, GL_FLOAT, 0, shadowVertices); glPushMatrix(); //glScalef(0.99,100.0,0.99); //glTranslatef(0.0,-50.505,0.0); glCullFace(GL_FRONT); glStencilFunc(GL_ALWAYS, 0x0, 0xff); // if depth fails (can't see only due to z) then increment pixel's value glStencilOp(GL_KEEP, GL_INCR, GL_KEEP); glDrawElements(GL_TRIANGLES, 36*shadowsVisible, GL_UNSIGNED_INT, shadowIndices); glCullFace(GL_BACK); glStencilFunc(GL_ALWAYS, 0x0, 0xff); // if depth also fails for back, decrement it so it stays at zero // but if one increments and the other does not... // (we'll come back to that later when we see where to place shadows) glStencilOp(GL_KEEP, GL_DECR, GL_KEEP); glDrawElements(GL_TRIANGLES, 36*shadowsVisible, GL_UNSIGNED_INT, shadowIndices); glPopMatrix(); // deactivate vertex arrays after drawing glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); } /* for (int i=0; i<cubeNum; i++) { // cubeWithinPlayerRange demonstrates noticeable improvements, // castle level with 4player, sfx and music went from 7fps to 12. // now goes from 24 to 35fps! Wow! if (cubeWithinPlayerRange(i,player)) { drawCubeShadow(i); } }*/ for (int i=0; i<cubiorNum; i++) { drawPlayerShadow(i); } drawGoalShadow(); drawItemShadows(); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glDepthMask(GL_TRUE); // Where the front and the back are not the same (so front face could be seen but back was obscured) // that is where a shadow is on the ground // or that is what I believe NOTEQUAL and REPLACE are being used for // all three replaces means no matter what (fail/zfail/succeed), we will the pixel with the new color glStencilFunc(GL_NOTEQUAL, 0x0, 0xff); glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); fillScreenWithShadow(); glDisable(GL_STENCIL_TEST); glDisable( GL_BLEND ); // end of shadow stuff } // 100% copied from draw_shadow for testing purposes // full permission to copy this though, according to Josh Beam: // http://joshbeam.com/articles/stenciled_shadow_volumes_in_opengl/ void fillScreenWithShadow() { // Fills the stencilled area with a shadow of 50% opacity on top of everything else glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0, 1, 1, 0, 0, 1); glDisable(GL_DEPTH_TEST); glColor4f(0.0f, 0.0f, 0.0f, 0.5f); glBegin(GL_QUADS); glVertex2i(0, 0); glVertex2i(0, 1); glVertex2i(1, 1); glVertex2i(1, 0); glEnd(); glEnable(GL_DEPTH_TEST); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); } The function drawItemShadows is the exact one for the crumbling block shadows, but it works the same way as what you see here already. It increments the stencil's pixel value for front faces and decrements it for back faces, so it should be zero if both faces are visible or both are obscured, but if only one is then that's where a shadow lands. But again, the problem is that the z test there isn't taking into account transparent polygons. Before this code is where I draw the items and world itself (shadows are drawn last) and those are drawn with 3 point polygon indexes and 4 point color indexes, 4th slot being alpha.   So how do I skip alpha in my depth tests, but then apply that alpha to the shadow I draw ultimately? Is that possible, or do I need to break this up into separate passes somehow?
  7. I'm working on a team right now for a pet game, like Chaos in Sonic, Nintendogs, Tamagotchi, etc. You have various stat bars that you should be keeping filled (not sure of the consequences for not doing this yet - which makes me cautious) and you can level up your character by playing with them, which gives you access to more items to customize with.   So you start the game and there's your pet with a few furniture items you can click on. You can click each furniture item to access a different menu - minigames, clothes, food, medicine.   The goal, I believe, is to level up the character by playing with them so that you can customize your character more, and that's about it.   How do I convey this objective or basic concept without tutorials? Mario, Megaman X, and any direct manipulation game seems to have no trouble with this, but I don't know of any pet games or second/third person manipulation games that don't use a tutorial. Any tips?
  8. New guy to the networking board here (although I have been blessed by the knowledge of the graphics boards before). I'm making my first networked game, and it's a 3d platformer. I'll be allowing players to jump on each others' heads, shove each other around, and in general physically interact a good deal - but they're just cubes, so it's rotation, position, and momentum. That's it.   So right now, I'm having my local game send my local character data of position/rotation/momentum to the remote game, where a copy character represents my local character in that remote game. So, it's a 1:1 of me in the offsite game.   Now I've got my local character, and the offsite player decides to take his offsite character and push it into the copy character. In local play, one character pushing against another leads to the pusher pushing the pushee around. In networked play though, the copy character is told to maintain that exact position based on the data my local game keeps sending about my local character. This leads to either no pushing or very slow pushing, because everything has to first go across the network twice before any real movement is made. That's bad!   So how can I fix this? If I don't send position, the momentum could ruin where they end up if any packets are lost. If I send position back and update my local character with data from the copy character, won't that overwrite my new controls/momentum/input that I'm sending locally? And if I just average everything, it moves at half speed.   The closest idea I have so far is that I should send the data both ways, but I have to be careful with my timing. Eg. I would read in the data sent back at the beginning of my game loop, so the first thing that happens is updates from across the network are applied, then I add my own changes with input, and then I finally send out that new broadcast of data at the end of the gameplay loop. But would that really work, or just lead to more cases of the players locking up against each other?   Thanks!
  9. Any options for affordable ray tracing?

    Great video and articles, thanks kalle_h! Any idea if he plans to make the code public?
  10. Any options for affordable ray tracing?

    Hodgman: fantastic! What wonderful examples - I'm really keen on that Nvidia one.   ddn3: Windows only! I was unable to open the exe, but working with Unity sounds fantastic.   Seeing Arauna's list though: Do I need any special features to have the light curve in the glass? I have no experience with that, just a lot of curiosity.
  11. So as someone who has dealt with real time graphics instead of prerendered for his entire career, when I look at this..   http://upload.wikimedia.org/wikipedia/commons/e/ec/Glasses_800_edit.png   ...I feel like it's still a distant dream. Everything I'm learning is about how mirrors are too hard and how Portal's whole system was simplified to work with multiple cameras/physics in the game. That just doesn't seem right to me. There must be some way, especially with all these new consoles rolling in, to handle bending light, right?   My ideal would be something like these:   http://tobifairley.com/blog/wp-content/uploads/2010/07/crystal-glassware.jpg http://devrajniwas.files.wordpress.com/2013/12/crystal_wine_glasses_tif.gif http://www.homewetbar.com/images/prod/w-Crystal-Glass-Set-133769.jpg   Reflections and curved/bent light, that's really all I'm looking for. Now, that might be asking for a whole new Google/Facebook (or some equally absurd and impossible amount of work), but I really think there's a workaround I just haven't heard of yet.   If all I want is these two things, do I have any options? Maybe even ones with a camera that moves?   I'd love to have a world the player can navigate where light bends in these beautiful ways. Are there any options at all for that right now?
  12. I really like the idea of sending it through a shader, so it can change in runtime.   How do I go from 2D PNG with transparency to an outline though, even with a static value?   I'm sure there's a way to do it without the 24 copies, but what is it? I've heard people mention edge detection before, does that work on 2d? (and as someone relatively new to shaders, how do I tell it to draw the outline itself, instead of just recoloring pixels or moving vertices by an offset?)
  13. This is probably the most complicated semi-2d thing I have attempted before, and so far I have not found anything online about this kind of a shader, approach, anything.    I'm trying to make one outline for multiple 2d textures (from image files with transparency) rendered on separate 3d planes (couldn't wait until Unity 4.3). It should have A, B, and C up front, and then A's outline, B's outline, and C's outline in back (so that A, B, and C have no outlines at their overlaps). An image might help:   The final monkey accomplishes everything that I'm looking for. The pieces overlap, but the outlines all appear behind.   Now, there are a couple of ways to do this, but I want to see if there's a way to do it without doubling the assets, and without having a crazy slowdown. Reasonable requirements in general, but lofty goals for this particular issue it seems.   Some have suggested simply scaling all assets and rendering them in black:     This does not work with shapes like crescents, where there is empty space between the center of the object and one of its filled pixels. Scaling a silhouette will instead lead to outlines only for the outer edges.   An approach that does make a decent outline is rendering the silhouette in 24 different angles, offset by some radius:   This approach though becomes painfully slow if anything is changing. It can be done once at the beginning of a scene to great effect, but it does not work well if your animations change every frame.   Luckily: I am not seeking to change my animations every frame, so I believe this approach will work for me. The question then is, how can I get it to appear with a Z-offset?   Conceptually, I will most likely have a separate plane for every object, then a second plane for each object's outline, and then have all the outline planes mimicking the original planes every frame, and compute the outline from those 24 offsets at the beginning of the scene only. The Unity forums said that creating a shader would be too expensive if it was trying to do an outline every frame, so having extra assets was the best approach. I think I can still do those assets programmatically, but just in general I am looking for the most flexible approach to this.   Are there any other techniques in this field that I should be looking at for 2d outlines of image files with transparency, rendered on 3d planes?
  14. Fuzz edge is definitely the effect I was looking for (very similar to velvet though), which looks to be a variant of rim lighting, and the wrap diffuse lighting will help too! Thank you all, this is far more than I could have asked for :)
  15. You guys always know how to pull off these fancy tricks, so perhaps you can help me with this. Nintendo's newest round of games all have this amazing "soft" look to them visually, no more [url=http://i.imgur.com/AfDGgae.jpg]hard light-to-dark gradients[/url]. Instead, there's backlighting or that layered skin effect, underlighting, *something*. That's what I'm trying to figure out, and then how to do it.   Examples:   Kirby here, and maybe Pikachu's chest just under his arm.   These two cube men, with some ridiculously soft lighting/shadowing system, although I think it might be different from the others.   The back of this girls head, just under her hairline. It definitely glows, but only at the edge of her head.   Here Pascal, the red otter, has the glow all around his head. The girl also has it, but on her jawline.   So I'm guessing the glow is a reflection, due to what fancy-schmancy art class still life taught me.   ^art skewl   Although I'm also inclined to think it's a skin transparency layering mimicking thing, like the PS4 demo by David Cage (only significantly cheaper on the processor, I'm sure).   And I still think that Cube Men one is a different shader/lighting/thing altogether, but I don't know how to describe it compared to the others.   So, thoughts? Directions? Help? I want my game to have friendly, soft, and welcoming visuals. So far, all of the above do an excellent job of that, so I'd like to learn what I can from them. Many thanks!
  • Advertisement