Skip to main content
gamedev.net
🔒 Locked

Specular Map!

Started by golgoth 11 replies 1.8k views
Original Post
golgoth
golgoth
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
azjerei
azjerei
I am not quite following you on what it is that you are trying to achieve here :)

Want to elaborate a bit plz?
golgoth
golgoth
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

aaron_ds
aaron_ds
I can think of a REALLY easy way of doing this with a texture unit and a fragment shader.
Herr_O
Herr_O
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.
azjerei
azjerei
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?
Herr_O
Herr_O
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?
Songoku
Songoku
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.
azjerei
azjerei
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.
golgoth
golgoth
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
azjerei
azjerei
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 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.