Skip to content

Commit 8b8d17b

Browse files
RealBadAngelest31
authored andcommitted
Remove use of engine sent texture tiling flags - theyre no longer needed
1 parent 5009d31 commit 8b8d17b

File tree

6 files changed

+13
-84
lines changed

6 files changed

+13
-84
lines changed

client/shaders/nodes_shader/opengl_fragment.glsl

+3-54
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ varying vec3 lightVec;
1616
varying vec3 tsLightVec;
1717

1818
bool normalTexturePresent = false;
19-
bool texTileableHorizontal = false;
20-
bool texTileableVertical = false;
21-
bool texSeamless = false;
2219

2320
const float e = 2.718281828459;
2421
const float BS = 10.0;
@@ -29,45 +26,6 @@ void get_texture_flags()
2926
if (flags.r > 0.5) {
3027
normalTexturePresent = true;
3128
}
32-
if (flags.g > 0.5) {
33-
texTileableHorizontal = true;
34-
}
35-
if (flags.b > 0.5) {
36-
texTileableVertical = true;
37-
}
38-
if (texTileableHorizontal && texTileableVertical) {
39-
texSeamless = true;
40-
}
41-
}
42-
43-
vec2 validate_displacement(vec2 uv, vec2 ds, float dist)
44-
{
45-
if (texSeamless) {
46-
uv += dist * ds;
47-
} else if (texTileableVertical == false) {
48-
vec2 uv2 = uv + dist * ds;
49-
// limit vertical texure displacement
50-
if ((uv.y + uv2.y) < 0.0) {
51-
uv.y = 0.0;
52-
} else if ((uv.y + uv2.y) > 1.999) {
53-
uv.y = 0.999;
54-
} else {
55-
uv.y = uv2.y;
56-
}
57-
uv.x = uv2.x;
58-
} else {
59-
vec2 uv2 = uv + dist * ds;
60-
// limit horizontal texure displacement
61-
if ((uv.x + uv2.x) < 0.0) {
62-
uv.x = 0.0;
63-
} else if ((uv.x + uv2.x) > 1.999) {
64-
uv.x = 0.999;
65-
} else {
66-
uv.x = uv2.x;
67-
}
68-
uv.y = uv2.y;
69-
}
70-
return uv;
7129
}
7230

7331
float intensity(vec3 color)
@@ -77,11 +35,7 @@ float intensity(vec3 color)
7735

7836
float get_rgb_height(vec2 uv)
7937
{
80-
if (texSeamless) {
81-
return intensity(texture2D(baseTexture, uv).rgb);
82-
} else {
83-
return intensity(texture2D(baseTexture, clamp(uv, 0.0, 0.999)).rgb);
84-
}
38+
return intensity(texture2D(baseTexture, uv).rgb);
8539
}
8640

8741
vec4 get_normal_map(vec2 uv)
@@ -144,18 +98,13 @@ void main(void)
14498
// Relief mapping
14599
if (normalTexturePresent && area_enable_parallax > 0.0) {
146100
vec2 ds = eyeRay * PARALLAX_OCCLUSION_SCALE;
147-
// offset the texture by maximum possible displacement,
148-
// this will help align seamless and non seamless textures
149-
uv -= ds;
150101
float dist = find_intersection(uv, ds);
151-
uv = validate_displacement(uv, ds, dist);
152-
102+
uv += dist * ds;
153103
#endif
154104
} else if (GENERATE_NORMALMAPS == 1 && area_enable_parallax > 0.0) {
155105
vec2 ds = eyeRay * PARALLAX_OCCLUSION_SCALE;
156-
uv -= ds;
157106
float dist = find_intersectionRGB(uv, ds);
158-
uv = validate_displacement(uv, ds, dist);
107+
uv += dist * ds;
159108
}
160109
#endif
161110

client/shaders/nodes_shader/opengl_vertex.glsl

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void main(void)
9494

9595
// Don't generate heightmaps when too far from the eye
9696
float dist = distance (vec3(0.0, 0.0 ,0.0), vPosition);
97-
if (dist > 300.0) {
97+
if (dist > 150.0) {
9898
area_enable_parallax = 0.0;
9999
}
100100

src/client/tile.cpp

+4-12
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,7 @@ class TextureSource : public IWritableTextureSource
385385

386386
video::ITexture* getNormalTexture(const std::string &name);
387387
video::SColor getTextureAverageColor(const std::string &name);
388-
video::ITexture *getShaderFlagsTexture(
389-
bool normamap_present, bool tileable_vertical, bool tileable_horizontal);
388+
video::ITexture *getShaderFlagsTexture(bool normamap_present);
390389

391390
private:
392391

@@ -2054,26 +2053,19 @@ video::SColor TextureSource::getTextureAverageColor(const std::string &name)
20542053
}
20552054

20562055

2057-
video::ITexture *TextureSource::getShaderFlagsTexture(
2058-
bool normalmap_present, bool tileable_vertical, bool tileable_horizontal)
2056+
video::ITexture *TextureSource::getShaderFlagsTexture(bool normalmap_present)
20592057
{
20602058
std::string tname = "__shaderFlagsTexture";
20612059
tname += normalmap_present ? "1" : "0";
2062-
tname += tileable_horizontal ? "1" : "0";
2063-
tname += tileable_vertical ? "1" : "0";
2064-
2060+
20652061
if (isKnownSourceImage(tname)) {
20662062
return getTexture(tname);
20672063
} else {
20682064
video::IVideoDriver *driver = m_device->getVideoDriver();
20692065
video::IImage *flags_image = driver->createImage(
20702066
video::ECF_A8R8G8B8, core::dimension2d<u32>(1, 1));
20712067
sanity_check(flags_image != NULL);
2072-
video::SColor c(
2073-
255,
2074-
normalmap_present ? 255 : 0,
2075-
tileable_horizontal ? 255 : 0,
2076-
tileable_vertical ? 255 : 0);
2068+
video::SColor c(255, normalmap_present ? 255 : 0, 0, 0);
20772069
flags_image->setPixel(0, 0, c);
20782070
insertSourceImage(tname, flags_image);
20792071
flags_image->drop();

src/client/tile.h

+3-13
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ class ITextureSource : public ISimpleTextureSource
113113
const TextureFromMeshParams &params)=0;
114114
virtual video::ITexture* getNormalTexture(const std::string &name)=0;
115115
virtual video::SColor getTextureAverageColor(const std::string &name)=0;
116-
virtual video::ITexture *getShaderFlagsTexture(bool normamap_present,
117-
bool tileable_vertical, bool tileable_horizontal)=0;
116+
virtual video::ITexture *getShaderFlagsTexture(bool normalmap_present)=0;
118117
};
119118

120119
class IWritableTextureSource : public ITextureSource
@@ -137,8 +136,7 @@ class IWritableTextureSource : public ITextureSource
137136
virtual void rebuildImagesAndTextures()=0;
138137
virtual video::ITexture* getNormalTexture(const std::string &name)=0;
139138
virtual video::SColor getTextureAverageColor(const std::string &name)=0;
140-
virtual video::ITexture *getShaderFlagsTexture(bool normamap_present,
141-
bool tileable_vertical, bool tileable_horizontal)=0;
139+
virtual video::ITexture *getShaderFlagsTexture(bool normalmap_present)=0;
142140
};
143141

144142
IWritableTextureSource* createTextureSource(IrrlichtDevice *device);
@@ -218,9 +216,7 @@ struct TileSpec
218216
alpha == other.alpha &&
219217
material_type == other.material_type &&
220218
material_flags == other.material_flags &&
221-
rotation == other.rotation &&
222-
(material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL) &&
223-
(material_flags & MATERIAL_FLAG_TILEABLE_VERTICAL)
219+
rotation == other.rotation
224220
);
225221
}
226222

@@ -254,12 +250,6 @@ struct TileSpec
254250
}
255251
material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING)
256252
? true : false;
257-
if (!(material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL)) {
258-
material.TextureLayer[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
259-
}
260-
if (!(material_flags & MATERIAL_FLAG_TILEABLE_VERTICAL)) {
261-
material.TextureLayer[0].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
262-
}
263253
}
264254

265255
void applyMaterialOptionsWithShaders(video::SMaterial &material) const

src/nodedef.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -1012,9 +1012,7 @@ void CNodeDefManager::fillTileAttribs(ITextureSource *tsrc, TileSpec *tile,
10121012
if (use_normal_texture) {
10131013
tile->normal_texture = tsrc->getNormalTexture(tiledef->name);
10141014
}
1015-
tile->flags_texture = tsrc->getShaderFlagsTexture(
1016-
tile->normal_texture ? true : false,
1017-
tiledef->tileable_vertical, tiledef->tileable_horizontal);
1015+
tile->flags_texture = tsrc->getShaderFlagsTexture(tile->normal_texture ? true : false);
10181016

10191017
// Material flags
10201018
tile->material_flags = 0;

src/wieldmesh.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ void WieldMeshSceneNode::setExtruded(const std::string &imagename,
302302
material.setFlag(video::EMF_USE_MIP_MAPS, false);
303303
#endif
304304
if (m_enable_shaders) {
305-
material.setTexture(2, tsrc->getShaderFlagsTexture(false, true, true));
305+
material.setTexture(2, tsrc->getShaderFlagsTexture(false));
306306
}
307307
}
308308

0 commit comments

Comments
 (0)