Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gloss control #131

Closed
ghost opened this issue Jun 4, 2014 · 21 comments
Closed

Gloss control #131

ghost opened this issue Jun 4, 2014 · 21 comments

Comments

@ghost
Copy link

ghost commented Jun 4, 2014

Hey guys,

I'm really digging the new RB-BFG engine and I was wondering if Gloss control is out of the question?

It'd be neat if it was something similar to how Prey supports it in their Materials.

Right now I am trying to make a map for this engine and Gloss support would be very very cool.

If possible, store the Gloss map in the alpha channel of the Specular, or a separate image, I don't think that is super important.

@motorsep
Copy link

motorsep commented Jun 4, 2014

Same thing as in Doom 3 - alpha channel of specular works as gloss. Supported out of the box.

@ghost
Copy link
Author

ghost commented Jun 4, 2014

That's interesting, I'll have to try that when I get home then, Thanks!

@BielBdeLuna
Copy link

Motorsep, I didn't know about that. Do you need to do anything special in the material in order for it to recognize the alpha channel in the specular map?

@motorsep
Copy link

motorsep commented Jun 4, 2014

nope, material system doesn't support it. I don't know for sure BFG engine supports it, but idTech 4 does.

@RobertBeckebans
Copy link
Owner

The BFG renderer does not support alpha values in the specularmaps. It
would require changes to the .bimage format with DXT5 instead of DXT1 RGB
compression and changes to the interaction shaders.

2014-06-04 22:54 GMT+02:00 motorsep notifications@github.com:

nope, material system doesn't support it. I don't know for sure BFG engine
supports it, but idTech 4 does.


Reply to this email directly or view it on GitHub
#131 (comment)
.

@BielBdeLuna
Copy link

and having the material shader having a "gloss" value for a more generalist approach to the issue? so instead of having a new map to take care of, maybe it could be easier to treat the whole surface of that material as a whole when it comes to glossiness level. would it be?

@ghost
Copy link
Author

ghost commented Jun 4, 2014

Biel, yeah that'd be a pretty good trade off. Controlling the "sharpness" of the specular like Prey does in the material. I've gotten some decent results doing, Not UE4 results, but good enough.

@ghost
Copy link
Author

ghost commented Jun 4, 2014

I added an alpha channel to my specular and it didn't change the gloss at all. In Vanilla D3

@motorsep
Copy link

motorsep commented Jun 4, 2014

@garthhendy Your alpha channel has to be <250 RGB, otherwise it will be treated as 255, which is what engine uses by default for gloss.

Material shader? What is that? GLSL shader? Why do that and give up a bit of performance?

@ghost
Copy link
Author

ghost commented Jun 4, 2014

I'm painting with grey 175 RGB value with a black back ground and it doesn't affect the gloss at all.

@BielBdeLuna
Copy link

no, Motorsep I meant a new argument in the material shader definition, so it's the whole surface that is treated equal, you don't get the same control, as having a an image to express different gloss values for every texel, but you get some on the glossiness on the whole of the material. it might prove an improvement on the gloss from standard D3 where everything has the same amount of gloss.

@ghost
Copy link
Author

ghost commented Jun 4, 2014

http://i.imgur.com/NKPRthk.jpg screenshot of material

http://i.imgur.com/0TmQpUn.jpg shot of the alpha channel. As you can see I get nothing affecting the gloss. The metal part in the middle should be affected.

@ghost
Copy link
Author

ghost commented Jun 4, 2014

So I did a bit of googling and people reference Carmack saying Doom 3 doesn't support gloss maps. Engine coders who are dabbling with the engine say it doesn't support gloss maps. So something is a miss here.

@BielBdeLuna
Copy link

in fact in d3w.org there was a funny user who kept posting on this issue but soon it turned to postwar. it was funny back then. but one thing is doom3 as a product, another the open source engine. gloss maps are possible (in fact it's one of the new things on the new rendering techniques in the render engines today)

@ghost
Copy link
Author

ghost commented Jun 4, 2014

Oh yeah gloss is possible. I found it strange that all of a sudden I didn't know vanilla D3 supported Gloss maps. I've been using the engine since 2004 and shipped a retail game on idtech4 so I'm pretty well versed in knowing what it can and cannot do.

I'd still be totally down with how Prey controls the gloss though. No alpha channel, just values in the material.

{
blend   specularmap
map     textures/scifi_clean/scifi_clean_s
specularexp 240, 1
}   

A value of 1 gives it a soft skin look, a value of 240 is like metal, and 750 is like a wet slime look.

I played around with this in Prey a bunch and it's pretty damn good.

@motorsep
Copy link

motorsep commented Jun 4, 2014

@garthhendy What idTech 4 game did you ship and what was your role?

I'll check our old engine and see if gloss was ever added in the code. I am almost positive it was supported from day 1.

@RobertBeckebans
Copy link
Owner

From base/renderprogs/interaction.pixel

That is the part that controls the light equation and specular contribution

const half specularPower = 10.0f;
half hDotN = dot3( normalize( fragment.texcoord6.xyz ), localNormal );
half3 specularContribution = _half3( pow( abs( hDotN ), specularPower ) );

half3 diffuseColor = diffuseMap * rpDiffuseModifier.xyz;
half3 specularColor = specMap.xyz * specularContribution *
rpSpecularModifier.xyz;
half3 lightColor = lightProj.xyz * lightFalloff.xyz;

result.color.xyz = ( diffuseColor + specularColor ) * lambert * lightColor

  • fragment.color.rgb;// + rimColor;
    result.color.w = 1.0;

Vanilla D3 used texture lookup to calc the specular contribution so it had
a fixed specular power too.

A simple gloss map implementation would be to scale the alpha channel of
the specMap which is in range from 0 to 1 to something like 0 and 100.

Then it would be something like

const half specularPower = specMap.a * 100;
half3 specularContribution = _half3( pow( abs( hDotN ), specularPower ) )

However this would break compatibility with the original assets because if
there is no alpha value then specMap.a will be 1 and 1 * 100 = 100 instead
of 10.
The result would be similar to UE4 roughness 0. I'm not sure if a scalar
multiplier like 10 is enough for good artistic control.

2014-06-05 1:13 GMT+02:00 motorsep notifications@github.com:

@garthhendy https://github.com/garthhendy What idTech 4 game did you
ship and what was your role?

I'll check our old engine and see if gloss was ever added in the code. I
am almost positive it was supported from day 1.


Reply to this email directly or view it on GitHub
#131 (comment)
.

@motorsep
Copy link

motorsep commented Jun 4, 2014

@RobertBeckebans Where in idTEch 4 would that look up code for specular be? I could diff my fork with vanilla and see if gloss code was added at some point.

@RobertBeckebans
Copy link
Owner

In the interaction.vfp ARB assembly shader.

2014-06-05 1:25 GMT+02:00 motorsep notifications@github.com:

@RobertBeckebans https://github.com/RobertBeckebans Where in idTEch 4
would that look up code for specular be? I could diff my fork with vanilla
and see if gloss code was added at some point.


Reply to this email directly or view it on GitHub
#131 (comment)
.

@motorsep
Copy link

motorsep commented Jun 4, 2014

Ahh, too good to be true - indeed that was added to the shader :( I thought Doom 3 always supported gloss.

@BielBdeLuna
Copy link

now I've found again the Sikkpin mod that added gloss maps in the alpha channel of the specular map
https://web.archive.org/web/20130909073250/http://www.doom3world.org/phpbb2/viewtopic.php?t=24193
in here there is the ARB implementation on having lights with cubemaps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants