Software-OK
≡... News | ... Home | ... FAQ | Impressum | Contact | Listed at | Thank you |

  
HOME ► Windows Tip - OpenGL ► «««« 01 / 18 »»»»

gl_FragDepth Manipulation, deception and effects!


The perspective version of optical illusion is great, but the problem remains until an object touches the ground or another object!





1.) ... The first example with the solution is difficult to use!
2.) ... The second example is easy to understand!
3.) ... What's the point of all this stuff with gl_FragDepth, gl_DepthRange, ....?




1.) The first example with solution is difficult to use!

This doesn't behave like an object intended for the depth buffer. As far as that goes, it's just a circle! 

Here's the solution:  https://paroj.github.io/gltut/Illumination/Tut13%20Deceit%20in%20Depth.html 

Part of the fragment shader's output is a depth value. If you don't write one, OpenGL likes to use gl_FragCoord.z , the fragment shader's depth output. This value is subjected to a depth test against the current depth value and, if the test passes, is written to the depth buffer.

https://paroj.github.io/gltut/Illumination/Tutorial%2013.html

(Image-1) How can I in OpenGL!
How can I in OpenGL!

-
▲ Back to the top ▲




Related:

https://www.cl.cam.ac.uk/teaching/1718/FGraphics/6.%20Advanced%20Shader%20Techniques.pdf

2.) The second example is easy to understand!



https://www.raywenderlich.com/2323-opengl-es-pixel-shaders-tutorial



(Bild-2) Gl_FragDepth Manipulation!
Gl_FragDepth manipulation!


When working with a 3D sphere, vector normalization makes equations much easier, and the same applies to procedural textures, especially noise. Functions like smoothing and interpolation are much easier when performed on a square grid. 



-
▲ Back to the top ▲


3.) Why all this with gl_FragDepth, gl_DepthRange, ....?


It's always good to know, as it allows you to display 3D objects in a different way. You must never forget that no matter how you go about it, 3D doesn't exist and is only an illusion. Whether you use triangles or other formulas is irrelevant; only the result and the improved appearance count here! 

As with everything else, the simplest is usually the best! 

Further links:

Source code for MS Visual Studio 10:
http://tubafun.bplaced.net/public/sphere_shader.zip
Description:
http://11235813tdd.blogspot.com/2013/04/raycasted-spheres-and-point-sprites-vs.html !


Calculation of gl_FragDepth ;-)

/*something*/ = Position in space

https://microeducate.tech/glsl-gl_fragcoord-z-calculation-and-setting-gl_fragdepth/
https://stackoverflow.com/questions/10264949/glsl-gl-fragcoord-z-calculation-and-setting-gl-fragdepth

Also good for understanding:
►►  http://www.songho.ca/opengl/gl_transform.html


float far=gl_DepthRange.far; float near=gl_DepthRange.near;

vec4 eye_space_pos = gl_ModelViewMatrix * /*something*/
vec4 clip_space_pos = gl_ProjectionMatrix * eye_space_pos;

float ndc_depth = clip_space_pos.z / clip_space_pos.w;

float depth = (((far-near) * ndc_depth) + near + far) / 2.0;
gl_FragDepth = depth;




Implementing Soft Particles in WebGL and OpenGL Particles are one of the easiest ways to enhance the visual appearance of a scene. Using gl_FragDepth, gl_FragCoord.z, and gl_FragCoord.w, you can significantly save processing power! 

https://keaukraine.medium.com/implementing-soft-particles-in-webgl-and-opengl-es-b968d61133b0

 
(Image-3) Gl_FragDepth manipulation, deception also for particle effects!
Gl_FragDepth manipulation, deception also for particle effects!

-
▲ Back to the top ▲



https://github.com/ssloy/glsltuto

(Image-4) Gl_FragDepth Manipulation, deception and effects!
Gl_FragDepth Manipulation, deception and effects!

-
▲ Back to the top ▲




Updated on: 12 April 2025 20:36 Windows
Keywords: opengl, fragdepth, manipulation, deception, effects, perspective, version, optical, illusion, great, problem, remains, until, object, touches, ground, another, first, example


Similar information on the page

Windows

... Wi-Fi and Wireless display on Windows 11?


The wireless display function under Windows 11 is very convenient and easy to make a presentation on the big TV screen in the living room or in the office
Windows

... Easy Share the folder with everyone on Windows 11?


The easy file sharing in Windows 11 can be deactivated and activated quite easily via the corresponding folder or drive options Content: 1. Share Folder,
Windows

... Clean up TEMP quickly on Windows 11


Its easy to quickly clean up temporary files and temporary folders on Windows 11 or with one button klick 1. Deleting the temporary files via the
Windows

... Multiple windows with multiple monitors behave on Windows 11


The new function to easily influence the behavior of the window with multiple monitors on Windows 11 is practical and can also be adapted Everyone probably
Windows

... Is the new Windows 11 really installed?


It is quite easy to see whether the new Windows 11 has really been installed on your computer Content: 1. Is the new Windows 11 installed? 2.
Windows

... Difference between screen keyboard and touch keyboard, Windows 11, 10, ...?


The difference between screen keyboard and touch keyboard under Windows 11, 10, The ►  classic on-screen keyboard and the touchscreen keyboard  are
Windows

... Uninstall applications on Windows 11


Nothing is easier than uninstalling applications under Windows 11 to free up a little space on your PC 1. Uninstall Windows applications quickly



▲ Back to the top ▲



... OpenGL Tip



3D.Benchmark.OK # AlwaysMouseWheel # AutoHideDesktopIcons # AutoPowerOptionsOK # ClassicDesktopClock # DesktopDigitalClock # DesktopNoteOK # DesktopOK # DontSleep # Edge-Chromium # ExperienceIndexOK # Find.Same.Images.OK # FontViewOK # GetPixelColor # GetWindowText # Internet # IsMyHdOK # KeepMouseSpeedOK # NewFileTime # OpenCloseDriveEject # OpenGL # PhotoResizerOK # Q-Dir # QuickMemoryTestOK # QuickTextPaste # Registry # ShortDoorNote # StressMyPC # System # TheAeroClock # Tools # Version # WinScan2PDF #




  

  + Freeware
  + Order on the PC
  + File management
  + Automation
  + Office Tools
  + PC testing tools
  + Decoration and fun
  + Desktop-Clocks
  + Security

  + SoftwareOK Pages
  + Micro Staff
  + Freeware-1
  + Freeware-2
  + Freeware-3
  + FAQ
  + Downloads

  + Top
  + Desktop-OK
  + The Quad Explorer
  + Don't Sleep
  + Win-Scan-2-PDF
  + Quick-Text-Past
  + Print Folder Tree
  + Find Same Images
  + Experience-Index-OK
  + Font-View-OK


  + Freeware
  + CoronaKO
  + MatriX.CoronaKO
  + Find.Same.Images.OK
  + 3D.Benchmark.OK
  + PhotoResizerOK
  + Office.Files.Images
  + Film.Strip.Explorer
  + WinScan2PDF
  + DontSleep
  + PAD-s


Home | Thanks | Contact | Link me | FAQ | Settings | Windows 10 | gc24b | English-AV | Impressum | Translate | PayPal | PAD-s

 © 2025 by Nenad Hrg ERR2: softwareok.de • softwareok.com • softwareok.com • softwareok.eu
63.013 msec.


>> ☕ Buy SoftwareOK a Coffee ☕ <<



► Will Windows Settings ⚙️ be available in Windows 12? ◄
► Can I share, post the analog freeware desktop clock for Windows for free to all? ◄
► The new troubleshooter in Windows 11 and 12? ◄
► Can I use the mouse wheel forwarding tool on Windows 11? ◄


This website does not store personal data. However, third-party providers are used to display ads,
which are managed by Google and comply with the IAB Transparency and Consent Framework (IAB-TCF).
The CMP ID is 300 and can be individually customized at the bottom of the page.
more Infos & Privacy Policy

....