🔒 Locked
Specular Map!
Advertisement
Original Post
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
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
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
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.
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.specularSaturation); call to use that face's particular specular shininess value.
Is this somewhere near what you are looking for?
Is this somewhere near what you are looking for?
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.
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 :)
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 value0 45.0f1 40.0f2 35.0f3 30.0f4 25.0f5 20.0f6 15.0f7 10.0f8 5.0f9 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 :)
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement