Shader abilities · Discussion #3817 · google/filament - GitHub
文章推薦指數: 80 %
If you break writing to gl_FragDepth I hope you will provide some ... a view-filling quad with a material that samples the depth texture.
Skiptocontent
{{message}}
google
/
filament
Public
Notifications
Fork
1.4k
Star
14k
Code
Issues
89
Pullrequests
3
Discussions
Actions
Projects
8
Wiki
Security
Insights
More
Code
Issues
Pullrequests
Discussions
Actions
Projects
Wiki
Security
Insights
Shaderabilities
#3817
Answered
by
romainguy
jwwalker
askedthisquestionin
Q&A
Shaderabilities
#3817
jwwalker
Apr16,2021
·
1answers
·
4replies
Answered
by
romainguy
Returntotop
jwwalker
Apr16,2021
Iunderstandthattheusualgoalofamaterialfragmentblockistocomputematerialproperties,butcanitdootherthingspermittedinOpenGLESfragmentshaders,suchasdiscardthefragmentorwritetothegl_FragDepthvariable?
1
Answeredby
romainguy
Apr16,2021
YoucandoanythingGLSLsupportbutwedon'tsupportwritingtogl_*variables.Meaningthatwemaybreakyourcodeinthefuturesincewemakenoguarantees(espaswewilleventuallymoveawayfromGLandfocusonVulkanandMetal).Theuseofdiscardisfullysupportedthough.
Viewfullanswer
Replies
1suggestedanswer
·
4replies
Oldest
Newest
Top
romainguy
Apr16,2021
Maintainer
YoucandoanythingGLSLsupportbutwedon'tsupportwritingtogl_*variables.Meaningthatwemaybreakyourcodeinthefuturesincewemakenoguarantees(espaswewilleventuallymoveawayfromGLandfocusonVulkanandMetal).Theuseofdiscardisfullysupportedthough.
Markedasanswer
1
👍
1
4replies
jwwalker
Apr21,2021
Author
Ifyoubreakwritingtogl_FragDepthIhopeyouwillprovidesomealternatewayofmodifyingthedepthofthecurrentfragment.
romainguy
Apr21,2021
Maintainer
Whatareyoudoingwiththisbtw?Modifyinggl_FragDepthisneverrecommended(forperformancereasons).
jwwalker
Apr21,2021
Author
WhatI'mtryingtodoisdrawacoloredoutlinearoundaselectedobject,andIwantpointsoftheoutlinetohavethesamedepthasnearbypointsoftheobject.Here'sasimpleexample:
InanoldOpenGLprogram,Ididthatbyamethodthatdrewtheobjectinedgemodewithlinethicknessandusingthestencilbuffertomaskouttheobjectbeingoutlined.ButinFilamentthereisnoedgemodeandnolinethicknesscontrol.MyattempttoproduceasimilareffectinFilamentinvolvesdrawingtheselectedobjectintoadepthtexture,thendrawingaview-fillingquadwithamaterialthatsamplesthedepthtexture.Ifthefragmentshaderdeterminesthatthecurrentfragmentisintheselectedobject,orfarawayfromit,itdiscardsthefragment.Ontheotherhand,ifmyfragmentshaderdeterminesthatthecurrentfragmentisnear,butnotin,theselectedobject,itneedstosetthefragmentdepthtothedepthsampledfromthedepthtexture,becausemybigquadisatthewrongdepth.
romainguy
Apr21,2021
Maintainer
Ahyeahthatmakesalotofsenseforthisusecase.
Answerselectedbyjwwalker
Signupforfree
tojointhisconversationonGitHub.
Alreadyhaveanaccount?
Signintocomment
Category
🙏
Q&A
Labels
Noneyet
2participants
Addheadingtext
Addboldtext,
延伸文章資訊
- 1computing gl_FragDepth - Game Development Stack Exchange
- 2gl_FragDepth - GLSL ES 3 - docs.gl
Available only in the fragment language, gl_FragDepth is an output variable that is used to estab...
- 3GLSL-to-HLSL 參考- UWP applications | Microsoft Docs
Sample [datatype.Function]. sampler2D [datatype], Texture2D [datatype] ... gl_FragDepth. 此變數為floa...
- 4Playing with gl_FragDepth - OpenGL - Khronos Forums
I continued with my last example. I have a lots of quads that they are always looking to the came...
- 5高级GLSL
如果着色器中没有像 gl_FragDepth 变量写入,它就会自动采用 gl_FragCoord.z 的值。 我们自己设置深度值有一个显著缺点,因为只要我们在片段着色器中对 gl_FragDep...