generated from AfonsoCMSousa/CPP-Template
Feat: Better noise and position of effect.
This commit is contained in:
parent
cb38b2445e
commit
fcb28671c2
Binary file not shown.
BIN
build/bin/RASTER
BIN
build/bin/RASTER
Binary file not shown.
@ -75,10 +75,10 @@ void main() {
|
||||
vec2 st = gl_FragCoord.xy / u_resolution; // Normalize coordinates
|
||||
st += 13.0 + (u_oscilator * 0.001); // Center the coordinates
|
||||
|
||||
vec2 pos = st * (3.0);
|
||||
vec2 pos = st * (2.2);
|
||||
|
||||
pos = rotate2d(perlinNoise(pos)) * pos;
|
||||
pos -= (u_time * (float(u_oscilator) * 0.5) * 0.2);
|
||||
pos -= (u_time * (float(u_oscilator) * 0.5) * 0.1);
|
||||
|
||||
float n = perlinNoise(pos);
|
||||
vec3 color;
|
||||
|
||||
@ -108,7 +108,7 @@ int main() {
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
glfwWindowHint(GLFW_SAMPLES, 16); // 16x MSAA
|
||||
|
||||
GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "OpenGL Template", nullptr, nullptr);
|
||||
GLFWwindow* window = glfwCreateWindow((int)SCR_WIDTH, (int)SCR_HEIGHT, "OpenGL Template", nullptr, nullptr);
|
||||
if (!window) {
|
||||
glfwTerminate();
|
||||
return -1;
|
||||
@ -182,14 +182,14 @@ int main() {
|
||||
glm::mat4 view = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -1.0f));
|
||||
glm::mat4 projection = glm::perspective(glm::radians(45.0f), SCR_WIDTH/SCR_HEIGHT, 0.1f, 100.0f);
|
||||
|
||||
GLuint modelLoc = glGetUniformLocation(shaderProgram, "model");
|
||||
GLuint viewLoc = glGetUniformLocation(shaderProgram, "view");
|
||||
GLuint projLoc = glGetUniformLocation(shaderProgram, "projection");
|
||||
GLuint modelLoc = (unsigned int) glGetUniformLocation(shaderProgram, "model");
|
||||
GLuint viewLoc = (unsigned int) glGetUniformLocation(shaderProgram, "view");
|
||||
GLuint projLoc = (unsigned int) glGetUniformLocation(shaderProgram, "projection");
|
||||
|
||||
glUseProgram(shaderProgram);
|
||||
glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model));
|
||||
glUniformMatrix4fv(viewLoc, 1, GL_FALSE, glm::value_ptr(view));
|
||||
glUniformMatrix4fv(projLoc, 1, GL_FALSE, glm::value_ptr(projection));
|
||||
glUniformMatrix4fv((int) modelLoc, 1, GL_FALSE, glm::value_ptr(model));
|
||||
glUniformMatrix4fv((int) viewLoc, 1, GL_FALSE, glm::value_ptr(view));
|
||||
glUniformMatrix4fv((int) projLoc, 1, GL_FALSE, glm::value_ptr(projection));
|
||||
|
||||
|
||||
GLint resLoc = glGetUniformLocation(shaderProgram, "u_resolution");
|
||||
@ -218,12 +218,12 @@ int main() {
|
||||
|
||||
if (oscillation < 5) invert = 0;
|
||||
|
||||
if (invert) oscillation -= 0.001;
|
||||
else oscillation += 0.001;
|
||||
if (invert) oscillation -= 0.01f;
|
||||
else oscillation += 0.001f;
|
||||
|
||||
// Debug
|
||||
std::cout << "Oscillation: " << oscillation << "\t";
|
||||
std::cout << "Invert: " << invert << std::endl;
|
||||
// std::cout << "Oscillation: " << oscillation << "\t";
|
||||
// std::cout << "Invert: " << invert << std::endl;
|
||||
|
||||
direction = rand() % 50; // change direction every 300 frames
|
||||
}
|
||||
@ -235,29 +235,11 @@ int main() {
|
||||
|
||||
glClearColor(0.01f, 0.01f, 0.01f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBindVertexArray(VAO);
|
||||
glDrawElements(GL_TRIANGLES,6,GL_UNSIGNED_INT,0);
|
||||
|
||||
glUseProgram(shaderProgram);
|
||||
|
||||
// Move WASD
|
||||
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
|
||||
view = glm::translate(view, glm::vec3(0.0f, 0.01f, 0.0f));
|
||||
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
|
||||
view = glm::translate(view, glm::vec3(0.0f, -0.01f, 0.0f));
|
||||
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
|
||||
view = glm::translate(view, glm::vec3(-0.01f, 0.0f, 0.0f));
|
||||
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
|
||||
view = glm::translate(view, glm::vec3(0.01f, 0.0f, 0.0f));
|
||||
|
||||
// QE rotate
|
||||
if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS)
|
||||
view = glm::rotate(view, glm::radians(1.0f), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
if (glfwGetKey(window, GLFW_KEY_E) == GLFW_PRESS)
|
||||
view = glm::rotate(view, glm::radians(-1.0f), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
|
||||
glUniformMatrix4fv(viewLoc, 1, GL_FALSE, glm::value_ptr(view));
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user