Skip to content

Commit 3f6f327

Browse files
committedJul 4, 2013
Add texture bumpmapping feature.
1 parent b850f0f commit 3f6f327

11 files changed

+602
-2
lines changed
 
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
trans_alphach
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
uniform sampler2D myTexture;
3+
uniform sampler2D normalTexture;
4+
5+
uniform vec4 skyBgColor;
6+
uniform float fogDistance;
7+
8+
varying vec3 vPosition;
9+
10+
varying vec3 viewVec;
11+
12+
void main (void)
13+
{
14+
vec4 col = texture2D(myTexture, vec2(gl_TexCoord[0]));
15+
float alpha = col.a;
16+
vec2 uv = gl_TexCoord[0].st;
17+
vec4 base = texture2D(myTexture, uv);
18+
vec4 final_color = vec4(0.2, 0.2, 0.2, 1.0) * base;
19+
vec3 vVec = normalize(viewVec);
20+
vec3 bump = normalize(texture2D(normalTexture, uv).xyz * 2.0 - 1.0);
21+
vec3 R = reflect(-vVec, bump);
22+
vec3 lVec = normalize(vec3(0.0, -0.4, 0.5));
23+
float diffuse = max(dot(lVec, bump), 0.0);
24+
25+
vec3 color = diffuse * texture2D(myTexture, gl_TexCoord[0].st).rgb;
26+
27+
28+
float specular = pow(clamp(dot(R, lVec), 0.0, 1.0),1.0);
29+
vec4 vSpecular = 0.2*specular * diffuse;
30+
color += vSpecular;
31+
32+
33+
col = vec4(color.r, color.g, color.b, alpha);
34+
col *= gl_Color;
35+
col = col * col; // SRGB -> Linear
36+
col *= 1.8;
37+
col.r = 1.0 - exp(1.0 - col.r) / exp(1.0);
38+
col.g = 1.0 - exp(1.0 - col.g) / exp(1.0);
39+
col.b = 1.0 - exp(1.0 - col.b) / exp(1.0);
40+
col = sqrt(col); // Linear -> SRGB
41+
if(fogDistance != 0.0){
42+
float d = max(0.0, min(vPosition.z / fogDistance * 1.5 - 0.6, 1.0));
43+
alpha = mix(alpha, 0.0, d);
44+
}
45+
46+
gl_FragColor = vec4(col.r, col.g, col.b, alpha);
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
2+
uniform mat4 mWorldViewProj;
3+
uniform mat4 mInvWorld;
4+
uniform mat4 mTransWorld;
5+
uniform float dayNightRatio;
6+
7+
varying vec3 vPosition;
8+
varying vec3 viewVec;
9+
10+
void main(void)
11+
{
12+
gl_Position = mWorldViewProj * gl_Vertex;
13+
14+
vPosition = (mWorldViewProj * gl_Vertex).xyz;
15+
16+
vec3 tangent;
17+
vec3 binormal;
18+
19+
vec3 c1 = cross( gl_Normal, vec3(0.0, 0.0, 1.0) );
20+
vec3 c2 = cross( gl_Normal, vec3(0.0, 1.0, 0.0) );
21+
22+
if( length(c1)>length(c2) )
23+
{
24+
tangent = c1;
25+
}
26+
else
27+
{
28+
tangent = c2;
29+
}
30+
31+
tangent = normalize(tangent);
32+
33+
//binormal = cross(gl_Normal, tangent);
34+
//binormal = normalize(binormal);
35+
36+
vec4 color;
37+
//color = vec4(1.0, 1.0, 1.0, 1.0);
38+
39+
float day = gl_Color.r;
40+
float night = gl_Color.g;
41+
float light_source = gl_Color.b;
42+
43+
/*color.r = mix(night, day, dayNightRatio);
44+
color.g = color.r;
45+
color.b = color.r;*/
46+
47+
float rg = mix(night, day, dayNightRatio);
48+
rg += light_source * 1.5; // Make light sources brighter
49+
float b = rg;
50+
51+
// Moonlight is blue
52+
b += (day - night) / 13.0;
53+
rg -= (day - night) / 13.0;
54+
55+
// Emphase blue a bit in darker places
56+
// See C++ implementation in mapblock_mesh.cpp finalColorBlend()
57+
b += max(0.0, (1.0 - abs(b - 0.13)/0.17) * 0.025);
58+
59+
// Artificial light is yellow-ish
60+
// See C++ implementation in mapblock_mesh.cpp finalColorBlend()
61+
rg += max(0.0, (1.0 - abs(rg - 0.85)/0.15) * 0.065);
62+
63+
color.r = rg;
64+
color.g = rg;
65+
color.b = b;
66+
67+
// Make sides and bottom darker than the top
68+
color = color * color; // SRGB -> Linear
69+
if(gl_Normal.y <= 0.5)
70+
color *= 0.6;
71+
//color *= 0.7;
72+
color = sqrt(color); // Linear -> SRGB
73+
74+
color.a = gl_Color.a;
75+
76+
gl_FrontColor = gl_BackColor = color;
77+
78+
gl_TexCoord[0] = gl_MultiTexCoord0;
79+
80+
vec3 n1 = normalize(gl_NormalMatrix * gl_Normal);
81+
vec4 tangent1 = vec4(tangent.x, tangent.y, tangent.z, 0);
82+
//vec3 t1 = normalize(gl_NormalMatrix * tangent1);
83+
//vec3 b1 = cross(n1, t1);
84+
85+
vec3 v;
86+
vec3 vVertex = vec3(gl_ModelViewMatrix * gl_Vertex);
87+
vec3 vVec = -vVertex;
88+
//v.x = dot(vVec, t1);
89+
//v.y = dot(vVec, b1);
90+
//v.z = dot(vVec, n1);
91+
//viewVec = vVec;
92+
viewVec = normalize(vec3(0.0, -0.4, 0.5));
93+
//Vector representing the 0th texture coordinate passed to fragment shader
94+
//gl_TexCoord[0] = vec2(gl_MultiTexCoord0);
95+
96+
// Transform the current vertex
97+
//gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
98+
}
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
trans_alphach_ref
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
uniform sampler2D myTexture;
3+
uniform sampler2D normalTexture;
4+
5+
uniform vec4 skyBgColor;
6+
uniform float fogDistance;
7+
8+
varying vec3 vPosition;
9+
10+
varying vec3 viewVec;
11+
12+
void main (void)
13+
{
14+
vec4 col = texture2D(myTexture, vec2(gl_TexCoord[0]));
15+
float alpha = col.a;
16+
vec2 uv = gl_TexCoord[0].st;
17+
vec4 base = texture2D(myTexture, uv);
18+
vec4 final_color = vec4(0.2, 0.2, 0.2, 1.0) * base;
19+
vec3 vVec = normalize(viewVec);
20+
vec3 bump = normalize(texture2D(normalTexture, uv).xyz * 2.0 - 1.0);
21+
vec3 R = reflect(-vVec, bump);
22+
vec3 lVec = normalize(vec3(0.0, -0.4, 0.5));
23+
float diffuse = max(dot(lVec, bump), 0.0);
24+
25+
vec3 color = diffuse * texture2D(myTexture, gl_TexCoord[0].st).rgb;
26+
27+
28+
float specular = pow(clamp(dot(R, lVec), 0.0, 1.0),1.0);
29+
vec4 vSpecular = 0.2*specular * diffuse;
30+
color += vSpecular;
31+
32+
33+
col = vec4(color.r, color.g, color.b, alpha);
34+
col *= gl_Color;
35+
col = col * col; // SRGB -> Linear
36+
col *= 1.8;
37+
col.r = 1.0 - exp(1.0 - col.r) / exp(1.0);
38+
col.g = 1.0 - exp(1.0 - col.g) / exp(1.0);
39+
col.b = 1.0 - exp(1.0 - col.b) / exp(1.0);
40+
col = sqrt(col); // Linear -> SRGB
41+
if(fogDistance != 0.0){
42+
float d = max(0.0, min(vPosition.z / fogDistance * 1.5 - 0.6, 1.0));
43+
col = mix(col, skyBgColor, d);
44+
}
45+
gl_FragColor = vec4(col.r, col.g, col.b, alpha);
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
2+
uniform mat4 mWorldViewProj;
3+
uniform mat4 mInvWorld;
4+
uniform mat4 mTransWorld;
5+
uniform float dayNightRatio;
6+
7+
varying vec3 vPosition;
8+
varying vec3 viewVec;
9+
10+
void main(void)
11+
{
12+
gl_Position = mWorldViewProj * gl_Vertex;
13+
14+
vPosition = (mWorldViewProj * gl_Vertex).xyz;
15+
16+
vec3 tangent;
17+
vec3 binormal;
18+
19+
vec3 c1 = cross( gl_Normal, vec3(0.0, 0.0, 1.0) );
20+
vec3 c2 = cross( gl_Normal, vec3(0.0, 1.0, 0.0) );
21+
22+
if( length(c1)>length(c2) )
23+
{
24+
tangent = c1;
25+
}
26+
else
27+
{
28+
tangent = c2;
29+
}
30+
31+
tangent = normalize(tangent);
32+
33+
//binormal = cross(gl_Normal, tangent);
34+
//binormal = normalize(binormal);
35+
36+
vec4 color;
37+
//color = vec4(1.0, 1.0, 1.0, 1.0);
38+
39+
float day = gl_Color.r;
40+
float night = gl_Color.g;
41+
float light_source = gl_Color.b;
42+
43+
/*color.r = mix(night, day, dayNightRatio);
44+
color.g = color.r;
45+
color.b = color.r;*/
46+
47+
float rg = mix(night, day, dayNightRatio);
48+
rg += light_source * 1.5; // Make light sources brighter
49+
float b = rg;
50+
51+
// Moonlight is blue
52+
b += (day - night) / 13.0;
53+
rg -= (day - night) / 13.0;
54+
55+
// Emphase blue a bit in darker places
56+
// See C++ implementation in mapblock_mesh.cpp finalColorBlend()
57+
b += max(0.0, (1.0 - abs(b - 0.13)/0.17) * 0.025);
58+
59+
// Artificial light is yellow-ish
60+
// See C++ implementation in mapblock_mesh.cpp finalColorBlend()
61+
rg += max(0.0, (1.0 - abs(rg - 0.85)/0.15) * 0.065);
62+
63+
color.r = rg;
64+
color.g = rg;
65+
color.b = b;
66+
67+
// Make sides and bottom darker than the top
68+
color = color * color; // SRGB -> Linear
69+
if(gl_Normal.y <= 0.5)
70+
color *= 0.6;
71+
//color *= 0.7;
72+
color = sqrt(color); // Linear -> SRGB
73+
74+
color.a = gl_Color.a;
75+
76+
gl_FrontColor = gl_BackColor = color;
77+
78+
gl_TexCoord[0] = gl_MultiTexCoord0;
79+
80+
vec3 n1 = normalize(gl_NormalMatrix * gl_Normal);
81+
vec4 tangent1 = vec4(tangent.x, tangent.y, tangent.z, 0);
82+
//vec3 t1 = normalize(gl_NormalMatrix * tangent1);
83+
//vec3 b1 = cross(n1, t1);
84+
85+
vec3 v;
86+
vec3 vVertex = vec3(gl_ModelViewMatrix * gl_Vertex);
87+
vec3 vVec = -vVertex;
88+
//v.x = dot(vVec, t1);
89+
//v.y = dot(vVec, b1);
90+
//v.z = dot(vVec, n1);
91+
//viewVec = vVec;
92+
viewVec = normalize(vec3(0.0, -0.4, 0.5));
93+
//Vector representing the 0th texture coordinate passed to fragment shader
94+
//gl_TexCoord[0] = vec2(gl_MultiTexCoord0);
95+
96+
// Transform the current vertex
97+
//gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
98+
}

‎minetest.conf.example

+2
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@
172172
# (1: low level shaders; not implemented)
173173
# 2: enable high level shaders
174174
#enable_shaders = 2
175+
# Set to true to enable textures bumpmapping. Requires shaders enabled.
176+
#enable_bumpmapping = false
175177
# The time in seconds it takes between repeated
176178
# right clicks when holding the right mouse button
177179
#repeat_rightclick_time = 0.25

‎src/defaultsettings.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ void set_default_settings(Settings *settings)
127127
settings->setDefault("trilinear_filter", "false");
128128
settings->setDefault("preload_item_visuals", "true");
129129
settings->setDefault("enable_shaders", "2");
130+
settings->setDefault("enable_bumpmapping", "false");
130131
settings->setDefault("repeat_rightclick_time", "0.25");
131132
settings->setDefault("enable_particles", "true");
132133

‎src/game.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,10 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter
804804
u32 daynight_ratio = m_client->getEnv().getDayNightRatio();
805805
float daynight_ratio_f = (float)daynight_ratio / 1000.0;
806806
services->setPixelShaderConstant("dayNightRatio", &daynight_ratio_f, 1);
807+
808+
// Normal map texture layer
809+
int layer = 1;
810+
services->setPixelShaderConstant("normalTexture" , (irr::f32*)&layer, 1);
807811
}
808812
};
809813

‎src/mapblock_mesh.cpp

+49-2
Original file line numberDiff line numberDiff line change
@@ -1072,12 +1072,18 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data):
10721072
Also store animation info
10731073
*/
10741074
bool enable_shaders = (g_settings->getS32("enable_shaders") > 0);
1075+
bool enable_bumpmapping = g_settings->getBool("enable_bumpmapping");
10751076
video::E_MATERIAL_TYPE shadermat1 = m_gamedef->getShaderSource()->
10761077
getShader("test_shader_1").material;
10771078
video::E_MATERIAL_TYPE shadermat2 = m_gamedef->getShaderSource()->
10781079
getShader("test_shader_2").material;
10791080
video::E_MATERIAL_TYPE shadermat3 = m_gamedef->getShaderSource()->
10801081
getShader("test_shader_3").material;
1082+
video::E_MATERIAL_TYPE bumpmaps1 = m_gamedef->getShaderSource()->
1083+
getShader("bumpmaps_solids").material;
1084+
video::E_MATERIAL_TYPE bumpmaps2 = m_gamedef->getShaderSource()->
1085+
getShader("bumpmaps_liquids").material;
1086+
10811087
for(u32 i = 0; i < collector.prebuffers.size(); i++)
10821088
{
10831089
PreMeshBuffer &p = collector.prebuffers[i];
@@ -1154,8 +1160,33 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data):
11541160
material.MaterialType
11551161
= video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
11561162
material.setTexture(0, p.tile.texture);
1157-
if(enable_shaders)
1158-
p.tile.applyMaterialOptionsWithShaders(material, shadermat1, shadermat2, shadermat3);
1163+
if (enable_shaders)
1164+
{
1165+
if (enable_bumpmapping)
1166+
{
1167+
ITextureSource *tsrc = data->m_gamedef->tsrc();
1168+
std::string basename,normal,replace;
1169+
replace = "_normal.png";
1170+
basename = tsrc->getTextureName(p.tile.texture_id);
1171+
unsigned pos = basename.find(".");
1172+
normal = basename.substr (0, pos) + replace;
1173+
if (tsrc->isKnownSourceImage(normal))
1174+
{
1175+
// look for image extension and replace it
1176+
for(std::string::size_type i = 0; (i = basename.find(".", i)) != std::string::npos;)
1177+
{
1178+
basename.replace(i, 4, replace);
1179+
i += replace.length();
1180+
}
1181+
material.setTexture(1, tsrc->getTexture(basename));
1182+
p.tile.applyMaterialOptionsWithShaders(material, bumpmaps1,bumpmaps2, shadermat3);
1183+
}
1184+
else
1185+
p.tile.applyMaterialOptionsWithShaders(material, shadermat1, shadermat2, shadermat3);
1186+
}
1187+
else
1188+
p.tile.applyMaterialOptionsWithShaders(material, shadermat1, shadermat2, shadermat3);
1189+
}
11591190
else
11601191
p.tile.applyMaterialOptions(material);
11611192

@@ -1217,6 +1248,9 @@ MapBlockMesh::~MapBlockMesh()
12171248

12181249
bool MapBlockMesh::animate(bool faraway, float time, int crack, u32 daynight_ratio)
12191250
{
1251+
bool enable_shaders = (g_settings->getS32("enable_shaders") > 0);
1252+
bool enable_bumpmapping = g_settings->getBool("enable_bumpmapping");
1253+
12201254
if(!m_has_animation)
12211255
{
12221256
m_animation_force_timer = 100000;
@@ -1271,6 +1305,19 @@ bool MapBlockMesh::animate(bool faraway, float time, int crack, u32 daynight_rat
12711305
os<<"^[verticalframe:"<<(int)tile.animation_frame_count<<":"<<frame;
12721306
// Set the texture
12731307
buf->getMaterial().setTexture(0, tsrc->getTexture(os.str()));
1308+
if (enable_shaders && enable_bumpmapping)
1309+
{
1310+
std::string basename,normal;
1311+
basename = tsrc->getTextureName(tile.texture_id);
1312+
unsigned pos;
1313+
pos = basename.find(".");
1314+
normal = basename.substr (0, pos);
1315+
normal += "_normal.png";
1316+
os.str("");
1317+
os<<normal<<"^[verticalframe:"<<(int)tile.animation_frame_count<<":"<<frame;
1318+
if (tsrc->isKnownSourceImage(normal))
1319+
buf->getMaterial().setTexture(1, tsrc->getTexture(os.str()));
1320+
}
12741321
}
12751322

12761323
// Day-night transition

‎util/generate-texture-normals.sh

+255
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
#!/bin/bash
2+
3+
# This script generates normalmaps using The GIMP to do the heavy lifting.
4+
# give any unrecognized switch (say, -h) for usage info.
5+
6+
rm /tmp/normals_filelist.txt
7+
8+
numprocs=6
9+
10+
skiptools=false
11+
skipinventory=false
12+
invresolution=64
13+
dryrun=false
14+
pattern="*.png *.jpg"
15+
16+
filter=0
17+
scale=8
18+
wrap=0
19+
heightsource=0
20+
conversion=0
21+
invertx=0
22+
inverty=0
23+
24+
while test -n "$1"; do
25+
case "$1" in
26+
--scale|-s)
27+
if [ -z "$2" ] ; then echo "Missing scale parameter"; exit 1; fi
28+
scale=$2
29+
shift
30+
shift
31+
;;
32+
--pattern|-p)
33+
if [ -z "$2" ] ; then echo "Missing pattern parameter"; exit 1; fi
34+
pattern=$2
35+
shift
36+
shift
37+
;;
38+
--skiptools|-t)
39+
skiptools=true
40+
shift
41+
;;
42+
--skipinventory|-i)
43+
if [[ $2 =~ ^[0-9]+$ ]]; then
44+
invresolution=$2
45+
shift
46+
fi
47+
skipinventory=true
48+
shift
49+
;;
50+
--filter|-f)
51+
if [ -z "$2" ] ; then echo "Missing filter parameter"; exit 1; fi
52+
53+
case "$2" in
54+
sobel3|1)
55+
filter=1
56+
;;
57+
sobel5|2)
58+
filter=2
59+
;;
60+
prewitt3|3)
61+
filter=3
62+
;;
63+
prewitt5|4)
64+
filter=4
65+
;;
66+
3x3|5)
67+
filter=5
68+
;;
69+
5x5|6)
70+
filter=6
71+
;;
72+
7x7|7)
73+
filter=7
74+
;;
75+
9x9|8)
76+
filter=8
77+
;;
78+
*)
79+
filter=0
80+
;;
81+
esac
82+
83+
shift
84+
shift
85+
;;
86+
--heightalpha|-a)
87+
heightsource=1
88+
shift
89+
;;
90+
--conversion|-c)
91+
if [ -z "$2" ] ; then echo "Missing conversion parameter"; exit 1; fi
92+
93+
case "$2" in
94+
biased|1)
95+
conversion=1
96+
;;
97+
red|2)
98+
conversion=2
99+
;;
100+
green|3)
101+
conversion=3
102+
;;
103+
blue|4)
104+
conversion=4
105+
;;
106+
maxrgb|5)
107+
conversion=5
108+
;;
109+
minrgb|6)
110+
conversion=6
111+
;;
112+
colorspace|7)
113+
conversion=7
114+
;;
115+
normalize-only|8)
116+
conversion=8
117+
;;
118+
heightmap|9)
119+
conversion=9
120+
;;
121+
*)
122+
conversion=0
123+
;;
124+
esac
125+
126+
shift
127+
shift
128+
;;
129+
--wrap|-w)
130+
wrap=1
131+
shift
132+
;;
133+
--invertx|-x)
134+
invertx=1
135+
shift
136+
;;
137+
--inverty|-y)
138+
inverty=1
139+
shift
140+
;;
141+
--dryrun|-d)
142+
dryrun=true
143+
shift
144+
;;
145+
*)
146+
echo -e "\nUsage:\n"
147+
echo "`basename $0` [--scale|-s <value>] [--filter|-f <string>]"
148+
echo " [--wrap|-w] [--heightalpha|-a] [--invertx|-x] [--inverty|-y]"
149+
echo " [--conversion|-c <string>] [--skiptools|-t] [--skipinventory|-i [<value>]]"
150+
echo " [--dryrun|-d] [--pattern|-p <pattern>]"
151+
echo -e "\nDefaults to a scale of 8, checking all files in the current directory, and not"
152+
echo "skipping apparent tools or inventory images. Filter, if specified, may be one"
153+
echo "of: sobel3, sobel5, prewitt3, prewitt5, 3x3, 5x5, 7x7, or 9x9, or a value 1"
154+
echo "through 8 (1=sobel3, 2=sobel5, etc.). Defaults to 0 (four-sample). The height"
155+
echo "source is taken from the image's alpha channel if heightalpha is specified.\n"
156+
echo ""
157+
echo "If inventory skip is specified, an optional resolution may also be included"
158+
echo "(default is 64). Conversion can be one of: biased, red, green, blue, maxrgb,"
159+
echo "minrgb, colorspace, normalize-only, heightmap or a value from 1 to 9"
160+
echo "corresponding respectively to those keywords. Defaults to 0 (simple"
161+
echo "normalize) if not specified. Wrap, if specified, enables wrapping of the"
162+
echo "normalmap around the edges of the texture (defaults to no). Invert X/Y"
163+
echo "reverses the calculated gradients for the X and/or Y dimensions represented"
164+
echo "by the normalmap (both default to non-inverted)."
165+
echo ""
166+
echo "The pattern, can be an escaped pattern string such as \*apple\* or"
167+
echo "default_\*.png or similar (defaults to all PNG and JPG images in the current"
168+
echo "directory that do not contain \"_normal\" or \"_specular\" in their filenames)."
169+
echo ""
170+
echo "If set for dry-run, the actions this script will take will be printed, but no"
171+
echo "images will be generated. Passing an invalid value to a switch will generally"
172+
echo "cause that switch to revert to its default value."
173+
echo ""
174+
exit 1
175+
;;
176+
esac
177+
done
178+
179+
echo -e "\nProcessing files based on pattern \"$pattern\" ..."
180+
181+
normalMap()
182+
{
183+
out=`echo "$1" | sed 's/.png/_normal.png/' | sed 's/.jpg/_normal.png/'`
184+
185+
echo "Launched process to generate normalmap: \"$1\" --> \"$out\"" >&2
186+
187+
gimp -i -b "
188+
(define
189+
(normalMap-fbx-conversion fileName newFileName filter nscale wrap heightsource conversion invertx inverty)
190+
(let*
191+
(
192+
(image (car (gimp-file-load RUN-NONINTERACTIVE fileName fileName)))
193+
(drawable (car (gimp-image-get-active-layer image)))
194+
(drawable (car (gimp-image-flatten image)))
195+
)
196+
(if (> (car (gimp-drawable-type drawable)) 1)
197+
(gimp-convert-rgb image) ()
198+
)
199+
200+
(plug-in-normalmap
201+
RUN-NONINTERACTIVE
202+
image
203+
drawable
204+
filter
205+
0.0
206+
nscale
207+
wrap
208+
heightsource
209+
0
210+
conversion
211+
0
212+
invertx
213+
inverty
214+
0
215+
0.0
216+
drawable)
217+
(gimp-file-save RUN-NONINTERACTIVE image drawable newFileName newFileName)
218+
(gimp-image-delete image)
219+
)
220+
)
221+
(normalMap-fbx-conversion \"$1\" \"$out\" $2 $3 $4 $5 $6 $7 $8)" -b '(gimp-quit 0)'
222+
}
223+
224+
export -f normalMap
225+
226+
for file in `ls $pattern |grep -v "_normal.png"|grep -v "_specular"` ; do
227+
228+
invtest=`file "$file" |grep "$invresolution x $invresolution"`
229+
if $skipinventory && [ -n "$invtest" ] ; then
230+
echo "Skipped presumed "$invresolution"px inventory image: $file" >&2
231+
continue
232+
fi
233+
234+
tooltest=`echo "$file" \
235+
| grep -v "_tool" \
236+
| grep -v "_shovel" \
237+
| grep -v "_pick" \
238+
| grep -v "_axe" \
239+
| grep -v "_sword" \
240+
| grep -v "_hoe" \
241+
| grep -v "bucket_"`
242+
243+
if $skiptools && [ -z "$tooltest" ] ; then
244+
echo "Skipped presumed tool image: $file" >&2
245+
continue
246+
fi
247+
248+
if $dryrun ; then
249+
echo "Would have generated a normalmap for $file" >&2
250+
continue
251+
else
252+
echo \"$file\" $filter $scale $wrap $heightsource $conversion $invertx $inverty
253+
fi
254+
done | xargs -P $numprocs -n 8 -I{} bash -c normalMap\ \{\}\ \{\}\ \{\}\ \{\}\ \{\}\ \{\}\ \{\}\ \{\}
255+

0 commit comments

Comments
 (0)
Please sign in to comment.