Please help
How to treat pixels and image to make TWO mouse flashlight effects and avoid fucking up the whole image by going over the 255 RGB limit?
Please help
How to treat pixels and image to make TWO mouse flashlight effects and avoid fucking up the whole image by going over the 255 RGB limit?
Other urls found in this thread:
en.wikipedia.org
twitter.com
i managed to do it by multiplying twice, one per flashlight, and then dividing by -width.
but they go dark when they overlap. No idea how to fix that. Although i can work with this, but if anyone still wants to help, that'd be good
didn't unnderstand what you want but I'm sure I know how to do it
im trying to treat an image pixel by pixel, checking the distance between 2 reference points (say, one is the mouse, the other a random moving point) and each pixel of the image, therefore creating a flashlight effect as the closer pixels to each reference point have a brightness of 1.0 while the ones that are beyond a threshold go dark.
i managed to do all that, im just having trouble understanding how to add those two values without the RGB values going crazy. I used constraint, but it still went crazy until i did what the second post says. Only problem is it's going dark when they overlap
>im trying to treat an image pixel by pixel
How in image editor? Wth some program that opens file, edits it and saves edited copy? With some program with opengl canvas?
processing IDE
all this should happen in real time, the reference points would be blobs, meaning, people walking in a room
so you are writing image processing code?
um.. yea. It's very basic. Processing uses some sort of pseudo javascript btw.
i'm a begginer at programming in general, i'm sure most you can do this shit with your eyes closed
Are the rgb values wrapping around to low numbers? Like did you use mod 255 instead of maximum 255? Are you sure you used maximum 255 and not 0 somehow?
Anyway it sounds like your math is off somewhere, maybe try tracing your RGB values at each step to see what's up.
>fucking up the whole image by going over the 255 RGB limit
Maybe you are simply addimg values? If yes try something like this en.wikipedia.org
i'll check the RGB values and let you know in a minute
what's "mod 255"?
my workflow goes something like this
>grab RGB from each pixel
>compare to mouseXY
>map the distance (min 0, max 100, min 8, max 0) and multiply R, G and B by that value
>repeat with the other ref point
>divide by -width
>constrain RGB between 0,255
im pretty sure the mapping gives negative values or something that i wasn't counting on.
I dunno how to see the values since i can't println inside a FOR. If anything, i can check the last pixel's RGB, and they just show how it lights up and darkens when i can see it does.
i haven't tried to use alpha for this, i dunno if i can even understand that operation but i'll fool around with alpha for a while
Processing uses Java syntax. P5js is a parser for JavaScript into processing. I have experience in p5js, when i get home Ill help you.
thanks bro.
Can you draw or present somehow whats with the flashlight? Would help me understand what you actually want.
this is the full project with blobs and stuff. As you can see by the trail of the image(affected by the lightsource's position), it's only being light up from the right blob's position.
Now, i managed to have two lights working (on a side sketch so i don't fuckup my main project), but as they get closer to each other they darken, until going fully dark when overlapped.
desu my main project would kinda work with this overlapping bug, since overlapping blobs would just be counted as a single blob. But i'd like to make things right.
I also have another problem with storing more than one blob's position. I guess i should use arraylist to make a dynamic array that creates and deletes indexes as blobs come and go? haven't got around to it yet
Literally what the fuck is this?
You want to have two points, both of which will generate light yes? Or what? Or is this supposed to be first person perspective?
I can't understand what you are trying to do.
there's no perspective or 3D, it's a 2D image with pixel treatment so the distance between a certain point and EVERY PIXEL of the image is calculated and the closest to the certain point the pixel is, the brightest it is.
So it looks like a flashlight but there is no light, it's actually a brightness processing on a 2D image. In real time, with more than one "point" to calculate distance
So you have a square on a 2D plane, then you have a point on the same 2D plane. Now the square generates a 'shadow' of itself (gradually getting darker) in the opposite direction of the point. Does the shadow get shorter the closer the point is or is it constant 'length'?
it's like a gradient. These look dim as fuck but dont mind that, i can turn up the ammount of light if i wanted to.
The thing is, the closer each "point" gets to the other one, they both get darker, to the point of complete darkness when they overlap, and two full bright points when they're as further away as they can be
Oh now I understand. so it makes everything around the point visible gradually dimming it. Sort of like fog of war in games right?
Why not draw X (let's say 100) circles around the point (x,y) which will vary in opacity? From transparent to opaque at the end. And make everything else except the circle dark.
it would simplify the maths surely, but it would diminish my resolution. Althought the "using opacity" AKA alpha might do the trick.. i said i would try it and i forgot.
I'm on it now.
I managed to get something working where the two points generate some sort of ellipse, so the closest they get, the brightest and roundest, the further away, darker and thinner ellipse.
It's not what i wanted exactly but it'd work pretty well for what im doing. I just have to figure out a little color offset that i'm getting when there's more than 2 points.
I just applied the distance mapping like this:
>(r is carrying the image values before next line is applied)
>r += map(distance...)+ map(distance2...));
mapping the distances to 127, so they both add 255. And just in case i fuck up and go over 255, i can always rely on constrain before i updatePixels();
I'm still open for any guidance or opinions in case you all care, i have to keep working on this for a while yet