I have four 1920 x 1080 PImage instances with alpha channel that I have to "blend" together at runtime on every frame.
You may be tempted to ask why - and I may be able to answer it but it could be a long explanation.
I thought about having a PImage and just "copy" the others into it on every frame. In Flash you can copy pixels from an image extremely fast. But it looks like copy() ignores the alpha channel. I have tried blend() and it is very slow.
I think I am misunderstanding how fragment shaders work. I thought that this shader would not do anything. Simply set the color of each pixel to whatever it was before:
I have been trying for days now to make a shader to fade out a PGraphics instance that I draw on top of my other graphics. I have never written a shader until now so I did some reading and looked at many examples. From what I read this should be very simple but I am not succeeding.
Here is my shader.
#define PROCESSING_TEXTURE_SHADER
uniform sampler2D texture;
varying vec4 vertColor;
varying vec4 vertTexCoord;
void main()
{
// Get the rgba value for the pixel
vec4 rgba = texture2D(texture, vertTexCoord.st);
// if it still has some alpha value then reduce it
if(rgba.a>0)
{
rgba.a-=.1;
}
gl_FragColor = rgba;
}
What happens is that the pixels never get totally transparent. Can you guys see what I am doing wrong in my shader?
Although I have experimented with Processing in the past I am only a beginner. I have been a Flash developer for many many years and I guess I am a bit spoiled because layer composition is so easy there.
I have browsed the internet for a solution to my problem but haven't found a good answer. I guess I am looking for the wrong things so I was hoping someone could help me. So here goes:
In Processing a common way to create a fade/trail is to draw a semitransparent rectangle over the sketch in every run. This is fine if you want everything to fade. I don't want that. I have a map in the background (full screen) and on top of that I am trying to draw graphics (full screen) that fades out over time, leaving a trail. I think I am supposed to use createGraphics() and create an off screen buffer for the graphic that I want to fade over time, and use the semitransparent trick on that graphic. Then I would use image() in the main draw loop to add the graphic on top of the map.
This works, but of course not quite. The semitransparent rectangle is exactly that - semi transparent - and therefor visible over the map.
Is there a simple and fast trick that I am missing when it comes to layering like this? I am sure it is not very effective to manipulate all the 1920x1080 pixels in the top layer and reducing the alpha over time.
I am working on a project that requires a variable speed in video playback. This can be achieved with Movie.speed(). I have two questions regarding it that I was hoping someone would shed a light on:
- What limits the maximum speed? For my HD video I see no speed difference once I go over speed(2). I can go from -2 up to 2 but anything outside that range does not do anything. Is this a CPU thing so smaller videos could go faster?
- What codec is best for a video that should play backwards and forwards at speeds up to maybe 10x. ( Matroska x264? )
I am wondering how you manage multiple versions of Processing on your computers? I have been doing some work in 1.5.1 but now, obviously, I want to start with 2.0b1. I have both versions in my C:Program FilesProcessing folder:
- processing-1.5.1
- processing-2.0b1
This works fine ofcourse.The problem is that the sketchbook location, as well as many preferences is stored in
C:USammiAppDataRoamingProcessingpreferences.txt and hence common for all versions of Processing.
Is there a way around this? Or should I not bother?