Skip to content

How to change Physarum background color? #6

@Vamoss

Description

@Vamoss

Hello again Amanda,

I am trying to change the default black background color without success.

We can also refer to this example in the further code:
https://openprocessing.org/sketch/1760726

I tried to change the render fragment shader from this:

in vec2 v_uv;
uniform sampler2D u_trail;
uniform float u_scale;
out vec4 out_state;
void main() {
	out_state = vec4(texture(u_trail, v_uv).xyz * u_scale, 1);
}

To this:

in vec2 v_uv;
uniform sampler2D u_trail;
uniform float u_scale;
out vec4 out_state;
float luma(vec3 color) {
	return dot(color, vec3(0.299, 0.587, 0.114));
}
void main() {
	vec3 trailColor = texture(u_trail, v_uv).xyz * u_scale;
	float brightness = luma(trailColor );
	vec3 backgroundColor = vec3(1.0, 0.0, 0.0);
	vec3 mixedColor = mix(backgroundColor, trailColor , brightness);
	out_state = vec4(vec3(mixedColor), 1);
}

The result is almost there, but the mixedColor borders are not smooth.

Thank you once again,
Carlos

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions