0

in https://www.shadertoy.com in the following code:

void mainImage( out vec4 fragColor, in vec2 fragCoord ) { fragColor = vec4(1.0,0.0,0.0,1.0); } which code must i put in 1.0,0.0,0.0,1.0 to obtain a rgb (76, 38, 82) color ?

i tried looking for rgb to r,g,b,a converter i found a website called: https://www.myfixguide.com/color-converter/ and i wrote the hex color that equals that rgb color; i wrote #4C2652; because it is the hex color that equals my rgb color ; and then i got that RGBA is (76,38,82,1.000) but this code doesn´ty work because in 1.0,0.0,0.0,1.0 must be only numbers from 0 to 1 so i can´t find out in this code:

void mainImage( out vec4 fragColor, in vec2 fragCoord ) { fragColor = vec4(1.0,0.0,0.0,1.0); } which code must i put in 1.0,0.0,0.0,1.0 to obtain a rgb (76, 38, 82) color ? can you answer me that please ?

1 Answers1

0

to solve that issue i kept in mind that r,g,b,a 1 equals to 255 in rgb and r,g,b,a 0 equals to 0 in rgb; so i used a rule of try to find out my color with my rgb color (76,38,82); first i did the rule of 3 like this if 1 is 255 76 must be; so i multiplied 1*76 and divided by 255 and used the first obtained number as my first number in this part of the code (1.0,0.0,0.0,1.0); and in the same way i did for the second and three number and the fourth number was the last from the r,g,b,a code i got that was 1.000 and i used it as 1 so i got the first to thrid number of r,g,b,a as i said i got the first and third number and the fourth r,g,b,a number in the way i said i found it

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 14 '23 at 19:35