Procedural texturing in OGLSL

hi all,
i’d like to simulate the metal flakes effect on the mesh of a car, and the only way i can think of is with a procedural testure containing the small bumps and flakes that become visible getting closer to the surface.
Now how can i produce the procedural texture in GL Shading Language? Does anybody knows that???

thx the G.

Couldn’t you get that effect by basing your specular lighting on a really high-frequency normal map? The normal map could probably just be a bunch of random vectors pointing every which way.

There is a GLSL metal paint sample included in the NVIDIA SDK 7.0, you can download the individual sample here:

http://download.nvidia.com/developer/SDK/Individual_Samples/samples.html#glsl_metalpaint

or if you have the SDK installed, you can find it in DEMOS\OpenGL\src\glsl_metalpaint within the SDK folder.

Has anyone of you managed to get the metalpaint shaders from the NVIDIA SDK 8.0 running on ATI hardware (I’m using a Radeon 9800 Pro, Catalyst 4.9)? In fact, they compile out-of-the-box, but they only run in software. I’ve absolutely no clue why that’s the case. At least I figured out when replacing “f” with a constant in line 155, the shaders run in hardware. This is not much of a help, though …

Originally posted by eyebex:
In fact, they compile out-of-the-box, but they only run in software. I’ve absolutely no clue why that’s the case. At least I figured out when replacing “f” with a constant in line 155, the shaders run in hardware. This is not much of a help, though …
f is the fresnel term which is computed in the fragment program. If you change that to a constant it no longer needs to get computed so the shader goes from ~100 instructions to ~70 instructions which probably fits within your hardwares fragment program limits.

Thanks, I meanwhile assumed something like this. Do you know what’s the limit for fragment shaders on ATI hardware? What kind of tool do you use to count the number of assembly lines generated by the GLSL compiler?

EDIT: The limit seems to be 96 instructions …

I think rendermonkey includes a car paint example which includes the type of effect you’re after. IT was used in a launch demo for the 9700 so it’s definitely doable on that hardware. There are also pdf:s that document the technique at ATIs dev site.

Thanks, I already managed to optimize NV’s metalpaint code somewhat to squeeze it into 96 instructions, i.e. the shader now runs in hardware on my ATI.

The limit seems to be 96 instructions …
No, it is not. Or, more exactly, it is not 96 of the same instruction.

The card is capable of performing 32 texture ops, 32 3-vector, and 32 scalar ops. If you do a 4-vector op, then you use up both a 3-vector and a 4-vector operation.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.