Skip to main content
gamedev.net
🔒 Locked

Specular Mapping

Started by cippyboy Jan 8, 2004 at 11:14 AM 14 replies 1k views
Original Post
cippyboy
cippyboy
I thought of it, I made something and now I wanna compare results and all http://www.geocities.com/cippyboy_7/specular_mapping.jpg http://www.geocities.com/cippyboy_7/specular_mapping2.jpg I was amazed of the results and I wanna know if you think this is actually specualar mapping so I won`t understand this wrong and all. If not then I`d like to know how it is different than what I did. PS:Im using generated tex-coords for this and... If I could subtract the texcoords from OpenGL to some data I could make... my own LightMapMaker , or... how to make the generated texcoords be static(now its camera dependent I tryed not using glTexGen() anymore but it still uses it), I`d like the texcoords to remain static after a frame.
Relative Games - My apps
JuNC
JuNC
Nice, but..

Can''t see any obvious specular behaviour, but it''s hard to tell from static images like that.

Maybe if you outline your algorithm/process someone can tell you if it is actually specular mapping (although a little research should enable you to answer the question yourself).
Tree Penguin
Tree Penguin
I don''t think this is specular lighting, as specular lighting is the reflection of light (which normally occurs on shiny materials, like coffee cups and such), this looks more like diffuse lighting, which is the (lightrange-lightdistance) * color
cippyboy
cippyboy
[Tree Penguin]->"I don't think this is specular lighting, as specular lighting is the reflection of light"
I didnt said specular lighting it was specular mapping

Anyways i
ll make some research and all... you want shiny ? I can scale the RGB to 4x(I found it to be max) and make it whiter

edit: I reuploaded the second pic with a brigther light

[edited by - cippyboy on January 8, 2004 12:51:30 PM]
Relative Games - My apps
Tree Penguin
Tree Penguin
Haha, sorry, my bad, for specular mappig, hmm, it looks pretty good!

By the way, for lightmapping take a look at this tutorial (it''s pretty usefull), i created my own ''LightMapMaker'' with this .
cippyboy
cippyboy
Well... to make a LMM I would just need a glGetTexGen()
Which I think exists but I dont know how to use it...
I
d need the texcoord array(or something like that) that`s being generated by a glTexGen()... how can I do that ?
Relative Games - My apps
Tree Penguin
Tree Penguin
I realy wouldn''t know, the only type of lightmapping i use is dynamic lightmaps, they work like this (at least with my code):

All triangles have a texture, with tex coords (0,0), (1,0) and (0.5,1).

I then calculate the position of each texel and with that, calculate the distance from the light (per texel).
I then convert that to an intensity value and multiply that by the dot product of the normal of the surface and the normal pointing at the light (so surfaces directly facing the light are brighter than the ones that don''t).
Then i look up the correct value in my 1d lightmapvalue texture (isn''t really neccesary, but it''s nice to play with lights that get darker and then lighter again and that a few times ).
Then i create rgb colorvalues by multiplieing the light''s r,g and b values to let it be colored.
Then i add these values to the lightmap texel data.

So, that''s one way, actually the most realistic way (of diffuse lighting) but by far the fastest .
orbano
orbano
A specular lighted surface''s point becomes very brigth, when the light reflected hits your eyes. Its an "upgrade" to diffuse lighting. All you need to calculate is the sum of the camera direction and the light direction. You get the specular component from the dot product of the normal and this vector. Now you have two values, a diffuse component (you used it to multiplicate the color with it) and the specular component (d and s). The final calculations are:
if d<0 then d=0;
if s<0 then s=0 else s=s^x where x is the specular coefficient (brightness of the surface, use ~32)
Then the final color:
color=d*diffusematerialcolor+s*specularcolor;

I hope i did not make any mistakes...
"Knowledge is no more expensive than ignorance, and at least as satisfying." -Barrin
Luke Miklos
Luke Miklos
that 2nd picture looks great & me being a gamer, I instantly think of a game that that would look cool on... how about some kinda police copter game where you have to go through the city over rooftops with your spot light (& weapons of course) doing stuff???? : )
Whatsoever you do, do it heartily as to the Lord, and not unto men.
cippyboy
cippyboy
I think some of you misunderstood what I did so this is what generates me texels->
glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_EYE_LINEAR);
glTexGeni(GL_T,GL_TEXTURE_GEN_MODE,GL_EYE_LINEAR);

Get it ?
Now If I could extract the texcoords OpenGL generates... it would be pretty damn cool

Edit:I also uploaded a new http://www.geocities.com/cippyboy_7/specular_mapping.jpg
so now theres a Teapot with a... metal like texture
I looked at the spout so you
ll see the corect texturing
I also used that RGB scalling 4x so it`s really shiny

[edited by - cippyboy on January 9, 2004 6:18:51 AM]
Relative Games - My apps
orbano
orbano
Isnt it somethig like environment mapping (metallic surfaces are generated with this method)? I dont see any specularity in it (btw its really nice);
If you need any ogl function, try www.msdn.com. There are very good specifications (just search for you function), describing every parameter and their behavior...
Oh and please tell us what kind of effect you are trying to make with this? Oh and Tree Penguin! The most realistic way of diffuse lighting is already implemented in the T&L engine, you just have to turn it on. I think we got messed up with names without knowing what we really want (maybe cippyboy does).
"Knowledge is no more expensive than ignorance, and at least as satisfying." -Barrin
cippyboy
cippyboy
Well... first of all the effect is done trough automated texcord generation Process, Second yes, I do wanna make specular mapping , this is just what I came up with...
If it isnt real specular mapping... I dont really care, it`s interesting and fun anyhow.
Relative Games - My apps
orbano
orbano
You are right! If you find any way to get those texcoords, please write it here!
"Knowledge is no more expensive than ignorance, and at least as satisfying." -Barrin
Luke Miklos
Luke Miklos
The lighting effect on that teapot looks interesting, is there a "spot light" pointed straight the thing??? Obviouslt the pot itself isn't shiny... otherwise the light wouldn't come back at us from that angle, it is more opaque & bright than anything else.

[edited by - Luke Miklos on January 9, 2004 1:42:31 PM]
Whatsoever you do, do it heartily as to the Lord, and not unto men.
cippyboy
cippyboy
After countless tests... well that glGetTexGeniv() is good for nothing... it can only return 2 plane equations(for s and t tex coords) GL_EYE_PLANE and GL_OBJECT_PLANE , which I cant seem to find any good use for them

Though I found glGetPointerv(), which seems pretty right to use and all but... I can
t seem to find an adequate variable for the second param(GLvoid* *params).
Id say it wants arrays of pointers(or 2 dimensional vectors) but that doesnt work... not even a float ** to void ** cant work... pretty stupid, but anyways Id like to know how to use it.

Every reference site tells me the params and what params to use... not what to use with it nor sample code

Edit: In that way the Specular Mapping is like this->
Where the camera is facing its total lit(thats up to the specular map... you could do inverse and make Dark Lights->what a good test to do) and the rest of the light(kind of diffuse mapping because it comes from the same texture its the sides of the specular texture... so for that texture, in front it shines and in the rest... total darkness. I think Ill try to make an ambient light though so it would be more realistic

Edit2:I made a Dark Lights test here->http://www.geocities.com/cippyboy_7/specular_mapping3.jpg
you can also the total brightness ambient light from the specular map
[edited by - cippyboy on January 10, 2004 4:12:59 AM]

[edited by - cippyboy on January 10, 2004 4:17:45 AM]
Relative Games - My apps

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.