Skip to content

fix switching RAW mode to RGB mode issue#62913

Closed
KuaiDain wants to merge 1 commit into
godotengine:masterfrom
KuaiDain:fixes#62894
Closed

fix switching RAW mode to RGB mode issue#62913
KuaiDain wants to merge 1 commit into
godotengine:masterfrom
KuaiDain:fixes#62894

Conversation

@KuaiDain

Copy link
Copy Markdown

fixes #62894

return next_power_of_2(MAX(255, color.components[idx] * 255.0)) - 1;

when result of color.components[idx] * 255.0 beyond 255, this issue will happen, so i modified this function as other mode

@KuaiDain KuaiDain requested a review from a team as a code owner July 11, 2022 14:40
@YuriSizov YuriSizov added this to the 4.0 milestone Jul 11, 2022
@KoBeWi

KoBeWi commented Jul 11, 2022

Copy link
Copy Markdown
Member

Doesn't this always clamp the value to 255? It means your color is truncated when you switch from RAW to RGB. Not sure if it's desired 🤔

@fire

fire commented Jul 11, 2022

Copy link
Copy Markdown
Member

You can have different "intensity" value that is multiplied with a rgba8 to store the original value, but converting values outside of 0 to 1 to RGBA8 is a lossy conversion.

Would like some opinions.

@KuaiDain

Copy link
Copy Markdown
Author

thanks for your advice
i think this issue again, when i change value in RGB mode, it will store value/255.0 back to color, so rgba is in range 0 to 1,

Color ColorModeRGB::get_color() const {
	Vector<float> values = color_picker->get_active_slider_values();
	Color color;
	for (int i = 0; i < 4; i++) {
		color.components[i] = values[i] / 255.0;
	}
	return color;
}

except RAW mode, other mode do a calculation, then store back to color

Color ColorModeRAW::get_color() const {
	Vector<float> values = color_picker->get_active_slider_values();
	Color color;
	for (int i = 0; i < 4; i++) {
		color.components[i] = values[i];
	}
	return color;
}

float slider_max[4] = { 100, 100, 100, 1 }; this line cause that we can store value beyond 1 back to color, so i change it to float slider_max[4] = { 1, 1, 1, 1 };

@AThousandShips

Copy link
Copy Markdown
Member

@Repiteo

Repiteo commented Apr 22, 2025

Copy link
Copy Markdown
Contributor

Superseded by #102240

@Repiteo Repiteo closed this Apr 22, 2025
@Repiteo Repiteo removed this from the 4.x milestone Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switching to RAW mode and then to RGB will change slider max value until refreshed

7 participants