Sign in to follow this  
golgoth

Specular Map!

Recommended Posts

Hi all! I m trying to get specular(on a mesh) affected by a gray scaled texture map! using multitexturing and GL_SEPARATE_SPECULAR_COLOR // Specular after texture if you prefere... but in one pass... I only want a see specular throught a grayscale map... black = no specular at all and white = maximum specular any sugestions? THX

Share this post


Link to post
Share on other sites
sure!

the idea is to control the amount of specular a mesh will recieved with a texture map...

with a texture map all black 0,0,0 (r,g,b)... the mesh will recieved no specular highlights at all...

opposite...
with a texture map all white1,1,1 (r,g,b)... the mesh will be fully exposed to specular highlights!

the plan is... to use grayscale values of a texture map to control the specular intensity... from black(intensity = 0%) to white(intensity = 100%)...

Makes more sense?

THX

Share this post


Link to post
Share on other sites
You can't have vertice based specular highlighting with seperate specular color in one pass. I've asked the same question right here :( The scissors demo at delphi3d doesn't use SEPARATE_SPECULAR_COLOR, instead they have a second "specular-texture" and do it with multipass. Not the same thing unfortunately.

Share this post


Link to post
Share on other sites
Hmm, if I am not mistaken, the "amount of specularity", by your reference, would mean the shininess, right? If that is the case, you could make due with a pre-specular calculation that calculates and stores each face's specular "saturation" based on something. For example: the alpha channel of a TGA texture applied to it, or perhaps a number indicator in the texture name. I dunno. Whatever you would decide to use there, I think it would work. Then you simply use the glMaterialfv(GL_FRON_AND_BACK, GL_SHININESS, object->face[i].specularSaturation); call to use that face's particular specular shininess value.

Is this somewhere near what you are looking for?

Share this post


Link to post
Share on other sites
I wasn't very clear in my post I think. I'm talking about masking the specularity/GL_SHININESS in glMaterialfv with a texture. Are you saying I can mask a material property?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Herr_O got it...

the master plan is to MASK specularity and/or any material attributes with a texture...

anyone tried this?

THX

Share this post


Link to post
Share on other sites
I am not sure if i understand you but i think you can do it very well with a shader. It would be something like a bumpmap but for the specular component only. So use the bumgmapping technique for your specular light computation.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
Herr_O got it...

the master plan is to MASK specularity and/or any material attributes with a texture...

anyone tried this?

THX


Yes, have tried it. Using both specularity, translucency and culling per definition of the material.

Share this post


Link to post
Share on other sites
ok great so it works!!!

would you mind explain how you did it? maybe a snip of code?!

must be easy but a bit of wisdom will be appreciated!!

thx

Share this post


Link to post
Share on other sites
I can only offer pseudo code and explanations since I don't have the code here at home:

Put a float value on your objects (I am assuming you use one material per object, but this could easily be expanded to a per-face thing) that will store the specular saturation (i.e. how strong the specularity will be on the object.

In your "reading all objects in the scene" function, put an initial value on the specular saturation float. This could be anything you like, but I do it so that all objects start with 50.0f, which means no specularity at all.

Then, in the "read this object's material" function, you do some form of check to see if the material somehow manipulates the specular saturation value for the object. I am using simple identifiers in the name of the material itself. If the material's name contains the phrase "_S#", then it'll manipulate the specular value. Since I am using 3DS models, I am limited to very short material names, hence the short identifier.

The # in the identifier represents a number between 0 and 9.


# Specular Saturation value
0 45.0f
1 40.0f
2 35.0f
3 30.0f
4 25.0f
5 20.0f
6 15.0f
7 10.0f
8 5.0f
9 1.0f (highest specularity value)


Finally, in the render code, I check if the current rendered object has a specular saturation value below 50.0f. If it does, then it sets the GL_SPECULAR to a color (this is up to you, I use white since it makes it looks good and shiny) and the GL_SHININESS to the specular saturation value of the object.

There, quite simple. Maybe not the best way to do this, but it works good and does the job one expects from it :)

Share this post


Link to post
Share on other sites

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

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this