GMLscripts.com

Discuss and collaborate on GML scripts

You are not logged in.

#21 2009-11-23 07:04:40

icuurd12b42
Member
Registered: 2008-12-11
Posts: 303

Re: UV Hijinks - Smoke and Mirrors

You change the amplitude by changing the path, of course that is easy. BUT for putting in the right <exact> frequency. I gave up on that for the obvious reason you mentioned. You cant have full control of the frequency or you will never get it to loop right.

That is why I use the term loosely soemwhere in the comments. It's also why I decided to use paths for that too. I can grab exactly what part of the wave I need to have it loop right according to the number of frames wanted.

It was a stroke of genius after I failed so many times to mimic reality. I decided to fake it realistically. A path allowed me to losely define speed and crest, + varying signal as well as to grab easily what the wave value is at a specific distane / time.

One thing is I use path get lenght combined with point_distance to give me a fraction I can use with path_get_X/y. It's not right... The fraction should be based on the distance covered by the x axis in the wave path. That hack gave me that crest value at a known position, I figured it was good enough. the repeat factor in the AddGenerator sortof compensates for this inexactitude. But I get you. If I wanted to "visually" show harmonics, like for music... Anyway, you can check out the concept and maybe you can make it right.

Last edited by icuurd12b42 (2009-11-23 07:06:45)

Offline

#22 2010-01-14 14:17:32

Wargasmic
Member
Registered: 2010-01-14
Posts: 2

Re: UV Hijinks - Smoke and Mirrors

I'm new here, so I'll start by saying hey there!

Xot, would it be possible to use this method of distortion to create an interactive, fluid-like surface as seen in the grid effect of Geometry Wars 2? If you havn't played GW2 heres a link that shows the grid effect nicely.

Offline

#23 2010-01-14 19:47:57

icuurd12b42
Member
Registered: 2008-12-11
Posts: 303

Re: UV Hijinks - Smoke and Mirrors

Yes

on a 32x32 grid, you should be able to do it live/update it live instead of making a series of models..

Offline

#24 2010-01-14 20:15:42

xot
Administrator
Registered: 2007-08-18
Posts: 1,201

Re: UV Hijinks - Smoke and Mirrors

Hi Wargasmic, welcome to the forums!

It would be difficult to get an effect quite as detailed as GW. The resolution of the distortion grid is very high in GW. I believe it uses Verlet integration and simple texture mapped quads. GM is far too slow to use that method at the level of detail shown in GW. Thesnidr's example linked in the first post is actually pretty close to the way GW works (minus the springs). There may be another example at GMC that tries it. I'll see if I can find it.

"Thesnidr's Grid Distortion Effect, Almost like in Geometry Wars"
http://gmc.yoyogames.com/index.php?showtopic=445247

"Gravity Grids, Any faster way?"
http://gmc.yoyogames.com/index.php?showtopic=417474

Regardless, this is something that you would have to do "live", as icuurd12b42 describes it. Pre-built models could make a some distortion effects like those in GW faster, but it would be difficult to layer effects the way GW does. You can apply effects in series, distorting already distorted textures, but you start running into generation-loss problems causing texture detail to disappear. This is not unlike the way making a photocopy of a photocopy of a photocopy makes it hard to read.

Last edited by xot (2010-01-14 21:07:58)

Abusing forum power since 1986.

Offline

#25 2010-01-15 17:36:06

Wargasmic
Member
Registered: 2010-01-14
Posts: 2

Re: UV Hijinks - Smoke and Mirrors

Thanks for the welcome and the replies , icuurd12b42 and Xot. icuurd12b42, I like your grid distortion technique on the GMC forums, in fact I built my own before I made this post which is very simalar to yours. The main problem with mine though is that the points always twitched when they were at their starting point. So ive stolen your technique for the movement of the points which is nice and smooth if thats okay with you:).  Heres the code i origionally used for my own grid effect.

objGrid - Create event

var i, o, gridDone, gWidth, gHeight, distX, distY, incX, incY;

gridDone = false;
gWidth = 2100;
gHeight = 1600;
pointsX = 25;
pointsY = 20;
distX = gWidth / pointsX;
distY = gHeight / pointsY;
x = 0;
y = 0;
incX = x;
incY = y;

r = 0;

for(i = 0; i < pointsY + 1; i += 1){
for(o = 0; o < pointsX; o += 1){
if(i == 0 || o == 0 || i == pointsY - 1 || o == pointsX - 1){
global.rows[i, o] = instance_create(incX, incY, objPointStatic);
}
else{
global.rows[i, o] = instance_create(incX, incY, objPoint);
}

incX += distX;
}

incX = 0;

incY += distY;
}

gridDone = true;

objGrid - Draw event

if(gridDone){
for(i = 0; i < pointsY - 1; i += 1){
for(o = 0; o < pointsX - 1; o += 1){
nextPoint = global.rows[i, o + 1];
nextRow = global.rows[i + 1, o];

with(global.rows[i, o]){
// sprGrid is a 1 pixel wide/10 pixel high sprite stretched and angled from one point/row to the next.

draw_sprite_ext(sprGrid, 0, x, y, point_distance(x, y, other.nextPoint.x, other.nextPoint.y), 1, point_direction(x, y, other.nextPoint.x, other.nextPoint.y), c_white, 1);
draw_sprite_ext(sprGrid, 0, x, y, point_distance(x, y, other.nextRow.x, other.nextRow.y), 1, point_direction(x, y, other.nextRow.x, other.nextRow.y), c_white, 1);
}
}
}
}

objPoint - Create event

originX = x;
originY = y;
gravity = 0;
friction = 2;

objPoint - Begin step event

if(instance_exists(objInfluence)){
influence = instance_nearest(x, y, objInfluence);
influenceCheck = point_distance(x, y, influence.x, influence.y);
originCheck = point_distance(x, y, originX, originY);

if(influenceCheck < influence.radius && originCheck < influence.radius){
if(influence.type == 0){
if(influence.distEffect){
pull = influence.strength / influenceCheck;

if(pull > 10){
pull = 10;
}

gravity = pull;
}
else{
gravity = 4;
}

gravity_direction = point_direction(x, y, influence.x, influence.y);
}
else{
gravity_direction = point_direction(x, y, influence.x, influence.y) + 180;
gravity = 4;
}
}
else{
gravity_direction = point_direction(x, y, originX, originY);
gravity = 4;
}
}
else{
gravity_direction = point_direction(x, y, originX, originY);
gravity = 4;
}

objInfluence - Create event

var i, lifeTime, radius, strength, tolerence, type, distEffect;

i = 0;
lifeTime = 30;
radius = 0;
strength = 0;
tolerence = 0;
type = 1;
distEffect = 0;

objInfluence - Begin step event

if(lifeTime > 0){
if(i >= lifeTime){
instance_destroy();
}
}

i += 1;

The main difference here is (other than your code being much cleaner and optimized) the way in which I'm drawing the texture between the points. But, while giving a much nicer effect being able to use a sprite than the default line drawing of gamemaker and eliminating texture distortion alltogether which appears with the texture/primative effect, it is slower than I would like:(. I think in the end I will have to go for the 'primative with a texture applied' method.

Oh and I know I have probably gone the long way round with this code and have way more variables and conditions than needed, but, I am new to gamemaker and game programming in general so thats my excuse:P

Edit: Rather than make a new post, I'll ask here. Is there an active IRC channel for gamemaker users? I've taken a look in the GMChat channel (forget which server it was) and it is always empty, other than what seems to be a bot.

Last edited by Wargasmic (2010-01-15 18:02:04)

Offline

#26 2012-02-24 19:51:28

icuurd12b42
Member
Registered: 2008-12-11
Posts: 303

Re: UV Hijinks - Smoke and Mirrors

I dont know if anyone has the courage to help me fix this

http://www.host-a.net/u/icuurd12b42/SurfaceEffects.gmk

OK, this is a "componentized" of my implementation of that flow field I posted above a while back.

The idea was to create a component that would use GM's editor feature and a few functions to enable people to have effects on the scree for a particular region. Say a campfire effect could possibly be created with some twaking.

Well anyway, to start with, I decided to simply do the recurring draw model over same surface like that flow method I have posted.

I use paths instead of the spline in that example.

I have a grid like mesh model that draws over the surface and the UVs define the motion of the flow using path. It's prety well documented in the readme script.

But I hit this really odd behavior.  If you use a path that goes straight up or down the effect works like the initial example. but if the path if straight left to right, I get garbage or sometimes, depending on the coord of the path, I get no motion. On a 45 degree upper left to lower right path I get garbage. like some triangles are not included when it comes to the __dx calculation but included for the __dy. (tilt)

I debugged a few places and I simply cant figure out why this is happening

Is there a courageous soul that can take a look. You know how it is when you try to figure out a brain fart in your own code.... you never see it.

Offline

Board footer

Powered by FluxBB