# materials and textures

This topic is 3296 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I'm having some problems dealing with materials on textured objects. The thing is if I call, for example:
float mat[] = { 1.0, 1.0, 1.0 }
glMaterialfv(GL_FRONT, GL_SPECULAR,  mat);

On a non-textured object, I get a nice and expected effect, but I can't see the specular highlight on a textured object. My question is: how are materials handled in games? Thanks!

##### Share on other sites
Quote:
 Original post by FreJafloat mat[] = { 1.0, 1.0, 1.0 }glMaterialfv(GL_FRONT, GL_SPECULAR, mat);
GL_SPECULAR expects 4 floating point values (don't forget the alpha value).

Quote:
 On a non-textured object, I get a nice and expected effect, but I can't see the specular highlight on a textured object. My question is: how are materials handled in games?
Don't forget to set GL_SHININESS (with glMaterialf), which is the specular exponent, and defaults to zero.

##### Share on other sites
Quote:
Original post by swiftcoder
Quote:
 Original post by FreJafloat mat[] = { 1.0, 1.0, 1.0 }glMaterialfv(GL_FRONT, GL_SPECULAR, mat);
GL_SPECULAR expects 4 floating point values (don't forget the alpha value).

Quote:
 On a non-textured object, I get a nice and expected effect, but I can't see the specular highlight on a textured object. My question is: how are materials handled in games?
Don't forget to set GL_SHININESS (with glMaterialf), which is the specular exponent, and defaults to zero.

I did all that I just showed that bit of code to give you an idea... its not actually what i have implemented.

##### Share on other sites
Quote:
 Original post by FreJaI did all that I just showed that bit of code to give you an idea... its not actually what i have implemented.
It is a bit hard to tell you where you have gone wrong without seeing any actual code.
Quote:
 Original post by FreJaMy question is: how are materials handled in games?
These days materials in games are done entirely through shaders - and speaking for myself at least, everything is considerably simpler with shaders.

##### Share on other sites
Quote:
Original post by swiftcoder
Quote:
 Original post by FreJaI did all that I just showed that bit of code to give you an idea... its not actually what i have implemented.
It is a bit hard to tell you where you have gone wrong without seeing any actual code.
Quote:
 Original post by FreJaMy question is: how are materials handled in games?
These days materials in games are done entirely through shaders - and speaking for myself at least, everything is considerably simpler with shaders.

hmm, k, i'll take a look at shaders then. Just one thing: how sure can I be that my ogl app, with shaders, will run on a given computer? I mean, when shaders aren't supported by the graphics card, are they always run in software mode?

thanks

##### Share on other sites
Quote:
 Original post by FreJahmm, k, i'll take a look at shaders then. Just one thing: how sure can I be that my ogl app, with shaders, will run on a given computer? I mean, when shaders aren't supported by the graphics card, are they always run in software mode?
At some point, you have to decide what segment of the market you are looking at - going the shaders route is going to rule out many old computers, and the majority of integrated GPUs.

If you are intending to target a fairly 'casual' demographic, then you are probably better off sticking with fixed function for the time being. In this case, I suggest that you get hold of a recent copy of the OpenGL Red Book, and thoroughly read up on materials and lighting.

##### Share on other sites

This topic is 3296 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account