Turned Sky render code in Blender to become fully float, it still returned
bytes for RGB. This to allow very bright contrasted images to be used for AO as well. As a first start also the Texture->Colors panel now allows contrast setting up to 5.0 (was 2.0).
This commit is contained in:
@@ -274,11 +274,11 @@
|
|||||||
if(Tin<0.0) Tin= 0.0; else if(Tin>1.0) Tin= 1.0;
|
if(Tin<0.0) Tin= 0.0; else if(Tin>1.0) Tin= 1.0;
|
||||||
|
|
||||||
#define BRICONRGB Tr= tex->rfac*((Tr-0.5)*tex->contrast+tex->bright-0.5); \
|
#define BRICONRGB Tr= tex->rfac*((Tr-0.5)*tex->contrast+tex->bright-0.5); \
|
||||||
if(Tr<0.0) Tr= 0.0; else if(Tr>1.0) Tr= 1.0; \
|
if(Tr<0.0) Tr= 0.0; \
|
||||||
Tg= tex->gfac*((Tg-0.5)*tex->contrast+tex->bright-0.5); \
|
Tg= tex->gfac*((Tg-0.5)*tex->contrast+tex->bright-0.5); \
|
||||||
if(Tg<0.0) Tg= 0.0; else if(Tg>1.0) Tg= 1.0; \
|
if(Tg<0.0) Tg= 0.0; \
|
||||||
Tb= tex->bfac*((Tb-0.5)*tex->contrast+tex->bright-0.5); \
|
Tb= tex->bfac*((Tb-0.5)*tex->contrast+tex->bright-0.5); \
|
||||||
if(Tb<0.0) Tb= 0.0; else if(Tb>1.0) Tb= 1.0;
|
if(Tb<0.0) Tb= 0.0;
|
||||||
|
|
||||||
/* mystifying stuff from blendef... */
|
/* mystifying stuff from blendef... */
|
||||||
#define SELECT 1
|
#define SELECT 1
|
||||||
|
|||||||
@@ -252,7 +252,8 @@ struct EnvMap *RE_copy_envmap(struct EnvMap *env);
|
|||||||
|
|
||||||
/* patch for the external if, to support the split for the ui */
|
/* patch for the external if, to support the split for the ui */
|
||||||
void RE_addalphaAddfac(char *doel, char *bron, char addfac);
|
void RE_addalphaAddfac(char *doel, char *bron, char addfac);
|
||||||
void RE_sky(float *view, char *col);
|
void RE_sky_char(float *view, char *col);
|
||||||
|
void RE_sky(float *view, float *col);
|
||||||
void RE_renderflare(struct HaloRen *har);
|
void RE_renderflare(struct HaloRen *har);
|
||||||
/**
|
/**
|
||||||
* Shade the pixel at xn, yn for halo har, and write the result to col.
|
* Shade the pixel at xn, yn for halo har, and write the result to col.
|
||||||
|
|||||||
@@ -1544,17 +1544,11 @@ static void traceray(short depth, float *start, float *vec, float *col, VlakRen
|
|||||||
|
|
||||||
}
|
}
|
||||||
else { /* sky */
|
else { /* sky */
|
||||||
char skycol[4];
|
|
||||||
|
|
||||||
VECCOPY(shi.view, vec);
|
VECCOPY(shi.view, vec);
|
||||||
Normalise(shi.view);
|
Normalise(shi.view);
|
||||||
|
|
||||||
RE_sky(shi.view, skycol);
|
RE_sky(shi.view, col);
|
||||||
|
|
||||||
col[0]= skycol[0]/255.0;
|
|
||||||
col[1]= skycol[1]/255.0;
|
|
||||||
col[2]= skycol[2]/255.0;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2121,7 +2115,7 @@ void ray_ao(ShadeInput *shi, World *wrld, float *shadfac)
|
|||||||
else sh+= 1.0;
|
else sh+= 1.0;
|
||||||
}
|
}
|
||||||
else if(wrld->aocolor!=WO_AOPLAIN) {
|
else if(wrld->aocolor!=WO_AOPLAIN) {
|
||||||
char skycol[4];
|
float skycol[4];
|
||||||
float fac, view[3];
|
float fac, view[3];
|
||||||
|
|
||||||
view[0]= -vec[0];
|
view[0]= -vec[0];
|
||||||
@@ -2137,9 +2131,9 @@ void ray_ao(ShadeInput *shi, World *wrld, float *shadfac)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
RE_sky(view, skycol);
|
RE_sky(view, skycol);
|
||||||
shadfac[0]+= skycol[0]/255.0;
|
shadfac[0]+= skycol[0];
|
||||||
shadfac[1]+= skycol[1]/255.0;
|
shadfac[1]+= skycol[1];
|
||||||
shadfac[2]+= skycol[2]/255.0;
|
shadfac[2]+= skycol[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,9 +163,9 @@ float mistfactor(float *co) /* dist en height, return alpha */
|
|||||||
return (1.0-fac)* (1-R.wrld.misi);
|
return (1.0-fac)* (1-R.wrld.misi);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RE_sky(float *view, char *col)
|
void RE_sky(float *view, float *col)
|
||||||
{
|
{
|
||||||
float lo[3], rf, gf, bf;
|
float lo[3];
|
||||||
|
|
||||||
if((R.wrld.skytype & (WO_SKYBLEND+WO_SKYTEX))==0) {
|
if((R.wrld.skytype & (WO_SKYBLEND+WO_SKYTEX))==0) {
|
||||||
*( (unsigned int *)col)= R.wrld.fastcol;
|
*( (unsigned int *)col)= R.wrld.fastcol;
|
||||||
@@ -206,22 +206,31 @@ void RE_sky(float *view, char *col)
|
|||||||
R.inprh= 1.0-R.inprz;
|
R.inprh= 1.0-R.inprz;
|
||||||
|
|
||||||
if(R.wrld.skytype & WO_SKYBLEND) {
|
if(R.wrld.skytype & WO_SKYBLEND) {
|
||||||
rf= 255.0*(R.inprh*R.wrld.horr + R.inprz*R.wrld.zenr);
|
col[0]= (R.inprh*R.wrld.horr + R.inprz*R.wrld.zenr);
|
||||||
gf= 255.0*(R.inprh*R.wrld.horg + R.inprz*R.wrld.zeng);
|
col[1]= (R.inprh*R.wrld.horg + R.inprz*R.wrld.zeng);
|
||||||
bf= 255.0*(R.inprh*R.wrld.horb + R.inprz*R.wrld.zenb);
|
col[2]= (R.inprh*R.wrld.horb + R.inprz*R.wrld.zenb);
|
||||||
|
|
||||||
if (rf>255.0) col[0]= 255;
|
|
||||||
else col[0]= (char)rf;
|
|
||||||
if (gf>255.0) col[1]= 255;
|
|
||||||
else col[1]= (char)gf;
|
|
||||||
if (bf>255.0) col[2]= 255;
|
|
||||||
else col[2]= (char)bf;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
col[0]= 255.0*R.wrld.horr;
|
col[0]= R.wrld.horr;
|
||||||
col[1]= 255.0*R.wrld.horg;
|
col[1]= R.wrld.horg;
|
||||||
col[2]= 255.0*R.wrld.horb;
|
col[2]= R.wrld.horb;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RE_sky_char(float *view, char *col)
|
||||||
|
{
|
||||||
|
float f, colf[3];
|
||||||
|
|
||||||
|
RE_sky(view, colf);
|
||||||
|
f= 255.0*colf[0];
|
||||||
|
if(f<=0.0) col[0]= 0; else if(f>255.0) col[0]= 255;
|
||||||
|
else col[0]= (char)f;
|
||||||
|
f= 255.0*colf[1];
|
||||||
|
if(f<=0.0) col[1]= 0; else if(f>255.0) col[1]= 255;
|
||||||
|
else col[1]= (char)f;
|
||||||
|
f= 255.0*colf[2];
|
||||||
|
if(f<=0.0) col[2]= 0; else if(f>255.0) col[2]= 255;
|
||||||
|
else col[2]= (char)f;
|
||||||
col[3]= 1; /* to prevent wrong optimalisation alphaover of flares */
|
col[3]= 1; /* to prevent wrong optimalisation alphaover of flares */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,7 +381,7 @@ void scanlinesky(char *rect, int y)
|
|||||||
view[2]= -panosi*u + panoco*v;
|
view[2]= -panosi*u + panoco*v;
|
||||||
}
|
}
|
||||||
|
|
||||||
RE_sky(view, (char *)&col);
|
RE_sky_char(view, (char *)&col);
|
||||||
|
|
||||||
if(rect[3]==0) *((unsigned int *)rect)= col;
|
if(rect[3]==0) *((unsigned int *)rect)= col;
|
||||||
else alphafunc(rect, &col);
|
else alphafunc(rect, &col);
|
||||||
|
|||||||
@@ -1172,7 +1172,7 @@ static void texture_panel_colors(Tex *tex)
|
|||||||
|
|
||||||
uiBlockBeginAlign(block);
|
uiBlockBeginAlign(block);
|
||||||
uiDefButF(block, NUMSLI, B_TEXPRV, "Bright", 10,10,150,20, &tex->bright, 0.0, 2.0, 0, 0, "Changes the brightness of the colour or intensity of a texture");
|
uiDefButF(block, NUMSLI, B_TEXPRV, "Bright", 10,10,150,20, &tex->bright, 0.0, 2.0, 0, 0, "Changes the brightness of the colour or intensity of a texture");
|
||||||
uiDefButF(block, NUMSLI, B_TEXPRV, "Contr", 160,10,150,20, &tex->contrast, 0.01, 2.0, 0, 0, "Changes the contrast of the colour or intensity of a texture");
|
uiDefButF(block, NUMSLI, B_TEXPRV, "Contr", 160,10,150,20, &tex->contrast, 0.01, 5.0, 0, 0, "Changes the contrast of the colour or intensity of a texture");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,8 @@
|
|||||||
|
|
||||||
#include "RE_renderconverter.h"
|
#include "RE_renderconverter.h"
|
||||||
|
|
||||||
|
#include "blendef.h" /* CLAMP */
|
||||||
|
|
||||||
#define PR_RECTX 141
|
#define PR_RECTX 141
|
||||||
#define PR_RECTY 141
|
#define PR_RECTY 141
|
||||||
#define PR_XMIN 10
|
#define PR_XMIN 10
|
||||||
@@ -385,7 +387,7 @@ static void sky_preview_pixel(float lens, int x, int y, char *rect)
|
|||||||
view[2]= -lens*PR_RECTX/32.0;
|
view[2]= -lens*PR_RECTX/32.0;
|
||||||
Normalise(view);
|
Normalise(view);
|
||||||
}
|
}
|
||||||
RE_sky(view, rect);
|
RE_sky_char(view, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lamp_preview_pixel(ShadeInput *shi, LampRen *la, int x, int y, char *rect)
|
static void lamp_preview_pixel(ShadeInput *shi, LampRen *la, int x, int y, char *rect)
|
||||||
@@ -642,9 +644,12 @@ static void texture_preview_pixel(Tex *tex, int x, int y, char *rect)
|
|||||||
|
|
||||||
if(rgbnor & 1) {
|
if(rgbnor & 1) {
|
||||||
|
|
||||||
rect[0]= 255.0*Tr;
|
v1= 255.0*Tr;
|
||||||
rect[1]= 255.0*Tg;
|
rect[0]= CLAMPIS(v1, 0, 255);
|
||||||
rect[2]= 255.0*Tb;
|
v1= 255.0*Tg;
|
||||||
|
rect[1]= CLAMPIS(v1, 0, 255);
|
||||||
|
v1= 255.0*Tb;
|
||||||
|
rect[2]= CLAMPIS(v1, 0, 255);
|
||||||
|
|
||||||
if(Ta!=1.0) {
|
if(Ta!=1.0) {
|
||||||
tracol= 64+100*(abs(x)>abs(y));
|
tracol= 64+100*(abs(x)>abs(y));
|
||||||
|
|||||||
@@ -666,7 +666,7 @@ static void renderview_progress_display_cb(int y1, int y2, int w, int h, unsigne
|
|||||||
|
|
||||||
|
|
||||||
/* callback for print info in top header in interface */
|
/* callback for print info in top header in interface */
|
||||||
static void printrenderinfo_cb(double time, int sample, int blur)
|
static void printrenderinfo_cb(double time, int sample)
|
||||||
{
|
{
|
||||||
extern int mem_in_use;
|
extern int mem_in_use;
|
||||||
float megs_used_memory= mem_in_use/(1024.0*1024.0);
|
float megs_used_memory= mem_in_use/(1024.0*1024.0);
|
||||||
@@ -679,9 +679,6 @@ static void printrenderinfo_cb(double time, int sample, int blur)
|
|||||||
if (R.r.mode & R_FIELDS) {
|
if (R.r.mode & R_FIELDS) {
|
||||||
spos+= sprintf(spos, "Field %c ", (R.flag&R_SEC_FIELD)?'B':'A');
|
spos+= sprintf(spos, "Field %c ", (R.flag&R_SEC_FIELD)?'B':'A');
|
||||||
}
|
}
|
||||||
if (blur!=-1) {
|
|
||||||
spos+= sprintf(spos, "Blur: %d ", blur);
|
|
||||||
}
|
|
||||||
if (sample!=-1) {
|
if (sample!=-1) {
|
||||||
spos+= sprintf(spos, "Sample: %d ", sample);
|
spos+= sprintf(spos, "Sample: %d ", sample);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user