erM
This commit is contained in:
parent
7f9cd7ef7c
commit
cce6a90cbd
14
c3d.c
14
c3d.c
|
@ -124,7 +124,7 @@ void Tri2DSortByY(Tri2D *t) {
|
|||
}
|
||||
|
||||
void DrawScanline(Zee *zee, Tri2D *trianglepointer, double start, double end, int scanline) {
|
||||
|
||||
float depth = 0;
|
||||
Vector3 f1baryatpoint = Tri2DBaryAtPoint(trianglepointer, (Vector2){Max(start, 0), scanline});
|
||||
float f1depth = DepthAtBary(trianglepointer, f1baryatpoint);
|
||||
|
||||
|
@ -137,13 +137,15 @@ void DrawScanline(Zee *zee, Tri2D *trianglepointer, double start, double end, in
|
|||
for (int i = (Max(start, 0)); i < (Min(end, RENDERWIDTH)); i++) {
|
||||
/* zee[IndexOfZBuff(i, scanline)].triangle = tp; */
|
||||
|
||||
/* Vector3 baryatpoint = Tri2DBaryAtPoint(tp, (Vector2){i, scanline}); */
|
||||
/* float depth = DepthAtBary(tp, baryatpoint); */
|
||||
|
||||
float aproxdepth = f1depth + (dslope * ((float)i - (float)(Max(start, 0))));
|
||||
if (aproxdepth > zee[IndexOfZBuff(i, scanline)].depth) {
|
||||
//UNCOMMENT TO DO TRUE NON SLOPE BASED DEPTH CALC:
|
||||
/* Vector3 baryatpoint = Tri2DBaryAtPoint(trianglepointer, (Vector2){i, scanline}); */
|
||||
/* depth = DepthAtBary(trianglepointer, baryatpoint); */
|
||||
|
||||
depth = f1depth + (dslope * ((float)i - (float)(Max(start, 0))));
|
||||
if (depth > zee[IndexOfZBuff(i, scanline)].depth) {
|
||||
zee[IndexOfZBuff(i, scanline)].c = trianglepointer->color;
|
||||
zee[IndexOfZBuff(i, scanline)].depth = aproxdepth;
|
||||
zee[IndexOfZBuff(i, scanline)].depth = depth;
|
||||
//zee[IndexOfZBuff(i, scanline)].tri = trianglepointer;
|
||||
}
|
||||
}
|
||||
|
|
15
c3dtypes.h
15
c3dtypes.h
|
@ -16,6 +16,12 @@ struct LocalCam {
|
|||
};
|
||||
typedef struct LocalCam LocalCam;
|
||||
|
||||
struct CMaterial {
|
||||
char * name;
|
||||
char * texturefile;
|
||||
};
|
||||
typedef struct CMaterial CMaterial;
|
||||
|
||||
struct Tri {
|
||||
Vector3 a;
|
||||
Vector3 b;
|
||||
|
@ -23,6 +29,7 @@ struct Tri {
|
|||
|
||||
Color color;
|
||||
|
||||
Material material;
|
||||
|
||||
Vector2 auv;
|
||||
Vector2 buv;
|
||||
|
@ -30,10 +37,6 @@ struct Tri {
|
|||
|
||||
};
|
||||
|
||||
struct Mat {
|
||||
char * name;
|
||||
char * file;
|
||||
}
|
||||
|
||||
typedef struct Tri Tri;
|
||||
|
||||
|
@ -42,8 +45,6 @@ struct Tri2D {
|
|||
Vector2 b;
|
||||
Vector2 c;
|
||||
|
||||
|
||||
|
||||
float adepth;
|
||||
float bdepth;
|
||||
float cdepth;
|
||||
|
@ -76,8 +77,6 @@ struct Tri2DArray {
|
|||
};
|
||||
typedef struct Tri2DArray Tri2DArray;
|
||||
|
||||
|
||||
|
||||
struct Object3D {
|
||||
char name[100];
|
||||
TriArray * triangles;
|
||||
|
|
Loading…
Reference in a new issue