mirror of https://github.com/minetest/minetest.git
Remove use of engine sent texture tiling flags (no longer needed)
This commit is contained in:
parent
bcf38a2ad1
commit
b3a55c076e
|
@ -16,9 +16,6 @@ varying vec3 lightVec;
|
||||||
varying vec3 tsLightVec;
|
varying vec3 tsLightVec;
|
||||||
|
|
||||||
bool normalTexturePresent = false;
|
bool normalTexturePresent = false;
|
||||||
bool texTileableHorizontal = false;
|
|
||||||
bool texTileableVertical = false;
|
|
||||||
bool texSeamless = false;
|
|
||||||
|
|
||||||
const float e = 2.718281828459;
|
const float e = 2.718281828459;
|
||||||
const float BS = 10.0;
|
const float BS = 10.0;
|
||||||
|
@ -29,45 +26,6 @@ void get_texture_flags()
|
||||||
if (flags.r > 0.5) {
|
if (flags.r > 0.5) {
|
||||||
normalTexturePresent = true;
|
normalTexturePresent = true;
|
||||||
}
|
}
|
||||||
if (flags.g > 0.5) {
|
|
||||||
texTileableHorizontal = true;
|
|
||||||
}
|
|
||||||
if (flags.b > 0.5) {
|
|
||||||
texTileableVertical = true;
|
|
||||||
}
|
|
||||||
if (texTileableHorizontal && texTileableVertical) {
|
|
||||||
texSeamless = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vec2 validate_displacement(vec2 uv, vec2 ds, float dist)
|
|
||||||
{
|
|
||||||
if (texSeamless) {
|
|
||||||
uv += dist * ds;
|
|
||||||
} else if (texTileableVertical == false) {
|
|
||||||
vec2 uv2 = uv + dist * ds;
|
|
||||||
// limit vertical texure displacement
|
|
||||||
if ((uv.y + uv2.y) < 0.0) {
|
|
||||||
uv.y = 0.0;
|
|
||||||
} else if ((uv.y + uv2.y) > 1.999) {
|
|
||||||
uv.y = 0.999;
|
|
||||||
} else {
|
|
||||||
uv.y = uv2.y;
|
|
||||||
}
|
|
||||||
uv.x = uv2.x;
|
|
||||||
} else {
|
|
||||||
vec2 uv2 = uv + dist * ds;
|
|
||||||
// limit horizontal texure displacement
|
|
||||||
if ((uv.x + uv2.x) < 0.0) {
|
|
||||||
uv.x = 0.0;
|
|
||||||
} else if ((uv.x + uv2.x) > 1.999) {
|
|
||||||
uv.x = 0.999;
|
|
||||||
} else {
|
|
||||||
uv.x = uv2.x;
|
|
||||||
}
|
|
||||||
uv.y = uv2.y;
|
|
||||||
}
|
|
||||||
return uv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float intensity(vec3 color)
|
float intensity(vec3 color)
|
||||||
|
@ -77,11 +35,7 @@ float intensity(vec3 color)
|
||||||
|
|
||||||
float get_rgb_height(vec2 uv)
|
float get_rgb_height(vec2 uv)
|
||||||
{
|
{
|
||||||
if (texSeamless) {
|
return intensity(texture2D(baseTexture, uv).rgb);
|
||||||
return intensity(texture2D(baseTexture, uv).rgb);
|
|
||||||
} else {
|
|
||||||
return intensity(texture2D(baseTexture, clamp(uv, 0.0, 0.999)).rgb);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 get_normal_map(vec2 uv)
|
vec4 get_normal_map(vec2 uv)
|
||||||
|
@ -144,18 +98,13 @@ void main(void)
|
||||||
// Relief mapping
|
// Relief mapping
|
||||||
if (normalTexturePresent && area_enable_parallax > 0.0) {
|
if (normalTexturePresent && area_enable_parallax > 0.0) {
|
||||||
vec2 ds = eyeRay * PARALLAX_OCCLUSION_SCALE;
|
vec2 ds = eyeRay * PARALLAX_OCCLUSION_SCALE;
|
||||||
// offset the texture by maximum possible displacement,
|
|
||||||
// this will help align seamless and non seamless textures
|
|
||||||
uv -= ds;
|
|
||||||
float dist = find_intersection(uv, ds);
|
float dist = find_intersection(uv, ds);
|
||||||
uv = validate_displacement(uv, ds, dist);
|
uv += dist * ds;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
} else if (GENERATE_NORMALMAPS == 1 && area_enable_parallax > 0.0) {
|
} else if (GENERATE_NORMALMAPS == 1 && area_enable_parallax > 0.0) {
|
||||||
vec2 ds = eyeRay * PARALLAX_OCCLUSION_SCALE;
|
vec2 ds = eyeRay * PARALLAX_OCCLUSION_SCALE;
|
||||||
uv -= ds;
|
|
||||||
float dist = find_intersectionRGB(uv, ds);
|
float dist = find_intersectionRGB(uv, ds);
|
||||||
uv = validate_displacement(uv, ds, dist);
|
uv += dist * ds;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -14,22 +14,22 @@ varying vec3 eyeVec;
|
||||||
varying vec3 lightVec;
|
varying vec3 lightVec;
|
||||||
varying vec3 tsEyeVec;
|
varying vec3 tsEyeVec;
|
||||||
varying vec3 tsLightVec;
|
varying vec3 tsLightVec;
|
||||||
varying float area_enable_parallax;
|
varying float area_enable_parallax;
|
||||||
|
|
||||||
const float e = 2.718281828459;
|
const float e = 2.718281828459;
|
||||||
const float BS = 10.0;
|
const float BS = 10.0;
|
||||||
|
|
||||||
float smoothCurve(float x)
|
float smoothCurve(float x)
|
||||||
{
|
{
|
||||||
return x * x * (3.0 - 2.0 * x);
|
return x * x * (3.0 - 2.0 * x);
|
||||||
}
|
}
|
||||||
float triangleWave(float x)
|
float triangleWave(float x)
|
||||||
{
|
{
|
||||||
return abs(fract(x + 0.5) * 2.0 - 1.0);
|
return abs(fract(x + 0.5) * 2.0 - 1.0);
|
||||||
}
|
}
|
||||||
float smoothTriangleWave(float x)
|
float smoothTriangleWave(float x)
|
||||||
{
|
{
|
||||||
return smoothCurve(triangleWave(x)) * 2.0 - 1.0;
|
return smoothCurve(triangleWave(x)) * 2.0 - 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
|
@ -37,17 +37,17 @@ void main(void)
|
||||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||||
//TODO: make offset depending on view angle and parallax uv displacement
|
//TODO: make offset depending on view angle and parallax uv displacement
|
||||||
//thats for textures that doesnt align vertically, like dirt with grass
|
//thats for textures that doesnt align vertically, like dirt with grass
|
||||||
//gl_TexCoord[0].y += 0.008;
|
//gl_TexCoord[0].y += 0.008;
|
||||||
|
|
||||||
//Allow parallax/relief mapping only for certain kind of nodes
|
//Allow parallax/relief mapping only for certain kind of nodes
|
||||||
//Variable is also used to control area of the effect
|
//Variable is also used to control area of the effect
|
||||||
#if (DRAW_TYPE == NDT_NORMAL || DRAW_TYPE == NDT_LIQUID || DRAW_TYPE == NDT_FLOWINGLIQUID)
|
#if (DRAW_TYPE == NDT_NORMAL || DRAW_TYPE == NDT_LIQUID || DRAW_TYPE == NDT_FLOWINGLIQUID)
|
||||||
area_enable_parallax = 1.0;
|
area_enable_parallax = 1.0;
|
||||||
#else
|
#else
|
||||||
area_enable_parallax = 0.0;
|
area_enable_parallax = 0.0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ((MATERIAL_TYPE == TILE_MATERIAL_LIQUID_TRANSPARENT || MATERIAL_TYPE == TILE_MATERIAL_LIQUID_OPAQUE) && ENABLE_WAVING_WATER)
|
#if ((MATERIAL_TYPE == TILE_MATERIAL_LIQUID_TRANSPARENT || MATERIAL_TYPE == TILE_MATERIAL_LIQUID_OPAQUE) && ENABLE_WAVING_WATER)
|
||||||
vec4 pos = gl_Vertex;
|
vec4 pos = gl_Vertex;
|
||||||
pos.y -= 2.0;
|
pos.y -= 2.0;
|
||||||
|
|
||||||
|
@ -91,33 +91,33 @@ void main(void)
|
||||||
|
|
||||||
vPosition = gl_Position.xyz;
|
vPosition = gl_Position.xyz;
|
||||||
worldPosition = (mWorld * gl_Vertex).xyz;
|
worldPosition = (mWorld * gl_Vertex).xyz;
|
||||||
|
|
||||||
// Don't generate heightmaps when too far from the eye
|
// Don't generate heightmaps when too far from the eye
|
||||||
float dist = distance (vec3(0.0, 0.0 ,0.0), vPosition);
|
float dist = distance (vec3(0.0, 0.0 ,0.0), vPosition);
|
||||||
if (dist > 300.0) {
|
if (dist > 150.0) {
|
||||||
area_enable_parallax = 0.0;
|
area_enable_parallax = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 sunPosition = vec3 (0.0, eyePosition.y * BS + 900.0, 0.0);
|
vec3 sunPosition = vec3 (0.0, eyePosition.y * BS + 900.0, 0.0);
|
||||||
|
|
||||||
vec3 normal, tangent, binormal;
|
vec3 normal, tangent, binormal;
|
||||||
normal = normalize(gl_NormalMatrix * gl_Normal);
|
normal = normalize(gl_NormalMatrix * gl_Normal);
|
||||||
tangent = normalize(gl_NormalMatrix * gl_MultiTexCoord1.xyz);
|
tangent = normalize(gl_NormalMatrix * gl_MultiTexCoord1.xyz);
|
||||||
binormal = normalize(gl_NormalMatrix * gl_MultiTexCoord2.xyz);
|
binormal = normalize(gl_NormalMatrix * gl_MultiTexCoord2.xyz);
|
||||||
|
|
||||||
vec3 v;
|
vec3 v;
|
||||||
|
|
||||||
lightVec = sunPosition - worldPosition;
|
lightVec = sunPosition - worldPosition;
|
||||||
v.x = dot(lightVec, tangent);
|
v.x = dot(lightVec, tangent);
|
||||||
v.y = dot(lightVec, binormal);
|
v.y = dot(lightVec, binormal);
|
||||||
v.z = dot(lightVec, normal);
|
v.z = dot(lightVec, normal);
|
||||||
tsLightVec = normalize (v);
|
tsLightVec = normalize (v);
|
||||||
|
|
||||||
eyeVec = -(gl_ModelViewMatrix * gl_Vertex).xyz;
|
eyeVec = -(gl_ModelViewMatrix * gl_Vertex).xyz;
|
||||||
v.x = dot(eyeVec, tangent);
|
v.x = dot(eyeVec, tangent);
|
||||||
v.y = dot(eyeVec, binormal);
|
v.y = dot(eyeVec, binormal);
|
||||||
v.z = dot(eyeVec, normal);
|
v.z = dot(eyeVec, normal);
|
||||||
tsEyeVec = normalize (v);
|
tsEyeVec = normalize (v);
|
||||||
|
|
||||||
vec4 color;
|
vec4 color;
|
||||||
float day = gl_Color.r;
|
float day = gl_Color.r;
|
||||||
|
|
Loading…
Reference in New Issue