How To Use GLSL shaders to Video Filter/Manipulation in Android












0















I am Working on video Processing Android Project As My School Project. I have Search on Google About Video Processing . And Found That most of the developers use GLSL file for manipulation video/image in android. they use vector Shaders and fragment shaders but i didn't unsderstand that code. Can any one explain glsl code.



I didn't get this code:



precision highp float;
uniform sampler2D inputImageTexture;
uniform sampler2D inputImageTexture2;
varying vec2 textureCoordinate;
void main()
{
vec4 video = texture2D(inputImageTexture, textureCoordinate);
vec4 mv = texture2D(inputImageTexture2, textureCoordinate);
gl_FragColor = video + mv;
}




precision highp float;
uniform sampler2D inputImageTexture;
uniform sampler2D inputImageTexture2;
uniform sampler2D inputImageTexture3;
varying highp vec2 blurCoordinates[5];

void main()
{
lowp vec4 sum = vec4(0.0);
sum += texture2D(inputImageTexture, blurCoordinates[0]) * 0.204164;
sum += texture2D(inputImageTexture, blurCoordinates[1]) * 0.304005;
sum += texture2D(inputImageTexture, blurCoordinates[2]) * 0.304005;
sum += texture2D(inputImageTexture, blurCoordinates[3]) * 0.093913;
sum += texture2D(inputImageTexture, blurCoordinates[4]) * 0.093913;
vec3 texel = texture2D(inputImageTexture, blurCoordinates[0]).rgb;
vec2 tc = (2.0 * blurCoordinates[0]) - 1.0;
float d = dot(tc, tc);
vec2 lookup = vec2(d, texel.r);
texel.r = texture2D(inputImageTexture3, lookup).r;
lookup.y = texel.g;
texel.g = texture2D(inputImageTexture3, lookup).g;
lookup.y = texel.b;
texel.b = texture2D(inputImageTexture3, lookup).b;
vec2 red = vec2(texel.r, 0.16666);
vec2 green = vec2(texel.g, 0.5);
vec2 blue = vec2(texel.b, .83333);
float r = texture2D(inputImageTexture2, red).r;
float g = texture2D(inputImageTexture2, green).g;
float b = texture2D(inputImageTexture2, blue).b;
lowp vec4 sharpImageColor = vec4(r,g,b,1.0);
lowp vec4 blurredImageColor = sum;
highp float distanceFromCenter = distance(vec2(0.5,0.5), blurCoordinates[0]);
gl_FragColor = mix(sharpImageColor, blurredImageColor, smoothstep(0.4, 0.5, distanceFromCenter));
}


and i didn't get how to use this code in android










share|improve this question

























  • You have to ask a more specific question, this is far to broad. What have you tried so far? Where are you struggling? Please read How do I ask a good question? and How to create a Minimal, Complete, and Verifiable example.

    – Rabbid76
    Jan 19 at 10:14











  • i have found on Web. that developer using Javascript file to animation of view and for that they use GLSL vertex and fargement in Json File and but i m not getting how they pass image glsl or video to glsl and how they execute glsl code

    – Memu Play
    Jan 19 at 12:21











  • So you're searching for a tutorial? For javascript and WebGL: WebGL Fundamentals and WebGL2 Fundamentals

    – Rabbid76
    Jan 19 at 12:25
















0















I am Working on video Processing Android Project As My School Project. I have Search on Google About Video Processing . And Found That most of the developers use GLSL file for manipulation video/image in android. they use vector Shaders and fragment shaders but i didn't unsderstand that code. Can any one explain glsl code.



I didn't get this code:



precision highp float;
uniform sampler2D inputImageTexture;
uniform sampler2D inputImageTexture2;
varying vec2 textureCoordinate;
void main()
{
vec4 video = texture2D(inputImageTexture, textureCoordinate);
vec4 mv = texture2D(inputImageTexture2, textureCoordinate);
gl_FragColor = video + mv;
}




precision highp float;
uniform sampler2D inputImageTexture;
uniform sampler2D inputImageTexture2;
uniform sampler2D inputImageTexture3;
varying highp vec2 blurCoordinates[5];

void main()
{
lowp vec4 sum = vec4(0.0);
sum += texture2D(inputImageTexture, blurCoordinates[0]) * 0.204164;
sum += texture2D(inputImageTexture, blurCoordinates[1]) * 0.304005;
sum += texture2D(inputImageTexture, blurCoordinates[2]) * 0.304005;
sum += texture2D(inputImageTexture, blurCoordinates[3]) * 0.093913;
sum += texture2D(inputImageTexture, blurCoordinates[4]) * 0.093913;
vec3 texel = texture2D(inputImageTexture, blurCoordinates[0]).rgb;
vec2 tc = (2.0 * blurCoordinates[0]) - 1.0;
float d = dot(tc, tc);
vec2 lookup = vec2(d, texel.r);
texel.r = texture2D(inputImageTexture3, lookup).r;
lookup.y = texel.g;
texel.g = texture2D(inputImageTexture3, lookup).g;
lookup.y = texel.b;
texel.b = texture2D(inputImageTexture3, lookup).b;
vec2 red = vec2(texel.r, 0.16666);
vec2 green = vec2(texel.g, 0.5);
vec2 blue = vec2(texel.b, .83333);
float r = texture2D(inputImageTexture2, red).r;
float g = texture2D(inputImageTexture2, green).g;
float b = texture2D(inputImageTexture2, blue).b;
lowp vec4 sharpImageColor = vec4(r,g,b,1.0);
lowp vec4 blurredImageColor = sum;
highp float distanceFromCenter = distance(vec2(0.5,0.5), blurCoordinates[0]);
gl_FragColor = mix(sharpImageColor, blurredImageColor, smoothstep(0.4, 0.5, distanceFromCenter));
}


and i didn't get how to use this code in android










share|improve this question

























  • You have to ask a more specific question, this is far to broad. What have you tried so far? Where are you struggling? Please read How do I ask a good question? and How to create a Minimal, Complete, and Verifiable example.

    – Rabbid76
    Jan 19 at 10:14











  • i have found on Web. that developer using Javascript file to animation of view and for that they use GLSL vertex and fargement in Json File and but i m not getting how they pass image glsl or video to glsl and how they execute glsl code

    – Memu Play
    Jan 19 at 12:21











  • So you're searching for a tutorial? For javascript and WebGL: WebGL Fundamentals and WebGL2 Fundamentals

    – Rabbid76
    Jan 19 at 12:25














0












0








0








I am Working on video Processing Android Project As My School Project. I have Search on Google About Video Processing . And Found That most of the developers use GLSL file for manipulation video/image in android. they use vector Shaders and fragment shaders but i didn't unsderstand that code. Can any one explain glsl code.



I didn't get this code:



precision highp float;
uniform sampler2D inputImageTexture;
uniform sampler2D inputImageTexture2;
varying vec2 textureCoordinate;
void main()
{
vec4 video = texture2D(inputImageTexture, textureCoordinate);
vec4 mv = texture2D(inputImageTexture2, textureCoordinate);
gl_FragColor = video + mv;
}




precision highp float;
uniform sampler2D inputImageTexture;
uniform sampler2D inputImageTexture2;
uniform sampler2D inputImageTexture3;
varying highp vec2 blurCoordinates[5];

void main()
{
lowp vec4 sum = vec4(0.0);
sum += texture2D(inputImageTexture, blurCoordinates[0]) * 0.204164;
sum += texture2D(inputImageTexture, blurCoordinates[1]) * 0.304005;
sum += texture2D(inputImageTexture, blurCoordinates[2]) * 0.304005;
sum += texture2D(inputImageTexture, blurCoordinates[3]) * 0.093913;
sum += texture2D(inputImageTexture, blurCoordinates[4]) * 0.093913;
vec3 texel = texture2D(inputImageTexture, blurCoordinates[0]).rgb;
vec2 tc = (2.0 * blurCoordinates[0]) - 1.0;
float d = dot(tc, tc);
vec2 lookup = vec2(d, texel.r);
texel.r = texture2D(inputImageTexture3, lookup).r;
lookup.y = texel.g;
texel.g = texture2D(inputImageTexture3, lookup).g;
lookup.y = texel.b;
texel.b = texture2D(inputImageTexture3, lookup).b;
vec2 red = vec2(texel.r, 0.16666);
vec2 green = vec2(texel.g, 0.5);
vec2 blue = vec2(texel.b, .83333);
float r = texture2D(inputImageTexture2, red).r;
float g = texture2D(inputImageTexture2, green).g;
float b = texture2D(inputImageTexture2, blue).b;
lowp vec4 sharpImageColor = vec4(r,g,b,1.0);
lowp vec4 blurredImageColor = sum;
highp float distanceFromCenter = distance(vec2(0.5,0.5), blurCoordinates[0]);
gl_FragColor = mix(sharpImageColor, blurredImageColor, smoothstep(0.4, 0.5, distanceFromCenter));
}


and i didn't get how to use this code in android










share|improve this question
















I am Working on video Processing Android Project As My School Project. I have Search on Google About Video Processing . And Found That most of the developers use GLSL file for manipulation video/image in android. they use vector Shaders and fragment shaders but i didn't unsderstand that code. Can any one explain glsl code.



I didn't get this code:



precision highp float;
uniform sampler2D inputImageTexture;
uniform sampler2D inputImageTexture2;
varying vec2 textureCoordinate;
void main()
{
vec4 video = texture2D(inputImageTexture, textureCoordinate);
vec4 mv = texture2D(inputImageTexture2, textureCoordinate);
gl_FragColor = video + mv;
}




precision highp float;
uniform sampler2D inputImageTexture;
uniform sampler2D inputImageTexture2;
uniform sampler2D inputImageTexture3;
varying highp vec2 blurCoordinates[5];

void main()
{
lowp vec4 sum = vec4(0.0);
sum += texture2D(inputImageTexture, blurCoordinates[0]) * 0.204164;
sum += texture2D(inputImageTexture, blurCoordinates[1]) * 0.304005;
sum += texture2D(inputImageTexture, blurCoordinates[2]) * 0.304005;
sum += texture2D(inputImageTexture, blurCoordinates[3]) * 0.093913;
sum += texture2D(inputImageTexture, blurCoordinates[4]) * 0.093913;
vec3 texel = texture2D(inputImageTexture, blurCoordinates[0]).rgb;
vec2 tc = (2.0 * blurCoordinates[0]) - 1.0;
float d = dot(tc, tc);
vec2 lookup = vec2(d, texel.r);
texel.r = texture2D(inputImageTexture3, lookup).r;
lookup.y = texel.g;
texel.g = texture2D(inputImageTexture3, lookup).g;
lookup.y = texel.b;
texel.b = texture2D(inputImageTexture3, lookup).b;
vec2 red = vec2(texel.r, 0.16666);
vec2 green = vec2(texel.g, 0.5);
vec2 blue = vec2(texel.b, .83333);
float r = texture2D(inputImageTexture2, red).r;
float g = texture2D(inputImageTexture2, green).g;
float b = texture2D(inputImageTexture2, blue).b;
lowp vec4 sharpImageColor = vec4(r,g,b,1.0);
lowp vec4 blurredImageColor = sum;
highp float distanceFromCenter = distance(vec2(0.5,0.5), blurCoordinates[0]);
gl_FragColor = mix(sharpImageColor, blurredImageColor, smoothstep(0.4, 0.5, distanceFromCenter));
}


and i didn't get how to use this code in android







android image video glsl






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 19 at 6:30







Memu Play

















asked Jan 19 at 6:26









Memu PlayMemu Play

64




64













  • You have to ask a more specific question, this is far to broad. What have you tried so far? Where are you struggling? Please read How do I ask a good question? and How to create a Minimal, Complete, and Verifiable example.

    – Rabbid76
    Jan 19 at 10:14











  • i have found on Web. that developer using Javascript file to animation of view and for that they use GLSL vertex and fargement in Json File and but i m not getting how they pass image glsl or video to glsl and how they execute glsl code

    – Memu Play
    Jan 19 at 12:21











  • So you're searching for a tutorial? For javascript and WebGL: WebGL Fundamentals and WebGL2 Fundamentals

    – Rabbid76
    Jan 19 at 12:25



















  • You have to ask a more specific question, this is far to broad. What have you tried so far? Where are you struggling? Please read How do I ask a good question? and How to create a Minimal, Complete, and Verifiable example.

    – Rabbid76
    Jan 19 at 10:14











  • i have found on Web. that developer using Javascript file to animation of view and for that they use GLSL vertex and fargement in Json File and but i m not getting how they pass image glsl or video to glsl and how they execute glsl code

    – Memu Play
    Jan 19 at 12:21











  • So you're searching for a tutorial? For javascript and WebGL: WebGL Fundamentals and WebGL2 Fundamentals

    – Rabbid76
    Jan 19 at 12:25

















You have to ask a more specific question, this is far to broad. What have you tried so far? Where are you struggling? Please read How do I ask a good question? and How to create a Minimal, Complete, and Verifiable example.

– Rabbid76
Jan 19 at 10:14





You have to ask a more specific question, this is far to broad. What have you tried so far? Where are you struggling? Please read How do I ask a good question? and How to create a Minimal, Complete, and Verifiable example.

– Rabbid76
Jan 19 at 10:14













i have found on Web. that developer using Javascript file to animation of view and for that they use GLSL vertex and fargement in Json File and but i m not getting how they pass image glsl or video to glsl and how they execute glsl code

– Memu Play
Jan 19 at 12:21





i have found on Web. that developer using Javascript file to animation of view and for that they use GLSL vertex and fargement in Json File and but i m not getting how they pass image glsl or video to glsl and how they execute glsl code

– Memu Play
Jan 19 at 12:21













So you're searching for a tutorial? For javascript and WebGL: WebGL Fundamentals and WebGL2 Fundamentals

– Rabbid76
Jan 19 at 12:25





So you're searching for a tutorial? For javascript and WebGL: WebGL Fundamentals and WebGL2 Fundamentals

– Rabbid76
Jan 19 at 12:25












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54264634%2fhow-to-use-glsl-shaders-to-video-filter-manipulation-in-android%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54264634%2fhow-to-use-glsl-shaders-to-video-filter-manipulation-in-android%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Homophylophilia

Updating UILabel text programmatically using a function

Cloud Functions - OpenCV Videocapture Read method fails for larger files from cloud storage