SeskaPeel

03-03-2004, 07:20 AM

After browsing through the specs, it apperas clearly how to implement fog in fragment program, either using OPTION fog, either copying the code from the spec.

This code use the fragment.fogcoord.x param that has to be written by the vertex program ... but ... couldn't find what is the exact computation to perform ...

Code snippet from ARB_fp spec :

EXP2:

#

# 2nd-order Exponential fog

# f = exp(-(d*z)^2)

#

PARAM p = {DENSITY/SQRT(LN(2)), NOT USED, NOT USED, NOT USED};

PARAM fogColor = state.fog.color;

TEMP fogFactor;

ATTRIB fogCoord = fragment.fogcoord.x;

MUL fogFactor.x, p.x, fogCoord.x;

MUL fogFactor.x, fogFactor.x, fogFactor.x;

EX2_SAT fogFactor.x, -fogFactor.x;

LRP result.color.rgb, fogFactor.x, finalColor, fogColor;

(Note this won't compile because of the ATTRIB line).

How am I supposed to compute the fragment.fogcoord.x ? (I suppose it must differ between radial and plane distance)

Thanks,

SeskaPeel.

[This message has been edited by SeskaPeel (edited 03-03-2004).]

[This message has been edited by SeskaPeel (edited 03-03-2004).]

This code use the fragment.fogcoord.x param that has to be written by the vertex program ... but ... couldn't find what is the exact computation to perform ...

Code snippet from ARB_fp spec :

EXP2:

#

# 2nd-order Exponential fog

# f = exp(-(d*z)^2)

#

PARAM p = {DENSITY/SQRT(LN(2)), NOT USED, NOT USED, NOT USED};

PARAM fogColor = state.fog.color;

TEMP fogFactor;

ATTRIB fogCoord = fragment.fogcoord.x;

MUL fogFactor.x, p.x, fogCoord.x;

MUL fogFactor.x, fogFactor.x, fogFactor.x;

EX2_SAT fogFactor.x, -fogFactor.x;

LRP result.color.rgb, fogFactor.x, finalColor, fogColor;

(Note this won't compile because of the ATTRIB line).

How am I supposed to compute the fragment.fogcoord.x ? (I suppose it must differ between radial and plane distance)

Thanks,

SeskaPeel.

[This message has been edited by SeskaPeel (edited 03-03-2004).]

[This message has been edited by SeskaPeel (edited 03-03-2004).]