first commit

This commit is contained in:
2019-12-30 17:23:05 +01:00
commit 7fe19ee89f
1149 changed files with 271279 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
uniform vec4 Color;
uniform vec3 CameraPosition;
uniform vec4 Position;
uniform float ScalingFactor;
uniform float MaximumDistance;
varying vec4 vertexColor;
void main(void) {
vertexColor = Color;
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
}

View File

@@ -0,0 +1,27 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
varying vec4 vertexColor;
void main(void) {
vertexColor = gl_Color;
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
}

View File

@@ -0,0 +1,28 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
varying vec4 vertexColor;
void main(void) {
vertexColor = gl_Color;
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
}

24
tb/shader/Compass.fragsh Normal file
View File

@@ -0,0 +1,24 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
void main() {
gl_FragColor = gl_Color;
}

47
tb/shader/Compass.vertsh Normal file
View File

@@ -0,0 +1,47 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
uniform vec3 CameraPosition;
uniform vec3 LightDirection;
uniform vec4 LightDiffuse;
uniform vec4 LightSpecular;
uniform vec4 MaterialDiffuse;
uniform vec4 MaterialAmbient;
uniform vec4 MaterialSpecular;
uniform float MaterialShininess;
uniform vec4 GlobalAmbient;
void main(void) {
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
float NdotL = max(dot(normal, LightDirection), 0.0); // cosine of normal and light direction
vec4 diffuse = NdotL * LightDiffuse * MaterialDiffuse;
vec4 ambient = GlobalAmbient * MaterialAmbient;
vec3 eyeVector = normalize(CameraPosition - gl_Vertex.xyz);
vec3 halfVector = normalize(eyeVector - LightDirection);
float NdotHV = max(-dot(normal, halfVector), 0.0);
vec4 specular = MaterialSpecular * LightSpecular * pow(NdotHV, MaterialShininess);
gl_FrontColor = vec4((diffuse + ambient + specular).xyz, 1.0);
}

View File

@@ -0,0 +1,27 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
uniform vec4 Color;
void main(void) {
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
gl_FrontColor = Color;
}

View File

@@ -0,0 +1,31 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
uniform float MaxDistance;
uniform float Alpha;
varying float distanceFromCamera;
varying vec4 color;
void main() {
float scale = (1.0 - clamp(distanceFromCamera / MaxDistance * 0.2 + 0.25, 0.0, 1.0));// * 0.35 + 0.65);
gl_FragColor = vec4(color.rgb, color.a * scale * Alpha);
}

View File

@@ -0,0 +1,31 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
uniform vec3 CameraPosition;
varying float distanceFromCamera;
varying vec4 color;
void main(void) {
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
distanceFromCamera = length(CameraPosition - gl_Vertex.xyz);
color = gl_Color;
}

View File

@@ -0,0 +1,31 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
uniform float MaxDistance;
uniform float Alpha;
varying float distanceFromCamera;
varying vec4 color;
void main() {
float scale = (1.0 - clamp(distanceFromCamera / MaxDistance * 0.2 + 0.25, 0.0, 1.0));// * 0.35 + 0.65);
gl_FragColor = vec4(color.rgb, color.a * scale * Alpha);
}

View File

@@ -0,0 +1,151 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
uniform vec3 CameraPosition;
varying float distanceFromCamera;
varying vec4 color;
const float almostZero = 0.001;
struct Quat {
float r;
vec3 v;
};
Quat setRotation(vec3 axis, float angle) {
Quat quat;
quat.r = cos(angle / 2.0f);
quat.v = axis * sin(angle / 2.0f);
return quat;
}
bool eqEpsilon(float a, float b, float epsilon) {
return abs(a - b) < epsilon;
}
/**
* Creates a new quaternion that rotates the 1st given vector onto the 2nd given vector. Both vectors are
* expected to be normalized.
*/
Quat makeQuat(vec3 from, vec3 to) {
float cosAngle = dot(from, to);
// check for `from` and `to` equal
if (eqEpsilon(cosAngle, 1.0, almostZero)) {
return setRotation(vec3(0.0, 0.0, 1.0), 0.0);
}
// check for `from` and `to` opposite
if (eqEpsilon(cosAngle, -1.0, almostZero)) {
// need to find a rotation axis that is perpendicular to `from`
vec3 axis = cross(from, vec3(0.0, 0.0, 1.0));
if (dot(axis, axis) < 0.01) {
axis = cross(from, vec3(1.0, 0.0, 0.0));
}
return setRotation(normalize(axis), radians(180.0));
}
vec3 axis = normalize(cross(from, to));
float angle = acos(cosAngle);
return setRotation(axis, angle);
}
Quat quatMult(Quat left, Quat right) {
float t = right.r;
vec3 w = right.v;
float nx = left.r * w.x + t * left.v.x + left.v.y * w.z - left.v.z * w.y;
float ny = left.r * w.y + t * left.v.y + left.v.z * w.x - left.v.x * w.z;
float nz = left.r * w.z + t * left.v.z + left.v.x * w.y - left.v.y * w.x;
Quat result;
result.r = left.r * t - dot(left.v, w);
result.v[0] = nx;
result.v[1] = ny;
result.v[2] = nz;
return result;
}
Quat conjugated(Quat left) {
Quat result;
result.r = left.r;
result.v = -left.v;
return result;
}
vec3 quatMult(Quat left, vec3 right) {
Quat p;
p.r = 0.0;
p.v = right;
p = quatMult(quatMult(left, p), conjugated(left));
return p.v;
}
/**
Computes the CCW angle between axis and vector in relation to the given up vector.
All vectors are expected to be normalized.
*/
float measureAngle(vec3 vec, vec3 axis, vec3 up) {
float cosAngle = dot(vec, axis);
if (eqEpsilon(+cosAngle, 1.0, almostZero)) {
return 0.0;
}
if (eqEpsilon(-cosAngle, 1.0, almostZero)) {
return radians(180.0);
}
vec3 crossProd = cross(axis, vec);
if (dot(crossProd, up) > -almostZero) {
return acos(cosAngle);
}
return radians(360.0) - acos(cosAngle);
}
void main(void) {
// TODO: use user-defined attributes for these
vec3 arrowPosition = gl_MultiTexCoord0.xyz;
vec3 lineDir = gl_MultiTexCoord1.xyz;
Quat rotateFromPosXToLineDir = makeQuat(vec3(1.0, 0.0, 0.0), lineDir);
// the above will point the arrow along the line, but we also want to roll it so it faces the camera.
// see: http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-17-quaternions/#how-do-i-find-the-rotation-between-2-vectors-
vec3 desiredUp = normalize(CameraPosition - arrowPosition);
vec3 desiredRight = cross(lineDir, desiredUp);
desiredUp = normalize(cross(desiredRight, lineDir)); // make desiredUp perpendicular to the lineDir
vec3 currentUp = quatMult(rotateFromPosXToLineDir, vec3(0.0, 0.0, 1.0));
// We want to specifically rotate about `lineDir` only, so can't use makeQuat() (which picks the rotation axis itself
// and could accidentally flip the arrow the wrong way instead of rolling it 180 degrees.)
Quat fixUp = setRotation(lineDir, -measureAngle(currentUp, desiredUp, lineDir));
distanceFromCamera = length(CameraPosition - arrowPosition);
// scale up as you get further away, to a maximum of 4x at 2048 units away
float scaleFactor = mix(1.0, 4.0, smoothstep(0.0, 2048.0, distanceFromCamera));
// now apply the scale, rotations, and translation to gl_Vertex
vec3 worldVert = arrowPosition + quatMult(quatMult(fixUp, rotateFromPosXToLineDir), gl_Vertex.xyz * scaleFactor);
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * vec4(worldVert, 1.0);
color = gl_Color;
}

View File

@@ -0,0 +1,49 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
uniform float Brightness;
uniform sampler2D Texture;
uniform bool ApplyTinting;
uniform vec4 TintColor;
uniform bool GrayScale;
void main() {
vec4 texel = texture2D(Texture, gl_TexCoord[0].st);
// Assume alpha masked or opaque.
// TODO: Make this optional if we gain support for translucent textures
if (texel.a < 0.5) {
discard;
}
gl_FragColor = vec4(vec3(Brightness / 2.0 * texel), texel.a);
gl_FragColor = clamp(2 * gl_FragColor, 0.0, 1.0);
if (GrayScale) {
float gray = dot(gl_FragColor.rgb, vec3(0.299, 0.587, 0.114));
gl_FragColor = vec4(gray, gray, gray, gl_FragColor.a);
}
if (ApplyTinting) {
gl_FragColor = vec4(gl_FragColor.rgb * TintColor.rgb * TintColor.a, gl_FragColor.a);
gl_FragColor = clamp(2.0 * gl_FragColor, 0.0, 1.0);
}
}

View File

@@ -0,0 +1,25 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
void main(void) {
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
}

107
tb/shader/Face.fragsh Normal file
View File

@@ -0,0 +1,107 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
uniform float Brightness;
uniform float Alpha;
uniform bool ApplyTexture;
uniform sampler2D Texture;
uniform bool ApplyTinting;
uniform vec4 TintColor;
uniform bool GrayScale;
uniform bool RenderGrid;
uniform float GridSize;
uniform float GridAlpha;
uniform vec3 GridColor;
uniform bool ShadeFaces;
uniform bool ShowFog;
varying vec4 modelCoordinates;
varying vec3 modelNormal;
varying vec4 faceColor;
varying vec3 viewVector;
float grid(vec3 coords, vec3 normal, float gridSize, float minGridSize, float lineWidthFactor);
void main() {
if (ApplyTexture)
gl_FragColor = texture2D(Texture, gl_TexCoord[0].st);
else
gl_FragColor = faceColor;
// Assume alpha masked or opaque.
// TODO: Make this optional if we gain support for translucent textures
if (gl_FragColor.a < 0.5) {
discard;
}
gl_FragColor = vec4(vec3(Brightness / 2.0 * gl_FragColor), gl_FragColor.a);
gl_FragColor = clamp(2.0 * gl_FragColor, 0.0, 1.0);
gl_FragColor.a = Alpha;
if (GrayScale) {
float gray = dot(gl_FragColor.rgb, vec3(0.299, 0.587, 0.114));
gl_FragColor = vec4(gray, gray, gray, gl_FragColor.a);
}
if (ApplyTinting) {
gl_FragColor = vec4(gl_FragColor.rgb * TintColor.rgb * TintColor.a, gl_FragColor.a);
float brightnessCorrection = 1.0 / max(max(abs(TintColor.r), abs(TintColor.g)), abs(TintColor.b));
gl_FragColor = clamp(brightnessCorrection * gl_FragColor, 0.0, 1.0);
}
if (ShadeFaces) {
// angular dimming ( can be controlled with dimStrength )
// TODO: make view option
float dimStrength = 0.25;
float angleDim = dot(normalize(viewVector), normalize(modelNormal)) * dimStrength + (1.0 - dimStrength);
gl_FragColor.rgb *= angleDim;
}
if (ShowFog) {
float distance = length(viewVector);
// TODO: make view options
vec3 fogColor = vec3(0.5, 0.5, 0.5);
float maxFogAmount = 0.15;
float fogBias = 0.0;
float fogScale = 0.00075;
float fogMinDistance = 512.0;
float fogFactor = max(distance - fogMinDistance, 0.0) * fogScale;
//gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, clamp(( gl_FragCoord.z / gl_FragCoord.w ) * fogScale + fogBias, 0.0, maxFogAmount ));
gl_FragColor.rgb = mix(gl_FragColor.rgb, fogColor, clamp(fogFactor + fogBias, 0.0, maxFogAmount));
}
if (RenderGrid && GridAlpha > 0.0) {
vec3 coords = modelCoordinates.xyz;
// get the maximum distance in world space between this and the neighbouring fragments
float maxWorldSpaceChange = max(length(dFdx(coords)), length(dFdy(coords)));
// apply the Nyquist theorem to get the smallest grid size that would make sense to render for this fragment
float minGridSize = 2.0 * maxWorldSpaceChange;
float gridValue = grid(coords, modelNormal.xyz, GridSize, minGridSize, 1.0);
gl_FragColor.rgb = mix(gl_FragColor.rgb, GridColor, gridValue * GridAlpha);
}
}

37
tb/shader/Face.vertsh Normal file
View File

@@ -0,0 +1,37 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
uniform vec4 Color;
uniform vec3 CameraPosition;
varying vec4 modelCoordinates;
varying vec3 modelNormal;
varying vec4 faceColor;
varying vec3 viewVector;
void main(void) {
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
modelCoordinates = gl_Vertex;
modelNormal = gl_Normal;
faceColor = Color;
viewVector = CameraPosition - gl_Vertex.xyz;
}

126
tb/shader/Grid.fragsh Normal file
View File

@@ -0,0 +1,126 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
float getSoftStripes(float value, float gridSize, float stripeSize) {
float mainVal = value * gridSize;
float filterWidth = fwidth(value);
float edge = filterWidth * gridSize * 2.0;
// major line shading, currently set to place a major line every 64 units
float mValue = 1.0 / (64.0 * gridSize);
float triMajor = abs(2.0 * fract(mainVal * mValue) - 1.0);
float isMajor = step(1.0 - mValue, triMajor);
float outIntensity = isMajor * 0.7 + 0.85; // tweak intensities here
float sSize = stripeSize;
float triangle = abs(2.0 * fract(mainVal) - 1.0);
return smoothstep(sSize - edge, sSize + edge, triangle) * outIntensity;
}
/**
* Draws two overlaid grids
*
* @param inCoords fragment coordinates (TODO: document units)
* @param gridRatio the reciprocal of the first grid size, e.g. (1/16) for a 16 unit grid
* @param gridRatio2 the reciprocal of the second grid size, e.g. (1/16) for a 16 unit grid
* @param lineWidth the line width (TODO: document units)
* @param gridBlend the fraction of the two grids to draw, between 0 and 1,
* where 0.0 means 100% of grid one, and 1.0 means 100% of grid two.
*/
float gridLinesSoft(vec2 inCoords, float gridRatio, float gridRatio2, float lineWidth, float gridBlend) {
float stripeRatio = lineWidth * gridRatio;
float stripeRatio2 = lineWidth * gridRatio2;
float stripeSize = 1.0 - stripeRatio;
float stripeSize2 = 1.0 - stripeRatio2;
float theGrid, nextGrid;
theGrid = getSoftStripes(inCoords.x, gridRatio, stripeSize);
theGrid = max(theGrid, getSoftStripes(inCoords.y, gridRatio, stripeSize));
nextGrid = getSoftStripes(inCoords.x, gridRatio2, stripeSize2);
nextGrid = max(nextGrid, getSoftStripes(inCoords.y, gridRatio2, stripeSize2));
theGrid = mix(theGrid, nextGrid, gridBlend);
return theGrid * 0.5;
}
/**
* Given a valid grid size, returns the next larger one.
*/
float gridNextLarger(float size) {
return 2.0 * size;
}
/**
* Given any size, finds the next smaller size that is a proper grid size.
* Returns the input unmodified if it's already a grid size.
*/
float gridFloor(float size) {
return exp2(floor(log2(size)));
}
/*
* Computes the grid for the current fragment with the given parameters.
*
* @param coords the coordinates of the fragment in world space (same units as gridSize)
* @param normal the normal vector of the fragment
* @param gridSize the actual size of the grid (e.g. 16, 32, 64, etc.)
* @param minGridSize the minimal grid size to render (to fade out smaller grids to prevent moire etc.)
* @param lineWidthFactor a factor for the line width of the grid
*
* @return opacity of the grid line to draw on this fragment, in [0..1]
*/
float grid(vec3 coords, vec3 normal, float gridSize, float minGridSize, float lineWidthFactor) {
float lineWidth = (gridSize < 1.0 ? (1.0 / 32.0)
: (gridSize < 4.0 ? 0.25 : 0.5)) * lineWidthFactor;
// magic number to make the grid fade sooner, preventing aliasing
float minGridSizeToRender = minGridSize * 2.0;
float baseGridSize = gridFloor(minGridSizeToRender);
if (gridSize > baseGridSize) {
baseGridSize = gridSize;
}
float nextGridSize = gridNextLarger(baseGridSize);
// This is 0 if we want to render just baseGridSize, and 1 if we want to fully render at nextGridSize
float gridBlend = smoothstep(baseGridSize, nextGridSize, minGridSizeToRender);
float gridRatio = 1.0 / baseGridSize;
float gridRatio2 = 1.0 / nextGridSize;
vec2 baseCoords; // coordinates used for overlay creation
if (abs(normal.x) > abs(normal.y)) {
if (abs(normal.x) > abs(normal.z))
baseCoords = coords.yz;
else
baseCoords = coords.xy;
} else if (abs(normal.y) > abs(normal.z)) {
baseCoords = coords.xz;
} else {
baseCoords = coords.xy;
}
return gridLinesSoft(baseCoords, gridRatio, gridRatio2, lineWidth, gridBlend);
}

41
tb/shader/Grid2D.fragsh Normal file
View File

@@ -0,0 +1,41 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
uniform bool RenderGrid;
uniform vec4 GridColor;
uniform float GridSize;
uniform float GridAlpha;
uniform float CameraZoom;
uniform vec3 Normal;
varying vec4 modelCoordinates;
float grid(vec3 coords, vec3 normal, float gridSize, float minGridSize, float lineWidthFactor);
void main() {
if (RenderGrid && GridAlpha > 0.0) {
float minGridSize = 5.0 / CameraZoom;
float lineWidthFactor = 2.0 / CameraZoom;
float gridValue = grid(modelCoordinates.xyz, Normal.xyz, GridSize, minGridSize, lineWidthFactor);
gl_FragColor = vec4(GridColor.xyz, gridValue * GridAlpha);
}
}

27
tb/shader/Grid2D.vertsh Normal file
View File

@@ -0,0 +1,27 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
varying vec4 modelCoordinates;
void main(void) {
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
modelCoordinates = gl_Vertex;
}

26
tb/shader/Handle.fragsh Normal file
View File

@@ -0,0 +1,26 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
varying vec4 vertexColor;
void main() {
gl_FragColor = vertexColor;
}

29
tb/shader/Handle.vertsh Normal file
View File

@@ -0,0 +1,29 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
uniform vec4 Color;
varying vec4 vertexColor;
void main(void) {
vertexColor = Color;
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
}

View File

@@ -0,0 +1,34 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
uniform vec4 Color;
uniform vec3 BoundsMin;
uniform vec3 BoundsMax;
varying vec4 vertexWorldPosition;
void main() {
gl_FragColor = Color;
if (any(lessThan(vertexWorldPosition.xyz, BoundsMin)) ||
any(greaterThan(vertexWorldPosition.xyz, BoundsMax)))
gl_FragColor.a = 0.05;
}

View File

@@ -0,0 +1,27 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
varying vec4 vertexWorldPosition;
void main(void) {
vertexWorldPosition = gl_Vertex;
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
}

28
tb/shader/Text.fragsh Normal file
View File

@@ -0,0 +1,28 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
varying vec4 vertexColor;
uniform sampler2D Texture;
void main() {
vec4 texel = texture2D(Texture, gl_TexCoord[0].st);
gl_FragColor = vec4(vertexColor.r, vertexColor.g, vertexColor.b, vertexColor.a * texel.r);
}

30
tb/shader/Text.vertsh Normal file
View File

@@ -0,0 +1,30 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
uniform vec4 Color;
varying vec4 vertexColor;
void main(void) {
vertexColor = Color;
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
}

View File

@@ -0,0 +1,26 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
varying vec4 vertexColor;
void main() {
gl_FragColor = vertexColor;
}

View File

@@ -0,0 +1,27 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
varying vec4 vertexColor;
void main(void) {
vertexColor = gl_Color;
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
}

View File

@@ -0,0 +1,43 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
uniform float Brightness;
uniform sampler2D Texture;
uniform bool ApplyTinting;
uniform vec4 TintColor;
uniform bool GrayScale;
void main() {
gl_FragColor = texture2D(Texture, gl_TexCoord[0].st);
gl_FragColor = vec4(vec3(Brightness / 2.0 * gl_FragColor), gl_FragColor.a);
gl_FragColor = clamp(2.0 * gl_FragColor, 0.0, 1.0);
if (GrayScale) {
float gray = dot(gl_FragColor.rgb, vec3(0.299, 0.587, 0.114));
gl_FragColor = vec4(gray, gray, gray, gl_FragColor.a);
}
if (ApplyTinting) {
gl_FragColor = vec4(gl_FragColor.rgb * TintColor.rgb * TintColor.a, gl_FragColor.a);
gl_FragColor = clamp(2.0 * gl_FragColor, 0.0, 1.0);
}
}

View File

@@ -0,0 +1,25 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
void main(void) {
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
}

View File

@@ -0,0 +1,26 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
varying vec4 vertexColor;
void main() {
gl_FragColor = vertexColor;
}

View File

@@ -0,0 +1,27 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
varying vec4 vertexColor;
void main(void) {
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
vertexColor = gl_Color;
}

42
tb/shader/Triangle.fragsh Normal file
View File

@@ -0,0 +1,42 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
uniform bool ApplyTinting;
uniform vec4 TintColor;
varying vec4 vertexColor;
varying vec3 modelNormal;
varying vec3 viewVector;
void main() {
gl_FragColor = vertexColor;
if (ApplyTinting) {
gl_FragColor = vec4(gl_FragColor.rgb * TintColor.rgb * TintColor.a, gl_FragColor.a);
gl_FragColor = clamp(2.0 * gl_FragColor, 0.0, 1.0);
}
// angular dimming ( can be controlled with dimStrength )
float dimStrength = 0.5;
float angleDim = dot(normalize(viewVector), normalize(modelNormal)) * dimStrength + (1.0 - dimStrength);
gl_FragColor.rgb *= angleDim;
}

38
tb/shader/Triangle.vertsh Normal file
View File

@@ -0,0 +1,38 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
uniform vec3 CameraPosition;
uniform vec4 Color;
uniform bool UseColor;
varying vec4 vertexColor;
varying vec3 modelNormal;
varying vec3 viewVector;
void main(void) {
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
if (UseColor)
vertexColor = Color;
else
vertexColor = gl_Color;
modelNormal = gl_Normal;
viewVector = CameraPosition - gl_Vertex.xyz;
}

113
tb/shader/UVView.fragsh Normal file
View File

@@ -0,0 +1,113 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
uniform float Brightness;
uniform bool ApplyTexture;
uniform sampler2D Texture;
uniform bool RenderGrid;
uniform vec2 GridSizes;
uniform vec4 GridColor;
uniform vec2 GridScales;
uniform mat4 GridMatrix;
uniform vec2 GridDivider;
uniform float CameraZoom;
varying vec4 modelCoordinates;
varying vec3 modelNormal;
varying vec4 faceColor;
// Returns a measure for the closeness of the given coord from the next grid line, where 1 means the coord is on a
// grid line and 0 means the coord is exactly between two adjacent grid lines.
float closeness(float coord, float gridSize) {
return abs(2.0 * fract(coord / gridSize) - 1.0);
}
float getSoftStripes(float coord, float gridDivider, float gridSize, float stripeSize) {
// size of the minor and major grids
float minorGridSize = gridSize / gridDivider;
float majorGridSize = gridSize;
// How close is the coord to the next major and minor grid lines?
float minorCloseness = closeness(coord, minorGridSize);
float majorCloseness = closeness(coord, majorGridSize);
float isMajor = step(1.0 - 1.0 / gridDivider, majorCloseness);
float outIntensity = isMajor * 0.9 + 0.65; // tweak intensities here
float edge = 2.0 * fwidth(coord) / minorGridSize;
return smoothstep(stripeSize - edge, stripeSize + edge, minorCloseness) * outIntensity;
}
void gridLinesSoft(vec2 inCoords) {
// the width of the grid lines, corrected by the texture scaling factors and the camera zoom level
vec2 lineWidths = abs(1.5 / GridScales / CameraZoom);
// the widths of each grid stripe
vec2 stripeWidths = GridSizes / GridDivider;
// ratio of the line widths and the stripe widths
vec2 stripeRatios = lineWidths / stripeWidths;
vec2 stripeSizes = 1.0 - stripeRatios;
float alpha = max(getSoftStripes(inCoords.x, GridDivider.x, GridSizes.x, stripeSizes.x),
getSoftStripes(inCoords.y, GridDivider.y, GridSizes.y, stripeSizes.y));
gl_FragColor.rgb = mix(gl_FragColor.rgb, GridColor.rgb, alpha * GridColor.a * 0.5);
}
void main() {
if (ApplyTexture)
gl_FragColor = texture2D(Texture, gl_TexCoord[0].st);
else
gl_FragColor = faceColor;
gl_FragColor = vec4(vec3(Brightness / 2.0 * gl_FragColor), gl_FragColor.a);
gl_FragColor = clamp(2.0 * gl_FragColor, 0.0, 1.0);
if (RenderGrid) {
// vec2 gridRatios = GridDivider / GridSizes;
// vec2 gridThickness = abs(1.5 / GridScales / CameraZoom);
vec4 texCoordinates = GridMatrix * modelCoordinates;
gridLinesSoft(texCoordinates.xy);
/*
float normX = abs(modelNormal.x);
float normY = abs(modelNormal.y);
float normZ = abs(modelNormal.z);
float gridThickness = GridSize < 4 ? 0.25 : 0.5;
float gridRatio = 1.0 / GridSize;
vec2 baseCoords; // coordinates used for overlay creation
if (normX > normY) {
if (normX > normZ)
baseCoords = modelCoordinates.yz;
else
baseCoords = modelCoordinates.xy;
} else if (normY > normZ) {
baseCoords = modelCoordinates.xz;
} else {
baseCoords = modelCoordinates.xy;
}
gridLinesSoft(baseCoords, gridRatio, gridThickness);
*/
}
}

34
tb/shader/UVView.vertsh Normal file
View File

@@ -0,0 +1,34 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
uniform vec4 Color;
varying vec4 modelCoordinates;
varying vec3 modelNormal;
varying vec4 faceColor;
void main(void) {
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
modelCoordinates = gl_Vertex;
modelNormal = gl_Normal;
faceColor = Color;
}

View File

@@ -0,0 +1,34 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
uniform bool ApplyTinting;
uniform vec4 TintColor;
varying vec4 vertexColor;
void main() {
gl_FragColor = vertexColor;
if (ApplyTinting) {
gl_FragColor = vec4(gl_FragColor.rgb * TintColor.rgb * TintColor.a, gl_FragColor.a);
gl_FragColor = clamp(2.0 * gl_FragColor, 0.0, 1.0);
}
}

View File

@@ -0,0 +1,27 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
varying vec4 vertexColor;
void main(void) {
vertexColor = gl_Color;
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
}

View File

@@ -0,0 +1,29 @@
#version 120
/*
Copyright (C) 2010-2017 Kristian Duske
This file is part of TrenchBroom.
TrenchBroom is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TrenchBroom is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
*/
uniform vec4 Color;
varying vec4 vertexColor;
void main(void) {
vertexColor = Color;
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
}