I am trying to render some part of the texture inside my quad using the shader and an object file (.pod) which is nothing but container format of holding the vertices, normals and UVs.
so, just imagine i made a simple quad using 3ds max and export it as .pod and load into my scene from world to MVP . it has UVs as (0,0)(1,0)(0,1)(1,1)
.. now I have a texture(.pvr) of 1024x128
pixels. I have sent all the data from cpp to vertex shader using appropriate buffers and everything is working fine.
Now question is, I want to render only some of the texture, lets say, starting from 200,30(left,bottom)
pixels to 500,100(width,height)
.
How can I achieve the above using the vertex shader. I have written some logic in vertex shader, which acc to me is working for (0,0)
coordinates, but how can I define height, width as there is only one vec2 variable. Below is the logic in vertex shader...
varying mediump vec2 TexCoord;
attribute mediump vec2 inTexCoord;
TexCoord.x = inTexCoord.x * (1024.0/(1024.0-200.0))-(200.0/1024.0);
TexCoord.y = inTexCoord.y * (128.0/(128.0-30.0))-(30.0/128.0);
same logic and values are working for all the UVs, Dont know how to mention height, width in it. and above code is doing some trick but not what I am expecting. it is repeating the texture inside the quad.
Instead I want to render only (200,30,500,100)(l,b,w,h)
part of the texture and that too inside the quad showing black boundary on the side of the quad from 0-127
pixels and 0-30
pixels from left and bottom respectively and black border from 629th
pixel to 1024
from right .
I am trying to make A video wall project where TVs will be rotated in diff diff angles.