Added option to set 'full Osa' on non raytraced scenes. This makes sure

old files still use the old fast OSA, and when you want a specific
material to have specular/shader/texture AA you can set this individual.

When rendering ray_mir or ray_transp or ray_shadow the new OSA will be
effective by default however.

Still todo; make this switch work for transparant faces and unified...
This commit is contained in:
Ton Roosendaal
2004-07-27 22:23:45 +00:00
parent f3beeec296
commit fb40ae6413
7 changed files with 92 additions and 46 deletions

View File

@@ -141,6 +141,7 @@ typedef struct Material {
#define MA_RAMP_COL 0x100000
#define MA_RAMP_SPEC 0x200000
#define MA_RAYBIAS 0x400000
#define MA_FULL_OSA 0x800000
/* diff_shader */
#define MA_DIFF_LAMBERT 0

View File

@@ -345,11 +345,11 @@ typedef struct Scene {
#define R_RENDERING 16
#define R_ANIMRENDER 32
/* vlakren->flag (vlak = face in dutch) */
/* vlakren->flag (vlak = face in dutch) char!!! */
#define R_SMOOTH 1
#define R_VISIBLE 2
#define R_NOPUNOFLIP 8
#define R_CMAPCODE 16
#define R_FULL_OSA 16
#define R_FACE_SPLIT 32
#define R_DIVIDE_24 64 /* Tells render to divide face other way. */

View File

@@ -185,7 +185,7 @@ typedef struct RadFace {
typedef struct VlakRen
{
struct VertRen *v1, *v2, *v3, *v4;
float n[3], len;
float n[3];
struct Material *mat;
struct TFace *tface;
unsigned int *vcol;
@@ -197,6 +197,7 @@ typedef struct VlakRen
Object *ob;
} VlakRen;
/* vlakren->flag is in DNA_scene_types.h */
typedef struct HaloRen
{

View File

@@ -3095,6 +3095,7 @@ void zbufshadeDA(void) /* Delta Accum Pixel Struct */
{
extern float Zjitx,Zjity;
PixStr *ps;
VlakRen *vlr;
float xd, yd, xs, ys;
unsigned int *rz, *rp, *rt, mask, fullmask;
unsigned int *rowbuf1, *rowbuf2, *rowbuf3, *rb1, *rb2, *rb3;
@@ -3189,7 +3190,7 @@ void zbufshadeDA(void) /* Delta Accum Pixel Struct */
ps= (PixStr *) POINTER_FROM_CODE(*rd);
else ps= NULL;
if(TRUE) {
if(0) {
for(samp=0; samp<R.osa; samp++) {
curmask= 1<<samp;
@@ -3212,33 +3213,57 @@ void zbufshadeDA(void) /* Delta Accum Pixel Struct */
}
}
else { /* do collected faces together */
if(ps) face= ps->vlak0;
else face= (int)*rd;
int full_osa, face0;
if(ps) face0= ps->vlak0;
else face0= (int)*rd;
mask= 0;
while(ps) {
b= centmask[ps->mask];
xs= (float)x+centLut[b & 15];
ys= (float)y+centLut[b>>4];
shadepixel_short(xs, ys, ps->vlak, ps->mask, shortcol);
if(shortcol[3]) add_filt_mask(ps->mask, shortcol, rb1, rb2, rb3);
mask |= ps->mask;
ps= ps->next;
}
mask= (~mask) & fullmask;
if(mask) {
b= centmask[mask];
xs= (float)x+centLut[b & 15];
ys= (float)y+centLut[b>>4];
shadepixel_short(xs, ys, face, mask, shortcol);
/* complex loop, because first pixelstruct has a vlak0, without mask */
while(TRUE) {
if(ps==NULL) {
face= face0;
curmask= (~mask) & fullmask;
}
else {
face= ps->vlak;
curmask= ps->mask;
}
/* check osa level */
if(face==0) full_osa= 0;
else {
vlr= RE_findOrAddVlak( (face-1) & 0x7FFFFF);
full_osa= (vlr->flag & R_FULL_OSA);
}
if(full_osa) {
for(samp=0; samp<R.osa; samp++) {
if(curmask & (1<<samp)) {
xs= (float)x + jit[samp][0];
ys= (float)y + jit[samp][1];
shadepixel_short(xs, ys, face, curmask, shortcol);
if(shortcol[3]) add_filt_mask(1<<samp, shortcol, rb1, rb2, rb3);
}
}
}
else {
b= centmask[curmask];
xs= (float)x+centLut[b & 15];
ys= (float)y+centLut[b>>4];
shadepixel_short(xs, ys, face, curmask, shortcol);
if(shortcol[3]) add_filt_mask(mask, shortcol, rb1, rb2, rb3);
if(shortcol[3]) add_filt_mask(curmask, shortcol, rb1, rb2, rb3);
}
mask |= curmask;
if(ps==NULL) break;
else ps= ps->next;
}
}
rb1+=4;

View File

@@ -1191,9 +1191,9 @@ static void init_render_mball(Object *ob)
vlr->v4= 0;
if(ob->transflag & OB_NEG_SCALE)
vlr->len= CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->n);
CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->n);
else
vlr->len= CalcNormFloat(vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n);
CalcNormFloat(vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n);
vlr->mat= ma;
vlr->flag= ME_SMOOTH+R_NOPUNOFLIP;
@@ -1207,9 +1207,9 @@ static void init_render_mball(Object *ob)
vlr1->v2= vlr1->v3;
vlr1->v3= RE_findOrAddVert(startvert+index[3]);
if(ob->transflag & OB_NEG_SCALE)
vlr->len= CalcNormFloat(vlr1->v1->co, vlr1->v2->co, vlr1->v3->co, vlr1->n);
CalcNormFloat(vlr1->v1->co, vlr1->v2->co, vlr1->v3->co, vlr1->n);
else
vlr->len= CalcNormFloat(vlr1->v3->co, vlr1->v2->co, vlr1->v1->co, vlr1->n);
CalcNormFloat(vlr1->v3->co, vlr1->v2->co, vlr1->v1->co, vlr1->n);
}
}
@@ -1452,7 +1452,8 @@ static void init_render_mesh(Object *ob)
if(dlm && (dlm->flag & ME_OPT_EDGES)==0) edcode= ME_V1V2|ME_V2V3|ME_V3V4|ME_V4V1;
if(v3) {
float len;
vlr= RE_findOrAddVlak(R.totvlak++);
vlr->ob= ob;
vlr->v1= RE_findOrAddVert(vertofs+v1);
@@ -1462,9 +1463,9 @@ static void init_render_mesh(Object *ob)
else vlr->v4= 0;
/* render normals are inverted in render */
if(vlr->v4) vlr->len= CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co,
if(vlr->v4) len= CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co,
vlr->v1->co, vlr->n);
else vlr->len= CalcNormFloat(vlr->v3->co, vlr->v2->co, vlr->v1->co,
else len= CalcNormFloat(vlr->v3->co, vlr->v2->co, vlr->v1->co,
vlr->n);
vlr->mat= ma;
@@ -1475,7 +1476,7 @@ static void init_render_mesh(Object *ob)
vlr->ec= edcode;
vlr->lay= ob->lay;
if(vlr->len==0) R.totvlak--;
if(len==0) R.totvlak--;
else {
if(vertcol) {
@@ -1955,7 +1956,6 @@ static void init_render_surf(Object *ob)
vlr->ob= ob;
vlr->v1= v1; vlr->v2= v2; vlr->v3= v3; vlr->v4= v4;
VECCOPY(vlr->n, n1);
vlr->len= flen;
vlr->lay= ob->lay;
vlr->mat= matar[ dl->col];
vlr->ec= ME_V1V2+ME_V2V3;
@@ -2094,7 +2094,6 @@ static void init_render_surf(Object *ob)
vlr->v3= v4;
vlr->v4= v2;
VECCOPY(vlr->n, n1);
vlr->len= flen;
vlr->lay= ob->lay;
vlr->mat= matar[ dl->col];
vlr->ec= ME_V1V2+ME_V2V3;
@@ -2342,9 +2341,9 @@ static void init_render_curve(Object *ob)
*/
if(frontside)
vlr->len= CalcNormFloat(vlr->v2->co, vlr->v3->co, vlr->v4->co, vlr->n);
CalcNormFloat(vlr->v2->co, vlr->v3->co, vlr->v4->co, vlr->n);
else
vlr->len= CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->n);
CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->n);
vlr->mat= matar[ nu->mat_nr ];
@@ -2673,6 +2672,26 @@ void RE_freeRotateBlenderScene(void)
R.totvlak=R.totvert=R.totlamp=R.tothalo= 0;
}
/* per face check if all samples should be taken.
if raytrace, do always for raytraced material, or when material full_osa set */
static void set_fullsample_flag(void)
{
VlakRen *vlr;
int a, trace;
trace= R.r.mode & R_RAYTRACE;
for(a=R.totvlak-1; a>=0; a--) {
vlr= RE_findOrAddVlak(a);
if(vlr->mat->mode & MA_FULL_OSA) vlr->flag |= R_FULL_OSA;
else if(trace) {
if(vlr->mat->mode & MA_SHLESS);
else if(vlr->mat->mode & (MA_RAYTRANSP|MA_RAYMIRROR|MA_SHADOW))
vlr->flag |= R_FULL_OSA;
}
}
}
static void check_non_flat_quads(void)
{
@@ -2976,6 +2995,7 @@ void RE_rotateBlenderScene(void)
if(blender_test_break()) return;
set_fullsample_flag();
check_non_flat_quads();
set_normalflags();
}
@@ -3091,10 +3111,10 @@ static void displace_render_face(VlakRen *vlr, float *scale)
/* Recalculate the face normal - if flipped before, flip now */
if(vlr->v4) {
vlr->len = CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n);
CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n);
}
else {
vlr->len= CalcNormFloat(vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n);
CalcNormFloat(vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n);
}
}

View File

@@ -1113,7 +1113,7 @@ static void render_panel_render(void)
uiDefButF(block, NUM,B_DIFF,"", 627,34,60,20,&G.scene->r.gauss,0.5, 1.5, 100, 2, "Sets the Gaussian filter size");
uiDefButI(block, TOG|BIT|9,REDRAWVIEWCAM, "Border", 565,13,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Render a small cut-out of the image");
uiDefButI(block, TOG|BIT|2,0, "Gamma", 627,13,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Enable gamma correction");
uiDefButI(block, TOG|BIT|2, B_REDR, "Gamma", 627,13,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Enable gamma correction");
uiBlockEndAlign(block);
}

View File

@@ -2604,6 +2604,7 @@ static void material_panel_tramir(Material *ma)
uiDefButF(block, NUMSLI, B_MATPRV, "Fac ", 170,140,140,20, &(ma->fresnel_mir_i), 1.0, 5.0, 10, 2, "Blending factor for Fresnel");
uiBlockBeginAlign(block);
uiDefButF(block, NUM, B_DIFF, "Zoffs:", 10,110,100,19, &(ma->zoffs), 0.0, 10.0, 0, 0, "Gives faces an artificial offset in the Z buffer for Ztransp option");
uiDefButI(block, TOG|BIT|6, B_MATZTRANSP,"ZTransp", 110,110,100,20, &(ma->mode), 0, 0, 0, 0, "Enables Z-Buffering of transparent faces");
uiDefButI(block, TOG|BIT|17, B_MATRAYTRANSP,"Ray Transp",210,110,100,20, &(ma->mode), 0, 0, 0, 0, "Enables raytracing for transparency rendering");
@@ -2844,9 +2845,7 @@ static void material_panel_material(Object *ob, Material *ma)
uiDefButI(block, TOG|BIT|7, B_REDR, "VCol Paint", 82,146,73,20, &(ma->mode), 0, 0, 0, 0, "Replaces material's colours with vertex colours");
uiDefButI(block, TOG|BIT|11, B_REDR, "TexFace", 156,146,73,20, &(ma->mode), 0, 0, 0, 0, "Sets UV-Editor assigned texture as color and texture info for faces");
uiDefButI(block, TOG|BIT|2, B_MATPRV, "Shadeless", 230,146,73,20, &(ma->mode), 0, 0, 0, 0, "Makes material insensitive to light or shadow");
uiBlockSetCol(block, TH_AUTO);
uiDefButF(block, NUM, 0, "Zoffs:", 8,127,147,19, &(ma->zoffs), 0.0, 10.0, 0, 0, "Gives faces an artificial offset in the Z buffer");
uiBlockSetCol(block, TH_BUT_SETTING1);
uiDefButI(block, TOG|BIT|23, 0, "Full Osa", 8,127,147,19, &(ma->mode), 0.0, 10.0, 0, 0, "Forces to render all OSA samples, for shading and texture antialiasing");
uiDefButI(block, TOG|BIT|3, 0, "Wire", 156,127,73,19, &(ma->mode), 0, 0, 0, 0, "Renders only the edges of faces as a wireframe");
uiDefButI(block, TOG|BIT|8, 0, "ZInvert", 230,127,73,19, &(ma->mode), 0, 0, 0, 0, "Renders material's faces with inverted Z Buffer");