Skip to content

Fix Transparent Ocean Surface#71

Open
kethan1 wants to merge 1 commit into
patrykcieslak:masterfrom
kethan1:fix-transparent-surface
Open

Fix Transparent Ocean Surface#71
kethan1 wants to merge 1 commit into
patrykcieslak:masterfrom
kethan1:fix-transparent-surface

Conversation

@kethan1

@kethan1 kethan1 commented Nov 1, 2025

Copy link
Copy Markdown
Contributor

Fixes transparent ocean surface when viewed from above

Before:
image

After:
image

@patrykcieslak

patrykcieslak commented Nov 11, 2025

Copy link
Copy Markdown
Owner

Hello @kethan1 ! I checked this PR and this fix does not make sense.
The "ShadingModel" function is defined by different material models - CookTorrance, Blinn-Phong, etc.
The "light.frag" file has the same role as, for example, the "blinnPhong.frag" - it is a material shader.
Why this worked is probably because you basically replaced all material models with the one defined in "light.frag" which is so basic that it has to work fine. The problem has to be in the CookTorrance shader I guess.

@kethan1 kethan1 closed this Nov 30, 2025
@kethan1 kethan1 force-pushed the fix-transparent-surface branch from 4d0b378 to 99e30e9 Compare November 30, 2025 08:57
@kethan1 kethan1 reopened this Nov 30, 2025
@kethan1

kethan1 commented Nov 30, 2025

Copy link
Copy Markdown
Contributor Author

@patrykcieslak Sorry for the late response and sorry for the erroneous fix. I'm fairly new to OpenGL, but I took another crack at this issue.

I believe the problem stemmed from the OpenGLRealOcean.cpp and OpenGLFlatOcean.cpp files, where lighting.frag was loaded without a corresponding fragment file containing the shading algorithm (definition of ShadingModel function) also being loaded.

I added a call to load the cookTorrance.frag file in the above mentioned files.

I have left OpenGLContent.cpp untouched, as it loads a corresponding shading algorithm.

Output before fix:

[INFO] Welcome to Stonefish 1.6.
[INFO] Window created. OpenGL 4.6 contexts created.
[INFO] Checking GPU capabilities...
[INFO] Number of texture units available: 192
[INFO] Maximum texture size: 16384
[INFO] Maximum number of texture layers: 8192
[INFO] Maximum number of fragment shader uniforms: 16384
[INFO] Setting up OpenGL...
[INFO] Loaded texture from: /home/kethan/Coding/AVBotz/high/stonefish/Library/shaders/logo_64.png
[INFO] Initializing rendering pipeline:
[INFO] Loading GUI...
[INFO] Loaded texture from: /home/kethan/Coding/AVBotz/high/stonefish/Library/shaders/logo_gray_64.png
[INFO] Loaded texture from: /home/kethan/Coding/AVBotz/high/stonefish/Library/shaders/gui.png
[INFO] Initialising OpenGL rendering pipeline...
[INFO] Loading shaders...
[INFO] Loaded texture from: /home/kethan/Coding/AVBotz/high/stonefish/Library/shaders/flake.png
[INFO] Initializing simulation:
[INFO] Building scenario...
[INFO] Loaded precomputed atmosphere model (20 wavelengths, 5 scattering orders)
[INFO] Material Dummy (0) created.
[INFO] Material Fiberglass (1) created.
[INFO] Material Rock (2) created.
[INFO] Loaded texture from: /home/kethan/Coding/AVBotz/high/stonefish/Tests/Data/sand_normal.png
[WARN] Texture has 4 channels while expected 3 channels!
[INFO] Loaded texture from: /home/kethan/Coding/AVBotz/high/stonefish/Tests/Data/propeller_tex.png
[WARN] Texture has 4 channels while expected 3 channels!
[INFO] Loaded texture from: /home/kethan/Coding/AVBotz/high/stonefish/Tests/Data/link4_tex.png
[INFO] Generating ocean waves...
[ERROR] Failed to link program!
[ERROR] Failed to link program!
...

Output before fix with lines 561 and 570 commented in GLSLShader.cpp (for extra debugging info):

[INFO] Welcome to Stonefish 1.6.
[INFO] Window created. OpenGL 4.6 contexts created.
[INFO] Checking GPU capabilities...
[INFO] Number of texture units available: 192
[INFO] Maximum texture size: 16384
[INFO] Maximum number of texture layers: 8192
[INFO] Maximum number of fragment shader uniforms: 16384
[INFO] Setting up OpenGL...
[INFO] Loaded texture from: /home/kethan/Coding/AVBotz/high/stonefish/Library/shaders/logo_64.png
[INFO] Initializing rendering pipeline:
[INFO] Loading GUI...
[INFO] Loaded texture from: /home/kethan/Coding/AVBotz/high/stonefish/Library/shaders/logo_gray_64.png
[INFO] Loaded texture from: /home/kethan/Coding/AVBotz/high/stonefish/Library/shaders/gui.png
[INFO] Initialising OpenGL rendering pipeline...
[INFO] Loading shaders...
[INFO] Loaded texture from: /home/kethan/Coding/AVBotz/high/stonefish/Library/shaders/flake.png
[INFO] Initializing simulation:
[INFO] Building scenario...
[INFO] Loaded precomputed atmosphere model (20 wavelengths, 5 scattering orders)
[INFO] Material Dummy (0) created.
[INFO] Material Fiberglass (1) created.
[INFO] Material Rock (2) created.
[INFO] Loaded texture from: /home/kethan/Coding/AVBotz/high/stonefish/Tests/Data/sand_normal.png
[WARN] Texture has 4 channels while expected 3 channels!
[INFO] Loaded texture from: /home/kethan/Coding/AVBotz/high/stonefish/Tests/Data/propeller_tex.png
[WARN] Texture has 4 channels while expected 3 channels!
[INFO] Loaded texture from: /home/kethan/Coding/AVBotz/high/stonefish/Tests/Data/link4_tex.png
[INFO] Generating ocean waves...
[WARN] Program link log: error: unresolved reference to function `ShadingModel'

[ERROR] Failed to link program!
[WARN] Program link log: error: unresolved reference to function `ShadingModel'

[ERROR] Failed to link program!
...

Output after fix:

[INFO] Welcome to Stonefish 1.6.
[INFO] Window created. OpenGL 4.6 contexts created.
[INFO] Checking GPU capabilities...
[INFO] Number of texture units available: 192
[INFO] Maximum texture size: 16384
[INFO] Maximum number of texture layers: 8192
[INFO] Maximum number of fragment shader uniforms: 16384
[INFO] Setting up OpenGL...
[INFO] Loaded texture from: /home/kethan/Coding/AVBotz/high/stonefish/Library/shaders/logo_64.png
[INFO] Initializing rendering pipeline:
[INFO] Loading GUI...
[INFO] Loaded texture from: /home/kethan/Coding/AVBotz/high/stonefish/Library/shaders/logo_gray_64.png
[INFO] Loaded texture from: /home/kethan/Coding/AVBotz/high/stonefish/Library/shaders/gui.png
[INFO] Initialising OpenGL rendering pipeline...
[INFO] Loading shaders...
[INFO] Loaded texture from: /home/kethan/Coding/AVBotz/high/stonefish/Library/shaders/flake.png
[INFO] Initializing simulation:
[INFO] Building scenario...
[INFO] Loaded precomputed atmosphere model (20 wavelengths, 5 scattering orders)
[INFO] Material Dummy (0) created.
[INFO] Material Fiberglass (1) created.
[INFO] Material Rock (2) created.
[INFO] Loaded texture from: /home/kethan/Coding/AVBotz/high/stonefish/Tests/Data/sand_normal.png
[WARN] Texture has 4 channels while expected 3 channels!
[INFO] Loaded texture from: /home/kethan/Coding/AVBotz/high/stonefish/Tests/Data/propeller_tex.png
[WARN] Texture has 4 channels while expected 3 channels!
[INFO] Loaded texture from: /home/kethan/Coding/AVBotz/high/stonefish/Tests/Data/link4_tex.png
[INFO] Generating ocean waves...
...
image image

@kethan1 kethan1 force-pushed the fix-transparent-surface branch from 1932273 to a6b4e1e Compare December 6, 2025 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants