projects
/
mesa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ARB prog lexer: Fix lexer to eat both DOS and Unix line endings
[mesa.git]
/
src
/
mesa
/
tnl
/
t_vb_fog.c
diff --git
a/src/mesa/tnl/t_vb_fog.c
b/src/mesa/tnl/t_vb_fog.c
index 5440ff7894d70b51a080c8beb947a3828e106eb8..f3a7bd49f40189a4ca81ebc92e0365a9d315138a 100644
(file)
--- a/
src/mesa/tnl/t_vb_fog.c
+++ b/
src/mesa/tnl/t_vb_fog.c
@@
-26,12
+26,12
@@
*/
*/
-#include "glheader.h"
-#include "colormac.h"
-#include "context.h"
-#include "macros.h"
-#include "imports.h"
-#include "mtypes.h"
+#include "
main/
glheader.h"
+#include "
main/
colormac.h"
+#include "
main/
context.h"
+#include "ma
in/ma
cros.h"
+#include "
main/
imports.h"
+#include "m
ain/m
types.h"
#include "math/m_xform.h"
#include "math/m_xform.h"
@@
-41,7
+41,6
@@
struct fog_stage_data {
GLvector4f fogcoord; /* has actual storage allocated */
struct fog_stage_data {
GLvector4f fogcoord; /* has actual storage allocated */
- GLvector4f input; /* points into VB->EyePtr Z values */
};
#define FOG_STAGE_DATA(stage) ((struct fog_stage_data *)stage->privatePtr)
};
#define FOG_STAGE_DATA(stage) ((struct fog_stage_data *)stage->privatePtr)
@@
-91,7
+90,8
@@
init_static_data( void )
* evaluating the GL_LINEAR, GL_EXP or GL_EXP2 fog function.
* Fog coordinates are distances from the eye (typically between the
* near and far clip plane distances).
* evaluating the GL_LINEAR, GL_EXP or GL_EXP2 fog function.
* Fog coordinates are distances from the eye (typically between the
* near and far clip plane distances).
- * Note the fog (eye Z) coords may be negative so we use ABS(z) below.
+ * Note that fogcoords may be negative, if eye z is source absolute
+ * value must be taken earlier.
* Fog blend factors are in the range [0,1].
*/
static void
* Fog blend factors are in the range [0,1].
*/
static void
@@
-114,7
+114,7
@@
compute_fog_blend_factors(GLcontext *ctx, GLvector4f *out, const GLvector4f *in)
else
d = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) {
else
d = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) {
- const GLfloat z =
FABSF(*v)
;
+ const GLfloat z =
*v
;
GLfloat f = (end - z) * d;
data[i][0] = CLAMP(f, 0.0F, 1.0F);
}
GLfloat f = (end - z) * d;
data[i][0] = CLAMP(f, 0.0F, 1.0F);
}
@@
-122,14
+122,14
@@
compute_fog_blend_factors(GLcontext *ctx, GLvector4f *out, const GLvector4f *in)
case GL_EXP:
d = ctx->Fog.Density;
for ( i = 0 ; i < n ; i++, STRIDE_F(v,stride)) {
case GL_EXP:
d = ctx->Fog.Density;
for ( i = 0 ; i < n ; i++, STRIDE_F(v,stride)) {
- const GLfloat z =
FABSF(*v)
;
+ const GLfloat z =
*v
;
NEG_EXP( data[i][0], d * z );
}
break;
case GL_EXP2:
d = ctx->Fog.Density*ctx->Fog.Density;
for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) {
NEG_EXP( data[i][0], d * z );
}
break;
case GL_EXP2:
d = ctx->Fog.Density*ctx->Fog.Density;
for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) {
- const GLfloat z =
FABSF(*v)
;
+ const GLfloat z =
*v
;
NEG_EXP( data[i][0], d * z * z );
}
break;
NEG_EXP( data[i][0], d * z * z );
}
break;
@@
-148,11
+148,13
@@
run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
struct fog_stage_data *store = FOG_STAGE_DATA(stage);
GLvector4f *input;
struct fog_stage_data *store = FOG_STAGE_DATA(stage);
GLvector4f *input;
- if (!ctx->Fog.Enabled || ctx->VertexProgram._Current)
- return GL_TRUE;
+ if (!ctx->Fog.Enabled)
+ return GL_TRUE;
- if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT) {
+ if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT && !ctx->VertexProgram._Current) {
+ GLuint i;
+ GLfloat *coord;
/* Fog is computed from vertex or fragment Z values */
/* source = VB->ObjPtr or VB->EyePtr coords */
/* dest = VB->AttribPtr[_TNL_ATTRIB_FOG] = fog stage private storage */
/* Fog is computed from vertex or fragment Z values */
/* source = VB->ObjPtr or VB->EyePtr coords */
/* dest = VB->AttribPtr[_TNL_ATTRIB_FOG] = fog stage private storage */
@@
-167,11
+169,10
@@
run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
*/
input = &store->fogcoord;
*/
input = &store->fogcoord;
- /* NOTE: negate plane here so we get positive fog coords! */
- plane[0] = -m[2];
- plane[1] = -m[6];
- plane[2] = -m[10];
- plane[3] = -m[14];
+ plane[0] = m[2];
+ plane[1] = m[6];
+ plane[2] = m[10];
+ plane[3] = m[14];
/* Full eye coords weren't required, just calculate the
* eye Z values.
*/
/* Full eye coords weren't required, just calculate the
* eye Z values.
*/
@@
-180,18
+181,29
@@
run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
VB->ObjPtr, plane );
input->count = VB->ObjPtr->count;
VB->ObjPtr, plane );
input->count = VB->ObjPtr->count;
+
+ /* make sure coords are really positive
+ NOTE should avoid going through array twice */
+ coord = input->start;
+ for (i = 0; i < input->count; i++) {
+ *coord = FABSF(*coord);
+ STRIDE_F(coord, input->stride);
+ }
}
else {
}
else {
- /* fog coordinates = eye Z coordinates
(use ABS later)
*/
- input = &store->
input
;
+ /* fog coordinates = eye Z coordinates
- need to copy for ABS
*/
+ input = &store->
fogcoord
;
if (VB->EyePtr->size < 2)
_mesa_vector4f_clean_elem( VB->EyePtr, VB->Count, 2 );
if (VB->EyePtr->size < 2)
_mesa_vector4f_clean_elem( VB->EyePtr, VB->Count, 2 );
- input->data = (GLfloat (*)[4]) &(VB->EyePtr->data[0][2]);
- input->start = VB->EyePtr->start+2;
- input->stride = VB->EyePtr->stride;
+ input->stride = 4 * sizeof(GLfloat);
input->count = VB->EyePtr->count;
input->count = VB->EyePtr->count;
+ coord = VB->EyePtr->start;
+ for (i = 0 ; i < VB->EyePtr->count; i++) {
+ input->data[i][0] = FABSF(coord[2]);
+ STRIDE_F(coord, VB->EyePtr->stride);
+ }
}
}
else {
}
}
else {
@@
-234,7
+246,6
@@
alloc_fog_data(GLcontext *ctx, struct tnl_pipeline_stage *stage)
return GL_FALSE;
_mesa_vector4f_alloc( &store->fogcoord, 0, tnl->vb.Size, 32 );
return GL_FALSE;
_mesa_vector4f_alloc( &store->fogcoord, 0, tnl->vb.Size, 32 );
- _mesa_vector4f_init( &store->input, 0, NULL );
if (!inited)
init_static_data();
if (!inited)
init_static_data();