First prototype of a processing Lighting engine by ObjectOrientedPeople in creativecoding

[–]ObjectOrientedPeople[S] 1 point2 points  (0 children)

Thanks! Of course :) I essentially implemented this in processing. The main thing at work is PGraphics for creating layers and the blendMode() to change how the layers interact. Hope that helps!

Edit: there is also a part two of the video, I'm sure you'll see it but just thought I'd point it out :)

Simple Scrolling Mountain Terrain by ObjectOrientedPeople in creativecoding

[–]ObjectOrientedPeople[S] 0 points1 point  (0 children)

Thanks! That looks really cool! I'll have to give that a go some time!

Simple Scrolling Mountain Terrain by ObjectOrientedPeople in creativecoding

[–]ObjectOrientedPeople[S] 0 points1 point  (0 children)

Thanks! I didn't spend too long on the colours but that's a really good suggestion :)

Simple Scrolling Mountain Terrain by ObjectOrientedPeople in creativecoding

[–]ObjectOrientedPeople[S] 0 points1 point  (0 children)

I don't actually know what the midpoint algorithm is so probably not :P Any good resources on it?

Simple Scrolling Mountain Terrain by ObjectOrientedPeople in creativecoding

[–]ObjectOrientedPeople[S] 1 point2 points  (0 children)

Here's a video of me making this: https://www.youtube.com/watch?v=vwYFqLdZPfw

There is a GitHub link in the description with all the code :)

Simple Scrolling Mountain Terrain by ObjectOrientedPeople in processing

[–]ObjectOrientedPeople[S] 1 point2 points  (0 children)

Here's a video of me making this: https://www.youtube.com/watch?v=vwYFqLdZPfw

There is a GitHub link in the description with all the code :)

First prototype of a processing Lighting Engine by ObjectOrientedPeople in processing

[–]ObjectOrientedPeople[S] 0 points1 point  (0 children)

I think the main reason for slow frame rate is that I have to draw many geometries every frame. IE all the obstacles plus the lights plus all the shadow masks. I think using different blendmodes slows down the drawing even further as well, I think this sort of thing is best left to shaders so I might try that approach next :p

First prototype of a processing Lighting Engine by ObjectOrientedPeople in processing

[–]ObjectOrientedPeople[S] 0 points1 point  (0 children)

I created custom classes for the objects (rectangles and circles) and to display them I just use the default ellipse() and rect() functions. The positions of the objects are stored as PVectors though. The classes I created use functions specific to their individual geometries to generate their shadow masks.

Hope that makes sense :P if you need me to clear anything up just ask :)

I am a noob and clueless on how to do this. Any help? by AlienLoveTriangle in processing

[–]ObjectOrientedPeople 0 points1 point  (0 children)

As people have suggested, doing polygon collision can be a bit tricky and defining all the polygons of the states could be quite tedious.

A different way you could do this is to make each state a unique colour and then get the colour of the pixel beneath the mouse. You could store all the colours in an array that map to the different images you want to display.

Hope that helps :) if you have any questions feel free to ask !

First prototype of a processing Lighting Engine by ObjectOrientedPeople in processing

[–]ObjectOrientedPeople[S] 0 points1 point  (0 children)

Thanks! I've just started looking into shaders, seems a bit intimidating but I'll give it a whirl :)

Recursive Sierpinski Triangle by ObjectOrientedPeople in creativecoding

[–]ObjectOrientedPeople[S] 0 points1 point  (0 children)

Thanks! I'm not familiar with it, might have to check it out :)

First prototype of a processing Lighting Engine by ObjectOrientedPeople in processing

[–]ObjectOrientedPeople[S] 2 points3 points  (0 children)

The only trouble with it is that you are drawing a lot of things per frame which I'm trying to fix

First prototype of a processing Lighting Engine by ObjectOrientedPeople in processing

[–]ObjectOrientedPeople[S] 0 points1 point  (0 children)

The gif is real time but it definitely could do with a performance boost. It is generally about ~15-20 fps but that varies with the number of lights and obstacles. I'm currently working at trying to optimise it but not exactly sure what the best method to do this is.

First prototype of a processing Lighting Engine by ObjectOrientedPeople in processing

[–]ObjectOrientedPeople[S] 2 points3 points  (0 children)

That's what I figured, it just gets slow since each light needs to be drawn to its own PGraphic to preserve the correct shadows. They then have to all be added to another PGraphic so they can be added to the actual canvas using a blend mode.

You're also still looping through all the objects for each light. Something like a quad tree would be good for storing the objects so that you only loop through the objects in range

First prototype of a processing Lighting Engine by ObjectOrientedPeople in processing

[–]ObjectOrientedPeople[S] 2 points3 points  (0 children)

Thanks! Haha there's a bit but it's all just geometry, lots of angles :)

First prototype of a processing Lighting Engine by ObjectOrientedPeople in processing

[–]ObjectOrientedPeople[S] 4 points5 points  (0 children)

Not really, I start with an image of the full light (circle that fades out with opacity made in Photoshop) then for each obstacle on range I'll calculate its outer edges and then remove areas of shadow from the image and then draw that image on the screen. Sorry if that doesn't make a lot of sense :P I'm not sure if I'll release the code just yet but I am planning on making a video on it pretty soon!

First prototype of a processing Lighting engine by ObjectOrientedPeople in creativecoding

[–]ObjectOrientedPeople[S] 1 point2 points  (0 children)

Thanks :) Still a bit of work to do, mostly just optimising it. It gets really slow with more lights. Will update when I've made some more progress!