Skip to content
Snippets Groups Projects
Commit 50145dda authored by Pascal Engeler's avatar Pascal Engeler
Browse files

Only one shader needed

parent 711f74d3
No related branches found
No related tags found
No related merge requests found
#version 410 core
out vec4 FragColor;
in vec4 vertexColor;
in float colorCoord;
in int colorOverridden;
uniform sampler1D colorscheme;
void main(){
if(colorOverridden == 1){
FragColor = vertexColor;
}
else{
FragColor = texture(colorscheme, colorCoord);
}
}
#version 410 core
layout (location = 0) in vec3 aPos;
out vec4 vertexColor;
out float colorCoord;
out int colorOverridden;
//perspective related uniforms
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
//Scale related uniforms
uniform float scale;
uniform float minZ;
uniform float maxZ;
uniform float bad_z_value;
//Cross section plots lines related uniforms
uniform int plotLinesEnabled;
uniform vec3 plotLineAlongX_color;
uniform vec3 plotLineAlongY_color;
uniform float plotLineAlongX_y;
uniform float plotLineAlongY_x;
uniform float plotLineHalfThickness;
void main(){
vec3 position = aPos;
if(aPos.z != bad_z_value){
position.z -= minZ;
position.z *= scale;
position.z += minZ;
}
else{
position.z = minZ - 0.5 * scale * (maxZ - minZ);
}
gl_Position = projection * view * model * vec4(position, 1.0);
colorCoord = (aPos.z - minZ)/(maxZ-minZ);
vertexColor = vec4(position.z, 0.0, 0.0, 1.);
colorOverridden = 0;
//Check if on cross section line
if(plotLinesEnabled == 1){
if(abs(position.x - plotLineAlongY_x) < plotLineHalfThickness){
colorOverridden = 1;
vertexColor = vec4(plotLineAlongY_color, 1.);
}
else if(abs(position.y - plotLineAlongX_y) < plotLineHalfThickness){
colorOverridden = 1;
vertexColor = vec4(plotLineAlongX_color, 1.);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment