Raydium 3D Game Engine

Official forum for everything about Raydium, ManiaDrive, MeMak, ...
It is currently Fri Aug 18, 2017 6:44 am

All times are UTC




Post new topic Reply to topic  [ 48 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
PostPosted: Tue Sep 30, 2008 11:55 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Just a tweaking version, no fixings.
http://www.guadagames.com/versusrx/lensflare4.tar.bz2

  • All elements animated.
  • Added anamorphic streak(just horizontal, like in HDcams)
  • Added a halo to the blue glow.
  • Main halo fixed
  • Effect timed to do not appear too suddenly


Top
 Profile  
 
PostPosted: Wed Oct 01, 2008 12:10 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
First version of the Lensflare Editor:
http://www.guadagames.com/versusrx/lens ... -1.tar.bz2
  • Fixed osd_color (stored and restored at the end)
  • Fixed blend function
  • Tunned a bit, again
  • You can place the source of lensflare in the camera position pressing 's' key
  • You can make an screenshot with F1 (Old feature, i forgot tell about)
  • You can toogle editor with space

ImageImage

Still things to fix, optimize, and add.
And no, it still doesn't load/save to file.

interesting points:
-The lensflare works inside the car, if you see it through a glass. I was surprised with this.
-The GUI system is hell... It took me hours to get what you see. I'll open a new thread about this soon.
-You can put the lensflare into one of the green column places and then move near like in a FPS to see the "growing in time" effect


Top
 Profile  
 
PostPosted: Sat Oct 04, 2008 11:53 am 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
New version of the lensflare editor.
Now supports import and export to ".lensflare" files.
  • If you press 'e' it will export the current lensflare to lf0.lensflare.
  • If you press'i' it will import the file lf0.lensflare
In the file, each effect(line) has the next structure:
{is_used?, size, velocity, color r, color g, color b}
Colors are useless right now.
Here the code:
Code:
/*
    Raydium - CQFD Corp.
    http://raydium.org/
    Released under both BSD license and Lesser GPL library license.
    See "license.txt" file.
*/

// This file is a default skeleton. Replace all [ ... ] sections with yours.
// Have fun !

#include "raydium/index.c"

#define RAYDIUM_MAX_LENS_FLARE 5
float raydium_lensflare_pos[RAYDIUM_MAX_LENS_FLARE][3];
int raydium_lensflare_type[RAYDIUM_MAX_LENS_FLARE];
float raydium_lensflare_color[RAYDIUM_MAX_LENS_FLARE][3];
int   raydium_lensflare_use[RAYDIUM_MAX_LENS_FLARE];
float raydium_lensflare_time_to_full[RAYDIUM_MAX_LENS_FLARE];
int raydium_lensflare_texture[6];
float raydium_lensflare_time_shown[RAYDIUM_MAX_LENS_FLARE];
int mode=0; //0=camera, 1=editor

#define RAYDIUM_MAX_FX 10
int raydium_lensflare_fx[RAYDIUM_MAX_LENS_FLARE][RAYDIUM_MAX_FX];
float raydium_lensflare_fxcolor[RAYDIUM_MAX_LENS_FLARE][RAYDIUM_MAX_FX][3];
float raydium_lensflare_fxvelocity[RAYDIUM_MAX_LENS_FLARE][RAYDIUM_MAX_FX];
float raydium_lensflare_fxsize[RAYDIUM_MAX_LENS_FLARE][RAYDIUM_MAX_FX];
void gui_feed(void);
void gui_create(void);


void raydium_lensflare_reset(int id)
{
   int a=id;
   int b;
   
   memset(raydium_lensflare_pos[a],0,3);
   memset(raydium_lensflare_color[a],0,3);
   raydium_lensflare_type[a]=0;
   raydium_lensflare_use[a]=0;
   raydium_lensflare_time_to_full[a]=0.5f;
   raydium_lensflare_time_shown[a]=0.0f;   

   for(b=0;b<RAYDIUM_MAX_FX;b++)
   {
      raydium_lensflare_fx[a][b]=1;
      raydium_lensflare_fxcolor[a][b][0]=1;
      raydium_lensflare_fxcolor[a][b][1]=1;
      raydium_lensflare_fxcolor[a][b][2]=1;
      raydium_lensflare_fxvelocity[a][b]=1;
   }   
}

void raydium_lensflare_import(int id, char *filename)
{
   FILE *fp;   
   int version=0;   
   int ret;
   char var[RAYDIUM_MAX_NAME_LEN];
   char val_s[RAYDIUM_MAX_NAME_LEN];
   GLfloat val_f[5];
   int size;
   if(id<0 || id>RAYDIUM_MAX_LENS_FLARE)
   {
      return;;
   }
   if((fp=raydium_file_fopen(filename,"r")))
   {
      raydium_log("reading lensflare file: %s",filename);
      while( (ret=raydium_parser_read(var,val_s,val_f,&size,fp))!=RAYDIUM_PARSER_TYPE_EOF)
      {
         //get data
         //version
         if(ret==RAYDIUM_PARSER_TYPE_FLOAT && size==1 && strcmp(var,"version")==0)
         {
            version=(int)val_f[0];
            raydium_log("version: %d",version);            
            if(version!=1)
            {
               raydium_lensflare_reset(id);         
               break;
            }
         }
         //anamorphic
         if(ret==RAYDIUM_PARSER_TYPE_FLOAT && strcmp(var,"anamorphic")==0)
         {
            raydium_log("there are %f elements here?????",size);
            raydium_lensflare_fx[id][0]=(int)val_f[0];                        
            raydium_lensflare_fxsize[id][0]=val_f[1];
            raydium_lensflare_fxvelocity[id][0]=val_f[2];
            raydium_lensflare_fxcolor[id][0][0]=val_f[3];
            raydium_lensflare_fxcolor[id][0][1]=val_f[4];
            raydium_lensflare_fxcolor[id][0][2]=val_f[5];         
         }
         //rays
         if(ret==RAYDIUM_PARSER_TYPE_FLOAT && strcmp(var,"rays")==0)
         {
            raydium_log("there are %f elements here?????",size);
            raydium_lensflare_fx[id][1]=(int)val_f[0];                        
            raydium_lensflare_fxsize[id][1]=val_f[1];
            raydium_lensflare_fxvelocity[id][1]=val_f[2];
            raydium_lensflare_fxcolor[id][1][0]=val_f[3];
            raydium_lensflare_fxcolor[id][1][1]=val_f[4];
            raydium_lensflare_fxcolor[id][1][2]=val_f[5];         
         }
         //halo
         if(ret==RAYDIUM_PARSER_TYPE_FLOAT && strcmp(var,"halo")==0)
         {
            raydium_log("there are %f elements here?????",size);
            raydium_lensflare_fx[id][2]=(int)val_f[0];                        
            raydium_lensflare_fxsize[id][2]=val_f[1];
            raydium_lensflare_fxvelocity[id][2]=val_f[2];
            raydium_lensflare_fxcolor[id][2][0]=val_f[3];
            raydium_lensflare_fxcolor[id][2][1]=val_f[4];
            raydium_lensflare_fxcolor[id][2][2]=val_f[5];         
         }
         //star streak
         if(ret==RAYDIUM_PARSER_TYPE_FLOAT && strcmp(var,"streak")==0)
         {
            raydium_log("there are %f elements here?????",size);
            raydium_lensflare_fx[id][3]=(int)val_f[0];                        
            raydium_lensflare_fxsize[id][3]=val_f[1];
            raydium_lensflare_fxvelocity[id][3]=val_f[2];
            raydium_lensflare_fxcolor[id][3][0]=val_f[3];
            raydium_lensflare_fxcolor[id][3][1]=val_f[4];
            raydium_lensflare_fxcolor[id][3][2]=val_f[5];         
         }
         //red dot
         if(ret==RAYDIUM_PARSER_TYPE_FLOAT && strcmp(var,"reddot")==0)
         {
            raydium_log("there are %f elements here?????",size);
            raydium_lensflare_fx[id][4]=(int)val_f[0];                        
            raydium_lensflare_fxsize[id][4]=val_f[1];
            raydium_lensflare_fxvelocity[id][4]=val_f[2];
            raydium_lensflare_fxcolor[id][4][0]=val_f[3];
            raydium_lensflare_fxcolor[id][4][1]=val_f[4];
            raydium_lensflare_fxcolor[id][4][2]=val_f[5];         
         }
         //glow
         if(ret==RAYDIUM_PARSER_TYPE_FLOAT && strcmp(var,"glow")==0)
         {
            raydium_log("there are %f elements here?????",size);
            raydium_lensflare_fx[id][5]=(int)val_f[0];                        
            raydium_lensflare_fxsize[id][5]=val_f[1];
            raydium_lensflare_fxvelocity[id][5]=val_f[2];
            raydium_lensflare_fxcolor[id][5][0]=val_f[3];
            raydium_lensflare_fxcolor[id][5][1]=val_f[4];
            raydium_lensflare_fxcolor[id][5][2]=val_f[5];         
         }
         //blueglow
         if(ret==RAYDIUM_PARSER_TYPE_FLOAT && strcmp(var,"blueglow")==0)
         {
            raydium_log("there are %f elements here?????",size);
            raydium_lensflare_fx[id][6]=(int)val_f[0];                        
            raydium_lensflare_fxsize[id][6]=val_f[1];
            raydium_lensflare_fxvelocity[id][6]=val_f[2];
            raydium_lensflare_fxcolor[id][6][0]=val_f[3];
            raydium_lensflare_fxcolor[id][6][1]=val_f[4];
            raydium_lensflare_fxcolor[id][6][2]=val_f[5];         
         }
      }
      fclose(fp);
      gui_feed();
      
   }
   /*
   {
      //anamorphic
      fprintf(file,"anamorphic.size=%f\n",raydium_lensflare_fxsize[0]);
      fprintf(file,"anamorphic.velocity=%f\n",raydium_lensflare_fxvelocity[0]);
      fprintf(file,"anamoprhic.color={%f,%f,%f}\n",raydium_lensflare_fxcolor[0][0],raydium_lensflare_fxcolor[0][1],raydium_lensflare_fxcolor[0][2]);
      //Rays
      fprintf(file,"rays.use=%d\n",raydium_lensflare_fx[1]);
      fprintf(file,"rays.size=%f\n",raydium_lensflare_fxsize[1]);
      fprintf(file,"rays.velocity=%f\n",raydium_lensflare_fxvelocity[1]);
      fprintf(file,"rays.color={%f,%f,%f}\n",raydium_lensflare_fxcolor[1][0],raydium_lensflare_fxcolor[1][1],raydium_lensflare_fxcolor[1][2]);
      //Halo
      fprintf(file,"halo.use=%d\n",raydium_lensflare_fx[2]);
      fprintf(file,"halo.size=%f\n",raydium_lensflare_fxsize[2]);
      fprintf(file,"halo.velocity=%f\n",raydium_lensflare_fxvelocity[2]);
      fprintf(file,"halo.color={%f,%f,%f}\n",raydium_lensflare_fxcolor[2][0],raydium_lensflare_fxcolor[2][1],raydium_lensflare_fxcolor[2][2]);
      //Star Streak
      fprintf(file,"streak.use=%d\n",raydium_lensflare_fx[3]);
      fprintf(file,"streak.size=%f\n",raydium_lensflare_fxsize[3]);
      fprintf(file,"streak.velocity=%f\n",raydium_lensflare_fxvelocity[3]);
      fprintf(file,"streak.color={%f,%f,%f}\n",raydium_lensflare_fxcolor[3][0],raydium_lensflare_fxcolor[3][1],raydium_lensflare_fxcolor[3][2]);
      //red dot
      fprintf(file,"reddot.use=%d\n",raydium_lensflare_fx[4]);
      fprintf(file,"reddot.size=%f\n",raydium_lensflare_fxsize[4]);
      fprintf(file,"reddot.velocity=%f\n",raydium_lensflare_fxvelocity[4]);
      fprintf(file,"reddot.color={%f,%f,%f}\n",raydium_lensflare_fxcolor[4][0],raydium_lensflare_fxcolor[4][1],raydium_lensflare_fxcolor[4][2]);
      //Glow
      fprintf(file,"glow.use=%d\n",raydium_lensflare_fx[5]);
      fprintf(file,"glow.size=%f\n",raydium_lensflare_fxsize[5]);
      fprintf(file,"glow.velocity=%f\n",raydium_lensflare_fxvelocity[5]);
      fprintf(file,"glow.color={%f,%f,%f}\n",raydium_lensflare_fxcolor[5][0],raydium_lensflare_fxcolor[5][1],raydium_lensflare_fxcolor[5][2]);
      //Blue Glow
      fprintf(file,"blueglow.use=%d\n",raydium_lensflare_fx[6]);
      fprintf(file,"blueglow.size=%f\n",raydium_lensflare_fxsize[6]);
      fprintf(file,"blueglow.velocity=%f\n",raydium_lensflare_fxvelocity[6]);
      fprintf(file,"blueglow.color={%f,%f,%f}\n",raydium_lensflare_fxcolor[6][0],raydium_lensflare_fxcolor[6][1],raydium_lensflare_fxcolor[6][2]);
      //more will come?
      fclose(file);
   }*/
}

void raydium_lensflare_export(int id,char *filename,int overwrite)
{
   FILE *file;
   //check file
   if(raydium_file_readable(filename) && !overwrite)
   {
      raydium_log("ERROR: File already exists!!!");
      return;
   }
   if(raydium_file_readable(filename) && overwrite)
   {
      raydium_log("WARNING: Overwriting file");
      
   }
   if((file=raydium_file_fopen(filename,"w")))
   {
      fprintf(file,"Lensflare definition\n");
      fprintf(file,"version=1\n");
      fprintf(file,"id=%d\n",id);
      //anamorphic
      fprintf(file,"anamorphic={ %f, %f, %f, %f, %f, %f}\n",(float)raydium_lensflare_fx[id][0],raydium_lensflare_fxsize[id][0],raydium_lensflare_fxvelocity[id][0],raydium_lensflare_fxcolor[id][0][0],raydium_lensflare_fxcolor[id][0][1],raydium_lensflare_fxcolor[id][0][2]);
      //Rays
      fprintf(file,"rays={ %f, %f, %f, %f, %f, %f}\n",(float)raydium_lensflare_fx[id][1],raydium_lensflare_fxsize[id][1],raydium_lensflare_fxvelocity[id][1],raydium_lensflare_fxcolor[id][1][0],raydium_lensflare_fxcolor[id][1][1],raydium_lensflare_fxcolor[id][1][2]);
      //Halo
      fprintf(file,"halo={ %f, %f, %f, %f, %f, %f}\n",(float)raydium_lensflare_fx[id][2],raydium_lensflare_fxsize[id][2],raydium_lensflare_fxvelocity[id][2],raydium_lensflare_fxcolor[id][2][0],raydium_lensflare_fxcolor[id][2][1],raydium_lensflare_fxcolor[id][2][2]);
      //Star Streak
      fprintf(file,"streak={ %f, %f, %f, %f, %f, %f}\n",(float)raydium_lensflare_fx[id][3],raydium_lensflare_fxsize[id][3],raydium_lensflare_fxvelocity[id][3],raydium_lensflare_fxcolor[id][3][0],raydium_lensflare_fxcolor[id][3][1],raydium_lensflare_fxcolor[id][3][2]);
      //red dot
      fprintf(file,"reddot={ %f, %f, %f, %f, %f, %f}\n",(float)raydium_lensflare_fx[id][4],raydium_lensflare_fxsize[id][4],raydium_lensflare_fxvelocity[id][4],raydium_lensflare_fxcolor[id][4][0],raydium_lensflare_fxcolor[id][4][1],raydium_lensflare_fxcolor[id][4][2]);
      //Glow
      fprintf(file,"glow={ %f, %f, %f, %f, %f, %f}\n",(float)raydium_lensflare_fx[id][5],raydium_lensflare_fxsize[id][5],raydium_lensflare_fxvelocity[id][5],raydium_lensflare_fxcolor[id][5][0],raydium_lensflare_fxcolor[id][5][1],raydium_lensflare_fxcolor[id][5][2]);
      //Blue Glow
      fprintf(file,"blueglow={ %f, %f, %f, %f, %f, %f}\n",(float)raydium_lensflare_fx[id][6],raydium_lensflare_fxsize[id][6],raydium_lensflare_fxvelocity[id][6],raydium_lensflare_fxcolor[id][6][0],raydium_lensflare_fxcolor[id][6][1],raydium_lensflare_fxcolor[id][6][2]);
      //more will come?
      fclose(file);
   }
   //save data
   //end
}
int raydium_point_is_occluded(float x, float y, float z)
{
   //code from nehe
   GLint viewport[4];                     // Space For Viewport Data
   GLdouble mvmatrix[16], projmatrix[16];               // Space For Transform Matrix
   GLdouble winx, winy, winz;                  // Space For Returned Projected Coords
   GLdouble flareZ;                     // Here We Will Store The Transformed Flare Z
   GLfloat bufferZ;                     // Here We Will Store The Read Z From The Buffer

   glGetIntegerv (GL_VIEWPORT, viewport);               // Get Actual Viewport
   glGetDoublev (GL_MODELVIEW_MATRIX, mvmatrix);            // Get Actual Model View Matrix
   glGetDoublev (GL_PROJECTION_MATRIX, projmatrix);         // Get Actual Projection Matrix

   // This Asks OGL To Guess The 2D Position Of A 3D Point Inside The Viewport
   gluProject(x, y, z, mvmatrix, projmatrix, viewport, &winx, &winy, &winz);
   //flareZ=raydium_math_point_unproject_3D(x,y,z,&winx,&winy);
   flareZ = winz;

   // We Read Back One Pixel From The Depth Buffer (Exactly Where Our Flare Should Be Drawn)
   glReadPixels(winx, winy,1,1,GL_DEPTH_COMPONENT, GL_FLOAT, &bufferZ);

   // If The Buffer Z Is Lower Than Our Flare Guessed Z Then Don't Draw
   // This Means There Is Something In Front Of Our Flare
   if (bufferZ < flareZ)
      return 1;
   else
      return 0;
}


void raydium_lensflare_init(void)
{
   int a,b;
   for(a=0;a<RAYDIUM_MAX_LENS_FLARE;a++)
   {
      memset(raydium_lensflare_pos[a],0,3);
      memset(raydium_lensflare_color[a],0,3);
      raydium_lensflare_type[a]=0;
      raydium_lensflare_use[a]=0;
      raydium_lensflare_time_to_full[a]=0.5f;
      raydium_lensflare_time_shown[a]=0.0f;
      for(b=0;b<RAYDIUM_MAX_FX;b++)
      {
         raydium_lensflare_fx[a][b]=1;
         raydium_lensflare_fxcolor[a][b][0]=1;
         raydium_lensflare_fxcolor[a][b][1]=1;
         raydium_lensflare_fxcolor[a][b][2]=1;
         raydium_lensflare_fxvelocity[a][b]=1;
      }
   }
   //prepare textures
   raydium_lensflare_texture[0]=raydium_texture_load("lensflare1.tga");
   raydium_lensflare_texture[1]=raydium_texture_load("lensflare2.tga");
   raydium_lensflare_texture[2]=raydium_texture_load("lensflare-streaks.tga");
   raydium_lensflare_texture[3]=raydium_texture_load("lensflare-halo.tga");
   raydium_lensflare_texture[4]=raydium_texture_load("lensflare-rays.tga");
   raydium_lensflare_texture[5]=raydium_texture_load("lensflare-anamorphic.tga");
   //setting then to blend
   raydium_texture_blended[raydium_lensflare_texture[0]]=1;
   raydium_texture_blended[raydium_lensflare_texture[1]]=1;
   raydium_texture_blended[raydium_lensflare_texture[2]]=1;
   raydium_texture_blended[raydium_lensflare_texture[3]]=1;
   raydium_texture_blended[raydium_lensflare_texture[4]]=1;   
   raydium_texture_blended[raydium_lensflare_texture[5]]=1;   
   //setting texture to be HDR'able
   raydium_hdr_texture(raydium_lensflare_texture[0],1);
   raydium_hdr_texture(raydium_lensflare_texture[1],1);
   raydium_hdr_texture(raydium_lensflare_texture[2],1);
   raydium_hdr_texture(raydium_lensflare_texture[3],1);
   raydium_hdr_texture(raydium_lensflare_texture[4],1);
   raydium_hdr_texture(raydium_lensflare_texture[5],1);

}



void raydium_lensflare_on(int a)
{
   raydium_lensflare_use[a]=1;
}
void raydium_lensflare_off(int a)
{
   raydium_lensflare_use[a]=0;
}
void raydium_lensflare_move_3f(int a, float x, float y, float z)
{
   raydium_lensflare_pos[a][0]=x;
   raydium_lensflare_pos[a][1]=y;
   raydium_lensflare_pos[a][2]=z;
}
void raydium_lensflare_move_relative_3f(int a, float x, float y, float z)
{
   raydium_lensflare_pos[a][0]+=x;
   raydium_lensflare_pos[a][1]+=y;
   raydium_lensflare_pos[a][2]+=z;
}
void raydium_lensflare_color_set(int a, float r, float g, float b)
{
   raydium_lensflare_color[a][0]=r;
   raydium_lensflare_color[a][1]=g;
   raydium_lensflare_color[a][2]=b;
}

void raydium_lensflare_type_set(int a, int type)
{
   raydium_lensflare_type[a]=type;
}


void raydium_osd_draw_quad(int tex,float x1,float y1,float x2, float y2, float anglerads)
{
   float tx,ty;   

   raydium_osd_start();
   tx=x1+((x2-x1)/2.0f);
   ty=y1+((y2-y1)/2.0f);
   
   raydium_texture_current_set(tex);
   raydium_rendering_internal_prepare_texture_render(tex);
   glColor4fv(raydium_osd_color);
   
   glTranslatef(tx,ty,0);
   glRotatef(anglerads,0,0,1);
   
   glBegin(GL_QUADS);   
   glTexCoord2f(0,0);glVertex3f(tx-x1,ty-y1,0);
   glTexCoord2f(1,0);glVertex3f(tx-x2,ty-y1,0);
   glTexCoord2f(1,1);glVertex3f(tx-x2,ty-y2,0);
   glTexCoord2f(0,1);glVertex3f(tx-x1,ty-y2,0);   
   glEnd();
   
   glRotatef(-anglerads,0,0,1);
   glTranslatef(-tx,-ty,0);
   
   raydium_rendering_internal_restore_render_state();
   raydium_osd_stop();
}



void raydium_lensflare_draw(int a)
{   
   float cx,cy; //center of screen   
   float vx,vy; //effect normalised vector   
   float phase,phase2,phase5,phase10;
   float posx,posy;
   float lf[3];   
   float dist;
   float size;
   float mulpos;
   float turn;
   float oldcolor[4];
   static float pt;
   float anam; //anamorphic proportion
   static float giro=0;
   
   giro+=4*raydium_frame_time;
   
   phase=cosf(giro);
   phase2=cosf(giro/2.0f);
   phase5=cosf(giro/5.0f);
   phase10=cosf(giro/10.0f);
      
   if(raydium_lensflare_use[a])
   {
      //get 2dproyection of the point      
      lf[0]=raydium_lensflare_pos[a][0];
      lf[1]=raydium_lensflare_pos[a][1];
      lf[2]=raydium_lensflare_pos[a][2];
      if(raydium_math_point_unproject_3D(lf[0],lf[1],lf[2],&posx,&posy))
      {
         if(!raydium_point_is_occluded(lf[0],lf[1],lf[2]))
         {
            //storing OSD color
            memcpy(oldcolor,(char *)raydium_osd_color,4*sizeof(float));
            
            pt+=raydium_frame_time*7.0f;
            if(pt>=1)pt=1.0f;
            //center of screen
            cx=50;
            cy=50;
            
            //geting vector
            vx=((float)posx-(float)cx);
            vy=((float)posy-(float)cy);
            
            //normalising
            dist=sqrt((vx*vx)+(vy*vy));
            vx=vx/dist;
            vy=vy/dist;
            //vx,vy are now normalized
            
            glBlendFunc(GL_ONE, GL_ONE);
            if(raydium_lensflare_fx[a][5])
            {
               //Glow
               size=(float)(40.0f*(1.0f-(dist/75.0f)));
               size=raydium_lensflare_fxsize[a][5]*size*pt;
               mulpos=dist;
               turn=raydium_lensflare_fxvelocity[a][5]*(-giro);
               raydium_osd_color_rgba(1,1,0.9,1);
               raydium_osd_draw_quad(raydium_lensflare_texture[0],cx+(vx*mulpos)-size,cy+(vy*mulpos)-size,cx+(vx*mulpos)+size,cy+(vy*mulpos)+size,turn);
            }
            if(raydium_lensflare_fx[a][1])
            {
               //Rays1
               size=(float)(60.0f*(1.0f-(dist/75.0f)));
               size=raydium_lensflare_fxsize[a][1]*size*pt;
               mulpos=dist;
               turn=raydium_lensflare_fxvelocity[a][1]*giro*0.5f;
               raydium_osd_color_rgba(1,1,1,0.2);
               raydium_osd_draw_quad(raydium_lensflare_texture[4],cx+(vx*mulpos)-size,cy+(vy*mulpos)-size,cx+(vx*mulpos)+size,cy+(vy*mulpos)+size,turn);
               
               //Rays2
               size=(float)(60.0f*(1.0f-(dist/75.0f)));
               size=raydium_lensflare_fxsize[a][1]*size*pt;
               mulpos=dist;
               turn=raydium_lensflare_fxvelocity[a][1]*(-giro)*0.5f;
               raydium_osd_color_rgba(1,1,1,0.2);
               raydium_osd_draw_quad(raydium_lensflare_texture[4],cx+(vx*mulpos)-size,cy+(vy*mulpos)-size,cx+(vx*mulpos)+size,cy+(vy*mulpos)+size,turn);
                  
               //Rays3
               size=(float)(60.0f*(1.0f-(dist/75.0f)));
               size=raydium_lensflare_fxsize[a][1]*size*pt;
               mulpos=dist;
               turn=raydium_lensflare_fxvelocity[a][1]*giro*0.6f;
               raydium_osd_color_rgba(1,1,1,0.2);
               raydium_osd_draw_quad(raydium_lensflare_texture[4],cx+(vx*mulpos)-size,cy+(vy*mulpos)-size,cx+(vx*mulpos)+size,cy+(vy*mulpos)+size,turn);
               
               //Rays4
               size=(float)(60.0f*(1.0f-(dist/75.0f)));
               size=raydium_lensflare_fxsize[a][1]*size*pt;
               mulpos=dist;
               turn=raydium_lensflare_fxvelocity[a][1]*(-giro)*0.6f;
               raydium_osd_color_rgba(1,1,1,0.2);
               raydium_osd_draw_quad(raydium_lensflare_texture[4],cx+(vx*mulpos)-size,cy+(vy*mulpos)-size,cx+(vx*mulpos)+size,cy+(vy*mulpos)+size,turn);
            }   
            
            if(raydium_lensflare_fx[a][3])
            {                              
               //Star Streaks
               size=(float)(80.0f*(1.0f-(dist/75.0f)));
               size=raydium_lensflare_fxsize[a][3]*size*pt;
               mulpos=dist;
               turn=raydium_lensflare_fxvelocity[a][3]*giro/5.0f;
               raydium_osd_color_rgba(1,1,0.4,1);
               raydium_osd_draw_quad(raydium_lensflare_texture[2],cx+(vx*mulpos)-size,cy+(vy*mulpos)-size,cx+(vx*mulpos)+size,cy+(vy*mulpos)+size,turn);
            }
            
            if(raydium_lensflare_fx[a][2])
            {
               //Halo
               size=(float)(2.0f*phase2/dist)+(50.0f*(1.0f-(dist/75.0f)));
               size=raydium_lensflare_fxsize[a][2]*size*pt;
               mulpos=dist;
               turn=raydium_lensflare_fxvelocity[a][2]*giro;
               raydium_osd_color_rgba(0.25f,0.25f,0.125f,0.5f);
               raydium_osd_draw_quad(raydium_lensflare_texture[3],cx+(vx*mulpos)-size,cy+(vy*mulpos)-size,cx+(vx*mulpos)+size,cy+(vy*mulpos)+size,turn);
            }
            
            if(raydium_lensflare_fx[a][6])
            {         
               //blue glow
               size=(float)(75.0f*(0.0f+(dist/75.0f)));
               size=raydium_lensflare_fxsize[a][6]*size*pt;
               mulpos=-dist;
               turn=raydium_lensflare_fxvelocity[a][6]*giro;
               raydium_osd_color_rgba(0,0,0.5,0.4);
               raydium_osd_draw_quad(raydium_lensflare_texture[0],cx+(vx*mulpos)-size,cy+(vy*mulpos)-size,cx+(vx*mulpos)+size,cy+(vy*mulpos)+size,turn);
               
               //blue glow-halo
               size=(float)(75.0f*(0.0f+(dist/75.0f)));            
               size=fmodf(size,75);
               size=raydium_lensflare_fxsize[a][6]*size*pt;
               mulpos=-dist;
               turn=raydium_lensflare_fxvelocity[a][6]*(-giro);
               raydium_osd_color_rgba(0,0,0.5f-(size/75.0f),0.4);
               raydium_osd_draw_quad(raydium_lensflare_texture[3],cx+(vx*mulpos)-size,cy+(vy*mulpos)-size,cx+(vx*mulpos)+size,cy+(vy*mulpos)+size,turn);
            }
            
            if(raydium_lensflare_fx[a][4])
            {                        
               //red glow
               size=(float)(10.0f*(0.0f+(dist/75.0f)));
               size=raydium_lensflare_fxsize[a][4]*size*pt;
               mulpos=-dist*1.53f;
               turn=raydium_lensflare_fxvelocity[a][4]*360.0f*(vx*vy);
               raydium_osd_color_rgba(0.5,0,0,0.3);
               raydium_osd_draw_quad(raydium_lensflare_texture[0],cx+(vx*mulpos)-size,cy+(vy*mulpos)-size,cx+(vx*mulpos)+size,cy+(vy*mulpos)+size,turn);
               
               //red star
               size=(float)(20.0f*(0.0f+(dist/75.0f)));
               size=raydium_lensflare_fxsize[a][4]*size*pt;
               mulpos=-dist*1.53f;
               turn=raydium_lensflare_fxvelocity[a][4]*giro*(float)vx*(float)vy*2;
               raydium_osd_color_rgba(0.3,0,0,0.3);
               raydium_osd_draw_quad(raydium_lensflare_texture[1],cx+(vx*mulpos)-size,cy+(vy*mulpos)-size,cx+(vx*mulpos)+size,cy+(vy*mulpos)+size,turn);                        
                           
               //red star
               size=(float)(20.0f*(0.0f+(dist/75.0f)));
               size=raydium_lensflare_fxsize[a][4]*size*pt;
               mulpos=-dist*1.53f;
               turn=raydium_lensflare_fxvelocity[a][4]*(-giro)*(float)vx*(float)vy*3;
               raydium_osd_color_rgba(0.3,0,0,0.3);
               raydium_osd_draw_quad(raydium_lensflare_texture[1],cx+(vx*mulpos)-size,cy+(vy*mulpos)-size,cx+(vx*mulpos)+size,cy+(vy*mulpos)+size,turn);                        
            }
            
            if(raydium_lensflare_fx[a][0])
            {
               //anamorphic1
               size=1.2f;
               size=size*pt;
               mulpos=dist;
               anam=raydium_lensflare_fxsize[a][0]*(25.0f+50.0f*(0.0f+(dist/50.0f)));
               turn=0;
               raydium_osd_color_rgba(0.7f,0.7f,0.7f,0.7f);
               raydium_osd_draw_quad(raydium_lensflare_texture[5],cx+(vx*mulpos)-size*anam,cy+(vy*mulpos)-size,cx+(vx*mulpos)+size*anam,cy+(vy*mulpos)+size,turn);                                    
               
               //anamorphic2
               size=1.1f;
               size=size*pt;
               mulpos=dist;
               anam=raydium_lensflare_fxsize[a][0]*((raydium_lensflare_fxvelocity[a][0]*phase+24.0f+50.0f*(0.0f+(dist/50.0f))));
               turn=0;
               raydium_osd_color_rgba(0.7f,0.7f,0.7f,0.7f);
               raydium_osd_draw_quad(raydium_lensflare_texture[5],cx+(vx*mulpos)+size*anam,cy+(vy*mulpos)+size,cx+(vx*mulpos)-size*anam,cy+(vy*mulpos)-size,turn);                                    
            }
            //restoring blend function
            glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
   
            //restoring color
            memcpy(raydium_osd_color,oldcolor,4*sizeof(float));
         }
         else
         {
            raydium_lensflare_time_shown[a]=0.0f;
            pt=0;
         }
      }
   }
}

void show_texts()
{
   raydium_osd_color_rgba(0,0,0,1);
   raydium_osd_printf(12,95,16,0.5,"font2.tga","Press [SPACE] to switch between camera and edition modes.");
   raydium_osd_printf(12,5,14,0.5,"font2.tga","Press [s] to place the lensflare in the camera position.");

}
void gui_feed(void)
{
   char str[RAYDIUM_MAX_NAME_LEN];
   //anamorphic streak   
   raydium_gui_write_name("window","fx1",str,raydium_lensflare_fx[0][0]);   
   raydium_gui_write_name("window","fx1v",str,raydium_lensflare_fxvelocity[0][0]*100.0f);
   raydium_gui_write_name("window","fx1s",str,raydium_lensflare_fxsize[0][0]*100.0f);
   
   
   //rays
   raydium_gui_write_name("window","fx2",str,raydium_lensflare_fx[0][1]);   
   raydium_gui_write_name("window","fx2v",str,raydium_lensflare_fxvelocity[0][1]*100.0f);
   raydium_gui_write_name("window","fx2s",str,raydium_lensflare_fxsize[0][1]*100.0f);
   
   //halo
   raydium_gui_write_name("window","fx3",str,raydium_lensflare_fx[0][2]);   
   raydium_gui_write_name("window","fx3v",str,raydium_lensflare_fxvelocity[0][2]*100.0f);
   raydium_gui_write_name("window","fx3s",str,raydium_lensflare_fxsize[0][2]*100.0f);
   
   //star
   raydium_gui_write_name("window","fx4",str,raydium_lensflare_fx[0][3]);   
   raydium_gui_write_name("window","fx4v",str,raydium_lensflare_fxvelocity[0][3]*100.0f);
   raydium_gui_write_name("window","fx4s",str,raydium_lensflare_fxsize[0][3]*100.0f);
   
   //red dot
   raydium_gui_write_name("window","fx5",str,raydium_lensflare_fx[0][4]);   
   raydium_gui_write_name("window","fx5v",str,raydium_lensflare_fxvelocity[0][4]*100.0f);
   raydium_gui_write_name("window","fx5s",str,raydium_lensflare_fxsize[0][4]*100.0f);
   
   //main glow
   raydium_gui_write_name("window","fx6",str,raydium_lensflare_fx[0][5]);   
   raydium_gui_write_name("window","fx6v",str,raydium_lensflare_fxvelocity[0][5]*100.0f);
   raydium_gui_write_name("window","fx6s",str,raydium_lensflare_fxsize[0][5]*100.0f);
   
   //blue glow
   raydium_gui_write_name("window","fx7",str,raydium_lensflare_fx[0][6]);   
   raydium_gui_write_name("window","fx7v",str,raydium_lensflare_fxvelocity[0][6]*100.0f);
   raydium_gui_write_name("window","fx7s",str,raydium_lensflare_fxsize[0][6]*100.0f);

}
void gui_process(void)
{
   char str[RAYDIUM_MAX_NAME_LEN];
   //anamorphic streak
   raydium_lensflare_fx[0][0]=raydium_gui_read_name("window","fx1",str);
   raydium_lensflare_fxvelocity[0][0]=raydium_gui_read_name("window","fx1v",str)/100.0f;
   raydium_lensflare_fxsize[0][0]=raydium_gui_read_name("window","fx1s",str)/100.0f;
   //rays
   raydium_lensflare_fx[0][1]=raydium_gui_read_name("window","fx2",str);
   raydium_lensflare_fxvelocity[0][1]=raydium_gui_read_name("window","fx2v",str)/100.0f;
   raydium_lensflare_fxsize[0][1]=raydium_gui_read_name("window","fx2s",str)/100.0f;
   //main halo
   raydium_lensflare_fx[0][2]=raydium_gui_read_name("window","fx3",str);
   raydium_lensflare_fxvelocity[0][2]=raydium_gui_read_name("window","fx3v",str)/100.0f;
   raydium_lensflare_fxsize[0][2]=raydium_gui_read_name("window","fx3s",str)/100.0f;
   //star
   raydium_lensflare_fx[0][3]=raydium_gui_read_name("window","fx4",str);
   raydium_lensflare_fxvelocity[0][3]=raydium_gui_read_name("window","fx4v",str)/100.0f;
   raydium_lensflare_fxsize[0][3]=raydium_gui_read_name("window","fx4s",str)/100.0f;
   //red dot
   raydium_lensflare_fx[0][4]=raydium_gui_read_name("window","fx5",str);
   raydium_lensflare_fxvelocity[0][4]=raydium_gui_read_name("window","fx5v",str)/100.0f;
   raydium_lensflare_fxsize[0][4]=raydium_gui_read_name("window","fx5s",str)/100.0f;
   //main glow
   raydium_lensflare_fx[0][5]=raydium_gui_read_name("window","fx6",str);
   raydium_lensflare_fxvelocity[0][5]=raydium_gui_read_name("window","fx6v",str)/100.0f;
   raydium_lensflare_fxsize[0][5]=raydium_gui_read_name("window","fx6s",str)/100.0f;
   //blue glow
   raydium_lensflare_fx[0][6]=raydium_gui_read_name("window","fx7",str);
   raydium_lensflare_fxvelocity[0][6]=raydium_gui_read_name("window","fx7v",str)/100.0f;
   raydium_lensflare_fxsize[0][6]=raydium_gui_read_name("window","fx7s",str)/100.0f;
}

void display(void)
{
   float *pos;
   gui_process();
   raydium_joy_key_emul();

   if(raydium_key_last==1027)
      exit(0);
   if(raydium_key_last==1) raydium_capture_frame_auto();      
   
   if(mode==0)//camera
   {      
      raydium_mouse_hide();
      raydium_osd_cursor_set("",0,0);
      raydium_gui_hide();
   }
   else
   if(mode==1)//editor
   {
      raydium_mouse_show();      
      raydium_osd_cursor_set("BOXmania_cursor.tga",4,6);   
      raydium_gui_show();
   }
   if(raydium_key_last==1000+'s')
   {
      pos=raydium_camera_get_data();
      raydium_lensflare_move_3f(0,pos[0],pos[1],pos[2]);
   }
   if(raydium_key_last==1000+'e')
   {
      raydium_lensflare_export(0,"lf0.lensflare",1);
   }
   if(raydium_key_last==1000+'i')
   {
      raydium_lensflare_import(0,"lf0.lensflare");
   }
   /* RENDER PIPELINE */
   raydium_clear_frame();
   raydium_camera_freemove(!mode);
   //space input here to prevent camera movements
   if(raydium_key_last==1000+' ') //space to switch modes
   {
      raydium_mouse_move(raydium_window_tx/2.0f,raydium_window_ty/2.0f);
      mode=mode?0:1;
   }
   raydium_ode_draw_all(0);   
   raydium_lensflare_draw(0);
   show_texts();   
   
   /* FINISH FRAME */
   raydium_rendering_finish();
}

void gui_init(void)
{
if(raydium_gui_isvisible())
    return;
raydium_gui_show();
raydium_osd_cursor_set("BOXmania_cursor.tga",4,6);
}

void gui_create(void)
{
int handle;
raydium_gui_theme_load("lensflare.gui");   

//anamorphic block
handle=raydium_gui_window_create("window",1,1,98,98);
raydium_gui_widget_sizes(0,0,20);
raydium_gui_label_create("Title",handle,25,90,"Anamorphic Streak",0,0,0);
raydium_gui_widget_sizes(3,3,16);
raydium_gui_check_create("fx1",handle, 2,86, "Active",100.0f*raydium_lensflare_fx[0][0]);

raydium_gui_widget_sizes(0,0,16);
raydium_gui_label_create("fx1l1",handle,10,84,"Velocity",0,0,0);
raydium_gui_widget_sizes(20,2,0);
raydium_gui_track_create("fx1v",handle,20,83,0,500,100*raydium_lensflare_fxsize[0][0]);

raydium_gui_widget_sizes(0,0,16);
raydium_gui_label_create("fx1l2",handle,10,81,"Size:",0,0,0);
raydium_gui_widget_sizes(20,2,0);
raydium_gui_track_create("fx1s",handle,20,80,0,500,100);

//rays
raydium_gui_widget_sizes(0,0,20);
raydium_gui_label_create("Title2",handle,25,75,"Rays",0,0,0);
raydium_gui_widget_sizes(3,3,16);
raydium_gui_check_create("fx2",handle, 2,71, "Active",raydium_lensflare_fx[0][1]);

raydium_gui_widget_sizes(0,0,16);
raydium_gui_label_create("fx2l1",handle,10,69,"Velocity",0,0,0);
raydium_gui_widget_sizes(20,2,0);
raydium_gui_track_create("fx2v",handle,20,68,0,500,100);

raydium_gui_widget_sizes(0,0,16);
raydium_gui_label_create("fx2l2",handle,10,66,"Size:",0,0,0);
raydium_gui_widget_sizes(20,2,0);
raydium_gui_track_create("fx2s",handle,20,65,0,500,100);

//main halo
raydium_gui_widget_sizes(0,0,20);
raydium_gui_label_create("Title3",handle,25,60,"Main Halo",0,0,0);
raydium_gui_widget_sizes(3,3,16);
raydium_gui_check_create("fx3",handle, 2,56, "Active",raydium_lensflare_fx[0][2]);

raydium_gui_widget_sizes(0,0,16);
raydium_gui_label_create("fx3l1",handle,10,53,"Velocity",0,0,0);
raydium_gui_widget_sizes(20,2,0);
raydium_gui_track_create("fx3v",handle,20,52,0,500,100);

raydium_gui_widget_sizes(0,0,16);
raydium_gui_label_create("fx3l2",handle,10,50,"Size:",0,0,0);
raydium_gui_widget_sizes(20,2,0);
raydium_gui_track_create("fx3s",handle,20,49,0,500,100);

//star
raydium_gui_widget_sizes(0,0,20);
raydium_gui_label_create("Title4",handle,25,45,"Star",0,0,0);
raydium_gui_widget_sizes(3,3,16);
raydium_gui_check_create("fx4",handle, 2,40, "Active",raydium_lensflare_fx[0][3]);

raydium_gui_widget_sizes(0,0,16);
raydium_gui_label_create("fx4l1",handle,10,37,"Velocity",0,0,0);
raydium_gui_widget_sizes(20,2,0);
raydium_gui_track_create("fx4v",handle,20,36,0,500,100);

raydium_gui_widget_sizes(0,0,16);
raydium_gui_label_create("fx4l2",handle,10,34,"Size:",0,0,0);
raydium_gui_widget_sizes(20,2,0);
raydium_gui_track_create("fx4s",handle,20,33,0,500,100);

//red dot
raydium_gui_widget_sizes(0,0,20);
raydium_gui_label_create("Title5",handle,25,28,"Red dot",0,0,0);
raydium_gui_widget_sizes(3,3,16);
raydium_gui_check_create("fx5",handle, 2,24, "Active",raydium_lensflare_fx[0][4]);

raydium_gui_widget_sizes(0,0,16);
raydium_gui_label_create("fx5l1",handle,10,21,"Velocity",0,0,0);
raydium_gui_widget_sizes(20,2,0);
raydium_gui_track_create("fx5v",handle,20,20,0,500,100);

raydium_gui_widget_sizes(0,0,16);
raydium_gui_label_create("fx5l2",handle,10,18,"Size:",0,0,0);
raydium_gui_widget_sizes(20,2,0);
raydium_gui_track_create("fx5s",handle,20,17,0,500,100);

//main glow
raydium_gui_widget_sizes(0,0,20);
raydium_gui_label_create("Title6",handle,75,28,"Main Glow",0,0,0);
raydium_gui_widget_sizes(3,3,16);
raydium_gui_check_create("fx6",handle, 52,24, "Active",raydium_lensflare_fx[0][5]);

raydium_gui_widget_sizes(0,0,16);
raydium_gui_label_create("fx6l1",handle,60,21,"Velocity",0,0,0);
raydium_gui_widget_sizes(20,2,0);
raydium_gui_track_create("fx6v",handle,70,20,0,500,100);

raydium_gui_widget_sizes(0,0,16);
raydium_gui_label_create("fx6l2",handle,60,18,"Size:",0,0,0);
raydium_gui_widget_sizes(20,2,0);
raydium_gui_track_create("fx6s",handle,70,17,0,500,100);

//blue glow
raydium_gui_widget_sizes(0,0,20);
raydium_gui_label_create("Title7",handle,75,45,"Blue Glow",0,0,0);
raydium_gui_widget_sizes(3,3,16);
raydium_gui_check_create("fx7",handle, 52,40, "Active",raydium_lensflare_fx[0][6]);

raydium_gui_widget_sizes(0,0,16);
raydium_gui_label_create("fx7l1",handle,60,37,"Velocity",0,0,0);
raydium_gui_widget_sizes(20,2,0);
raydium_gui_track_create("fx7v",handle,70,36,0,500,100);

raydium_gui_widget_sizes(0,0,16);
raydium_gui_label_create("fx7l2",handle,60,34,"Size:",0,0,0);
raydium_gui_widget_sizes(20,2,0);
raydium_gui_track_create("fx7s",handle,70,33,0,500,100);

gui_init();
}


int main(int argc, char **argv)
{
   int a;
   raydium_init_args(argc,argv);
   raydium_window_create(800,600,RAYDIUM_RENDERING_WINDOW,"Lensflare Editor");

   raydium_texture_filter_change(RAYDIUM_TEXTURE_FILTER_TRILINEAR);
   raydium_window_view_perspective(60,0.01,2500); // fov 60 + near and far planes

   raydium_fog_disable();
   raydium_light_enable();
   raydium_light_on(0);

   raydium_light_conf_7f(0,50,150,200,1000000,1,0.9,0.7); // id, pos, intensity and color (RGB)
   raydium_background_color_change(1,0.9,0.7,1);

   raydium_sky_box_cache();

   raydium_ode_ground_set_name("cocorobix.tri");
   raydium_lensflare_init();
   raydium_lensflare_on(0);
   //raydium_lensflare_on(1);
   raydium_lensflare_color_set(0,1,1,1);
   //raydium_lensflare_color_set(1,1,1,1);
   raydium_lensflare_move_3f(0,-32.57,13.68,12.74);
   //raydium_lensflare_move_3f(1,-20.57,19.68,13.74);
   raydium_hdr_enable();
   
   //gui   
   gui_create();
   raydium_hdr_settings_eye(0.31415f,0.5f);
   a=raydium_ode_object_create("WATURE");
   raydium_ode_object_box_add("corps",a,0.2,1.2,0.6,0.4,RAYDIUM_ODE_STANDARD,0,"clio.tri");

   raydium_callback(&display);
   return(0);
}

// EOF

And this is an example of common car lensflare:
Code:
Lensflare definition
version=1
id=0
anamorphic={ 1.000000, 0.780000, 4.970000, 1.000000, 1.000000, 1.000000}
rays={ 1.000000, 0.380000, 2.310000, 1.000000, 1.000000, 1.000000}
halo={ 0.000000, 1.410000, 1.970000, 1.000000, 1.000000, 1.000000}
streak={ 1.000000, 0.310000, 2.600000, 1.000000, 1.000000, 1.000000}
reddot={ 0.000000, 1.130000, 0.380000, 1.000000, 1.000000, 1.000000}
glow={ 0.000000, 0.000000, 0.030000, 1.000000, 1.000000, 1.000000}
blueglow={ 1.000000, 0.560000, 4.940000, 1.000000, 1.000000, 1.000000}

The GUI is updated with the import of the file.
Also all fx code has been rewritten cause of a big bug.


Top
 Profile  
 
PostPosted: Sun Oct 05, 2008 2:47 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2590
Location: gnniiiii (Scrat)
Mmmmm very nice all this, again ! :)

A few comments, if I may:
It could be a very nice if the config file allows to provides custom textures (and colors), so one can create totally different looking lens-flares. I can even try to add a file picker and a color picker to the GUI system so your lens-editor allows to change these settings in realtime ! No ? :)

And why not the same for the number of layers ? (so your rendering code could be very generic, using "for" loops ?) It's probably some big work, needing a lot of rewrite, so it's a just a thought :)

The way the flare appears, in a quick but smooth way looks very great, specially on small lens. Isn't it possible to do the same when it disappear ? And allow to change the speed of this in the config file ?

A point, more like a note to me: HDR effect is slow like hell on my laptop (15 FPS with HDR on, 140 with HDR disabled). I really need to "debug" this part of the engine :/ (it looks so cool with the lens-flare)

Nice job so far, vicente ! (apart from indentation :p )


Top
 Profile  
 
PostPosted: Sun Oct 05, 2008 3:29 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Quote:
It could be a very nice if the config file allows to provides custom textures (and colors), so one can create totally different looking lens-flares. I can even try to add a file picker and a color picker to the GUI system so your lens-editor allows to change these settings in realtime ! No ? :)

Color picker, File chooser... nice!! :D No problem with adding custom textures and colors. But I though and the color maybe is useless if we have a custom texture, even more is we are "burning" them, cause the tone information tents to disappear. But more tests are needed.
Quote:
And why not the same for the number of layers ? (so your rendering code could be very generic, using "for" loops ?) It's probably some big work, needing a lot of rewrite, so it's a just a thought :)
Well.... in fact it would be a full rewrite...it's possible.

Quote:
The way the flare appears, in a quick but smooth way looks very great, specially on small lens. Isn't it possible to do the same when it disappear ? And allow to change the speed of this in the config file ?
I did only the "appearance" cause I know is a real optical effect. But I have no read about the inverse effect. Anyaway it's a gamma adjustment, quite easy to achieve with real HDR, that occurs in fact when you stop viewing a point of light. But as we don't have real HDR and we don't touch gamma I don't see how this can be reproduced...
Anyway, yes, an "inverse" effect can be done. The question is: when you stop viewing a source of light, the 2D projected source(point) of lensflare has to be keept? I mean, there is no logical reason to calculate the new position of the lensflare if you are not really seeing it. So it would be like a residual effect in the retina of the eye.

Quote:
A point, more like a note to me: HDR effect is slow like hell on my laptop (15 FPS with HDR on, 140 with HDR disabled). I really need to "debug" this part of the engine :/ (it looks so cool with the lens-flare)
Shaders based HDR could be an interesting alternative.

Quote:
Nice job so far, vicente ! (apart from indentation :p )
Thanks. And... my indentation is right :) cause it's still not commited ;) (raydium-indentation will come)


Top
 Profile  
 
PostPosted: Sun Oct 05, 2008 5:15 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2590
Location: gnniiiii (Scrat)
OK, I'll try to work on a color picker ASAP, and will "eventually" try a file picker (requires way more work and changes to GUI system).

About "flare disappearing" effect position, your question is damn good ! My idea was based on afterimage illusion, so you're right, it should probably stay at the last position on the screen. Strange when when you think about it :)

Shader based HDR is quiet easy to implement, but does not fit in Raydium requirements. Users are not supposed to have shader support to use Raydium applications. The current HDR code is fine, it's only a matter of texture format "mask reading" compatibility, with some low end cards (as my ATI X600 Mobility). I'll probably have to provide different rendering paths, depending on the hardware.


Top
 Profile  
 
PostPosted: Mon Oct 06, 2008 7:53 am 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Ok, i'll be waiting for those new pickers.

About "flare disappearing" then it's decided: The effect has to stay in the last 2D calculated position.

About HDR, it could be something like

Code:
if(!shaders || shadersversion<needed version)
   if(low_end_graphic_card)
      rendering hdr type 1
   else
      rendering hdr type 2
else
   make me happy with shaders :)


Top
 Profile  
 
PostPosted: Tue Sep 01, 2009 6:09 pm 
Offline

Joined: Tue Jul 08, 2008 2:37 am
Posts: 181
Sorry for pushing up this thread, which is nearly about a year old now, but I really like to have a basic lens flare effect system integrated within the engine. I really like this effect at the current state as it was already done by Vicente.

I've totally reread the older thread from 2006 about lens flares and this one again.
There was invested much time and hard work into this topic, I don't want that it was wasted. Please don't throw everything away.

@Vicente: Is it possible to upload a package with the latest version available including all resources (source code files also including the examples and editor, textures, other resources)?
Perhaps I'll try to continue working on it in the future, so we can add this to the list of features. Perhaps it's sensible to polish everything to prepare and finally commit it. Afterwards we could add some more extras, where we have already talked about like variable colors and custom textures.

Currently it seems for me that everyone want to have this feature and that it is a must have for the engine. Perhaps we are in a deadlock between Vicente and Xfennec, waiting to finish something from the other side respectively, but it's only a guess.


Top
 Profile  
 
PostPosted: Tue Sep 01, 2009 7:38 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2590
Location: gnniiiii (Scrat)
Yeah, it's right, I stopped dev on my color picker ! :) I've a diff somewhere, and I can start to work on this again. In facts, this GUI widget was far more complicated to write than I tough at first, so I translated my time to some other "more critical" topics. But nothing was thrown away ! ;)

I'll have a bit less free time for Raydium until the end of the year ("day job" will became more and more intensive until the end of December) than I used to in the last weeks, so I've to prioritize tasks. If you guys decided that the color picker is a hot topic, I'll work on it ! Just tell me :)


Top
 Profile  
 
PostPosted: Wed Sep 02, 2009 8:22 am 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Ok, I'm quite busy today (and maybe tomorrow) but ASAP I'll upload a package with everything I have about this.
Anyway I'll keep apart until cal3d feature is ready :)


Top
 Profile  
 
PostPosted: Sun Sep 06, 2009 9:06 am 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Here is the last stuff about lensflare:

http://www.sendspace.com/file/3k9urc

It's not really a patch cause all the files are different from the official raydium ones. So you just have to unzip them in raydium folder.
./odyncomp.sh lensflare-test.c
./odyncomp.sh lensflare-editor.c

Tell me if something is missing/wrong.

I hope you can continue this feature ;)


Top
 Profile  
 
PostPosted: Sun Sep 06, 2009 9:41 am 
Offline

Joined: Tue Jul 08, 2008 2:37 am
Posts: 181
Thanks for providing the latest files. I'll try to work on this feature in the future.

As written before, my plan in general is to integrate a basic lens flare effect to the engine, then to polish everything including some documentation and finally to commit it.
Afterwards, after the initial commit to the trunk, we could add some more detailed extras.

Before the first commit to the trunk I'll surely post a patch package, so you can have a look and check it.


Top
 Profile  
 
PostPosted: Sun Oct 04, 2009 10:45 am 
Offline

Joined: Tue Jul 08, 2008 2:37 am
Posts: 181
To be short, I'm in a hurry, because I'm currently moving to another city.
I haven't much time and quietness for now to describe all the changes in detail.

Image

For me, the feature is now complete, all relevant things were implemented, perhaps it could be improved here and there, but all in all it's exactly what I'd initially requested.

lensflare.patch
data-lensflare.zip

Critics and comments are welcome.


Top
 Profile  
 
PostPosted: Wed Oct 07, 2009 8:19 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2590
Location: gnniiiii (Scrat)
I struggled to find an Internet access to post my comments on this patch ! :)

First, a few changes are missing for the new "module" : header file should be included in index.h, and Makefile HEADERS should be updated too, to make the patch "Linux compliant". Then, I've been able to run test-lensflare.c and wow ... I was amazed by the examples ! The "UFO invasion" demo is just stunning, for instance :)
This lens flare system seems simpler to the user than vicente's flavor, since most of the job and decisions are done "inside Raydium", at the cost of lower setting possibilities. It's OK to me, vicente may comment this point.

It would be a good idea to make a link between this feature and RayODE, so it would be possible to attach lensflares to elements, as particles emitters currently allows. It could be done after, and it's probably quite easy to do (I'm OK to do it if needed).

Small other points:
- car lights may be adjusted a bit ? Seems OK with (0.55,-0.15,-1.1) ...
- effect can be quite heavy on the framerate : multiple big blended layers = slowdown with low bandwidth GPU (as mine on the laptop). Probably nothing to do on this point, but it's important to mention this (and it may be a good idea to add this to the API doc)
- package system is cool ;) I've added "raydium_path_package_register("data-lensflare.zip")" to the main() of the demo and it worked perfectly.
- (not really related to topic) HDR effect is always "unstable". With fullscreen, on my Mobility Radeon HD 3400, it's slow like hell. I hate low-end ATI cards :) I don't think it's currently a good idea to enable it by default in the demo application.

Sounds this feature is finally very close to an official release ! :)


Top
 Profile  
 
PostPosted: Wed Oct 07, 2009 10:35 pm 
Offline

Joined: Tue Jul 08, 2008 2:37 am
Posts: 181
Thanks for the detailed review.

I totally agree with you in all points. I'll work on these changes and commit the module soon (maybe next weekend).
The connection with RayODE was also in my mind, but I haven't found an easy way to implement it yet. Perhaps you could add this helpful addition after my commit.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 48 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group