mirror of
https://github.com/minetest/minetest.git
synced 2024-09-12 00:26:50 +02:00
Remove use of engine sent texture tiling flags - theyre no longer needed
This commit is contained in:
parent
5009d31a33
commit
8b8d17b22b
@ -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
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ void main(void)
|
|||||||
|
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,8 +385,7 @@ public:
|
|||||||
|
|
||||||
video::ITexture* getNormalTexture(const std::string &name);
|
video::ITexture* getNormalTexture(const std::string &name);
|
||||||
video::SColor getTextureAverageColor(const std::string &name);
|
video::SColor getTextureAverageColor(const std::string &name);
|
||||||
video::ITexture *getShaderFlagsTexture(
|
video::ITexture *getShaderFlagsTexture(bool normamap_present);
|
||||||
bool normamap_present, bool tileable_vertical, bool tileable_horizontal);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -2054,14 +2053,11 @@ video::SColor TextureSource::getTextureAverageColor(const std::string &name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
video::ITexture *TextureSource::getShaderFlagsTexture(
|
video::ITexture *TextureSource::getShaderFlagsTexture(bool normalmap_present)
|
||||||
bool normalmap_present, bool tileable_vertical, bool tileable_horizontal)
|
|
||||||
{
|
{
|
||||||
std::string tname = "__shaderFlagsTexture";
|
std::string tname = "__shaderFlagsTexture";
|
||||||
tname += normalmap_present ? "1" : "0";
|
tname += normalmap_present ? "1" : "0";
|
||||||
tname += tileable_horizontal ? "1" : "0";
|
|
||||||
tname += tileable_vertical ? "1" : "0";
|
|
||||||
|
|
||||||
if (isKnownSourceImage(tname)) {
|
if (isKnownSourceImage(tname)) {
|
||||||
return getTexture(tname);
|
return getTexture(tname);
|
||||||
} else {
|
} else {
|
||||||
@ -2069,11 +2065,7 @@ video::ITexture *TextureSource::getShaderFlagsTexture(
|
|||||||
video::IImage *flags_image = driver->createImage(
|
video::IImage *flags_image = driver->createImage(
|
||||||
video::ECF_A8R8G8B8, core::dimension2d<u32>(1, 1));
|
video::ECF_A8R8G8B8, core::dimension2d<u32>(1, 1));
|
||||||
sanity_check(flags_image != NULL);
|
sanity_check(flags_image != NULL);
|
||||||
video::SColor c(
|
video::SColor c(255, normalmap_present ? 255 : 0, 0, 0);
|
||||||
255,
|
|
||||||
normalmap_present ? 255 : 0,
|
|
||||||
tileable_horizontal ? 255 : 0,
|
|
||||||
tileable_vertical ? 255 : 0);
|
|
||||||
flags_image->setPixel(0, 0, c);
|
flags_image->setPixel(0, 0, c);
|
||||||
insertSourceImage(tname, flags_image);
|
insertSourceImage(tname, flags_image);
|
||||||
flags_image->drop();
|
flags_image->drop();
|
||||||
|
@ -113,8 +113,7 @@ public:
|
|||||||
const TextureFromMeshParams ¶ms)=0;
|
const TextureFromMeshParams ¶ms)=0;
|
||||||
virtual video::ITexture* getNormalTexture(const std::string &name)=0;
|
virtual video::ITexture* getNormalTexture(const std::string &name)=0;
|
||||||
virtual video::SColor getTextureAverageColor(const std::string &name)=0;
|
virtual video::SColor getTextureAverageColor(const std::string &name)=0;
|
||||||
virtual video::ITexture *getShaderFlagsTexture(bool normamap_present,
|
virtual video::ITexture *getShaderFlagsTexture(bool normalmap_present)=0;
|
||||||
bool tileable_vertical, bool tileable_horizontal)=0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class IWritableTextureSource : public ITextureSource
|
class IWritableTextureSource : public ITextureSource
|
||||||
@ -137,8 +136,7 @@ public:
|
|||||||
virtual void rebuildImagesAndTextures()=0;
|
virtual void rebuildImagesAndTextures()=0;
|
||||||
virtual video::ITexture* getNormalTexture(const std::string &name)=0;
|
virtual video::ITexture* getNormalTexture(const std::string &name)=0;
|
||||||
virtual video::SColor getTextureAverageColor(const std::string &name)=0;
|
virtual video::SColor getTextureAverageColor(const std::string &name)=0;
|
||||||
virtual video::ITexture *getShaderFlagsTexture(bool normamap_present,
|
virtual video::ITexture *getShaderFlagsTexture(bool normalmap_present)=0;
|
||||||
bool tileable_vertical, bool tileable_horizontal)=0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
IWritableTextureSource* createTextureSource(IrrlichtDevice *device);
|
IWritableTextureSource* createTextureSource(IrrlichtDevice *device);
|
||||||
@ -218,9 +216,7 @@ struct TileSpec
|
|||||||
alpha == other.alpha &&
|
alpha == other.alpha &&
|
||||||
material_type == other.material_type &&
|
material_type == other.material_type &&
|
||||||
material_flags == other.material_flags &&
|
material_flags == other.material_flags &&
|
||||||
rotation == other.rotation &&
|
rotation == other.rotation
|
||||||
(material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL) &&
|
|
||||||
(material_flags & MATERIAL_FLAG_TILEABLE_VERTICAL)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,12 +250,6 @@ struct TileSpec
|
|||||||
}
|
}
|
||||||
material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING)
|
material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING)
|
||||||
? true : false;
|
? true : false;
|
||||||
if (!(material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL)) {
|
|
||||||
material.TextureLayer[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
|
|
||||||
}
|
|
||||||
if (!(material_flags & MATERIAL_FLAG_TILEABLE_VERTICAL)) {
|
|
||||||
material.TextureLayer[0].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void applyMaterialOptionsWithShaders(video::SMaterial &material) const
|
void applyMaterialOptionsWithShaders(video::SMaterial &material) const
|
||||||
|
@ -1012,9 +1012,7 @@ void CNodeDefManager::fillTileAttribs(ITextureSource *tsrc, TileSpec *tile,
|
|||||||
if (use_normal_texture) {
|
if (use_normal_texture) {
|
||||||
tile->normal_texture = tsrc->getNormalTexture(tiledef->name);
|
tile->normal_texture = tsrc->getNormalTexture(tiledef->name);
|
||||||
}
|
}
|
||||||
tile->flags_texture = tsrc->getShaderFlagsTexture(
|
tile->flags_texture = tsrc->getShaderFlagsTexture(tile->normal_texture ? true : false);
|
||||||
tile->normal_texture ? true : false,
|
|
||||||
tiledef->tileable_vertical, tiledef->tileable_horizontal);
|
|
||||||
|
|
||||||
// Material flags
|
// Material flags
|
||||||
tile->material_flags = 0;
|
tile->material_flags = 0;
|
||||||
|
@ -302,7 +302,7 @@ void WieldMeshSceneNode::setExtruded(const std::string &imagename,
|
|||||||
material.setFlag(video::EMF_USE_MIP_MAPS, false);
|
material.setFlag(video::EMF_USE_MIP_MAPS, false);
|
||||||
#endif
|
#endif
|
||||||
if (m_enable_shaders) {
|
if (m_enable_shaders) {
|
||||||
material.setTexture(2, tsrc->getShaderFlagsTexture(false, true, true));
|
material.setTexture(2, tsrc->getShaderFlagsTexture(false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user