Showing posts with label glsl. Show all posts
Showing posts with label glsl. Show all posts

Thursday 27 October 2022

GLSL style textures with COPS

 Create a COP network.

Create a VOP Generator

Inside this, make a snippet.

below is an example of what you could do inside the texture. This fills the image with pink and has blue borders on the left and right side of the image. The Step function doesn't exist in vex, so I define it in the beginning. So at least functions are code-able. Annoyingly chf("blabla" aren't possible, but you can add parameter inputs to the node.
The bottom line is the important part. It assigns the red, green, blue and alpha to the output (you don't need to plug anything into the output nodes of the VOP network).

Instead of U and V, you have X and Y.
You can still do things like multiply X and the modulo it to achieve tiling. I need to test out things like matrix rotations next. Much excite

float step(float a, b){

float jog=0;

if(a<b){jog=1;

}

else{jog=0;}


return jog;

}


float are=step(0.1,X)*(1-step(0.9,X));


vector4 rgba=set(are,0,1,1);

assign(R,G,B,A,rgba);



ROTATION UPDATE

so I couldn't figure out the matrix stuff...but handily a maths site mentioned that the resultant x' and y'

were: x'= x*cos(angle)-y*sin(angle) AND y'=x*sin(angle)+y*cos(angle)

doing some crap maths in vex gives you this:

vector2 uv=set(X,Y);

vector2 uvN=uv;

uvN.x=uv.x*cos(angle)-uv.y*sin(angle);

uvN.y=uv.x*sin(angle)+uv.y*cos(angle);


so now when you use uvN for any coordinate references the image will be rotated! I think the pivot is broken though...so that's next on the list of things