> Actually, the code that creates the texture is in
> scene/util/StateAttributeFactory.cxx, but you would have to do
> something similar to the noise texture code in TextureBuilder to
> access your texture from a texture. It would be nice if the Effects
> framework had a way to load arbitrary textures and make them available
> to effects.
>  These days you aren't limited to 8 bit texture components. There is a
> rich set of data formats for textures: 32 bit floats, 16 bit floats,
> exotic combinations of different length floats per RGB component... I
> don't know if there is a better way to create your texture offline
> than write C++ code in simgear. OSG will read a TIFF file with 32bits
> per component as a floating point texture... assuming you can create
> such a thing.

Thanks for the explanations and locations.

After some experiments, it seems the way to do this is to implement the noise 
function directly as GLSL code in the fragment shader. This has a whole bunch 
of advantages:

1) Creating a 4-component noise vector corresponding to what is in the texture 
beats the texture lookup call by (very roughly) ~20% on my system
2) Unlike a noise texture, noise generated on the fly never has tiling 
artefacts, so there is no need to superimpose nearby wavelengths in the first 
place, saving between a third and half of the total use of noise
3) Unlike texture lookup, the noise function can be evaluated just when needed, 
even inside a non-uniform conditional,i.e. for instance respecting a distance 
cut which makes a lot of sense for LOD, again that saves a lot of un-needed work

(and 4), I can write it in a completely intuitive way by passing a wavelength 
in and getting a number between 0 and 1 out, so there's no need to do any 
re-scaling and mental arithmetics).

So, that just means I have to change a few numbers everywhere...

* Thorsten
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Flightgear-devel mailing list

Reply via email to