Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #1

Open
wants to merge 52 commits into
base: feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
3969c95
Setting up GitHub Classroom Feedback
github-classroom[bot] Mar 14, 2024
ed4ff3a
inital commitment of README.md
chewbeccaroni Mar 14, 2024
3a86a93
Add files via upload
chewbeccaroni May 12, 2024
05a2f95
Add files via upload
chewbeccaroni May 12, 2024
bd5b4b4
Create build.ninja
chewbeccaroni May 12, 2024
9009ff9
Add files via upload
chewbeccaroni May 12, 2024
7700cd4
Add files via upload
chewbeccaroni May 12, 2024
9574cd1
Delete cmake-build-debug directory
chewbeccaroni May 12, 2024
14e5912
Delete include directory
chewbeccaroni May 12, 2024
8051dfb
Delete shaders directory
chewbeccaroni May 12, 2024
2d9bfe9
Delete src directory
chewbeccaroni May 12, 2024
ebc2dfc
Delete texture directory
chewbeccaroni May 12, 2024
30da084
Add files via upload
chewbeccaroni May 12, 2024
9d8ca85
Create build.ninja
chewbeccaroni May 12, 2024
bae981a
Add files via upload
chewbeccaroni May 12, 2024
2fcd5df
Update ParticleFragment.glsl
chewbeccaroni May 12, 2024
2262081
Update README.md
chewbeccaroni May 12, 2024
df2f672
Delete cmake-build-debug directory
chewbeccaroni May 12, 2024
a69ff27
Delete include directory
chewbeccaroni May 12, 2024
5d4d5b1
Delete moc directory
chewbeccaroni May 12, 2024
8437b5a
Delete shaders directory
chewbeccaroni May 12, 2024
8f65da7
Delete src directory
chewbeccaroni May 12, 2024
e20cfb1
Add files via upload
chewbeccaroni May 12, 2024
a16d6f9
Create build.ninja
chewbeccaroni May 12, 2024
054db92
Add files via upload
chewbeccaroni May 12, 2024
2a5f232
Update README.md
chewbeccaroni May 12, 2024
d2a6e96
Update README.md
chewbeccaroni May 12, 2024
aec5c33
Update README.md
chewbeccaroni May 12, 2024
bd62cb8
Update ParticleFragment.glsl
chewbeccaroni May 13, 2024
895706c
Update NGLScene.cpp
chewbeccaroni May 13, 2024
acc050c
Update README.md
chewbeccaroni May 13, 2024
c242151
Update README.md
chewbeccaroni May 18, 2024
ddefba1
Add files via upload
chewbeccaroni May 18, 2024
42028e7
Update NGLScene.cpp
chewbeccaroni May 18, 2024
c9d6b4e
Update NGLScene.h
chewbeccaroni May 18, 2024
3fb0463
Update README.md
chewbeccaroni May 20, 2024
22a175f
Update README.md
chewbeccaroni May 21, 2024
ba63c92
Add files via upload
chewbeccaroni May 21, 2024
506548a
Update README.md
chewbeccaroni May 21, 2024
701a58c
Update README.md
chewbeccaroni May 21, 2024
866afa6
Add files via upload
chewbeccaroni May 21, 2024
4977a63
Update README.md
chewbeccaroni May 21, 2024
a2256e3
Update README.md
chewbeccaroni May 21, 2024
69c34d2
Add files via upload
chewbeccaroni May 21, 2024
dc5f844
Update README.md
chewbeccaroni May 21, 2024
81b9fac
Add files via upload
chewbeccaroni May 21, 2024
642531f
Update README.md
chewbeccaroni May 21, 2024
ac44b72
Update NGLScene.cpp
chewbeccaroni May 21, 2024
c8a9020
Update NGLScene.h
chewbeccaroni May 21, 2024
6f8af77
Update ParticleFragment.glsl
chewbeccaroni May 21, 2024
fe33029
Update ParticleBlur.glsl
chewbeccaroni May 21, 2024
ed20cf5
Update NGLScene.cpp
chewbeccaroni May 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .giti
Empty file.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
cmake-build*
build/
55 changes: 55 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
cmake_minimum_required(VERSION 3.12)
#-------------------------------------------------------------------------------------------
# I'm going to use vcpk in most cases for our install of 3rd party libs
# this is going to check the environment variable for CMAKE_TOOLCHAIN_FILE and this must point to where
# vcpkg.cmake is in the University this is set in your .bash_profile to
# export CMAKE_TOOLCHAIN_FILE=/public/devel/2020/vcpkg/scripts/buildsystems/vcpkg.cmake
# to build see the NGL instructions
# Windows :- mkdir build; cd build ; cmake -DCMAKE_PREFIX_PATH=~/NGL/ .. ; cmake --build .
# Linux / Mac mkdir build; cd build; cmake -DCMAKE_PREFIX_PATH~/NGL/ .. ; make
#-------------------------------------------------------------------------------------------
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{CMAKE_TOOLCHAIN_FILE})
set(CMAKE_TOOLCHAIN_FILE $ENV{CMAKE_TOOLCHAIN_FILE})
endif()

# Name of the project
project(BlankNGLBuild)
# This is the name of the Exe change this and it will change everywhere
set(TargetName BlankNGL)
# This will include the file NGLConfig.cmake, you need to add the location to this either using
# -DCMAKE_PREFIX_PATH=~/NGL or as a system environment variable.
find_package(NGL CONFIG REQUIRED)
# Instruct CMake to run moc automatically when needed (Qt projects only)
set(CMAKE_AUTOMOC ON)
# find Qt libs
# find Qt libs first we check for Version 6
find_package(Qt6 COMPONENTS OpenGL Widgets QUIET )
if ( Qt6_FOUND )
message("Found Qt6 Using that")
else()
message("Found Qt5 Using that")
find_package(Qt5 COMPONENTS OpenGL Widgets REQUIRED)
endif()

# use C++ 17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
# Set the name of the executable we want to build
add_executable(${TargetName})

# Add NGL include path
include_directories(include $ENV{HOME}/NGL/include)
target_sources(${TargetName} PRIVATE ${PROJECT_SOURCE_DIR}/src/main.cpp
${PROJECT_SOURCE_DIR}/src/NGLScene.cpp
${PROJECT_SOURCE_DIR}/src/NGLSceneMouseControls.cpp
${PROJECT_SOURCE_DIR}/include/NGLScene.h
)

target_link_libraries(${TargetName} PRIVATE Qt::Widgets Qt::OpenGL NGL)

add_custom_target(${TargetName}CopyShaders ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/shaders
$<TARGET_FILE_DIR:${TargetName}>/shaders
)
Binary file added Images/effect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/final.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/fragment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/initilizegl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/paintgl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/particlefragment(1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/particlefragnotes(1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/particlefragnotes(2).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Rebecca Blundell CFGAA Assignment

## Assignment Idea

The aim of my project was to create some type of glowing effect using 2 shaders in c++ using OpenGL. One shader renders the base colour or texture, the other
renders a blurred framebuffer using kernels. From the start I ran into issues. I couldn't get the blurred shader to work. I tried many different methods from many different sources but nothing seemed to solve my issues. I asked ChatGPT and it told me that I was blurring the textures rather than the frame buffer itself. I then fixed this issue so that the framebuffer was the blurring unit, however in the end it still didn't work. In this documentation I aim to talk about the different files and what each function includes and what it should have done in the final code.

## Particle Fragment Shader

I included shaders in my project as it was how I would get the 'Bloom' effect to work. Originally, I decided to ignore the texture/colour shader and get straight into blurring effect which is why there are many different versions that have been commented out in this file. However, the image below shows what added colour to the dragon in the image in the final code using Vec4 and Vec3. It took a bit to get this right as 'particleColour' was vec3 trying to convert to a vec4 but I figured this out with the '.rgb' at the end of 'fragColour'.

![image](https://github.com/NCCA/cfgaa24programingassignment-chewbeccaroni/blob/main/Images/particlefragment(1).png)

Whilst using this particle shader, I'm going to comment on the parts that didn't work and did not make it to the final code as they parts helped me develop my code and let me understand how to go about it but at the same time it's code I worked on but never ended up using.

![Image](https://github.com/NCCA/cfgaa24programingassignment-chewbeccaroni/blob/main/Images/particlefragnotes(1).png)

The image above is a repeat of the final code but includes a brightness like effect. I can't get this to work now but this made the colours in the texture brighter or darker depending on the values used in the main function.

![Image](https://github.com/NCCA/cfgaa24programingassignment-chewbeccaroni/blob/main/Images/fragment.png)

This next one was my first attempt at a blurring effect using offsets and kernels. Using Advanced OpenGL [4] I divided everything by 16 in the kernel so that the colours shown aren't really bright and overexposed. Then you create offsets for the texture and multiply it by the weight of the kernels. The problem came when adding the texture part, because I haven't been able to add 2 shaders at the same time, I'm unable to check if this code blurs the texture or not as it shown a black screen as it comes off screen textures rather than added in textures from me. This was when I put this into ChatGPT to ask what was wrong with it and told me I was blurring the texture rather than as a frambuffer. I went through a couple of iterations of similar code to figure out what went wrong but it ended up going to waste.

Therefore, I went from a different angle and looked more at Bloom OpenGL [1] to create the blurring effect. I then ran into issues on this end as the sources online aren't up to date so some vec3/vec4 functions had changed. It also missed out code about lighting but as a novice coder I couldn't figure out what it was telling me. I concluded that it didn't make much of a difference and continued trying out methods. I used a version where it takes samples of distance to blur, to make more of a DOF effect instead but this wasn't what I was going for so this became anothe deadend. In the end I added the code into another particle shader called 'ParticleBlur' using OpenGL Bloom [1] again.

## SRC

### nglscene.cpp - InitializeGL

The problem however was the fact that I couldn't get 2 shaders to work similtaneously in NGLScene.cpp even after trying many methods. At one point I had a function called 'renderQuad' which did exactly that, It used to triangles to render a 2D texture into the scene, but this got rid of the dragon so this got discared earlier on.

![Image](https://github.com/NCCA/cfgaa24programingassignment-chewbeccaroni/blob/main/Images/initilizegl.png)

So instead I added the framebuffer and particle shaders through intializeGL. This establishes the background colour of the window and adds the shaders into the scene. The same code is repeated twice, however the second half isn't needed but just there for if I got the second particle shader to work. It was made for the framebuffer effects but never went through. It also inlcudes the camera for the scene.

## nglscne.cpp - PaintGL

![Image](https://github.com/NCCA/cfgaa24programingassignment-chewbeccaroni/blob/main/Images/paintgl.png)

PaintGL adds the dragon to the scene and goes through a loop of adding the blur texture by going between the 2 shaders like a ping pong effect. It includes transformations through NGL. Before starting this project and adding a shader, the colour of the dragon was red, hence "Colour" being set to red but not showing up. I also commented out the 'glUniform1i' as it kept spraying warnings at me. I went to the source library on Github to figure out it was this line specifically that as creating that warning which it was.

## nglscenemousecontrols.cpp

I will breifly talk about the functions in here, however as these were part of the original code from Jon Macey, I can't claim that I created these. When using the scene, the left mouse buttoms rotates the camera, and the right mouse button moves it around the scene whether that be in the x, y or z axis. This didn't work in the scene at first (or stopped working) but I managed to fix that issue in nglscene.cpp. It updates every frame so it rerenders the scene every frame. Therefore 'glClear' is needed so that the frames update and don't add on top of eachother. (Alhtough this does create a cool effect as seen below)

![Image](https://github.com/NCCA/cfgaa24programingassignment-chewbeccaroni/blob/main/Images/effect.png)

# Final Result

![Image](https://github.com/NCCA/cfgaa24programingassignment-chewbeccaroni/blob/main/Images/final.png)

I'm quite disappointed that I didn't get the blur effect to work as that would have made this look a lot more visually pleasing. However, I'm happy I tried and this project as a whole has helped me better understand my limits but also the limits of OpenGL. I found it hard to find out how to fix errors on the internet as alot of the code sources come from Jon Macey's NCCA github library (my own choice as it is what we were learning in workshops) so unless ChatGPT gives you a good reliable answer (0.6% probibility) it takes a while to figure out why an error isn't working which really backtracked me and slowed me down.

[1] <p>A <a href="https://learnopengl.com/Advanced-Lighting/Bloom">link to opengl bloom</a>.</p>

This website helps with establishing the set up of a bloom/glow effect but creating 2 different shaders and combining them. I used this as reference quite often, however, some parts are outdated (along with a lot of other elements in this website) so I had to figure out how to change some functions in the particle shader.

[2] <p>A <a href="https://learnopengl.com/Advanced-Lighting/HDR">link to opengl HDR</a>.</p>

A website that talks about exposure and brightness. It uses similar methods to bloom but changes things slightly so I used it to analyse and create some functions but in the end I didn't use them.

[3] <p>A <a href="https://github.com/NCCA/FBODemos/tree/main">link to NCCA on github FBOs</a>.</p>

A whole repository for FBO's so very handy for what I'm doing. If I had issues I used this as a source as to why I'm getting such errors. Again, bit outdated and code has been updated since so some parts weren't useful but some were.

[4] <p>A <a href="https://learnopengl.com/Advanced-OpenGL/Framebuffers">link to opengl framebuffer</a>.</p>

The most useful of my sources. This really helped my understand what offsets and kernels did and why I needed them. After I understood this, I could go onto use reference [1] more easily and used this in my blurring fragment shader.


Loading