Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 12-29-2009, 04:17 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2009
Location: LONDON
Posts: 22
Default Splatter effect

One of the projects I'm working on requires a splatter effect where by the user can wipe the slime off the screen.

My first attempt (plan on having a few attempts to find the best approach, next I'll try using particles) is using CoreGraphics where by I have a splatter image that I'm scaling up until its mostly filling the screen.

Now; I have the image there, rendered to a CALayer - my question is... How do I go about smudging the image around when the user drags their finger across the screen?

The current solution I have in mind is to obtain the images raw data and applying some type of gaussian blur effect to the surrounding pixels (but sounds heavy weight and slow). Any suggestions, tips will be much appreciated.

Cheers
josh is offline   Reply With Quote
Old 12-29-2009, 07:17 AM   #2 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 234
Default

Quote:
Originally Posted by josh View Post
One of the projects I'm working on requires a splatter effect where by the user can wipe the slime off the screen.

My first attempt (plan on having a few attempts to find the best approach, next I'll try using particles) is using CoreGraphics where by I have a splatter image that I'm scaling up until its mostly filling the screen.

Now; I have the image there, rendered to a CALayer - my question is... How do I go about smudging the image around when the user drags their finger across the screen?

The current solution I have in mind is to obtain the images raw data and applying some type of gaussian blur effect to the surrounding pixels (but sounds heavy weight and slow). Any suggestions, tips will be much appreciated.

Cheers

A few months back, I had to code something similar and the only way I could get it to perform was to use OpenGL ES.


Here is a little demo ( a concept of proof - it supports two erasing modes : - "drop shadow" and "scratch mode" )
It runs around 40-50 fps on the older iphone.

http://www.warmi.net/tmp/scratchme.mov
warmi is offline   Reply With Quote
Old 12-29-2009, 07:47 AM   #3 (permalink)
Registered Member
 
Join Date: Mar 2009
Location: LONDON
Posts: 22
Default

Quote:
Originally Posted by warmi View Post
A few months back, I had to code something similar and the only way I could get it to perform was to use OpenGL ES.


Here is a little demo ( a concept of proof - it supports two erasing modes : - "drop shadow" and "scratch mode" )
It runs around 40-50 fps on the older iphone.

http://www.warmi.net/tmp/scratchme.mov
Cheers - looks good.

Any hints on how you went about this? Also; any ideas of how you would get a smudging effect ie instead of clearing the area you move them with the finger (if that makes sense)?
josh is offline   Reply With Quote
Old 12-30-2009, 12:07 PM   #4 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 234
Default

Quote:
Originally Posted by josh View Post
Cheers - looks good.

Any hints on how you went about this? Also; any ideas of how you would get a smudging effect ie instead of clearing the area you move them with the finger (if that makes sense)?
I am not entirely sure what do you mean by a smudging effect.

If you mean true real-time transformations ( the way Photoshop handles Smudge Tool) then there is not much choice but doing it on the CPU which would be slow (mostly because you would have to reupload the resulting texture on every frame).

The way I handed it was to render to texture a black/white mask in response to user actions and use the mask texture as an alpha image when rendering two textures ( the background and the foreground.) to the screen.

I am not sure how would it work for you, but theoretically you could have two versions of the same image, one containing your pristine image and another a smudged version of it and use the same approach to mask them based on user input.


Another way would be to use a grid approach - which is essentially an image rendered on a grid of quads and then get the desired effect by manipulating quad coordinates.
Given dense enough mesh, it works fine for all kinds of image transformations.

Here is an example ( using low res grid designed for a specific effect - you would have to use denser mesh)

http://www.warmi.net/tmp/Image.mov
warmi is offline   Reply With Quote
Old 02-08-2010, 12:19 PM   #5 (permalink)
Registered Member
 
Join Date: Mar 2009
Location: LONDON
Posts: 22
Default

Hi warmi, thanks for your feedback.

I've experimented around with particles and your suggestion, which appears to the the better out of the two, the only issue I'm coming across is that I've connecting the grids together (tile above and left to each one) and applying a spring type physics to hold them together but obviously when they start moving you see gaps in the image.

I'm thinking possibly scaling each tile when the distance between 1 tile is greater than it's resting length. ... ???

I'm assuming you've connected your grid in the same way (previous col and previous row) but instead of having them spring together you have them fixed to one another - is this right?

Appreciate your help,
Josh
josh is offline   Reply With Quote
Old 02-08-2010, 12:45 PM   #6 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 234
Default

Quote:
Originally Posted by josh View Post
I'm assuming you've connected your grid in the same way (previous col and previous row) but instead of having them spring together you have them fixed to one another - is this right?

Appreciate your help,
Josh
Yeah, all you need to do is to create your grid with X*Y # of vertices and then use indices to build your triangle array.

In other words, don't duplicate shared corner vertices.

http://www.warmi.net/tmp/grid.png

PS. Are you familiar with how to create meshes using both - vertex and index arrays ?
warmi is offline   Reply With Quote
Old 02-08-2010, 12:54 PM   #7 (permalink)
Registered Member
 
Join Date: Mar 2009
Location: LONDON
Posts: 22
Default

Ah.... I was a bit (a fair bit) off your approach, I actually ended up creating a grid of quads (sounds stupid now when you think about it) and spread the texture across them.

I did consider this (creating a mesh - going off the waving flag example from the book OpenGL Game programming) but not sure how you go about picking vertices (via touch). Also not sure how I would go about restoring the mesh back to its previous state.... Whats my chances for a bit of help?
josh is offline   Reply With Quote
Old 02-08-2010, 01:11 PM   #8 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 234
Default

Quote:
Originally Posted by josh View Post
Ah.... I was a bit (a fair bit) off your approach, I actually ended up creating a grid of quads (sounds stupid now when you think about it) and spread the texture across them.

I did consider this (creating a mesh - going off the waving flag example from the book OpenGL Game programming) but not sure how you go about picking vertices (via touch). Also not sure how I would go about restoring the mesh back to its previous state.... Whats my chances for a bit of help?
I generally keep 2 sets of grids ... one is just a const reference and the other one is populated on every frame using some sort of algorithm and then displayed.

In other words, think of your grid transformations as a displacement from the original position and not as an absolute value.

In fact sometimes I even keep 3 copies of the grid ... one is the original undisturbed grid , the other is a transformed version of the same grid ( you could precalculate whatever transformations you want - and since it is done only once , it doesn't matter if it is fast)

Once you got that in place ... you can animate their transformation by simply interpolating positions between grid 1 and grid 2 and then writing the value to the final grid 3 ( which gets displayed.)

Linear interpolation - Wikipedia, the free encyclopedia
warmi is offline   Reply With Quote
Old 02-09-2010, 02:12 PM   #9 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 223
Default

That effect looked pretty sweet. If you are using opengl, I suppose one way is to alter the pixels of a the slime texture's alpha channel and update it as necessary, no idea if you'd get 60 fps though.

To make the slime seem to move, you can alter the opengl texture matrix
mlfarrell is offline   Reply With Quote
Old 02-09-2010, 02:25 PM   #10 (permalink)
Obj-C Learner
 
Join Date: Apr 2009
Location: Manchester, UK
Posts: 1,030
Send a message via MSN to ZunePod Send a message via Yahoo to ZunePod
Default

Quote:
Originally Posted by warmi View Post
A few months back, I had to code something similar and the only way I could get it to perform was to use OpenGL ES.


Here is a little demo ( a concept of proof - it supports two erasing modes : - "drop shadow" and "scratch mode" )
It runs around 40-50 fps on the older iphone.

http://www.warmi.net/tmp/scratchme.mov
Which is more than needed.
ZunePod is offline   Reply With Quote
Old 02-14-2010, 01:00 PM   #11 (permalink)
Registered Member
 
Join Date: Mar 2009
Location: LONDON
Posts: 22
Default

Quote:
Originally Posted by warmi View Post
I generally keep 2 sets of grids ... one is just a const reference and the other one is populated on every frame using some sort of algorithm and then displayed.

In other words, think of your grid transformations as a displacement from the original position and not as an absolute value.

In fact sometimes I even keep 3 copies of the grid ... one is the original undisturbed grid , the other is a transformed version of the same grid ( you could precalculate whatever transformations you want - and since it is done only once , it doesn't matter if it is fast)

Once you got that in place ... you can animate their transformation by simply interpolating positions between grid 1 and grid 2 and then writing the value to the final grid 3 ( which gets displayed.)
[/url]
First off - thanks again warmi for all your help.

So I've created my mesh, wrapped a texture around it, and now allowing the user to manipulate/pull each vertex. Each vertex is connected with its neighbor and has some simple spring dynamics associated it.

http://www.ubinow.net/preview/goo-take1.mp4

... Getting closer but not quite the effect I need - any ideas on how to get it to behave more like goo? The selected vertex is automatically de-selected after 1/3 of a second because too much movement created a very deformed image. I've tried adding different weights to the inner nodes with little success.

Be great to hear your (and everyone elses) thoughts on how to make it behave more like goo.

Thanks,
josh is offline   Reply With Quote
Old 02-14-2010, 01:02 PM   #12 (permalink)
Obj-C Learner
 
Join Date: Apr 2009
Location: Manchester, UK
Posts: 1,030
Send a message via MSN to ZunePod Send a message via Yahoo to ZunePod
Default

It looks like water now.
ZunePod is offline   Reply With Quote
Old 02-14-2010, 02:56 PM   #13 (permalink)
Registered Member
 
Join Date: Mar 2009
Location: LONDON
Posts: 22
Default

Quote:
Originally Posted by ZunePod View Post
It looks like water now.
Ha - Cheers... I've made it alot more stiffer but still doesn't have that goo feel to it (obviously).

http://www.ubinow.net/preview/goo-take2.mp4

Can you think of any technique that I could use that would give it more of a goo feel? I'm thinking maybe repelling the vertices where the user touches.
josh is offline   Reply With Quote
Old 02-14-2010, 03:27 PM   #14 (permalink)
Registered Member
 
Join Date: Mar 2009
Location: LONDON
Posts: 22
Default

Any better?

http://www.ubinow.net/preview/goo-take3.mp4

Thinking if I push out vertices, which should resolve the folding look, it should look more like goo...

Last edited by josh; 02-14-2010 at 03:32 PM.
josh is offline   Reply With Quote
Old 02-14-2010, 04:36 PM   #15 (permalink)
Obj-C Learner
 
Join Date: Apr 2009
Location: Manchester, UK
Posts: 1,030
Send a message via MSN to ZunePod Send a message via Yahoo to ZunePod
Default

Looks more like goo.

but now it looks as if you've got a thin skin of membrane on top of some water, and your dabbing your finger in it.
ZunePod is offline   Reply With Quote
Old 02-14-2010, 06:10 PM   #16 (permalink)
Beast Iphone Developor
 
justill45's Avatar
 
Join Date: Aug 2009
Location: Atlanta, Georgia
Age: 16
Posts: 1,302
Default

Quote:
Originally Posted by ZunePod View Post
Looks more like goo.

but now it looks as if you've got a thin skin of membrane on top of some water, and your dabbing your finger in it.
lol, love the positive feedback
justill45 is offline   Reply With Quote
Old 02-14-2010, 06:24 PM   #17 (permalink)
Obj-C Learner
 
Join Date: Apr 2009
Location: Manchester, UK
Posts: 1,030
Send a message via MSN to ZunePod Send a message via Yahoo to ZunePod
Default

Quote:
Originally Posted by justill45 View Post
lol, love the positive feedback
I'm just C&C'ing, this guy will thank me in the end.
ZunePod is offline   Reply With Quote
Old 02-14-2010, 08:49 PM   #18 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 234
Default

Quote:
Originally Posted by josh View Post
Any better?

http://www.ubinow.net/preview/goo-take3.mp4

Thinking if I push out vertices, which should resolve the folding look, it should look more like goo...
Yeah it does look like goo.... I would try to perhaps use a second grid with some kind of blending applied (perhaps alpha/ or maybe addictive) moving in a slightly different direction and perhaps with different grid resolution ...

Don't know if that would look better, just throwing out some ideas ... with GLES 1.x you are pretty much limited to hacks like these.
warmi is offline   Reply With Quote
Old 02-15-2010, 12:54 PM   #19 (permalink)
Registered Member
 
Join Date: Mar 2009
Location: LONDON
Posts: 22
Default

Quote:
Originally Posted by josh View Post
Any better?

http://www.ubinow.net/preview/goo-take3.mp4

Thinking if I push out vertices, which should resolve the folding look, it should look more like goo...
Quote:
Originally Posted by warmi View Post
Yeah it does look like goo.... I would try to perhaps use a second grid with some kind of blending applied (perhaps alpha/ or maybe addictive) moving in a slightly different direction and perhaps with different grid resolution ...

Don't know if that would look better, just throwing out some ideas ... with GLES 1.x you are pretty much limited to hacks like these.
Thanks (again) warmi - good ideas and has improved it alot. Previously I was just selecting and pulling one vertex, now it 'collects' the verticies the user finger covers which gives a more gooey type effect along with making those parts being moved more transparent.
josh is offline   Reply With Quote
Old 06-07-2010, 05:34 AM   #20 (permalink)
JP
 
Join Date: Dec 2009
Location: India,Bangalore
Posts: 109
Default Image Warphing in iPhone

Hi Josh,

Can you share your sample Code for Image Warphing technique in iPhone.Atpresent i am doing one project based on Image Warphing.i searched in google.i didn't get any sample source code or basic ideas for image Warphing.Please send me ur sample source code to jpiphonedeveloper@gmail.com.


Thanks in Advance,
jayaprakash S
jpsubbarayalu is offline   Reply With Quote
Old 06-07-2010, 07:08 AM   #21 (permalink)
JP
 
Join Date: Dec 2009
Location: India,Bangalore
Posts: 109
Default Image Warphing in iPhone

Hi Josh,

Can u share ur code with me.in my app i am using Image Warphing Technique.Last 1 weak i searched in google and i tried myself.But i couldn't move forward.Please send ur source code(Image Warphing Technique) to jpiphone developer@gmail.com.


Thanks in Advance,
jayaprakash S
jpsubbarayalu is offline   Reply With Quote
Old 06-11-2010, 06:23 PM   #22 (permalink)
Registered Member
 
Join Date: Mar 2009
Location: LONDON
Posts: 22
Default

Quote:
Originally Posted by jpsubbarayalu View Post
Hi Josh,

Can u share ur code with me.in my app i am using Image Warphing Technique.Last 1 weak i searched in google and i tried myself.But i couldn't move forward.Please send ur source code(Image Warphing Technique) to jpiphone developer@gmail.com.


Thanks in Advance,
jayaprakash S
The code is tied up in the clients project but hopefully I get some time this week where I can put together a quick prototype. This will just be code that wraps a image around dense(ish) mesh and allows the user pick the closest vertex and pull it around. Should be enough to set you on your way
josh is offline   Reply With Quote
Old 06-11-2010, 06:25 PM   #23 (permalink)
Beast Iphone Developor
 
justill45's Avatar
 
Join Date: Aug 2009
Location: Atlanta, Georgia
Age: 16
Posts: 1,302
Default

Quote:
Originally Posted by josh View Post
The code is tied up in the clients project but hopefully I get some time this week where I can put together a quick prototype. This will just be code that wraps a image around dense(ish) mesh and allows the user pick the closest vertex and pull it around. Should be enough to set you on your way
ooh, could i have this code aswell?
justill45 is offline   Reply With Quote
Old 06-16-2010, 09:15 AM   #24 (permalink)
JP
 
Join Date: Dec 2009
Location: India,Bangalore
Posts: 109
Default Image Warphing in iPhone

Hi Josh,

Sorry for long reply...i need ur sample code to do image warphing in iPhone.Now i am trying last 2 weeks this.But still i didn't get any valuable solution. So please share ur code with me.
My gemail id --> jpiphonedeveloper@gmail.com.
Hopefully Positive response from you...


Thanks in Advance,
jayaprakash S
jpsubbarayalu is offline   Reply With Quote
Old 06-21-2010, 05:30 AM   #25 (permalink)
JP
 
Join Date: Dec 2009
Location: India,Bangalore
Posts: 109
Thumbs up Image Warphing in iPhone

Hi All,

Still i am facing a problem in an Image Warphing Techniques in iPhone.If anybody know please help me to sort out of this problem.i don't know how to start?..

Hopefully positive response from you all,
Thanks in Advance,
jayaprakash S
jpsubbarayalu is offline   Reply With Quote
Reply

Bookmarks

Tags
coregraphics, image effects, quartz2d

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 250
18 members and 232 guests
ADY, Alsahir, beleg_1998, Dani77, e2applets, iDifferent, iph_s, JamesCahall, JasonR, mer10, Monstertaco, prchn4christ, Promo Dispenser, Robiwan, Rudy, smithdale87, spiderguy84, timle8n1
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,756
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:18 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0