First Prototype of FractalInspector
This commit is contained in:
@@ -15,10 +15,10 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
include(cmake/CPM.cmake)
|
||||
|
||||
CPMAddPackage(NAME jlog
|
||||
URL https://git.redacted.cc/josh/jlog/archive/Prerelease-17.zip)
|
||||
URL https://git.redacted.cc/josh/jlog/archive/Prerelease-18.zip)
|
||||
|
||||
CPMAddPackage(NAME mcolor
|
||||
URL https://git.redacted.cc/maxine/mcolor/archive/Prerelease-7.zip)
|
||||
URL https://git.redacted.cc/maxine/mcolor/archive/Prerelease-7.2.zip)
|
||||
|
||||
CPMAddPackage(NAME Event
|
||||
URL https://git.redacted.cc/josh/Event/archive/Release-12.zip)
|
||||
@@ -30,10 +30,10 @@ CPMAddPackage(NAME ReWindow
|
||||
URL https://git.redacted.cc/Redacted/ReWindow/archive/Prerelease-32.zip)
|
||||
|
||||
CPMAddPackage(NAME JGL
|
||||
URL https://git.redacted.cc/josh/JGL/archive/Prerelease-54.zip)
|
||||
URL https://git.redacted.cc/josh/JGL/archive/Prerelease-55.zip)
|
||||
|
||||
CPMAddPackage(NAME JUI
|
||||
URL https://git.redacted.cc/josh/ReJUI/archive/Prerelease-5.16.zip)
|
||||
URL https://git.redacted.cc/josh/ReJUI/archive/Prerelease-5.17.zip)
|
||||
|
||||
add_executable(ReShader main.cpp)
|
||||
|
||||
@@ -43,6 +43,7 @@ target_include_directories(ReShader PUBLIC ${jlog_SOURCE_DIR}/include)
|
||||
target_include_directories(ReShader PUBLIC ${JGL_SOURCE_DIR}/include)
|
||||
target_include_directories(ReShader PUBLIC ${ReWindow_SOURCE_DIR}/include)
|
||||
target_include_directories(ReShader PUBLIC ${JUI_SOURCE_DIR}/include)
|
||||
target_include_directories(ReShader PUBLIC ${mcolor_SOURCE_DIR}/include)
|
||||
|
||||
target_link_libraries(ReShader PUBLIC Event J3ML jlog ReWindow JGL JUI)
|
||||
target_link_libraries(ReShader PUBLIC Event J3ML jlog ReWindow JGL JUI mcolor)
|
||||
|
||||
|
88
main.cpp
88
main.cpp
@@ -7,6 +7,7 @@
|
||||
#include "JUI/Widgets/CommandLine.hpp"
|
||||
#include "JGL/types/Shader.h"
|
||||
#include <ReWindow/Logger.h>
|
||||
#include <Color4.hpp>
|
||||
|
||||
std::vector<std::string> string_expand(const std::string& input, char delimiter = ' ');
|
||||
|
||||
@@ -40,15 +41,17 @@ using namespace JUI::UDimLiterals;
|
||||
/// A JUI Widget that displays a HSV color input dialog.
|
||||
class ColorPicker : public JUI::Rect {
|
||||
public:
|
||||
JUI::Slider* hue_slider;
|
||||
JUI::Slider* sat_slider;
|
||||
JUI::Slider* bri_slider;
|
||||
JUI::Text* hue_label;
|
||||
JUI::TextRect* sat_label;
|
||||
JUI::TextRect* bri_label;
|
||||
Event<Color4> OnColorValueChanged;
|
||||
void SetColorValue(const Color4& color);
|
||||
Color4 GetColorValue() const;
|
||||
|
||||
JUI::TextRect* hex_label;
|
||||
|
||||
|
||||
float hue = 0;
|
||||
float sat = 1.f;
|
||||
float bri = 1.f; // AKA val
|
||||
|
||||
ColorPicker() : Rect() {
|
||||
|
||||
Size({100_percent, 100_percent});
|
||||
@@ -60,22 +63,55 @@ public:
|
||||
hue_slider->Minimum(0.f); hue_slider->Maximum(1.f);
|
||||
hue_slider->Interval(1e-3f);
|
||||
hue_slider->ValueChanged += [this] (float val) mutable {
|
||||
hue_label->SetContent(std::format("Hue: {}", Math::FloorInt(val*255)));
|
||||
hue_slider->ScrubberColor(Color4(HSV{val*255, 255, 255}));
|
||||
hue_label->SetContent(std::format("Hue: {}", Math::FloorInt(val*360)));
|
||||
|
||||
hue = val * 360;
|
||||
|
||||
hue_slider->ScrubberColor(Color4::FromHSV(hue, 1.f, 1.f));
|
||||
|
||||
OnColorValueChanged.Invoke(Color4::FromHSV(hue, sat, bri));
|
||||
};
|
||||
|
||||
hue_label = new JUI::Text(hue_slider);
|
||||
hue_label->AlignCenterHorizontally();
|
||||
hue_label->AlignTop();
|
||||
hue_label->SetTextColor(Colors::Black);
|
||||
hue_label->SetContent("Hue: 255");
|
||||
hue_label->SetContent("Hue: 0");
|
||||
|
||||
sat_slider = new JUI::Slider(row_layout);
|
||||
sat_slider->Size({100_percent, 28_px});
|
||||
sat_slider->Minimum(0); sat_slider->Maximum(1);
|
||||
sat_slider->Interval(1e-3f);
|
||||
sat_slider->ValueChanged += [this] (float val) mutable {
|
||||
sat_label->SetContent(std::format("Saturation: {}%", val*100.f));
|
||||
|
||||
sat = val;
|
||||
OnColorValueChanged.Invoke(Color4::FromHSV(hue, sat, bri));
|
||||
};
|
||||
|
||||
sat_label = new JUI::Text(sat_slider);
|
||||
sat_label->AlignCenterHorizontally();
|
||||
sat_label->AlignTop();
|
||||
sat_label->SetTextColor(Colors::Black);
|
||||
sat_label->SetContent("Saturation: 100%");
|
||||
|
||||
bri_slider = new JUI::Slider(row_layout);
|
||||
bri_slider->Size({100_percent, 28_px});
|
||||
bri_slider->Minimum(0); bri_slider->Maximum(1);
|
||||
bri_slider->Interval(1e-3f);
|
||||
bri_slider->ValueChanged += [this] (float val) mutable {
|
||||
bri_label->SetContent(std::format("Brightness: {}%", val*100.f));
|
||||
|
||||
bri = val;
|
||||
|
||||
OnColorValueChanged.Invoke(Color4::FromHSV(hue, sat, bri));
|
||||
};
|
||||
|
||||
bri_label = new JUI::Text(bri_slider);
|
||||
bri_label->AlignCenterHorizontally();
|
||||
bri_label->AlignTop();
|
||||
bri_label->SetTextColor(Colors::Black);
|
||||
bri_label->SetContent("Brightness: 100%");
|
||||
|
||||
auto* hue_box = new JUI::Rect();
|
||||
}
|
||||
@@ -85,6 +121,12 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
JUI::Slider* hue_slider;
|
||||
JUI::Slider* sat_slider;
|
||||
JUI::Slider* bri_slider;
|
||||
JUI::Text* hue_label;
|
||||
JUI::Text* sat_label;
|
||||
JUI::Text* bri_label;
|
||||
private:
|
||||
};
|
||||
|
||||
@@ -95,6 +137,8 @@ public:
|
||||
JGL::Shader shader;
|
||||
JGL::RenderTarget *canvas;
|
||||
float u_time;
|
||||
Color4 u_rgb_1 = Colors::Greens::Chartreuse;
|
||||
Color4 u_rgb_2 = Colors::Reds::LightCoral;
|
||||
std::string frag_name;
|
||||
std::string vert_name;
|
||||
|
||||
@@ -150,12 +194,28 @@ public:
|
||||
|
||||
// TODO: Utilize for things later.
|
||||
auto* wind = new JUI::Window(scene);
|
||||
wind->SetTitle("ReShader");
|
||||
wind->MinSize({100, 100});
|
||||
wind->Size({200_px, 100_px});
|
||||
wind->SetTitle("Color-Picker A");
|
||||
wind->MinSize({200, 150});
|
||||
wind->Size({200_px, 150_px});
|
||||
wind->Position({50_px, 50_px});
|
||||
//wind->Close();
|
||||
|
||||
ColorPicker* pp = new ColorPicker(wind->ViewportInstance());
|
||||
pp->OnColorValueChanged += [this] (const Color4& color) mutable {
|
||||
u_rgb_1 = color;
|
||||
};
|
||||
|
||||
|
||||
auto* wind2 = new JUI::Window(scene);
|
||||
wind2->SetTitle("Color-Picker B");
|
||||
wind2->MinSize({200, 150});
|
||||
wind2->Size({200_px, 150_px});
|
||||
wind2->Position({50_px, 250_px});
|
||||
|
||||
ColorPicker* pp2 = new ColorPicker(wind2->ViewportInstance());
|
||||
pp2->OnColorValueChanged += [this] (const Color4& color) mutable {
|
||||
u_rgb_2 = color;
|
||||
};
|
||||
|
||||
console = new JUI::CommandLine(scene);
|
||||
console->MinSize(Vector2(200, 200));
|
||||
@@ -222,7 +282,7 @@ public:
|
||||
CreateMenu();
|
||||
|
||||
canvas = new RenderTarget(vec_size);
|
||||
LoadShader("test");
|
||||
LoadShader("test", "mandelbrot");
|
||||
|
||||
console->Log(std::format("OpenGL Renderer: {}", GetGLRenderer()));
|
||||
console->Log(std::format("OpenGL Vendor: {}", GetGLVendor()));
|
||||
@@ -271,6 +331,8 @@ public:
|
||||
shader.SetVector2("u_resolution", u_res);
|
||||
shader.SetFloat("u_time", u_time);
|
||||
shader.SetVector2("u_mouse", u_mouse);
|
||||
shader.SetVector3("u_rgb_1", Vector3(u_rgb_1.RN(), u_rgb_1.GN(), u_rgb_1.BN()));
|
||||
shader.SetVector3("u_rgb_2", Vector3(u_rgb_2.RN(), u_rgb_2.GN(), u_rgb_2.BN()));
|
||||
}
|
||||
void Draw() {
|
||||
|
||||
|
0
shaders/julia.frag.glsl
Normal file
0
shaders/julia.frag.glsl
Normal file
@@ -13,6 +13,9 @@ uniform float u_time;
|
||||
uniform vec2 u_translation;
|
||||
uniform float u_zoom;
|
||||
|
||||
uniform vec3 u_rgb_1;
|
||||
uniform vec3 u_rgb_2;
|
||||
|
||||
#define N 48.
|
||||
#define B 4.
|
||||
|
||||
@@ -49,7 +52,7 @@ void main() {
|
||||
|
||||
float n = iterate(uv) / N;
|
||||
|
||||
vec3 col = pal(fract(n + 0.5), vec3(.5), vec3(.5), vec3(1), vec3(.0, .1, .2));
|
||||
vec3 col = pal(fract(n + 0.5), vec3(.5), u_rgb_1, u_rgb_2, vec3(.0, .1, .2));
|
||||
|
||||
//if (n == 1.) {n = 0; }
|
||||
gl_FragColor = vec4(n == 1. ? vec3(0) : col, 1.);
|
Reference in New Issue
Block a user