Urho3D/bin/CoreData/Shaders/GLSL/Basic.glsl
2015-03-16 23:36:35 +02:00

54 lines
1.2 KiB
GLSL

#include "Uniforms.glsl"
#include "Samplers.glsl"
#include "Transform.glsl"
#if defined(DIFFMAP) || defined(ALPHAMAP)
varying vec2 vTexCoord;
#endif
#ifdef VERTEXCOLOR
varying vec4 vColor;
#endif
void VS()
{
mat4 modelMatrix = iModelMatrix;
vec3 worldPos = GetWorldPos(modelMatrix);
gl_Position = GetClipPos(worldPos);
#ifdef DIFFMAP
vTexCoord = iTexCoord;
#endif
#ifdef VERTEXCOLOR
vColor = iColor;
#endif
}
void PS()
{
vec4 diffColor = cMatDiffColor;
#ifdef VERTEXCOLOR
diffColor *= vColor;
#endif
#if (!defined(DIFFMAP)) && (!defined(ALPHAMAP))
gl_FragColor = diffColor;
#endif
#ifdef DIFFMAP
vec4 diffInput = texture2D(sDiffMap, vTexCoord);
#ifdef ALPHAMASK
if (diffInput.a < 0.5)
discard;
#endif
gl_FragColor = diffColor * diffInput;
#endif
#ifdef ALPHAMAP
#ifdef GL3
float alphaInput = texture2D(sDiffMap, vTexCoord).r;
#else
float alphaInput = texture2D(sDiffMap, vTexCoord).a;
#endif
gl_FragColor = vec4(diffColor.rgb, diffColor.a * alphaInput);
#endif
}