Clean up project
Remove unnecessary files and change fitness value to unsigned long long.
This commit is contained in:
parent
d38e45dac8
commit
15640c9656
4 changed files with 4 additions and 66 deletions
|
|
@ -1,20 +0,0 @@
|
|||
// Compute the pixelwise diff between two textures.
|
||||
// Computes the diff for each color chanel separately (r, g, b).
|
||||
// Assumes both images are not transparent.
|
||||
|
||||
// try isampler2D, ivec4 etc.? Probably not
|
||||
uniform vec2 size;
|
||||
uniform vec2 offs;
|
||||
uniform sampler2D base;
|
||||
uniform sampler2D curr;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 pos = (gl_FragCoord.xy-offs)/size;
|
||||
pos.y = 1.0 - pos.y;
|
||||
vec4 color = texture2D(curr, pos);
|
||||
vec4 basecolor = texture2D(base, pos);
|
||||
color.xyz = color.xyz - basecolor.xyz;
|
||||
color.xyz = (vec3(1.0, 1.0, 1.0) + color.xyz)/2.0;
|
||||
gl_FragColor = color;
|
||||
}
|
||||
38
fire.glsl
38
fire.glsl
|
|
@ -1,38 +0,0 @@
|
|||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform float time;
|
||||
uniform vec2 mouse;
|
||||
uniform vec2 resolution;
|
||||
|
||||
float smove(float value)
|
||||
{
|
||||
return (value + 1.0)/2.0;
|
||||
}
|
||||
|
||||
float rand(vec2 co){
|
||||
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 pos = gl_FragCoord.xy; // rename for more meaty code
|
||||
mouse.y = -mouse.y;
|
||||
// vec2 uv = pos/resolution.xy;
|
||||
// vec2 muv = mouse/resolution.xy;
|
||||
|
||||
float scale = 100;
|
||||
float modifier = sin(pos.x/scale + time)*sin(pos.y/scale - time);
|
||||
modifier = smove(modifier);
|
||||
|
||||
float dist = distance(gl_FragCoord.xy, mouse);
|
||||
float radius = smove(sin(time))*50 + 100;
|
||||
|
||||
float value = max(1 - dist/radius, 0);
|
||||
value = value + modifier*0.3;
|
||||
|
||||
value = value + (rand(pos.x*pos.y)-0.5)*0.03;
|
||||
|
||||
gl_FragColor = vec4(value);
|
||||
}
|
||||
|
|
@ -4,9 +4,6 @@
|
|||
|
||||
|
||||
|
||||
Fitness::Fitness() {}
|
||||
|
||||
|
||||
Fitness::Fitness(sf::Texture target, float scale)
|
||||
{
|
||||
this->target = target;
|
||||
|
|
@ -36,7 +33,7 @@ bool Fitness::loadShader(std::string filename)
|
|||
}
|
||||
|
||||
|
||||
double Fitness::of(Chromosome chr)
|
||||
unsigned long long Fitness::of(Chromosome chr)
|
||||
{
|
||||
// first, render a reduced, shaderized version to RenderTextures
|
||||
this->tex.clear();
|
||||
|
|
@ -52,7 +49,7 @@ double Fitness::of(Chromosome chr)
|
|||
// then, download the result as an image and add the pixels
|
||||
sf::Image image = this->comp.getTexture().copyToImage();
|
||||
sf::Vector2u size = image.getSize();
|
||||
double fitness = 0;
|
||||
unsigned long long fitness = 0;
|
||||
for (unsigned int x=0; x<size.x; ++x) {
|
||||
for (unsigned int y=0; y<size.y; ++y) {
|
||||
sf::Color color = image.getPixel(x, y);
|
||||
|
|
|
|||
|
|
@ -8,11 +8,10 @@
|
|||
class Fitness
|
||||
{
|
||||
public:
|
||||
Fitness();
|
||||
Fitness(sf::Texture target, float scale=0.5);
|
||||
Fitness(sf::Texture target, float scale=1);
|
||||
bool loadShader(std::string filename);
|
||||
|
||||
double of(Chromosome chr);
|
||||
unsigned long long of(Chromosome chr);
|
||||
|
||||
sf::Texture target; // base image to compare against
|
||||
sf::RenderTexture tex; // big RenderWindow containg the Chromosome to be evaluated
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue