Jump to content
Eternal Lands Official Forums
Sign in to follow this  
emajekral

Point Particle Scaling bugfix

Recommended Posts

This patch fixes the tubes of smoke on distant chimneys and makes fires look a tad fuller close up when point particles are enabled.

 

I'm not sure that those are problems for everyone. Some drivers may have different default settings for point particles. My video card is a gForce 6800. Others with nVidia cards should get results similar to mine. However point sprite size and its granularity is dependant on what data type is used to represent point size which could be card specific.

 

This is a relatively simple change so I'm not doing a patch. If you want to provide one feel free. This is all part of my camera patch that will come out once I'm happy with the features (bugs) and maybe the new client code is stable.

 

The changes rely on the relatively stable GL_ARB_point_parameter extensions. I have tuned the parameters so that they closely resemble the textured quad based particles on my system, but your results may vary. Play with particleAtten[2] and the multiplier on system_id->def->part_size to get that to your liking.

 

 

Add these definitions to the definitions at the end of gl_init.h:

#ifndef POINT_DISTANCE_ATTENUATION_ARB
#define POINT_DISTANCE_ATTENUATION_ARB		0x8129
#endif

#ifndef POINT_SIZE_MIN_ARB
#define POINT_SIZE_MIN_ARB	0x8126
#endif

#ifndef POINT_SIZE_MAX_ARB
#define POINT_SIZE_MAX_ARB	0x8127
#endif

#ifndef POINT_FADE_THRESHOLD_SIZE_ARB
#define POINT_FADE_THRESHOLD_SIZE_ARB	0x8128
#endif

 

Add these extension function pointers to gl_init.h just before #ifdef USE_FRAMEBUFFER:

//Point Sprite Size/Brightness Adjusters
extern void (APIENTRY * ELglPointParameterfARB) (GLenum pname, GLfloat param);
extern void (APIENTRY * ELglPointParameterfvARB) (GLenum pname, GLfloat *params);

 

Add these extension function pointers to gl_init.c just before #ifdef USE_FRAMEBUFFER:

void (APIENTRY * ELglPointParameterfARB) (GLenum pname, GLfloat param);
void (APIENTRY * ELglPointParameterfvARB) (GLenum pname, GLfloat *params);

 

Initialize those pointers in void init_gl_extensions() in gl_init.c just before #ifdef USE_FRAMEBUFFER:

ELglPointParameterfARB=SDL_GL_GetProcAddress("glPointParameterfARB");
ELglPointParameterfvARB=SDL_GL_GetProcAddress("glPointParameterfvARB");

 

Add this near the end of void set_new_video_mode(int fs,int mode) in gl_init.c and void init_particles_list() in particles.c

 

//Add perspective to point particles. On my system
//these settings match size with textured quad particles, 	
//but point particles have 4x as many particles. It's hard coded.
//Tune particleAtten[2] if you like. 
if ((ELglPointParameterfARB!= NULL)&&(ELglPointParameterfvARB!= NULL))
{
	GLfloat particleAtten[] = {0,0,.01}; //This is a dumb place for this
	ELglPointParameterfvARB(POINT_DISTANCE_ATTENUATION_ARB, particleAtten); //This is a dumb place for this
	ELglPointParameterfARB(POINT_SIZE_MAX_ARB, 5000.0); //This is a dumb place for this
	ELglPointParameterfARB(POINT_SIZE_MIN_ARB, 0.01); //This is a dumb place for this
}

 

Change the call to glPointSize in void draw_point_particle_sys(particle_sys *system_id) in the file particles.c to this :

	//play with this if particle size is wrong. See also particleAtten[].
glPointSize(system_id->def->part_size*15.0f);

 

Tell me what that last line was originally if you like, I deleted mine, but it might be smart to keep it and set a global have_point_param variable just in case a system that supports point particles doesn't support the GL_ARB_point_parameter extensions.

 

Also please tell me if I left anything out.

 

Enjoy!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×