Merge branch 'ehofman/normal'
This commit is contained in:
commit
ca2afa9e51
2 changed files with 15 additions and 9 deletions
|
@ -35,11 +35,6 @@ int parse_option(char **args, int n) {
|
|||
}
|
||||
|
||||
sz = strlen(opt);
|
||||
if (!strncmp(opt, "-help", sz)) {
|
||||
printf("usage:\n normalmap [-c=contrast] [-b=brightness]");
|
||||
printf(" --t=file [--o=file]\n");
|
||||
exit(0);
|
||||
}
|
||||
if (!strncmp(opt, "-contrast", sz)) {
|
||||
contrast = atof(arg);
|
||||
return ret;
|
||||
|
@ -58,6 +53,11 @@ int parse_option(char **args, int n) {
|
|||
normalmap_file = strdup(arg);
|
||||
return ret;
|
||||
}
|
||||
if (!strncmp(opt, "-help", sz)) {
|
||||
printf("usage:\n normalmap [-c=contrast] [-b=brightness]");
|
||||
printf(" --i=file [--o=file]\n\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -71,7 +71,9 @@ int main (int argc, char **argv)
|
|||
|
||||
if ( !texture_file )
|
||||
{
|
||||
printf("Error: texture file not specified\n");
|
||||
printf("Error: texture file not specified.\n");
|
||||
printf("usage:\n normalmap [-c=contrast] [-b=brightness]");
|
||||
printf(" --i=file [--o=file]\n\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -79,7 +81,7 @@ int main (int argc, char **argv)
|
|||
if ( !texture.texture() )
|
||||
{
|
||||
printf("Error: unable to process input file: %s\n", texture_file);
|
||||
printf(" (%s)\n", texture.err_str());
|
||||
printf(" (%s)\n\n", texture.err_str());
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
|
|
@ -901,6 +901,7 @@ SGTexture::make_normalmap(float brightness, float contrast) {
|
|||
int yp1 = (y < (texture_height-1)) ? y+1 : 0;
|
||||
int posxp1 = (xp1 + ytw)*num_colors;
|
||||
int posyp1 = (x + yp1*texture_width)*num_colors;
|
||||
float fx,fy;
|
||||
|
||||
GLubyte c = texture_data[dpos];
|
||||
GLubyte cx1 = texture_data[posxp1];
|
||||
|
@ -918,8 +919,11 @@ SGTexture::make_normalmap(float brightness, float contrast) {
|
|||
map[mpos+3] = a;
|
||||
}
|
||||
|
||||
map[mpos+0] = (128+(cx1-c)/2);
|
||||
map[mpos+1] = (128+(cy1-c)/2);
|
||||
fx = asin((c/256.0-cx1/256.0))/1.57079633;
|
||||
fy = asin((cy1/256.0-c/256.0))/1.57079633;
|
||||
|
||||
map[mpos+0] = (GLuint)(fx*256.0)-128;
|
||||
map[mpos+1] = (GLuint)(fy*256.0)-128;
|
||||
map[mpos+2] = 127+int(brightness*128); // 255-c/2;
|
||||
|
||||
mpos += colors;
|
||||
|
|
Loading…
Reference in a new issue