LDraw.org Discussion Forums
OpengGL color / material properties - Printable Version

+- LDraw.org Discussion Forums (https://forums.ldraw.org)
+-- Forum: Models and Parts (https://forums.ldraw.org/forum-18.html)
+--- Forum: Parts Authoring (https://forums.ldraw.org/forum-19.html)
+--- Thread: OpengGL color / material properties (/thread-9763.html)

Pages: 1 2 3

OpengGL color / material properties - Roland Melkert - 2013-08-25

Hi all,

I'm playing around with making the difference between plastic and e.g. rubber parts visible in LDCad.

I've found some nice OpenGL material references but was wondering if there is some kind of 'standard' floating around. Especially for determining the diffuse, ambient and specular components based upon the single rgb supplied in LDConfig.ldr

Up to now I'm using the rgb for both diffuse and ambient, and have a static specular of 1,1,1 and shininess of 128 (which is more appropriate for chrome I'm realizing now).

I'm doing this with the standard lighting model (not shaders) for now (LDCad runs on OpenGL as low as 1.1), so I only can play with the base four components for now.

Re: OpengGL color / material properties - Ben Supnik - 2013-08-25

Hi Roland,

I'm not sure what kind of standard you're looking for. The LDConfig file appears to specify the material primarily through enumerations, which I think is good - standardizing the lighting model for LDraw would IMO be really problematic. (Either the lighting model would be extremely complex and every non-shader-based renderer would have to ignore the spec, or the lighting standard would be something that could be implemented in fixed function and we'd miss out on a lot of really good effects.)

In terms of actual rendering, when I did my first materials experiment I found that having a fresnel term to limit the specular hilites really helped to differentiate plastic and metal. In the experiment I used cube maps for both reflections and specularity; the fresnel term makes the plastic more reflective "on edge" than when viewed "straight on" - which makes the material not just look like a dull mirror.

(The code I used came straight from GPU gems chapter 19 - Schlick's fresnel approximation is what everyone uses.)



Re: OpengGL color / material properties - Roland Melkert - 2013-08-25

Ben Supnik Wrote:I'm not sure what kind of standard you're looking for.

Well the part authors have gone trough some trouble to define the RGB's of colors (which I consider the diffuse ones), so I was thinking maybe they have (secret) tables of the specular, ambient and shininess ones too.

I too discovered playing with specular (and shininess) is pretty much enough to create visual distinctions. I was a bit put off guard by 'scientific' tables like this one:

OpenGL material table

But it seems using the ldr RGB as both ambient and diffuse in combinations with static (shades of white) specular and shininess values per material finish type is good enough for most ldraw colors.

Thanks for the more advanced pointers Ben, I might go that route for the HQ option, but first I want an basic one. So I'm going to continue playing / tweaking the specular and shininess values for a while. If any of the part / color maintainers have ideas on those please let me know.

Re: OpengGL color / material properties - Travis Cobbs - 2013-08-26

For what it's worth, LDView uses the following:
| Specular         | Shininess
Standard    | .5, .5, .5       | 64
Transparent | .75, .75, .75    | 128
Rubber      | .075, .075, .075 | 15

It uses RGB for ambient and diffuse. Its standard lighting uses .2, .2, .2 for the ambient term, and its diffuse lighting uses .7, .7, .7. I also enable GL_SEPARATE_SPECULAR_COLOR in order to have correct specular on textured sections.

I did spend some time fiddling with the numbers looking for values that looked good, but I'll freely admit that it's highly likely that better numbers exist.

Re: OpengGL color / material properties - Roland Melkert - 2013-08-26

Thanks Travis,

I've been playing around and I'm using the following at the moment (shininess 0..1):

specular=0.5 0.5 0.5

specular=1 1 1

specular=0.3 0.3 0.3

specular=0.1 0.1 0.1

specular=0.4 0.4 0.4

specular=0.8 0.8 0.8

Although I'm not very happy with the metal and chrome ones, the difference with plain plastic is almost invisible unless you rotate it continuously so the spec properties become more apparent.

Re: OpengGL color / material properties - Roland Melkert - 2013-09-03

Ok, I've managed to get chrome more 'chromy'.

[Image: chromeTest.png]

but I'm still not completely happy, it's like you need to watch the picture for awhile in order to 'learn' the contrast, so the longer you look the more metal/chrome it starts to look.

But on the other hand I think this is the best you can do without using texture maps and or custom shaders, or does anybody have has a different insight?

Also it seems the current LDConfig doesn't use the 'matte metal' property for any color, I would have expected it to be used for at least magnets or something.

Re: OpengGL color / material properties - Travis Cobbs - 2013-09-03

I think it's about as good as you can do. In LDView, I cheated when ldconfig.ldr parsing is turned off, and use a light blue specular for chrome, which doesn't provide an accurate look, but at least provides a distinct look.

For what it's worth, Lego magnets aren't metal; they're ceramic.

Re: OpengGL color / material properties - Ben Supnik - 2013-09-03

I think you've gotten as much as you can out of the fixed function pipeline without environment texture maps - to even get that level of shininess is good!

(You can technically do some limited cube mapping or sphere mapping with fixed function, although by that point you might just want to invest in some shaders. :-)


Re: OpengGL color / material properties - Roland Melkert - 2013-09-04

Magnet is defined as metal in the current LDConfig.ldr which is too shiny imho.

That's why I expected it to be matte metal (duller look), which I discovered isn't used anywhere at the moment.

Re: OpengGL color / material properties - Roland Melkert - 2013-09-04

I'm basically using overexposure Smile

In a future version I want to introduce HQ rendering which will be using env mapping and maybe things like bump mapping to simulate imperfect (rubber) surfaces etc.

I might even give shader based ray tracing a try for fun.