update
This commit is contained in:
@@ -4,6 +4,9 @@ project(3dviewer)
|
|||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
include_directories(.)
|
include_directories(.)
|
||||||
|
|
||||||
|
find_package(glfw3 REQUIRED)
|
||||||
|
find_package(OpenGL REQUIRED)
|
||||||
|
|
||||||
add_executable(
|
add_executable(
|
||||||
${PROJECT_NAME}
|
${PROJECT_NAME}
|
||||||
main.cpp
|
main.cpp
|
||||||
@@ -15,5 +18,14 @@ add_executable(
|
|||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
${PROJECT_NAME}
|
${PROJECT_NAME}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
libglfw3.a
|
glfw3
|
||||||
|
OpenGL::GL
|
||||||
|
X11
|
||||||
|
Xrandr
|
||||||
|
Xi
|
||||||
|
Xcursor
|
||||||
|
Xinerama
|
||||||
|
pthread
|
||||||
|
dl
|
||||||
|
m
|
||||||
)
|
)
|
||||||
|
|||||||
2
camera.h
2
camera.h
@@ -82,6 +82,8 @@ public:
|
|||||||
|
|
||||||
void triggleFirstMouse() { firstMouse_ = !firstMouse_; }
|
void triggleFirstMouse() { firstMouse_ = !firstMouse_; }
|
||||||
|
|
||||||
|
float Zoom() const { return zoom_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateCameraVectors() {
|
void updateCameraVectors() {
|
||||||
glm::vec3 front;
|
glm::vec3 front;
|
||||||
|
|||||||
@@ -120,21 +120,35 @@ bool LOpenGLShader::compileShaderFromFile(const std::string &path) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOpenGLProgram::LOpenGLProgram() : linked_(false) {
|
LOpenGLProgram::LOpenGLProgram() { Create(); }
|
||||||
Create();
|
|
||||||
}
|
|
||||||
|
|
||||||
LOpenGLProgram::~LOpenGLProgram() {
|
LOpenGLProgram::~LOpenGLProgram() {
|
||||||
|
if (programId_ != 0) {
|
||||||
glDeleteProgram(programId_);
|
glDeleteProgram(programId_);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void LOpenGLProgram::Create() { programId_ = glCreateProgram(); }
|
void LOpenGLProgram::Create() {
|
||||||
|
programId_ = glCreateProgram();
|
||||||
|
created_ = (programId_ != 0);
|
||||||
|
linked_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
bool LOpenGLProgram::Link() const {
|
bool LOpenGLProgram::Link() {
|
||||||
if (!created_ || linked_ || shaderList_.empty()) {
|
if (!created_ || linked_ || shaderList_.empty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
glLinkProgram(programId_);
|
glLinkProgram(programId_);
|
||||||
|
GLint success = 0;
|
||||||
|
glGetProgramiv(programId_, GL_LINK_STATUS, &success);
|
||||||
|
if (!success) {
|
||||||
|
char infoLog[512];
|
||||||
|
glGetProgramInfoLog(programId_, 512, nullptr, infoLog);
|
||||||
|
std::cout << "ERROR::PROGRAM::LINK_FAILED\n" << infoLog << std::endl;
|
||||||
|
linked_ = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
linked_ = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +179,7 @@ void LOpenGLProgram::setUniformValue(const std::string &name, float x, float y,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LOpenGLProgram::setUniformValue(const std::string &name, glm::mat4 value) const {
|
void LOpenGLProgram::setUniformValue(const std::string &name, glm::mat4 value) const {
|
||||||
glUniform4fv(glGetUniformLocation(programId_, name.c_str()), 1, &value[0][0]);
|
glUniformMatrix4fv(glGetUniformLocation(programId_, name.c_str()), 1, GL_FALSE, &value[0][0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LOpenGLProgram::addShader(std::unique_ptr<LOpenGLShader> shader) {
|
bool LOpenGLProgram::addShader(std::unique_ptr<LOpenGLShader> shader) {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public:
|
|||||||
bool addShader(std::unique_ptr<LOpenGLShader> shader);
|
bool addShader(std::unique_ptr<LOpenGLShader> shader);
|
||||||
void removeShader(GLuint id);
|
void removeShader(GLuint id);
|
||||||
void Create();
|
void Create();
|
||||||
bool Link() const;
|
bool Link();
|
||||||
void Use() const;
|
void Use() const;
|
||||||
bool Linked() const { return linked_; }
|
bool Linked() const { return linked_; }
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::list<std::unique_ptr<LOpenGLShader>> shaderList_;
|
std::list<std::unique_ptr<LOpenGLShader>> shaderList_;
|
||||||
GLuint programId_;
|
GLuint programId_ = 0;
|
||||||
bool linked_;
|
bool linked_ = false;
|
||||||
bool created_;
|
bool created_ = false;
|
||||||
};
|
};
|
||||||
|
|||||||
160
main.cpp
160
main.cpp
@@ -4,7 +4,10 @@
|
|||||||
#include <GL/glext.h>
|
#include <GL/glext.h>
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <glm/ext/matrix_clip_space.hpp>
|
||||||
|
#include <glm/ext/matrix_transform.hpp>
|
||||||
#include <glm/fwd.hpp>
|
#include <glm/fwd.hpp>
|
||||||
|
#include <glm/trigonometric.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@@ -17,19 +20,28 @@ public:
|
|||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
};
|
};
|
||||||
GLWidget(ViewPort port) : viewport_(port),
|
GLWidget(ViewPort port) : viewport_(port)
|
||||||
window_(nullptr, [](GLFWwindow* w){if(w) glfwDestroyWindow(w);}) {
|
, window_(nullptr, [](GLFWwindow* w){if(w) glfwDestroyWindow(w);})
|
||||||
|
, deinit_(false) {
|
||||||
lastX_ = port.width / 2;
|
lastX_ = port.width / 2;
|
||||||
lastY_ = port.height / 2;
|
lastY_ = port.height / 2;
|
||||||
initGeometry();
|
initGeometry();
|
||||||
}
|
}
|
||||||
~GLWidget() {
|
~GLWidget() {
|
||||||
|
if (!deinit_) {
|
||||||
|
// OpenGL objects should be deleted while a valid context still exists.
|
||||||
|
if (window_) {
|
||||||
|
glfwMakeContextCurrent(window_.get());
|
||||||
|
}
|
||||||
if (bgVao_) {
|
if (bgVao_) {
|
||||||
glDeleteVertexArrays(1, &bgVao_);
|
glDeleteVertexArrays(1, &bgVao_);
|
||||||
}
|
}
|
||||||
if (bgVbo_) {
|
if (bgVbo_) {
|
||||||
glDeleteBuffers(1, &bgVbo_);
|
glDeleteBuffers(1, &bgVbo_);
|
||||||
}
|
}
|
||||||
|
deinit_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setViewPort(int width, int height) {
|
void setViewPort(int width, int height) {
|
||||||
@@ -37,7 +49,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool initGeometry() {
|
bool initGeometry() {
|
||||||
glfwInit();
|
if (!glfwInit()) {
|
||||||
|
std::cout << "Failed to initialize GLFW" << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
@@ -48,18 +63,20 @@ public:
|
|||||||
if (!window_) {
|
if (!window_) {
|
||||||
std::cout << "Failed to create GLFW window" << std::endl;
|
std::cout << "Failed to create GLFW window" << std::endl;
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
glfwMakeContextCurrent(window_.get());
|
glfwMakeContextCurrent(window_.get());
|
||||||
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
|
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
|
||||||
std::cout << "Failed to initialize GLAD" << std::endl;
|
std::cout << "Failed to initialize GLAD" << std::endl;
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
glViewport(0, 0, 800, 600);
|
glViewport(0, 0, 800, 600);
|
||||||
glfwSetWindowUserPointer(window_.get(), this);
|
glfwSetWindowUserPointer(window_.get(), this);
|
||||||
glfwSetFramebufferSizeCallback(window_.get(), &GLWidget::framebufferSizeCallback);
|
glfwSetFramebufferSizeCallback(window_.get(), &GLWidget::framebufferSizeCallback);
|
||||||
glfwSetCursorPosCallback(window_.get(), &GLWidget::mouseCallback);
|
glfwSetCursorPosCallback(window_.get(), &GLWidget::mouseCallback);
|
||||||
|
glfwSetScrollCallback(window_.get(), &GLWidget::scrollCallback);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBgShaderPath(std::string vp, std::string fp) {
|
void setBgShaderPath(std::string vp, std::string fp) {
|
||||||
@@ -95,16 +112,100 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void initPanelGeometry_() {
|
||||||
|
if (panelVbo_) {
|
||||||
|
glDeleteBuffers(1, &panelVbo_);
|
||||||
|
panelVbo_ = 0;
|
||||||
|
}
|
||||||
|
if (panelVao_) {
|
||||||
|
glDeleteVertexArrays(1, &panelVao_);
|
||||||
|
panelVao_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const float y = panelHeight_ * 0.5f;
|
||||||
|
const float x = panelWidth_ * 0.5f;
|
||||||
|
const float z = panelDepth_ * 0.5f;
|
||||||
|
|
||||||
|
struct V {
|
||||||
|
float x, y, z;
|
||||||
|
float nx, ny, nz;
|
||||||
|
};
|
||||||
|
const V verts[24] = {
|
||||||
|
// 顶面
|
||||||
|
{-x, y, -z, 0, 1, 0},
|
||||||
|
{x, y, -z, 0, 1, 0},
|
||||||
|
{x, y, z, 0, 1, 0 },
|
||||||
|
{-x, y, z, 0, 1, 0},
|
||||||
|
|
||||||
|
// 前面
|
||||||
|
{-x, y, z, 0, 0, 1},
|
||||||
|
{x, y, z, 0, 0, 1},
|
||||||
|
{x, -y, z, 0, 0, 1},
|
||||||
|
{-x, -y, z, 0, 0, 1},
|
||||||
|
|
||||||
|
// 底面
|
||||||
|
{-x, -y, -z, 0, -1, 0},
|
||||||
|
{x, -y, -z, 0, -1, 0},
|
||||||
|
{x, -y, z, 0, -1, 0},
|
||||||
|
{-x, -y, z, 0, -1, 0},
|
||||||
|
|
||||||
|
// 后面
|
||||||
|
{-x, y, -z, 0, 0, -1},
|
||||||
|
{x, y, -z, 0, 0, -1},
|
||||||
|
{x, -y, -z, 0, 0, -1},
|
||||||
|
{-x, -y, -z, 0, 0, -1},
|
||||||
|
|
||||||
|
// 左面
|
||||||
|
{-x, y, z, -1, 0, 0},
|
||||||
|
{-x, y, -z, -1, 0, 0},
|
||||||
|
{-x, -y, -z, -1, 0, 0},
|
||||||
|
{-x, -y, z, -1, 0, 0},
|
||||||
|
|
||||||
|
// 右面
|
||||||
|
{x, y, -z, 1, 0, 0},
|
||||||
|
{x, y, z, 1, 0, 0},
|
||||||
|
{x, -y, z, 1, 0, 0},
|
||||||
|
{x, -y, -z, 1, 0, 0},
|
||||||
|
};
|
||||||
|
|
||||||
|
unsigned int idx[36] = {
|
||||||
|
0, 1, 2, 0, 2, 3,
|
||||||
|
4, 5, 6, 4, 6, 7,
|
||||||
|
8, 9, 10, 8, 10, 11,
|
||||||
|
12, 13, 14, 12, 14, 15,
|
||||||
|
16, 17, 18, 16, 18, 19,
|
||||||
|
20, 21, 22, 20, 22, 23,
|
||||||
|
};
|
||||||
|
|
||||||
|
glGenVertexArrays(1, &panelVao_);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool initBgProgram() {
|
bool initBgProgram() {
|
||||||
auto vshader = std::make_unique<LOpenGLShader>(LOpenGLShader::ShaderType::Vertex);
|
auto vshader = std::make_unique<LOpenGLShader>(LOpenGLShader::ShaderType::Vertex);
|
||||||
auto fshader = std::make_unique<LOpenGLShader>(LOpenGLShader::ShaderType::Fragment);
|
auto fshader = std::make_unique<LOpenGLShader>(LOpenGLShader::ShaderType::Fragment);
|
||||||
vshader->compileShaderFromFile(bgVertShaderPath_);
|
if (!vshader->compileShaderFromFile(bgVertShaderPath_)) {
|
||||||
fshader->compileShaderFromFile(bgFragShaderPath_);
|
std::cout << "Vertex shader compile failed: " << bgVertShaderPath_ << "\n"
|
||||||
|
<< vshader->Log() << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!fshader->compileShaderFromFile(bgFragShaderPath_)) {
|
||||||
|
std::cout << "Fragment shader compile failed: " << bgFragShaderPath_ << "\n"
|
||||||
|
<< fshader->Log() << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
bgProg_ = std::make_unique<LOpenGLProgram>();
|
bgProg_ = std::make_unique<LOpenGLProgram>();
|
||||||
bgProg_->addShader(std::move(vshader));
|
if (!bgProg_->addShader(std::move(vshader))) {
|
||||||
bgProg_->addShader(std::move(fshader));
|
std::cout << "Failed to attach vertex shader\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!bgProg_->addShader(std::move(fshader))) {
|
||||||
|
std::cout << "Failed to attach fragment shader\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
bool ret = bgProg_->Link();
|
bool ret = bgProg_->Link();
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
|
std::cout << "Failed to link background program\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +220,7 @@ private:
|
|||||||
bgProg_->Use();
|
bgProg_->Use();
|
||||||
bgProg_->setUniformValue("uViewport", glm::vec2(viewport_.width, viewport_.height));
|
bgProg_->setUniformValue("uViewport", glm::vec2(viewport_.width, viewport_.height));
|
||||||
bgProg_->setUniformValue("uMajorStep", 120.0f);
|
bgProg_->setUniformValue("uMajorStep", 120.0f);
|
||||||
bgProg_->setUniformValue("uMinjorStep", 24.0f);
|
bgProg_->setUniformValue("uMinorStep", 24.0f);
|
||||||
glBindVertexArray(bgVao_);
|
glBindVertexArray(bgVao_);
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
@@ -131,11 +232,20 @@ private:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
void eventLoop() {
|
void eventLoop() {
|
||||||
|
if (!window_) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
initBgGeometry();
|
initBgGeometry();
|
||||||
initBgProgram();
|
if (!initBgProgram()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
while (!glfwWindowShouldClose(window_.get())) {
|
while (!glfwWindowShouldClose(window_.get())) {
|
||||||
processInput(window_.get());
|
processInput(window_.get());
|
||||||
|
glClearColor(0.08f, 0.08f, 0.10f, 1.0f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
drawBg();
|
drawBg();
|
||||||
|
glfwSwapBuffers(window_.get());
|
||||||
|
glfwPollEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,6 +259,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onFramebufferSize(int width, int height) {
|
void onFramebufferSize(int width, int height) {
|
||||||
|
viewport_ = {width, height};
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,6 +282,7 @@ private:
|
|||||||
float ypos = static_cast<float>(y);
|
float ypos = static_cast<float>(y);
|
||||||
|
|
||||||
if (camera_.firstMouse()) {
|
if (camera_.firstMouse()) {
|
||||||
|
std::cout << "in firstMouse()\n";
|
||||||
lastX_ = x;
|
lastX_ = x;
|
||||||
lastY_ = y;
|
lastY_ = y;
|
||||||
camera_.triggleFirstMouse();
|
camera_.triggleFirstMouse();
|
||||||
@@ -186,8 +298,10 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void scrollCallback(GLFWwindow* window, double xoffset, double yoffset) {
|
static void scrollCallback(GLFWwindow* window, double xoffset, double yoffset) {
|
||||||
|
std::cout << "scrollCallback\n";
|
||||||
auto* self = static_cast<GLWidget*>(glfwGetWindowUserPointer(window));
|
auto* self = static_cast<GLWidget*>(glfwGetWindowUserPointer(window));
|
||||||
if (!self) {
|
if (!self) {
|
||||||
|
std::cout << "auto* self = static_cast<GLWidget*>(glfwGetWindowUserPointer(window)) failed\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self->onScrollRoll(xoffset, yoffset);
|
self->onScrollRoll(xoffset, yoffset);
|
||||||
@@ -202,23 +316,35 @@ private:
|
|||||||
std::unique_ptr<GLFWwindow, std::function<void(GLFWwindow*)>> window_;
|
std::unique_ptr<GLFWwindow, std::function<void(GLFWwindow*)>> window_;
|
||||||
std::string bgFragShaderPath_;
|
std::string bgFragShaderPath_;
|
||||||
std::string bgVertShaderPath_;
|
std::string bgVertShaderPath_;
|
||||||
unsigned int bgVao_;
|
unsigned int bgVao_ = 0;
|
||||||
unsigned int bgVbo_;
|
unsigned int bgVbo_ = 0;
|
||||||
|
|
||||||
|
std::unique_ptr<LOpenGLProgram> panelProg_;
|
||||||
|
std::string panelVertShaderPath_;
|
||||||
|
std::string panelFragShaderPath_;
|
||||||
|
unsigned int panelVao_ = 0;
|
||||||
|
unsigned int panelVbo_ = 0;
|
||||||
|
float panelWidth_ = 0.25;
|
||||||
|
float panelHeight_ = 0.35;
|
||||||
|
float panelDepth_ = 0.05;
|
||||||
|
|
||||||
|
|
||||||
ViewPort viewport_{800, 600};
|
ViewPort viewport_{800, 600};
|
||||||
Camera camera_;
|
Camera camera_;
|
||||||
|
|
||||||
bool firstMouse_ = true;
|
bool firstMouse_ = true;
|
||||||
float lastX_;
|
float lastX_;
|
||||||
float lastY_;
|
float lastY_;
|
||||||
|
|
||||||
|
bool deinit_;
|
||||||
};
|
};
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
{
|
||||||
GLWidget glw({600, 800});
|
GLWidget glw({600, 800});
|
||||||
glw.setBgShaderPath("bg.vert", "bg.frag");
|
glw.setBgShaderPath("../shader/bg.vert", "../shader/bg.frag");
|
||||||
|
|
||||||
glw.eventLoop();
|
glw.eventLoop();
|
||||||
|
}
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -9,9 +9,9 @@ uniform bool uLightMode;
|
|||||||
|
|
||||||
float gridLine(float stepPx) {
|
float gridLine(float stepPx) {
|
||||||
vec2 coord = gl_FragCoord.xy;
|
vec2 coord = gl_FragCoord.xy;
|
||||||
vec2 q = coord / stepPx;
|
vec2 q = coord / max(stepPx, 1.0);
|
||||||
|
vec2 fw = max(fwidth(q), vec2(1e-6));
|
||||||
vec2 q = abs(fract(q - 0.5) - 0.5) / fwidth(stepPx);
|
q = abs(fract(q - 0.5) - 0.5) / fw;
|
||||||
float line = 1.0 - min(min(q.x, q.y), 1.0);
|
float line = 1.0 - min(min(q.x, q.y), 1.0);
|
||||||
|
|
||||||
return line;
|
return line;
|
||||||
@@ -21,27 +21,24 @@ void main() {
|
|||||||
vec2 viewport = max(uViewport, vec2(1.0));
|
vec2 viewport = max(uViewport, vec2(1.0));
|
||||||
vec2 uv = gl_FragCoord.xy / viewport;
|
vec2 uv = gl_FragCoord.xy / viewport;
|
||||||
|
|
||||||
vec3 topCol, botCol, majCol, minCol;
|
vec3 topCol, botCol;
|
||||||
float majStrength, minStrength;
|
float majorStrength, minorStrength;
|
||||||
float vignettePow, vignetteStrength;
|
|
||||||
|
|
||||||
topCol = vec3(0.99, 0.99, 1.00);
|
topCol = vec3(0.99, 0.99, 1.00);
|
||||||
botCol = vec3(0.94, 0.95, 0.98);
|
botCol = vec3(0.94, 0.95, 0.98);
|
||||||
|
|
||||||
minorCol = vec3(0.80, 0.82, 0.87);
|
vec3 minorCol = vec3(0.80, 0.82, 0.87);
|
||||||
majorCol = vec3(0.70, 0.73, 0.80);
|
vec3 majorCol = vec3(0.70, 0.73, 0.80);
|
||||||
|
|
||||||
minorStrength = 0.22;
|
minorStrength = 0.28;
|
||||||
majorStrength = 0.35;
|
majorStrength = 0.45;
|
||||||
vignettePow = 0.12;
|
|
||||||
vignetteStrength = 0.35;
|
|
||||||
|
|
||||||
vec3 col = mix(botCol, topCol, uv.y);
|
vec3 col = mix(botCol, topCol, uv.y);
|
||||||
float minor = gridLine(max(uMinorStep, 1.0));
|
float minor = gridLine(max(uMinorStep, 1.0));
|
||||||
float major = gridLine(max(uMajorStep, 1.0));
|
float major = gridLine(max(uMajorStep, 1.0));
|
||||||
|
|
||||||
col = mix(col, minorCol, minStrength * minor);
|
col = mix(col, minorCol, minorStrength * minor);
|
||||||
col = mix(col, majorCol, majStrength * major);
|
col = mix(col, majorCol, majorStrength * major);
|
||||||
|
|
||||||
vec2 p = uv * 2.0 - 1.0;
|
vec2 p = uv * 2.0 - 1.0;
|
||||||
float v = clamp(1.0 - dot(p, p) * 0.12 , 0.0, 1.0);
|
float v = clamp(1.0 - dot(p, p) * 0.12 , 0.0, 1.0);
|
||||||
|
|||||||
Reference in New Issue
Block a user