PDA

View Full Version : (Modulate Bump & Base) + Bump = Specular?



WhatEver
06-09-2002, 07:28 AM
Wrong terms used, I meant gloss not specular

Is "Modulate Bump & Base) + Bump = Gloss" the right formula for a glossy finish? It seems like that's what it would be anyway, but that would require 3 texture units. Is there any way to accomplish a glossy finish with only 2 texture units? I'm using the primary color to combine with the DOT3 bumpmap texture and then modulating the result with the base color texture...but it's only diffused http://www.opengl.org/discussion_boards/ubb/frown.gif...I want wet looking things http://www.opengl.org/discussion_boards/ubb/biggrin.gif.

Also, is there a way to modulate by a certain intensity...just so that the gloss texture can be multiplied by a scale and then added to the buffer?

Final clarafication:

1. DOT3 texture combined with primary color 2. Modulate with base texture
3. Add a scaled DOT3 texture combined with primary color for glossy effect

[This message has been edited by WhatEver (edited 06-09-2002).]

Nutty
06-09-2002, 07:33 AM
I dont think that sounds quite correct.

Read this, it's an excellent description of phong specular.
http://www.whisqu.se/per/docs/graphics10.htm

Nutty

WhatEver
06-09-2002, 07:52 AM
I'm using phong in my equasion to calculate the light reflecting off of the surface...oh my, I see why I was misunderstood, I meant to say that I want a glossy finish...the phong method I'm using is working perfectly already, I just want areas that are reflecting the light to be white instead of the textures full intensity.

Nutty
06-09-2002, 08:02 AM
Full intensity specular, does not limit at the textures src value.

Specular is addative, so it whites-out at full intensity.

Simply put, specular is added on after the texturing, not before.

Simple equation.
RGB = (diffuse * base_texture) + specular.

Old style specular in OpenGL, used to add it on before texturing, which was incorrect, which is why the seperate specular color extension was developed.

It sounds like you're the total lighting term of diffuse + specular, then modulating buy base map. Instead of diffuse modulate base, then add specular.

Nutty

WhatEver
06-09-2002, 08:20 AM
Just to see if I understand what you're saying, I could do this then:

Specular = DOT3 Bumpmap of sand
Diffuse = DOT3 Bumpmap of sand
BaseTexture = sandy texture

RGB = (Diffuse * BaseTexture) + Specular;

Just seeing your equasion has helped me understand what diffuse really is: scales the base textures rgb values.

[This message has been edited by WhatEver (edited 06-09-2002).]

Nutty
06-09-2002, 08:22 AM
You could do that, but ideally you want to power the specular value, to sharpen the fallof of the dot product value. The more shiny the surface, the more powering it requires.

Nutty

WhatEver
06-09-2002, 08:25 AM
How do I power the specular lighting?

Nutty
06-09-2002, 08:28 AM
Multiply it by itself lots of times.

WhatEver
06-09-2002, 08:35 AM
http://www.opengl.org/discussion_boards/ubb/redface.gif

How do you do that with OpenGL though? I'm not using vertex programs, I'm only using TexEnv.

WhatEver
06-09-2002, 08:37 AM
That emoticon bothers me. I always think that it should be a surprised look not a "oh, well, I'm bored of your comment" look.

It's suppose to be a surprised look http://www.opengl.org/discussion_boards/ubb/smile.gif.

Nutty
06-09-2002, 08:44 AM
ahh I thought you were using Register Combiners. Maybe you want to use seperate specular color extension, and setup material surface as shiny. Dunno how this all fits together with bump-mapping though.

Checkout the Dot3 demo in my previously unreleased section on my website. There might be something in there. I fiddled with a load of TexEnv stuff, to give it a kind of glossy finish.

Nutty

WhatEver
06-09-2002, 03:16 PM
Hey Nutty, your email didn't work for me, but it worked in WM. I posted a response in my forum, you can go there through this (http://www.spider3d.com/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=10;t=000001) link.

Devulon
06-10-2002, 09:04 AM
You can always calculate the lighting yourself. Do all your lighting calculations and the resulting rgb value you can just pass to opengl (with lighting disabled). Then you can do the specular to an arbitrary power. I am not sure what opengl does for specular lighting (the equation I mean). I really never use opengl lighting I just always did my own lighting, either in C with my own math or in register combiners.

Devulon

WhatEver
06-10-2002, 12:07 PM
I don't know what it's called, but I do do the lighting using the primary color channel. In order for my DOT3 bumpmapping to work, I have to use some algorithm, that without the DOT3 bumpmap, would make my surface look like a rainbow.

I really need to learn register combiners badly. It seems a lot of you use them for certain effects...first I need to understand the TexEnv stuff though.

jwatte
06-11-2002, 09:02 AM
> Specular = DOT3 Bumpmap of sand
> Diffuse = DOT3 Bumpmap of sand
> BaseTexture = sandy texture


Note that DOT3 bumpmap for Specular is different from DOT3 bumpmap for Diffuse. The DOT3 for diffuse is between the normal and the light. The DOT3 for specular is between the viewing vector reflected through the normal's surface and the light (which can get simplified to DOT3 between normal and half angle between viewer and light with a simple transformation).

WhatEver
06-11-2002, 01:42 PM
Let me see if I understand this then.

Diffuse is when a surface doesn't reflect any light, instead it sort of absorbs light.

Specular is when the surface reflects the light...and that's what Phong is.

I guess I didn't understand the terms. All I'm trying to do is get areas on my bump mapped surface to turn white when the refected surface is looking right at the light.

Right now I'm using this to set of the bumpmap:

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_DOT3_RGB_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PRIMARY_COLOR_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);

I'm doing the Phong color setup but it only makes a texture draw at its fullest intensity and fullbright instead of white.

I actually don't even understand what those TexEnv commands are even doing, except combining the primary color with the DOT3 bump map and resulting with a grey texture. For some reason if you use the next texture unit it's blended with the grey bumpmap...but why? If I use a third texture unit it replaces the second texture unit...I want the third texture unit to be added to the first two so I can get my glossy surface...I'm possitive it would work too.

[This message has been edited by WhatEver (edited 06-11-2002).]

WhatEver
06-11-2002, 03:57 PM
Here's what I have going right now. It's using Phong Specular lighting.

Run Fishy - 381KB (GeForce Only) (http://www.spider3d.com/dl/runfishy.zip)

I'm doing the primary color calculations manually, is there and extension that can do the calculations for me? Software is slow http://www.opengl.org/discussion_boards/ubb/frown.gif.

zed
06-11-2002, 08:45 PM
>>I guess I didn't understand the terms<<

those definitions are still wrong look them up in some graphics/physics book/site failing that look them up in a dictionary

WhatEver
06-11-2002, 10:50 PM
I just looked it up at both dictionary.com and in my OpenGL book. Specular and diffuse is what I thought they were, I just didn't quite know how to explain it in my post.

Let me give it another try http://www.opengl.org/discussion_boards/ubb/smile.gif.

Diffuse causes a surface to be it's fullest intensity when the light position is perpendicular to the surface.

Specular causes a surface to reach its fullest intensity when the half vector generated from the eye pos and light pos is perpendicular to the surface.

According to this site I just found; what we're actually doing in OpenGL is Gouraud lighting, because we're dealing with light on a per vertex basis. It says phong is the light being calculated on a per pixel basis.

Anyway, this was the phong I was refering to: http://www.whisqu.se/per/docs/graphics10.htm

Jogi
06-25-2002, 03:59 AM
How about:

final = texture + ((bump - 0.5 ) * 2.0)

Looks good.. I have that code somewhere..

AdrianD
06-25-2002, 05:17 AM
Originally posted by WhatEver:
(...)
According to this site I just found; what we're actually doing in OpenGL is Gouraud lighting, because we're dealing with light on a per vertex basis. It says phong is the light being calculated on a per pixel basis.

(...)


that's not correct.
OpenGL does Phong LIGHTING with Gourarud SHADING.

Gouraud Shading: compute vertex lighting and interpolate the colors between the vertices
Phong Shading: interpolate the facenormals and compute lighting for every pixel.

both are just methods to DRAW triangles.
and both of them must use some sort of formula to calculate the lighing at a given vertex/pixel. And in most cases it's the good old PHONG LIGHING MODEL.(notice the difference: the first one is a "shading method", and the second one is a "Lighing model" they both has the same name but they are not the same thing!)

There are several other Lighing Models:
- Blinn (improvmenet of phong, mostly used in per-pixel lighing, because the specular part is easier to compute as in the original phong lighing equation)
- Cook & Torrance (usualy for copper & polished metallic surfaces)
- Oran & Nayar (clothers)
- Anisotropic lighting
- Mineart shading

every of this LIGHING MODELS can be displayed using Gouraud shading or Phong Shading.

Spindle
06-25-2002, 09:41 PM
Hey, can someone cliarify soemthing for me! I have done per-pixel diffuse tangent space bump mapping implement sorta like how Nutty does it on his webstie. I am trying to moudulate it with the base tex which is GL_TEXTURE2_ARB, am I not allowed to call it in glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_TEXTURE2_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);

How could I do this, I am using 2 combiners and I will paste the code if needed. Its not that there is an error its that the texture looks all brown. if I use GL_TEXTRURE0_ARB I see the normalzation cubemap perfectly and same with GL_TEXTURE1_ARB for the normal map!

davepermen
06-25-2002, 11:42 PM
correct texcoords set for tex2 as well?

Spindle
06-26-2002, 07:55 AM
Yes, the tex coords are good, can I re use a texture unit (GL_TEXTURE_0) once I lready used it and stored it in spare0 and don't need it again?