davidedc / livecodelab

a web based livecoding environment
http://livecodelab.net/
MIT License
327 stars 63 forks source link

Textures and Images #218

Open noio opened 10 years ago

noio commented 10 years ago

Being able to not just color objects but texture them too would be really nice. LCL could have some 'stock' images included or load them from user-provided URL's. Basic patterns with some tinting/recoloring could give a huge array of options already.

Have you guys ever discussed something like this?

Another option would be to have a kind of texture-definition sublanguage:

material = 
    background red
    blue circle

Even crazier: http://threejs.org/examples/#webgl_materials_video, but kind of useless unless the user could load youtube videos or something.

P.S. I held off on posting a new issue until I fixed an old one, haha. :tophat:

davidedc commented 10 years ago

One option I'd like is to specify textures via fill so it would look like

fill "image.png" // image or shader name
box
noFill
fill "shaderName"
fillParams color(r,g,b,a), time, color(r,g,b), color(r,g,b,a) // this will be passed to the shader
tint color(r,g,b)
peg
noFill
ball
noTint
rect

of course one should be able to set a particular combination of fill image and tint via another function, and it should be possible to push/pop fills and tints in a state stack just like the matrix, so it's possible to have local materials.

So this would work: (in fact I'd like to get this to work just for standard fills quite soon, as the language already supports all of this apart from having the stack for the fills):

localMaterial = (drawingCode) ->
  pushFill
  pushTint
  fill "shaderName"
  drawingCode()
  popTint
  popFill

localMaterial <box peg 1.1 time rotate ball>
box // not affected by local material

localMaterial
  ...a bunch of code here...

peg // not affected by local material

(note that tint and noTint exist in processing, but we don't have them yet)

davidedc commented 10 years ago

p.s. localMaterial <box peg 1.1 time rotate ball> is just same as localMaterial -> box peg 1.1 time rotate ball

Richard-Mineall commented 9 years ago

hmm, this seems a little challenging but if people could get the embed code for a youtube video, it would be easy to display

xinaesthete commented 9 years ago

I thought there was an XSS restriction on loading data from other domains as texture.

Richard-Mineall commented 9 years ago

Oh, I forgot about that but if we could get images to work a video might, but it would need to be downloaded instead of put in as an embed code

On Tue, Feb 3, 2015 at 11:40 AM, Peter Todd notifications@github.com wrote:

I thought there was an XSS restriction on loading data from other domains as texture.

— Reply to this email directly or view it on GitHub https://github.com/davidedc/livecodelab/issues/218#issuecomment-72697036 .

xinaesthete commented 9 years ago

Yes I agree, video should be able to work and wouldn't be much more difficult in principle than images. If there were a server proxy, then YouTube etc could work as well.

I do heartily support the idea of supporting different shaders and think @davidedc's suggestion seems like a decent start. Would probably want to address shader uniforms by name.

My memory is that the materials were fairly buggy, doing fill colour with any reasonably complex program would start to go wrong pretty often in my experience. That may have improved with some of the recent changes I haven't kept up with... anyway, should be a separate issue really (maybe it already is).

xinaesthete commented 9 years ago

It could be that my experience with buggy materials were related to other material-related changes in my fork.

Richard-Mineall commented 9 years ago

An fps lock would be good for this it can't go up or down, that would definitely fix the problem, as well as any lag that is present

On Tue, Feb 3, 2015 at 11:57 AM, Peter Todd notifications@github.com wrote:

Yes I agree, video should be able to work and wouldn't be much more difficult in principle than images. If there were a server proxy, then YouTube etc could work as well.

I do heartily support the idea of supporting different shaders and think @davidedc https://github.com/davidedc's suggestion seems like a decent start. Would probably want to address shader uniforms by name.

My memory is that the materials were fairly buggy, doing fill colour with any reasonably complex program would start to go wrong pretty often in my experience. That may have improved with some of the recent changes I haven't kept up with... anyway, should be a separate issue really (maybe it already is).

— Reply to this email directly or view it on GitHub https://github.com/davidedc/livecodelab/issues/218#issuecomment-72700498 .

Richard-Mineall commented 9 years ago

With downloaded images and/or videos, it should be able to work, I don't think that it would be buggy as the image is already fully loaded on your computer. I think it wouldn't be necessary to lock the fps, except for crazy things like my flashing grid, so we should just put in .pdf file support, work on .gif files, and then try for videos, I might try a little experiment in a little copy of livecodelab I made for my computer, it's just a downloaded version of the website, but can be played offline, and I think it might run on tablets and things like Chromebooks, which is what I'm on right now, even offline, because the whole thing works offline (well, everything but the demos and tutorials)

Richard-Mineall commented 9 years ago

I think that we should be able to load images that we have downloaded to our computers by typing in the name that we have set for it on our computer, such as a picture I took of some braze welds I did I named it Welds and the file name is: "Welds.jpg" and by typing it in, it should load the image, and this might help with lag as well, as it is referencing a downloaded file instead of a file form the internet, and that negates the XSS restriction as well, Videos might work but It would definitely create lag, sounds might as well, but it would be a cool edition

On Tue, Feb 3, 2015 at 12:02 PM, Richard Layton < laytonrichard@students.pwssd.k12.wi.us> wrote:

An fps lock would be good for this it can't go up or down, that would definitely fix the problem, as well as any lag that is present

On Tue, Feb 3, 2015 at 11:57 AM, Peter Todd notifications@github.com wrote:

Yes I agree, video should be able to work and wouldn't be much more difficult in principle than images. If there were a server proxy, then YouTube etc could work as well.

I do heartily support the idea of supporting different shaders and think @davidedc https://github.com/davidedc's suggestion seems like a decent start. Would probably want to address shader uniforms by name.

My memory is that the materials were fairly buggy, doing fill colour with any reasonably complex program would start to go wrong pretty often in my experience. That may have improved with some of the recent changes I haven't kept up with... anyway, should be a separate issue really (maybe it already is).

— Reply to this email directly or view it on GitHub https://github.com/davidedc/livecodelab/issues/218#issuecomment-72700498 .

davidedc commented 9 years ago

sounds cool give it a shot!

Richard-Mineall commented 9 years ago

I'll do my best, my computer still has a problem running the master program

On Fri, Apr 24, 2015 at 8:10 AM, Davide Della Casa <notifications@github.com

wrote:

sounds cool give it a shot!

— Reply to this email directly or view it on GitHub https://github.com/davidedc/livecodelab/issues/218#issuecomment-95928969 .

Richard-Mineall commented 9 years ago

I made it work using the inspect element feature in chrome, It looks pretty good, and I even got a video to run on a sphere, I think I might be able to make it cinematic 3D as well, if we could add that in, but it will lag a little bit.

On Fri, Apr 24, 2015 at 11:01 AM, Richard Mineall Layton < laytonrichard@students.pwssd.k12.wi.us> wrote:

I'll do my best, my computer still has a problem running the master program

On Fri, Apr 24, 2015 at 8:10 AM, Davide Della Casa < notifications@github.com> wrote:

sounds cool give it a shot!

— Reply to this email directly or view it on GitHub https://github.com/davidedc/livecodelab/issues/218#issuecomment-95928969 .

davidedc commented 9 years ago

Great news man! Richard please do share the code here or on a gist, no matter how provisional it is... more hands make light work. If you put in a Gist I can help out and we can revision it there until we can merge something...

Richard-Mineall commented 9 years ago

All I did was replace one of the colors with a image file, and then with a video, It just needs to have the ability to reference it from the computers files, and I don't know exactly how to do that, but all that I did was put the .url from the image into the spot for one of the less useful colors and it worked with one that was downloaded, but not with one that wasn't downloaded, I thought I might be able to reference it directly from Google, but I couldn't, but you should be able to replicate what I did, sorry that I didn't save what I did before I replaced the hard drive on my computer.

On Wed, May 6, 2015 at 8:21 AM, Davide Della Casa notifications@github.com wrote:

Great news man! Richard please do share the code here or on a gist, no matter how provisional it is... more hands make light work. If you put in a Gist I can help out and we can revision it there until we can merge something...

— Reply to this email directly or view it on GitHub https://github.com/davidedc/livecodelab/issues/218#issuecomment-99456900 .

davidedc commented 9 years ago

pity that. Sounds simple enough, but I have zero time/focus to start this from scratch unfortunately. If you could re-build the example... it would really help to trampoline from something working...

Richard-Mineall commented 9 years ago

I'll see if I can get it working again, my computer is still being upgraded so I'm hoping I might be able to actually use the source code you provided me with, I'm modifying it with inspect element

On 5/6/15, Davide Della Casa notifications@github.com wrote:

pity that. Sounds simple enough, but I have zero time/focus to start this from scratch unfortunately. If you could re-build the example... it would really help to trampoline from something working...


Reply to this email directly or view it on GitHub: https://github.com/davidedc/livecodelab/issues/218#issuecomment-99471839

Richard Mineall Layton