### Method for introducing new vec3 color options

• 1 Replies
• 130 Views

0 Members and 1 Guest are viewing this topic.

• Moderator
• Posts: 660

#### Method for introducing new vec3 color options

« on: March 22, 2019, 12:55:23 AM »
Method for adding new vec3 color (sabine62 baseColor hack)

//tell FragM to use custom colours
#define providesColor

//add required uniforms to the Coloring-tab
#group Coloring
example:

Code: [Select]
#group Coloring                                          //multiplier for the divisionuniform vec3 LVI; slider[(-1,-1,-1),(0,0,0),(1,1,1)]        //added to LLI to give more possibilitiesuniform vec3 LVI2; slider[(-1,-1,-1),(0,0,0),(1,1,1)]      //determines for how many iterations the difference between the vectors should be calculateduniform int LightIter; slider[0,1,100]                      //choose between lightold/lightnew or lightnew/lightolduniform bool RevertDiv; checkbox[false]                     //in some cases/formulas I found it beneficial to add thisuniform bool AddOrbitStrength; checkbox[false] //previous vector          vec3 lightold;  //current vector                                             vec3 lightnew;

// add in code to extract values required to generate color
example:
Code: [Select]
 vec3 pos = z; lightold=z;                                 //initialize lightold, necessary in some formulas float DF = 1.0; for (int i = 0; i < Box_Iterations ; i++) { if (i<LightIter) {lightold=z;} else {lightold=lightold;};        //get old vector, stop at LightIter-value  z.xyz = clamp(z.xyz, -fold, fold)*2. - z.xyz; float r =dot2(z); if (r< 0.001 || r> 1000.) break; z/=-r; DF/= r; z.xz*=-1.; z+=(Julia ? JuliaC : pos); if (i<LightIter) {lightnew=z;} else {lightnew=lightnew;};            //get new vector, stop at LightIter-value

// Use vec3 baseColor to introduce the new color
Example:

Code: [Select]
vec3 baseColor(vec3 p, vec3 q){  if (RevertDiv) {q=abs(lightnew/lightold);} else {q=abs(lightold/lightnew);}; q*=(LVI+LVI2); if (AddOrbitStrength) q+=OrbitStrength;   return q;}

• Moderator
• Posts: 660

#### Re: Method for introducing new vec3 color options

« Reply #1 on: March 26, 2019, 12:53:06 AM »
How does it All WORK? I am going to find out by looking at the code

#ifdef  providesColor

DE-raytracer.frag

#ifdef  providesColor
hitColor = mix(BaseColor,  baseColor(hit,hitNormal),  OrbitStrength);
#else
hitColor = getColor();

This means that the orbitTrap code is disconnected, instead the points color will come from mixing the BaseColor (chosen with the BaseColor color-picker) with a vec3(R,G,B) generated in the fractal.frag
The two components are mixed with the slider scale called OrbitStrength (but in the hack it is just the mixing scale)

The lefthand side of the mix "BaseColor", is a vec3 containing numbers between 0.0 and 1.0

BaseColor is the pure color of object (in white light)
(1,1,1) is white, bright

(0,0,0) is black, dark

(1,0,0) is fully saturated bright red

The righthand side of the mix "baseColor(vec3,vec3); is the function that is used for coding in other types of color functions, without having to edit a DE-raymarching.frag.
Thinking about the size of the values that will be generated can be important!!   We really want the RGBs  to be between 0 and 1.

Examples

A standard Menger Sponge is contained within a cubic space from -1 to +1. If we use data from a color function using original point values then the data numbers will be inside that range. If we abs() the data it will then  be between 0 and +1

Summary. We are mixing whatever color setting we pick for BaseColor with the return from a function called baseColor (confusing naming:))

### Similar Topics

###### Mandelbulb frag with some options

Started by mclarekin on Fragmentarium

1 Replies
218 Views
October 07, 2018, 07:56:54 AM
by Sabine62
###### Groupbox options appear in Preferences > OpenCL settings

Started by Tas_mania on Mandelbulber

2 Replies
164 Views
May 21, 2019, 01:41:54 AM
by Tas_mania
###### ffmpeg: best mandelbrot video creation options for youtube

Started by CFJH on Fractal Programs Discussion, Help, & Support

2 Replies
232 Views
April 03, 2018, 11:13:27 PM
by CFJH
###### Introducing prefixes for advanced sorting

Started by Fraktalist on Fractal Image Gallery

14 Replies
2503 Views
October 03, 2017, 01:16:23 PM
by Fraktalist
###### Introducing the Mandelbrot Butterfly Safari

Started by JonathanD on Meet & Greet

0 Replies
57 Views
February 01, 2020, 02:47:24 AM
by JonathanD