irrBenchMark (irrBM) - Mini-BenchMark using Irrlicht3D

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Post Reply
TheMrCerebro
Competition winner
Posts: 80
Joined: Tue Jun 29, 2010 10:06 pm
Location: Valencia, Spain

irrBenchMark (irrBM) - Mini-BenchMark using Irrlicht3D

Post by TheMrCerebro »

Hi all :D
Some time ago I had the intention of carrying out a project where I would use the same code that is used in GLSL but using C/C++. I checked that it worked and added things to see how my computer reacted to so much stress since many of the examples are very expensive to render, from all that I developed "irrBM" or what is the same, "irrBenchMark". You can modify the parameters such as resolution, full screen, driver,...
NOTE: Rendering the scenes by CPU (Software) is very expensive and takes a long time, by GPU (OpenGL) they are faster.

For now it only shows statistics using the own ones provided by irrlicht3D. I am completing and improving the code to add more like knowing the temperature, video RAM memory, fan speed,...

Image

Example codes:

C/C++

Code: Select all

#define N 23    	// number of sources

f32 rnd(f32 i)
{
	return mod(4000.0f * sin(23464.345f * i + 45.345f), 1.0f);
}

f32 srnd(f32 i)
{
    return 2.0f * rnd(i) - 1.0f;
}

vec3 test(u32 x, u32 y)
{
        vec2 uv = (2.0f * vec2(x,y) - iResolution ) / iResolution.v[1];

	vec2 mouse = vec2(1.5f * cos(0.2345f * iTime) - 0.7f * sin(iTime), sin(0.3214f * iTime) + 0.5f * cos(1.234f * iTime)) / 1.5f;

	f32 xo = -0.75f, xt = xo + 0.03f;

	f32 Phi[N],D2[N];
	for (u32 i=0; i<N; i++)
        {
		vec2 P = 0.99f * vec2(sin(4.0f * xt), -cos(4.0f * xt));
		xt += (1.54f / f32(N)) * (1.0f + 0.7f * srnd(f32(i)));
		f32 dm = length(mouse-P), phim = dm, d = length(uv-P), phi  = d - 0.1f * iTime;
		Phi[i] = (2.0f * PI / 0.04f) * (phi - phim);
		D2[i] = pow(d, 1.0f);

		if (d<0.01f)
                return vec3(0.0f, 0.0f, 1.0f);
	}

	// combines waves or energy
	f32 v = 0.0f;
        for (u32 i=0; i<N; i++)
        {
            for (u32 j=0; j<N; j++)
                 v += cos(Phi[j] - Phi[i]) / (D2[i] * D2[j]);
        }

        v = sqrt(v / 2.0f);

	v = v * 4.5f / f32(N);

	return v * vec3(1.0f, 0.5f, 0.25f);
}
GLSL

Code: Select all

uniform float iTime;
uniform vec2 iResolution;

#define N 23    	// number of sources

float rnd(float i)
{
	return mod(4000.*sin(23464.345*i+45.345),1.0);
}

float srnd(float i)
{
	return 2.0 * rnd(i) - 1.0;
}

void main( out vec4 fragColor, in vec2 fragCoord )
{
	vec2 uv = (2.0 * gl_FragCoord.xy - iResolution ) / iResolution.y;

	// --- calc sources contribs
	vec2 mouse = vec2(1.5*cos(.2345*iTime)-.7*sin(iTime),sin(.3214*iTime)+.5*cos(1.234*iTime))/1.5;

	float x = -0.75, xt = x;
	
	float Phi[N], D2[N];
	for (int i=0; i<N; i++)
	{
		vec2 P = 0.99 * vec2(sin(4.0 * xt), -cos(4.0 * xt));
		xt += (1.54 / float(N)) * (1.0 + 0.7 * srnd(float(i)));
		float dm = length(mouse-P), phim = dm, d = length(uv-P), phi = d - 0.1 * iTime;
		Phi[i] = (2.0 * 3.14159 / 0.04) * (phi - phim);  // stores wave attributes
		D2[i] = pow(d,1.0);

		if (d<0.01)
		{
			fragColor = vec4(0,0,1,0);
			return;
		}
	}
	
	// --- combines waves or energy
	
	float v = 0.0;
	for (int i=0; i<N; i++)
	{
		for (int j=0; j<N; j++) 
			v += cos(Phi[j]-Phi[i]) / (D2[i]*D2[j]);			
	}
		
	v = sqrt(v/2.0);
	v = v * 4.5 / float(N);

	fragColor = v * vec4(1, 0.5, 0.25, 1);
}
You can download it from here:
https://github.com/TheMrCerebro/irrBM/releases

Bye :wink:
Follow me on twitter: @themrcerebro
Post Reply