Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #version 330
- layout(location = 0) in vec3 in_position;
- layout(location = 1) in vec3 in_normal;
- layout(location = 2) in vec3 in_colour;
- out vec3 pass_colour;
- uniform mat4 mvpMatrix;
- uniform vec3 material1;
- uniform vec3 material2;
- vec3 decodeColourCode(float code){
- vec3 weights = vec3(0.0);
- weights.x = mod(code, 2.0);
- code = (code - weights.x) * 0.5;
- weights.y = mod(code, 2.0);
- weights.z = (code - weights.y) * 0.5;
- return weights;
- }
- vec3 customizeColour(vec2 colourData, vec3 materialColour){
- vec3 weights = decodeColourCode(colourData.x);
- vec3 result = materialColour + (weights * colourData.y);
- return clamp(result, 0.0, 1.0);
- }
- void main(void){
- gl_Position = mvpMatrix * vec4(in_position, 1.0);
- pass_colour = in_colour;
- if(colour.x < -1.5){
- colour = customizeColour(colour.yz, material2);
- }else if(colour.x < -0.5){
- colour = customizeColour(colour.yz, material1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement