Format files to remove trailing spaces (#3384)

This commit is contained in:
Aaron Franke
2024-12-09 22:01:16 -08:00
committed by GitHub
parent 042ebe8814
commit 40961806bd
101 changed files with 3729 additions and 3763 deletions

108
README.md
View File

@@ -120,8 +120,8 @@ https://github.com/andr3wmac/Torque6 - Torque 6 is an MIT licensed 3D engine
loosely based on Torque2D. Being neither Torque2D or Torque3D it is the 6th loosely based on Torque2D. Being neither Torque2D or Torque3D it is the 6th
derivative of the original Torque Engine. derivative of the original Torque Engine.
<a href="http://www.youtube.com/watch?feature=player_embedded&v=p4LTM_QGK34" <a href="http://www.youtube.com/watch?feature=player_embedded&v=p4LTM_QGK34"
target="_blank"><img src="http://img.youtube.com/vi/p4LTM_QGK34/0.jpg" target="_blank"><img src="http://img.youtube.com/vi/p4LTM_QGK34/0.jpg"
alt="Torque 6 Material Editor" width="640" height="480" border="0" /></a> alt="Torque 6 Material Editor" width="640" height="480" border="0" /></a>
## Kepler Orbits ## Kepler Orbits
@@ -148,7 +148,7 @@ C++ and using bgfx to support multiple rendering APIs.
http://makingartstudios.itch.io/dls - DLS, the digital logic simulator game. http://makingartstudios.itch.io/dls - DLS, the digital logic simulator game.
<a href="http://www.youtube.com/watch?feature=player_embedded&v=6o1-sQRNqcA <a href="http://www.youtube.com/watch?feature=player_embedded&v=6o1-sQRNqcA
" target="_blank"><img src="http://img.youtube.com/vi/6o1-sQRNqcA/0.jpg" " target="_blank"><img src="http://img.youtube.com/vi/6o1-sQRNqcA/0.jpg"
alt="DLS - Creating a 4-bit Register " alt="DLS - Creating a 4-bit Register "
width="640" height="480" border="0" /></a> width="640" height="480" border="0" /></a>
@@ -168,8 +168,8 @@ https://blackshift.itch.io/blackshift - Blackshift is a grid-based, space-themed
action puzzle game which isn't afraid of complexity - think Chip's Challenge on action puzzle game which isn't afraid of complexity - think Chip's Challenge on
crack. crack.
<a href="http://www.youtube.com/watch?feature=player_embedded&v=PUl8612Y-ds" <a href="http://www.youtube.com/watch?feature=player_embedded&v=PUl8612Y-ds"
target="_blank"><img src="http://img.youtube.com/vi/PUl8612Y-ds/0.jpg" target="_blank"><img src="http://img.youtube.com/vi/PUl8612Y-ds/0.jpg"
alt="Blackshift Trailer, May 2016" alt="Blackshift Trailer, May 2016"
width="640" height="480" border="0" /></a> width="640" height="480" border="0" /></a>
@@ -179,8 +179,8 @@ https://eheitzresearch.wordpress.com/415-2/ - Real-Time Polygonal-Light Shading
with Linearly Transformed Cosines, Eric Heitz, Jonathan Dupuy, Stephen Hill and with Linearly Transformed Cosines, Eric Heitz, Jonathan Dupuy, Stephen Hill and
David Neubelt, ACM SIGGRAPH 2016. David Neubelt, ACM SIGGRAPH 2016.
<a href="http://www.youtube.com/watch?feature=player_embedded&v=ZLRgEN7AQgM" <a href="http://www.youtube.com/watch?feature=player_embedded&v=ZLRgEN7AQgM"
target="_blank"><img src="http://img.youtube.com/vi/ZLRgEN7AQgM/0.jpg" target="_blank"><img src="http://img.youtube.com/vi/ZLRgEN7AQgM/0.jpg"
alt="Real-Time Polygonal-Light Shading with Linearly Transformed Cosines" alt="Real-Time Polygonal-Light Shading with Linearly Transformed Cosines"
width="640" height="480" border="0" /></a> width="640" height="480" border="0" /></a>
@@ -190,8 +190,8 @@ http://www.dogbytegames.com/dead_venture.html - Dead Venture is a new Drive 'N
Gun game where you help a handful of survivals reach the safe haven: a military Gun game where you help a handful of survivals reach the safe haven: a military
base on a far island. base on a far island.
<a href="http://www.youtube.com/watch?feature=player_embedded&v=CgMr1g12yXw" <a href="http://www.youtube.com/watch?feature=player_embedded&v=CgMr1g12yXw"
target="_blank"><img src="http://img.youtube.com/vi/CgMr1g12yXw/0.jpg" target="_blank"><img src="http://img.youtube.com/vi/CgMr1g12yXw/0.jpg"
alt="Dead Venture - Gameplay Teaser (iOS / Android)" alt="Dead Venture - Gameplay Teaser (iOS / Android)"
width="640" height="480" border="0" /></a> width="640" height="480" border="0" /></a>
@@ -201,7 +201,7 @@ https://github.com/degenerated1123/REGoth - REGoth is an open-source
reimplementation of the zEngine, used by the game "Gothic" and "Gothic II". reimplementation of the zEngine, used by the game "Gothic" and "Gothic II".
<a href="http://www.youtube.com/watch?feature=player_embedded&v=8bLAGttYYpY <a href="http://www.youtube.com/watch?feature=player_embedded&v=8bLAGttYYpY
" target="_blank"><img src="http://img.youtube.com/vi/8bLAGttYYpY/0.jpg" " target="_blank"><img src="http://img.youtube.com/vi/8bLAGttYYpY/0.jpg"
alt="REGoth Engine" alt="REGoth Engine"
width="640" height="480" border="0" /></a> width="640" height="480" border="0" /></a>
@@ -217,8 +217,8 @@ and WYSIWYG editor.
http://gorallygame.com/ - Go Rally is top-down rally game with a career mode, http://gorallygame.com/ - Go Rally is top-down rally game with a career mode,
multiplayer time challenges, and a track creator. multiplayer time challenges, and a track creator.
<a href="http://www.youtube.com/watch?feature=player_embedded&v=ckbkQsB6RVY" <a href="http://www.youtube.com/watch?feature=player_embedded&v=ckbkQsB6RVY"
target="_blank"><img src="http://img.youtube.com/vi/ckbkQsB6RVY/0.jpg" target="_blank"><img src="http://img.youtube.com/vi/ckbkQsB6RVY/0.jpg"
alt="Go Rally" alt="Go Rally"
width="640" height="480" border="0" /></a> width="640" height="480" border="0" /></a>
@@ -237,8 +237,8 @@ open-world offroad driving game: explore massive landscapes, complete
challenges, smash zombies, find secret locations, unlock and upgrade cars and challenges, smash zombies, find secret locations, unlock and upgrade cars and
weapons, it's up to you! weapons, it's up to you!
<a href="http://www.youtube.com/watch?feature=player_embedded&v=LSiH0lRkw8g" <a href="http://www.youtube.com/watch?feature=player_embedded&v=LSiH0lRkw8g"
target="_blank"><img src="http://img.youtube.com/vi/LSiH0lRkw8g/0.jpg" target="_blank"><img src="http://img.youtube.com/vi/LSiH0lRkw8g/0.jpg"
alt="Zombie Safari - Official Gameplay Trailer (Android)" alt="Zombie Safari - Official Gameplay Trailer (Android)"
width="640" height="480" border="0" /></a> width="640" height="480" border="0" /></a>
@@ -249,8 +249,8 @@ shooter for PC, PS4 & XBoxOne arriving in late 2018. Smith and Winston features
a massively destructible voxel world, rapid twin stick combat, physics puzzles a massively destructible voxel world, rapid twin stick combat, physics puzzles
and Metroid-style discovery. and Metroid-style discovery.
<a href="http://www.youtube.com/watch?feature=player_embedded&v=Mr_L7KuiByU" <a href="http://www.youtube.com/watch?feature=player_embedded&v=Mr_L7KuiByU"
target="_blank"><img src="http://img.youtube.com/vi/Mr_L7KuiByU/0.jpg" target="_blank"><img src="http://img.youtube.com/vi/Mr_L7KuiByU/0.jpg"
alt="Smith and Winston: Gameplay Video" alt="Smith and Winston: Gameplay Video"
width="640" height="480" border="0" /></a> width="640" height="480" border="0" /></a>
@@ -260,8 +260,8 @@ http://www.footballmanager.com/ - Football Manager 2018 is a 2017 football
management simulation video game developed by Sports Interactive and published management simulation video game developed by Sports Interactive and published
by Sega. by Sega.
<a href="http://www.youtube.com/watch?feature=player_embedded&v=1Woak1Bl_KI" <a href="http://www.youtube.com/watch?feature=player_embedded&v=1Woak1Bl_KI"
target="_blank"><img src="http://img.youtube.com/vi/1Woak1Bl_KI/0.jpg" target="_blank"><img src="http://img.youtube.com/vi/1Woak1Bl_KI/0.jpg"
alt="Match Engine | Football Manager 2018" alt="Match Engine | Football Manager 2018"
width="640" height="480" border="0" /></a> width="640" height="480" border="0" /></a>
@@ -271,8 +271,8 @@ http://wonderworlds.me/ - WonderWorlds is a place to play thousands of
user-created levels and stories, make your own using the extensive in-game tools user-created levels and stories, make your own using the extensive in-game tools
and share them with whomever you want. and share them with whomever you want.
<a href="http://www.youtube.com/watch?feature=player_embedded&v=nY8y_dFolKo" <a href="http://www.youtube.com/watch?feature=player_embedded&v=nY8y_dFolKo"
target="_blank"><img src="http://img.youtube.com/vi/nY8y_dFolKo/0.jpg" target="_blank"><img src="http://img.youtube.com/vi/nY8y_dFolKo/0.jpg"
alt="WonderWorlds" alt="WonderWorlds"
width="640" height="480" border="0" /></a> width="640" height="480" border="0" /></a>
@@ -288,8 +288,8 @@ focused towards live graphical apps and games.
https://outfit7.com/apps/talking-tom-pool/ - A "sling and match" puzzle game for https://outfit7.com/apps/talking-tom-pool/ - A "sling and match" puzzle game for
mobile devices. mobile devices.
<a href="http://www.youtube.com/watch?feature=player_embedded&v=eNSI45zDEo0" <a href="http://www.youtube.com/watch?feature=player_embedded&v=eNSI45zDEo0"
target="_blank"><img src="http://img.youtube.com/vi/eNSI45zDEo0/0.jpg" target="_blank"><img src="http://img.youtube.com/vi/eNSI45zDEo0/0.jpg"
alt="Talking Tom Pool" alt="Talking Tom Pool"
width="640" height="480" border="0" /></a> width="640" height="480" border="0" /></a>
@@ -306,8 +306,8 @@ engine v3.0.
http://www.dogbytegames.com/off_the_road.html - A sandbox off-road driving http://www.dogbytegames.com/off_the_road.html - A sandbox off-road driving
simulator. simulator.
<a href="http://www.youtube.com/watch?feature=player_embedded&v=RgnIReFkbyU" <a href="http://www.youtube.com/watch?feature=player_embedded&v=RgnIReFkbyU"
target="_blank"><img src="http://img.youtube.com/vi/RgnIReFkbyU/hq720.jpg" target="_blank"><img src="http://img.youtube.com/vi/RgnIReFkbyU/hq720.jpg"
alt="Off The Road" alt="Off The Road"
width="640" height="360" border="0" /></a> width="640" height="360" border="0" /></a>
@@ -321,8 +321,8 @@ https://beardsvibe.com/ - A multiplayer PVP rhythm game.
https://outfit7.com/apps/my-talking-tom-2/ - Many mini games for mobile devices. https://outfit7.com/apps/my-talking-tom-2/ - Many mini games for mobile devices.
<a href="http://www.youtube.com/watch?feature=player_embedded&v=I0U7EQKKDjw" <a href="http://www.youtube.com/watch?feature=player_embedded&v=I0U7EQKKDjw"
target="_blank"><img src="http://img.youtube.com/vi/I0U7EQKKDjw/0.jpg" target="_blank"><img src="http://img.youtube.com/vi/I0U7EQKKDjw/0.jpg"
alt="My Talking Tom 2" alt="My Talking Tom 2"
width="640" height="480" border="0" /></a> width="640" height="480" border="0" /></a>
@@ -346,8 +346,8 @@ Hammerwatch. Encounter endless hordes of enemies, traps, puzzles, secrets and
lots of loot, as you battle your way through procedurally generated levels to lots of loot, as you battle your way through procedurally generated levels to
reach the top of the Forsaken Spire. reach the top of the Forsaken Spire.
<a href="http://www.youtube.com/watch?feature=player_embedded&v=uTIVDKdNvms" <a href="http://www.youtube.com/watch?feature=player_embedded&v=uTIVDKdNvms"
target="_blank"><img src="http://img.youtube.com/vi/uTIVDKdNvms/0.jpg" target="_blank"><img src="http://img.youtube.com/vi/uTIVDKdNvms/0.jpg"
alt="Heroes of Hammerwatch" alt="Heroes of Hammerwatch"
width="640" height="480" border="0" /></a> width="640" height="480" border="0" /></a>
@@ -365,8 +365,8 @@ SIGGRAPH 2019: Project Nira: Instant Interactive Real-Time Access to
Multi-Gigabyte Sized 3D Assets on Any Device: Multi-Gigabyte Sized 3D Assets on Any Device:
https://s2019.siggraph.org/presentation/?sess=sess104&id=real_130#038;id=real_130 https://s2019.siggraph.org/presentation/?sess=sess104&id=real_130#038;id=real_130
<a href="http://www.youtube.com/watch?feature=player_embedded&v=Gz9weuemhDA&t=3350" <a href="http://www.youtube.com/watch?feature=player_embedded&v=Gz9weuemhDA&t=3350"
target="_blank"><img src="http://img.youtube.com/vi/Gz9weuemhDA/0.jpg" target="_blank"><img src="http://img.youtube.com/vi/Gz9weuemhDA/0.jpg"
alt="Heroes of Hammerwatch" alt="Heroes of Hammerwatch"
width="640" height="480" border="0" /></a> width="640" height="480" border="0" /></a>
@@ -468,8 +468,8 @@ vehicle you bet you can hop into it! Pilot big rigs, helicopters, boats,
airplanes or even trains. Sand dunes, frozen plains, mountains to climb and airplanes or even trains. Sand dunes, frozen plains, mountains to climb and
conquer. conquer.
<a href="http://www.youtube.com/watch?feature=player_embedded&v=cwDR0Wj3LO4" <a href="http://www.youtube.com/watch?feature=player_embedded&v=cwDR0Wj3LO4"
target="_blank"><img src="http://img.youtube.com/vi/cwDR0Wj3LO4/0.jpg" target="_blank"><img src="http://img.youtube.com/vi/cwDR0Wj3LO4/0.jpg"
alt="Off The Road Unleashed" alt="Off The Road Unleashed"
width="640" height="480" border="0" /></a> width="640" height="480" border="0" /></a>
@@ -488,8 +488,8 @@ https://klei.com/games/griftlands - Griftlands is a roguelike deck-building game
with role-playing story elements in a science fiction setting, developed and with role-playing story elements in a science fiction setting, developed and
published by Klei Entertainment. published by Klei Entertainment.
<a href="http://www.youtube.com/watch?feature=player_embedded&v=ufl14_Ne5Lg" <a href="http://www.youtube.com/watch?feature=player_embedded&v=ufl14_Ne5Lg"
target="_blank"><img src="http://img.youtube.com/vi/ufl14_Ne5Lg/0.jpg" target="_blank"><img src="http://img.youtube.com/vi/ufl14_Ne5Lg/0.jpg"
alt="Griftlands" alt="Griftlands"
width="640" height="480" border="0" /></a> width="640" height="480" border="0" /></a>
@@ -508,8 +508,8 @@ Evoke 2022 demoparty.
https://github.com/astrofra/demo-marine-melodies https://github.com/astrofra/demo-marine-melodies
<a href="http://www.youtube.com/watch?feature=player_embedded&v=Ma1-UBa3f2E" <a href="http://www.youtube.com/watch?feature=player_embedded&v=Ma1-UBa3f2E"
target="_blank"><img src="http://img.youtube.com/vi/Ma1-UBa3f2E/0.jpg" target="_blank"><img src="http://img.youtube.com/vi/Ma1-UBa3f2E/0.jpg"
alt="Marine Melodies" alt="Marine Melodies"
width="640" height="480" border="0" /></a> width="640" height="480" border="0" /></a>
@@ -570,13 +570,13 @@ https://prototwin.com - Online industrial simulation software for manufacturing
## WARCANA ## WARCANA
WARCANA is a fantasy inspired base defence, RTS game with a deck-building mechanic. WARCANA is a fantasy inspired base defence, RTS game with a deck-building mechanic.
Face hundreds of thousands of unrelenting monsters in a battle royale between 30 other Face hundreds of thousands of unrelenting monsters in a battle royale between 30 other
mighty magicians. Build your deck. Prepare your defences. Summon your armies. mighty magicians. Build your deck. Prepare your defences. Summon your armies.
Survive the onslaught. Survive the onslaught.
<a href="http://www.youtube.com/watch?feature=player_embedded&v=UioR5ptCFYU" <a href="http://www.youtube.com/watch?feature=player_embedded&v=UioR5ptCFYU"
target="_blank"><img src="http://img.youtube.com/vi/UioR5ptCFYU/0.jpg" target="_blank"><img src="http://img.youtube.com/vi/UioR5ptCFYU/0.jpg"
alt="WARCANA Announcement Trailer" width="640" height="480" border="0" /></a> alt="WARCANA Announcement Trailer" width="640" height="480" border="0" /></a>
## DiskBoard ## DiskBoard
@@ -623,11 +623,11 @@ legacy Direct3D renderer with bgfx.
## Braid, Anniversary Edition ## Braid, Anniversary Edition
https://play.google.com/store/apps/details?id=com.netflix.NGP.BraidAnniversaryEdition - https://play.google.com/store/apps/details?id=com.netflix.NGP.BraidAnniversaryEdition -
bgfx is used only in Android version of the game. bgfx is used only in Android version of the game.
<a href="http://www.youtube.com/watch?feature=player_embedded&v=U738YZG1k1I" <a href="http://www.youtube.com/watch?feature=player_embedded&v=U738YZG1k1I"
target="_blank"><img src="http://img.youtube.com/vi/U738YZG1k1I/0.jpg" target="_blank"><img src="http://img.youtube.com/vi/U738YZG1k1I/0.jpg"
alt="Braid, Anniversary Edition" alt="Braid, Anniversary Edition"
width="640" height="480" border="0" /></a> width="640" height="480" border="0" /></a>
@@ -636,8 +636,8 @@ width="640" height="480" border="0" /></a>
https://store.steampowered.com/app/2015270/Rotwood/ - Rotwood is an upcoming https://store.steampowered.com/app/2015270/Rotwood/ - Rotwood is an upcoming
beat'em up, rogouelike video game developed and published by Klei Entertainment. beat'em up, rogouelike video game developed and published by Klei Entertainment.
<a href="http://www.youtube.com/watch?feature=player_embedded&v=SoTNhVPzmC8" <a href="http://www.youtube.com/watch?feature=player_embedded&v=SoTNhVPzmC8"
target="_blank"><img src="http://img.youtube.com/vi/SoTNhVPzmC8/0.jpg" target="_blank"><img src="http://img.youtube.com/vi/SoTNhVPzmC8/0.jpg"
alt="Rotwood" alt="Rotwood"
width="640" height="480" border="0" /></a> width="640" height="480" border="0" /></a>
@@ -653,12 +653,12 @@ Source: https://github.com/cubzh/cubzh
## World Of Goo 2 ## World Of Goo 2
https://store.epicgames.com/en-US/p/world-of-goo-2 - Build bridges, https://store.epicgames.com/en-US/p/world-of-goo-2 - Build bridges,
grow towers, terraform terrain, and fuel flying machines in grow towers, terraform terrain, and fuel flying machines in
the stunning followup to the multi-award winning World of Goo. the stunning followup to the multi-award winning World of Goo.
<a href="http://www.youtube.com/watch?feature=player_embedded&v=q3XVl53Ajsk" <a href="http://www.youtube.com/watch?feature=player_embedded&v=q3XVl53Ajsk"
target="_blank"><img src="http://img.youtube.com/vi/q3XVl53Ajsk/0.jpg" target="_blank"><img src="http://img.youtube.com/vi/q3XVl53Ajsk/0.jpg"
alt="World Of Goo 2" alt="World Of Goo 2"
width="640" height="480" border="0" /></a> width="640" height="480" border="0" /></a>
@@ -670,17 +670,17 @@ width="640" height="480" border="0" /></a>
</a> </a>
Copyright 2010-2024 Branimir Karadzic Copyright 2010-2024 Branimir Karadzic
Redistribution and use in source and binary forms, with or without modification, Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met: are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer. list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, 2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution. and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -3720,5 +3720,3 @@ pub inline fn blit(_id: ViewId, _dst: TextureHandle, _dstMip: u8, _dstX: u16, _d
return bgfx_blit(_id, _dst, _dstMip, _dstX, _dstY, _dstZ, _src, _srcMip, _srcX, _srcY, _srcZ, _width, _height, _depth); return bgfx_blit(_id, _dst, _dstMip, _dstX, _dstY, _dstZ, _src, _srcMip, _srcX, _srcY, _srcZ, _width, _height, _depth);
} }
extern fn bgfx_blit(_id: ViewId, _dst: TextureHandle, _dstMip: u8, _dstX: u16, _dstY: u16, _dstZ: u16, _src: TextureHandle, _srcMip: u8, _srcX: u16, _srcY: u16, _srcZ: u16, _width: u16, _height: u16, _depth: u16) void; extern fn bgfx_blit(_id: ViewId, _dst: TextureHandle, _dstMip: u8, _dstX: u16, _dstY: u16, _dstZ: u16, _src: TextureHandle, _srcMip: u8, _srcX: u16, _srcY: u16, _srcZ: u16, _width: u16, _height: u16, _depth: u16) void;

View File

@@ -689,7 +689,7 @@ Reference(s):
.. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/48-drawindirect/screenshot.png .. figure:: https://github.com/bkaradzic/bgfx/raw/master/examples/48-drawindirect/screenshot.png
:alt: example-48-drawindirect :alt: example-48-drawindirect
`49-hextile <https://github.com/bkaradzic/bgfx/tree/master/examples/49-hextile>`__ `49-hextile <https://github.com/bkaradzic/bgfx/tree/master/examples/49-hextile>`__
--------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------

View File

@@ -14,7 +14,7 @@ void main()
v_wpos = wpos; v_wpos = wpos;
gl_Position = mul(u_viewProj, vec4(wpos, 1.0) ); gl_Position = mul(u_viewProj, vec4(wpos, 1.0) );
vec4 normal = a_normal * 2.0 - 1.0; vec4 normal = a_normal * 2.0 - 1.0;
vec4 tangent = a_tangent * 2.0 - 1.0; vec4 tangent = a_tangent * 2.0 - 1.0;

View File

@@ -18,7 +18,7 @@ void main()
vec3 wpos = instMul(model, vec4(a_position, 1.0) ).xyz; vec3 wpos = instMul(model, vec4(a_position, 1.0) ).xyz;
gl_Position = mul(u_viewProj, vec4(wpos, 1.0) ); gl_Position = mul(u_viewProj, vec4(wpos, 1.0) );
vec4 normal = a_normal * 2.0 - 1.0; vec4 normal = a_normal * 2.0 - 1.0;
vec3 wnormal = instMul(model, vec4(normal.xyz, 0.0) ).xyz; vec3 wnormal = instMul(model, vec4(normal.xyz, 0.0) ).xyz;
@@ -33,7 +33,7 @@ void main()
v_wpos = wpos; v_wpos = wpos;
vec3 weyepos = mul(vec4(0.0, 0.0, 0.0, 1.0), u_view).xyz; vec3 weyepos = mul(vec4(0.0, 0.0, 0.0, 1.0), u_view).xyz;
v_view = instMul(weyepos - wpos, tbn); v_view = instMul(weyepos - wpos, tbn);
v_texcoord0 = a_texcoord0; v_texcoord0 = a_texcoord0;

View File

@@ -39,4 +39,3 @@ void main()
color.xyz = toLinear(color.xyz)*l; color.xyz = toLinear(color.xyz)*l;
gl_FragColor = toGamma(color); gl_FragColor = toGamma(color);
} }

View File

@@ -5,7 +5,7 @@ $input a_position
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "../common/common.sh" #include "../common/common.sh"
void main() void main()
{ {

View File

@@ -6,7 +6,7 @@ $output v_normal, v_view
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "../common/common.sh" #include "../common/common.sh"
void main() void main()
{ {

View File

@@ -6,7 +6,7 @@ $output v_texcoord0
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "../common/common.sh" #include "../common/common.sh"
void main() void main()
{ {

View File

@@ -6,7 +6,7 @@ $output v_texcoord0
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "../common/common.sh" #include "../common/common.sh"
void main() void main()
{ {

View File

@@ -6,7 +6,7 @@ $output v_normal, v_view, v_texcoord0
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "../common/common.sh" #include "../common/common.sh"
void main() void main()
{ {

View File

@@ -5,7 +5,7 @@
#include "../common/common.sh" #include "../common/common.sh"
uniform vec4 u_color; uniform vec4 u_color;
void main() void main()
{ {
gl_FragColor.xyz = u_color.xyz; gl_FragColor.xyz = u_color.xyz;

View File

@@ -11,7 +11,7 @@ vec4 stencilColor(float _k)
, float(abs(_k + 1.0) < 0.0001)/255.0 , float(abs(_k + 1.0) < 0.0001)/255.0
, float(abs(_k - 2.0) < 0.0001)/255.0 , float(abs(_k - 2.0) < 0.0001)/255.0
, float(abs(_k + 2.0) < 0.0001)/255.0 , float(abs(_k + 2.0) < 0.0001)/255.0
); );
} }
void main() void main()

View File

@@ -86,4 +86,3 @@ void main()
gl_FragColor.xyz = mix(u_fogColor, final, fogFactor); gl_FragColor.xyz = mix(u_fogColor, final, fogFactor);
gl_FragColor.w = 1.0; gl_FragColor.w = 1.0;
} }

View File

@@ -6,7 +6,7 @@ $output v_texcoord0
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "../common/common.sh" #include "../common/common.sh"
void main() void main()
{ {
@@ -14,4 +14,3 @@ void main()
v_texcoord0 = a_texcoord0; v_texcoord0 = a_texcoord0;
} }

View File

@@ -6,7 +6,7 @@ $output v_texcoord0
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "../common/common.sh" #include "../common/common.sh"
void main() void main()
{ {

View File

@@ -14,4 +14,3 @@ void main()
{ {
#include "fs_shadowmaps_color_lighting_main.sh" #include "fs_shadowmaps_color_lighting_main.sh"
} }

View File

@@ -15,4 +15,3 @@ void main()
{ {
#include "fs_shadowmaps_color_lighting_main.sh" #include "fs_shadowmaps_color_lighting_main.sh"
} }

View File

@@ -14,4 +14,3 @@ void main()
{ {
#include "fs_shadowmaps_color_lighting_main.sh" #include "fs_shadowmaps_color_lighting_main.sh"
} }

View File

@@ -14,4 +14,3 @@ void main()
{ {
#include "fs_shadowmaps_color_lighting_main.sh" #include "fs_shadowmaps_color_lighting_main.sh"
} }

View File

@@ -14,4 +14,3 @@ void main()
{ {
#include "fs_shadowmaps_color_lighting_main.sh" #include "fs_shadowmaps_color_lighting_main.sh"
} }

View File

@@ -14,4 +14,3 @@ void main()
{ {
#include "fs_shadowmaps_color_lighting_main.sh" #include "fs_shadowmaps_color_lighting_main.sh"
} }

View File

@@ -14,4 +14,3 @@ void main()
{ {
#include "fs_shadowmaps_color_lighting_main.sh" #include "fs_shadowmaps_color_lighting_main.sh"
} }

View File

@@ -14,4 +14,3 @@ void main()
{ {
#include "fs_shadowmaps_color_lighting_main.sh" #include "fs_shadowmaps_color_lighting_main.sh"
} }

View File

@@ -40,8 +40,8 @@ Revision 6 (2014-09-21)
Summary Summary
------- -------
Blendish is a small collection of drawing functions for NanoVG, designed to Blendish is a small collection of drawing functions for NanoVG, designed to
replicate the look of the Blender 2.5+ User Interface. You can use these replicate the look of the Blender 2.5+ User Interface. You can use these
functions to theme your UI library. Several metric constants for faithful functions to theme your UI library. Several metric constants for faithful
reproduction are also included. reproduction are also included.
@@ -50,7 +50,7 @@ icons is unclear, they are not included in Blendishes repository, but a SVG
template, "icons_template.svg" is provided, which you can use to build your own template, "icons_template.svg" is provided, which you can use to build your own
icon sheet. icon sheet.
To use icons, you must first load the icon sheet using one of the To use icons, you must first load the icon sheet using one of the
nvgCreateImage*() functions and then pass the image handle to bndSetIconImage(); nvgCreateImage*() functions and then pass the image handle to bndSetIconImage();
otherwise, no icons will be drawn. See bndSetIconImage() for more information. otherwise, no icons will be drawn. See bndSetIconImage() for more information.
@@ -81,7 +81,7 @@ before including blendish.h, otherwise the file will be in header-only mode.
#define BND_EXPORT #define BND_EXPORT
#endif #endif
// if that typedef is provided elsewhere, you may define // if that typedef is provided elsewhere, you may define
// BLENDISH_NO_NVG_TYPEDEFS before including the header. // BLENDISH_NO_NVG_TYPEDEFS before including the header.
#ifndef BLENDISH_NO_NVG_TYPEDEFS #ifndef BLENDISH_NO_NVG_TYPEDEFS
typedef struct NVGcontext NVGcontext; typedef struct NVGcontext NVGcontext;
@@ -119,14 +119,14 @@ typedef struct BNDnodeTheme {
NVGcolor wiresColor; NVGcolor wiresColor;
// color of text label when active // color of text label when active
NVGcolor textSelectedColor; NVGcolor textSelectedColor;
// inner color of active node (and dragged wire) // inner color of active node (and dragged wire)
NVGcolor activeNodeColor; NVGcolor activeNodeColor;
// color of selected wire // color of selected wire
NVGcolor wireSelectColor; NVGcolor wireSelectColor;
// color of background of node // color of background of node
NVGcolor nodeBackdropColor; NVGcolor nodeBackdropColor;
// how much a noodle curves (0 to 10) // how much a noodle curves (0 to 10)
int noodleCurving; int noodleCurving;
} BNDnodeTheme; } BNDnodeTheme;
@@ -192,7 +192,7 @@ typedef enum BNDcornerFlags {
BND_CORNER_DOWN_RIGHT = 4, BND_CORNER_DOWN_RIGHT = 4,
// sharp bottom left corner // sharp bottom left corner
BND_CORNER_DOWN_LEFT = 8, BND_CORNER_DOWN_LEFT = 8,
// all corners are sharp; // all corners are sharp;
// you can invert a set of flags using ^= BND_CORNER_ALL // you can invert a set of flags using ^= BND_CORNER_ALL
BND_CORNER_ALL = 0xF, BND_CORNER_ALL = 0xF,
// top border is sharp // top border is sharp
@@ -757,7 +757,7 @@ BND_EXPORT void bndSetTheme(BNDtheme theme);
BND_EXPORT const BNDtheme *bndGetTheme(); BND_EXPORT const BNDtheme *bndGetTheme();
// designates an image handle as returned by nvgCreateImage*() as the themes' // designates an image handle as returned by nvgCreateImage*() as the themes'
// icon sheet. The icon sheet format must be compatible to Blender 2.6's icon // icon sheet. The icon sheet format must be compatible to Blender 2.6's icon
// sheet; the order of icons does not matter. // sheet; the order of icons does not matter.
// A valid icon sheet is e.g. shown at // A valid icon sheet is e.g. shown at
// http://wiki.blender.org/index.php/Dev:2.5/Doc/How_to/Add_an_icon // http://wiki.blender.org/index.php/Dev:2.5/Doc/How_to/Add_an_icon
@@ -789,7 +789,7 @@ BND_EXPORT void bndLabel(NVGcontext *ctx,
// if label is not NULL, a label will be added to the widget // if label is not NULL, a label will be added to the widget
// widget looks best when height is BND_WIDGET_HEIGHT // widget looks best when height is BND_WIDGET_HEIGHT
BND_EXPORT void bndToolButton(NVGcontext *ctx, BND_EXPORT void bndToolButton(NVGcontext *ctx,
float x, float y, float w, float h, int flags, BNDwidgetState state, float x, float y, float w, float h, int flags, BNDwidgetState state,
int iconid, const char *label); int iconid, const char *label);
// Draw a radio button with its lower left origin at (x,y) and size of (w,h), // Draw a radio button with its lower left origin at (x,y) and size of (w,h),
@@ -799,9 +799,9 @@ BND_EXPORT void bndToolButton(NVGcontext *ctx,
// if label is not NULL, a label will be added to the widget // if label is not NULL, a label will be added to the widget
// widget looks best when height is BND_WIDGET_HEIGHT // widget looks best when height is BND_WIDGET_HEIGHT
BND_EXPORT void bndRadioButton(NVGcontext *ctx, BND_EXPORT void bndRadioButton(NVGcontext *ctx,
float x, float y, float w, float h, int flags, BNDwidgetState state, float x, float y, float w, float h, int flags, BNDwidgetState state,
int iconid, const char *label); int iconid, const char *label);
// Calculate the corresponding text position for given coordinates px/py // Calculate the corresponding text position for given coordinates px/py
// in a text field. // in a text field.
@@ -819,18 +819,18 @@ BND_EXPORT int bndTextFieldTextPosition(NVGcontext *ctx, float x, float y, float
// if cend < cbegin, then no caret will be drawn // if cend < cbegin, then no caret will be drawn
// widget looks best when height is BND_WIDGET_HEIGHT // widget looks best when height is BND_WIDGET_HEIGHT
BND_EXPORT void bndTextField(NVGcontext *ctx, BND_EXPORT void bndTextField(NVGcontext *ctx,
float x, float y, float w, float h, int flags, BNDwidgetState state, float x, float y, float w, float h, int flags, BNDwidgetState state,
int iconid, const char *text, int cbegin, int cend); int iconid, const char *text, int cbegin, int cend);
// Draw an option button with its lower left origin at (x,y) and size of (w,h), // Draw an option button with its lower left origin at (x,y) and size of (w,h),
// where flags is one or multiple flags from BNDcornerFlags and state denotes // where flags is one or multiple flags from BNDcornerFlags and state denotes
// the widgets current UI state. // the widgets current UI state.
// if label is not NULL, a label will be added to the widget // if label is not NULL, a label will be added to the widget
// widget looks best when height is BND_WIDGET_HEIGHT // widget looks best when height is BND_WIDGET_HEIGHT
BND_EXPORT void bndOptionButton(NVGcontext *ctx, BND_EXPORT void bndOptionButton(NVGcontext *ctx,
float x, float y, float w, float h, BNDwidgetState state, float x, float y, float w, float h, BNDwidgetState state,
const char *label); const char *label);
// Draw a choice button with its lower left origin at (x,y) and size of (w,h), // Draw a choice button with its lower left origin at (x,y) and size of (w,h),
// where flags is one or multiple flags from BNDcornerFlags and state denotes // where flags is one or multiple flags from BNDcornerFlags and state denotes
// the widgets current UI state. // the widgets current UI state.
@@ -838,9 +838,9 @@ BND_EXPORT void bndOptionButton(NVGcontext *ctx,
// if label is not NULL, a label will be added to the widget // if label is not NULL, a label will be added to the widget
// widget looks best when height is BND_WIDGET_HEIGHT // widget looks best when height is BND_WIDGET_HEIGHT
BND_EXPORT void bndChoiceButton(NVGcontext *ctx, BND_EXPORT void bndChoiceButton(NVGcontext *ctx,
float x, float y, float w, float h, int flags, BNDwidgetState state, float x, float y, float w, float h, int flags, BNDwidgetState state,
int iconid, const char *label); int iconid, const char *label);
// Draw a color button with its lower left origin at (x,y) and size of (w,h), // Draw a color button with its lower left origin at (x,y) and size of (w,h),
// where flags is one or multiple flags from BNDcornerFlags and state denotes // where flags is one or multiple flags from BNDcornerFlags and state denotes
// the widgets current UI state. // the widgets current UI state.
@@ -856,8 +856,8 @@ BND_EXPORT void bndColorButton(NVGcontext *ctx,
// a ":" separator // a ":" separator
// widget looks best when height is BND_WIDGET_HEIGHT // widget looks best when height is BND_WIDGET_HEIGHT
BND_EXPORT void bndNumberField(NVGcontext *ctx, BND_EXPORT void bndNumberField(NVGcontext *ctx,
float x, float y, float w, float h, int flags, BNDwidgetState state, float x, float y, float w, float h, int flags, BNDwidgetState state,
const char *label, const char *value); const char *label, const char *value);
// Draw slider control with its lower left origin at (x,y) and size of (w,h), // Draw slider control with its lower left origin at (x,y) and size of (w,h),
// where flags is one or multiple flags from BNDcornerFlags and state denotes // where flags is one or multiple flags from BNDcornerFlags and state denotes
@@ -868,7 +868,7 @@ BND_EXPORT void bndNumberField(NVGcontext *ctx,
// a ":" separator // a ":" separator
// widget looks best when height is BND_WIDGET_HEIGHT // widget looks best when height is BND_WIDGET_HEIGHT
BND_EXPORT void bndSlider(NVGcontext *ctx, BND_EXPORT void bndSlider(NVGcontext *ctx,
float x, float y, float w, float h, int flags, BNDwidgetState state, float x, float y, float w, float h, int flags, BNDwidgetState state,
float progress, const char *label, const char *value); float progress, const char *label, const char *value);
// Draw scrollbar with its lower left origin at (x,y) and size of (w,h), // Draw scrollbar with its lower left origin at (x,y) and size of (w,h),
@@ -878,9 +878,9 @@ BND_EXPORT void bndSlider(NVGcontext *ctx,
// horizontal widget looks best when height is BND_SCROLLBAR_HEIGHT, // horizontal widget looks best when height is BND_SCROLLBAR_HEIGHT,
// vertical looks best when width is BND_SCROLLBAR_WIDTH // vertical looks best when width is BND_SCROLLBAR_WIDTH
BND_EXPORT void bndScrollBar(NVGcontext *ctx, BND_EXPORT void bndScrollBar(NVGcontext *ctx,
float x, float y, float w, float h, BNDwidgetState state, float x, float y, float w, float h, BNDwidgetState state,
float offset, float size); float offset, float size);
// Draw a menu background with its lower left origin at (x,y) and size of (w,h), // Draw a menu background with its lower left origin at (x,y) and size of (w,h),
// where flags is one or multiple flags from BNDcornerFlags. // where flags is one or multiple flags from BNDcornerFlags.
BND_EXPORT void bndMenuBackground(NVGcontext *ctx, BND_EXPORT void bndMenuBackground(NVGcontext *ctx,
@@ -899,7 +899,7 @@ BND_EXPORT void bndMenuLabel(NVGcontext *ctx,
// if label is not NULL, a label will be added to the widget // if label is not NULL, a label will be added to the widget
// widget looks best when height is BND_WIDGET_HEIGHT // widget looks best when height is BND_WIDGET_HEIGHT
BND_EXPORT void bndMenuItem(NVGcontext *ctx, BND_EXPORT void bndMenuItem(NVGcontext *ctx,
float x, float y, float w, float h, BNDwidgetState state, float x, float y, float w, float h, BNDwidgetState state,
int iconid, const char *label); int iconid, const char *label);
// Draw a tooltip background with its lower left origin at (x,y) and size of (w,h) // Draw a tooltip background with its lower left origin at (x,y) and size of (w,h)
@@ -909,7 +909,7 @@ BND_EXPORT void bndTooltipBackground(NVGcontext *ctx, float x, float y, float w,
BND_EXPORT void bndNodePort(NVGcontext *ctx, float x, float y, BNDwidgetState state, BND_EXPORT void bndNodePort(NVGcontext *ctx, float x, float y, BNDwidgetState state,
NVGcolor color); NVGcolor color);
// Draw a node wire originating at (x0,y0) and floating to (x1,y1), with // Draw a node wire originating at (x0,y0) and floating to (x1,y1), with
// a colored gradient based on the states state0 and state1: // a colored gradient based on the states state0 and state1:
// BND_DEFAULT: default wire color // BND_DEFAULT: default wire color
// BND_HOVER: selected wire color // BND_HOVER: selected wire color
@@ -927,19 +927,19 @@ BND_EXPORT void bndColoredNodeWire(NVGcontext *ctx, float x0, float y0, float x1
BND_EXPORT void bndNodeBackground(NVGcontext *ctx, float x, float y, float w, float h, BND_EXPORT void bndNodeBackground(NVGcontext *ctx, float x, float y, float w, float h,
BNDwidgetState state, int iconid, const char *label, NVGcolor titleColor); BNDwidgetState state, int iconid, const char *label, NVGcolor titleColor);
// Draw a window with the upper right and lower left splitter widgets into // Draw a window with the upper right and lower left splitter widgets into
// the rectangle at origin (x,y) and size (w, h) // the rectangle at origin (x,y) and size (w, h)
BND_EXPORT void bndSplitterWidgets(NVGcontext *ctx, float x, float y, float w, float h); BND_EXPORT void bndSplitterWidgets(NVGcontext *ctx, float x, float y, float w, float h);
// Draw the join area overlay stencil into the rectangle // Draw the join area overlay stencil into the rectangle
// at origin (x,y) and size (w,h) // at origin (x,y) and size (w,h)
// vertical is 0 or 1 and designates the arrow orientation, // vertical is 0 or 1 and designates the arrow orientation,
// mirror is 0 or 1 and flips the arrow side // mirror is 0 or 1 and flips the arrow side
BND_EXPORT void bndJoinAreaOverlay(NVGcontext *ctx, float x, float y, float w, float h, BND_EXPORT void bndJoinAreaOverlay(NVGcontext *ctx, float x, float y, float w, float h,
int vertical, int mirror); int vertical, int mirror);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Estimator Functions // Estimator Functions
// ------------------- // -------------------
// Use these functions to estimate sizes for widgets with your NVGcontext. // Use these functions to estimate sizes for widgets with your NVGcontext.
@@ -971,12 +971,12 @@ BND_EXPORT NVGcolor bndOffsetColor(NVGcolor color, int delta);
BND_EXPORT void bndSelectCorners(float *radiuses, float r, int flags); BND_EXPORT void bndSelectCorners(float *radiuses, float r, int flags);
// computes the upper and lower gradient colors for the inner box from a widget // computes the upper and lower gradient colors for the inner box from a widget
// theme and the widgets state. If flipActive is set and the state is // theme and the widgets state. If flipActive is set and the state is
// BND_ACTIVE, the upper and lower colors will be swapped. // BND_ACTIVE, the upper and lower colors will be swapped.
BND_EXPORT void bndInnerColors(NVGcolor *shade_top, NVGcolor *shade_down, BND_EXPORT void bndInnerColors(NVGcolor *shade_top, NVGcolor *shade_down,
const BNDwidgetTheme *theme, BNDwidgetState state, int flipActive); const BNDwidgetTheme *theme, BNDwidgetState state, int flipActive);
// computes the text color for a widget label from a widget theme and the // computes the text color for a widget label from a widget theme and the
// widgets state. // widgets state.
BND_EXPORT NVGcolor bndTextColor(const BNDwidgetTheme *theme, BNDwidgetState state); BND_EXPORT NVGcolor bndTextColor(const BNDwidgetTheme *theme, BNDwidgetState state);
@@ -987,7 +987,7 @@ BND_EXPORT NVGcolor bndTextColor(const BNDwidgetTheme *theme, BNDwidgetState sta
BND_EXPORT void bndScrollHandleRect(float *x, float *y, float *w, float *h, BND_EXPORT void bndScrollHandleRect(float *x, float *y, float *w, float *h,
float offset, float size); float offset, float size);
// Add a rounded box path at position (x,y) with size (w,h) and a separate // Add a rounded box path at position (x,y) with size (w,h) and a separate
// radius for each corner listed in clockwise order, so that cr0 = top left, // radius for each corner listed in clockwise order, so that cr0 = top left,
// cr1 = top right, cr2 = bottom right, cr3 = bottom left; // cr1 = top right, cr2 = bottom right, cr3 = bottom left;
// this is a low level drawing function: the path must be stroked or filled // this is a low level drawing function: the path must be stroked or filled
@@ -1009,7 +1009,7 @@ BND_EXPORT void bndBevel(NVGcontext *ctx, float x, float y, float w, float h);
// corners of the rounded box. // corners of the rounded box.
BND_EXPORT void bndBevelInset(NVGcontext *ctx, float x, float y, float w, float h, BND_EXPORT void bndBevelInset(NVGcontext *ctx, float x, float y, float w, float h,
float cr2, float cr3); float cr2, float cr3);
// Draw an icon with (x,y) as its upper left coordinate; the iconid selects // Draw an icon with (x,y) as its upper left coordinate; the iconid selects
// the icon from the sheet; use the BND_ICONID macro to build icon IDs. // the icon from the sheet; use the BND_ICONID macro to build icon IDs.
BND_EXPORT void bndIcon(NVGcontext *ctx, float x, float y, int iconid); BND_EXPORT void bndIcon(NVGcontext *ctx, float x, float y, int iconid);
@@ -1020,7 +1020,7 @@ BND_EXPORT void bndIcon(NVGcontext *ctx, float x, float y, int iconid);
BND_EXPORT void bndDropShadow(NVGcontext *ctx, float x, float y, float w, float h, BND_EXPORT void bndDropShadow(NVGcontext *ctx, float x, float y, float w, float h,
float r, float feather, float alpha); float r, float feather, float alpha);
// Draw the inner part of a widget box, with a gradient from shade_top to // Draw the inner part of a widget box, with a gradient from shade_top to
// shade_down. If h>w, the gradient will be horizontal instead of // shade_down. If h>w, the gradient will be horizontal instead of
// vertical. // vertical.
BND_EXPORT void bndInnerBox(NVGcontext *ctx, float x, float y, float w, float h, BND_EXPORT void bndInnerBox(NVGcontext *ctx, float x, float y, float w, float h,
@@ -1040,7 +1040,7 @@ BND_EXPORT void bndOutlineBox(NVGcontext *ctx, float x, float y, float w, float
// if value is not NULL, label and value will be drawn with a ":" separator // if value is not NULL, label and value will be drawn with a ":" separator
// inbetween. // inbetween.
BND_EXPORT void bndIconLabelValue(NVGcontext *ctx, float x, float y, float w, float h, BND_EXPORT void bndIconLabelValue(NVGcontext *ctx, float x, float y, float w, float h,
int iconid, NVGcolor color, int align, float fontsize, const char *label, int iconid, NVGcolor color, int align, float fontsize, const char *label,
const char *value); const char *value);
// Draw an optional icon specified by <iconid> and an optional label with // Draw an optional icon specified by <iconid> and an optional label with
@@ -1049,7 +1049,7 @@ BND_EXPORT void bndIconLabelValue(NVGcontext *ctx, float x, float y, float w, fl
// if label is not NULL, it will be drawn with the specified alignment, fontsize // if label is not NULL, it will be drawn with the specified alignment, fontsize
// and color. // and color.
BND_EXPORT void bndNodeIconLabel(NVGcontext *ctx, float x, float y, float w, float h, BND_EXPORT void bndNodeIconLabel(NVGcontext *ctx, float x, float y, float w, float h,
int iconid, NVGcolor color, NVGcolor shadowColor, int align, int iconid, NVGcolor color, NVGcolor shadowColor, int align,
float fontsize, const char *label); float fontsize, const char *label);
// Calculate the corresponding text position for given coordinates px/py // Calculate the corresponding text position for given coordinates px/py
@@ -1057,8 +1057,8 @@ BND_EXPORT void bndNodeIconLabel(NVGcontext *ctx, float x, float y, float w, flo
// See bndIconLabelCaret for more info. // See bndIconLabelCaret for more info.
BND_EXPORT int bndIconLabelTextPosition(NVGcontext *ctx, float x, float y, float w, float h, BND_EXPORT int bndIconLabelTextPosition(NVGcontext *ctx, float x, float y, float w, float h,
int iconid, float fontsize, const char *label, int px, int py); int iconid, float fontsize, const char *label, int px, int py);
// Draw an optional icon specified by <iconid>, an optional label and // Draw an optional icon specified by <iconid>, an optional label and
// a caret with given fontsize and color within a widget box. // a caret with given fontsize and color within a widget box.
// if iconid is >= 0, an icon will be drawn and the labels remaining space // if iconid is >= 0, an icon will be drawn and the labels remaining space
// will be adjusted. // will be adjusted.
@@ -1068,9 +1068,9 @@ BND_EXPORT int bndIconLabelTextPosition(NVGcontext *ctx, float x, float y, float
// cend must be >= cbegin and <= strlen(text) and denotes the end of the caret // cend must be >= cbegin and <= strlen(text) and denotes the end of the caret
// if cend < cbegin, then no caret will be drawn // if cend < cbegin, then no caret will be drawn
BND_EXPORT void bndIconLabelCaret(NVGcontext *ctx, float x, float y, float w, float h, BND_EXPORT void bndIconLabelCaret(NVGcontext *ctx, float x, float y, float w, float h,
int iconid, NVGcolor color, float fontsize, const char *label, int iconid, NVGcolor color, float fontsize, const char *label,
NVGcolor caretcolor, int cbegin, int cend); NVGcolor caretcolor, int cbegin, int cend);
// Draw a checkmark for an option box with the given upper left coordinates // Draw a checkmark for an option box with the given upper left coordinates
// (ox,oy) with the specified color. // (ox,oy) with the specified color.
BND_EXPORT void bndCheck(NVGcontext *ctx, float ox, float oy, NVGcolor color); BND_EXPORT void bndCheck(NVGcontext *ctx, float ox, float oy, NVGcolor color);
@@ -1086,7 +1086,7 @@ BND_EXPORT void bndUpDownArrow(NVGcontext *ctx, float x, float y, float s, NVGco
BND_EXPORT void bndNodeArrowDown(NVGcontext *ctx, float x, float y, float s, NVGcolor color); BND_EXPORT void bndNodeArrowDown(NVGcontext *ctx, float x, float y, float s, NVGcolor color);
// return the color of a node wire based on state // return the color of a node wire based on state
// BND_HOVER indicates selected state, // BND_HOVER indicates selected state,
// BND_ACTIVE indicates dragged state // BND_ACTIVE indicates dragged state
BND_EXPORT NVGcolor bndNodeWireColor(const BNDnodeTheme *theme, BNDwidgetState state); BND_EXPORT NVGcolor bndNodeWireColor(const BNDnodeTheme *theme, BNDwidgetState state);
@@ -1258,10 +1258,10 @@ static BNDtheme bnd_theme = {
{{{ 0.6,0.6,0.6,1 }}}, // color_inner {{{ 0.6,0.6,0.6,1 }}}, // color_inner
{{{ 0.392,0.392,0.392,1 }}}, // color_inner_selected {{{ 0.392,0.392,0.392,1 }}}, // color_inner_selected
BND_COLOR_TEXT, // color_text BND_COLOR_TEXT, // color_text
BND_COLOR_TEXT_SELECTED, // color_text_selected BND_COLOR_TEXT_SELECTED, // color_text_selected
0, // shade_top 0, // shade_top
0, // shade_down 0, // shade_down
}, },
// toolTheme // toolTheme
{ {
{{{ 0.098,0.098,0.098,1 }}}, // color_outline {{{ 0.098,0.098,0.098,1 }}}, // color_outline
@@ -1269,7 +1269,7 @@ static BNDtheme bnd_theme = {
{{{ 0.6,0.6,0.6,1 }}}, // color_inner {{{ 0.6,0.6,0.6,1 }}}, // color_inner
{{{ 0.392,0.392,0.392,1 }}}, // color_inner_selected {{{ 0.392,0.392,0.392,1 }}}, // color_inner_selected
BND_COLOR_TEXT, // color_text BND_COLOR_TEXT, // color_text
BND_COLOR_TEXT_SELECTED, // color_text_selected BND_COLOR_TEXT_SELECTED, // color_text_selected
15, // shade_top 15, // shade_top
-15, // shade_down -15, // shade_down
}, },
@@ -1280,7 +1280,7 @@ static BNDtheme bnd_theme = {
{{{ 0.275,0.275,0.275,1 }}}, // color_inner {{{ 0.275,0.275,0.275,1 }}}, // color_inner
{{{ 0.337,0.502,0.761,1 }}}, // color_inner_selected {{{ 0.337,0.502,0.761,1 }}}, // color_inner_selected
BND_COLOR_TEXT_SELECTED, // color_text BND_COLOR_TEXT_SELECTED, // color_text
BND_COLOR_TEXT, // color_text_selected BND_COLOR_TEXT, // color_text_selected
15, // shade_top 15, // shade_top
-15, // shade_down -15, // shade_down
}, },
@@ -1291,7 +1291,7 @@ static BNDtheme bnd_theme = {
{{{ 0.6, 0.6, 0.6,1 }}}, // color_inner {{{ 0.6, 0.6, 0.6,1 }}}, // color_inner
{{{ 0.6, 0.6, 0.6,1 }}}, // color_inner_selected {{{ 0.6, 0.6, 0.6,1 }}}, // color_inner_selected
BND_COLOR_TEXT, // color_text BND_COLOR_TEXT, // color_text
BND_COLOR_TEXT_SELECTED, // color_text_selected BND_COLOR_TEXT_SELECTED, // color_text_selected
0, // shade_top 0, // shade_top
25, // shade_down 25, // shade_down
}, },
@@ -1302,7 +1302,7 @@ static BNDtheme bnd_theme = {
{{{ 0.275,0.275,0.275,1 }}}, // color_inner {{{ 0.275,0.275,0.275,1 }}}, // color_inner
{{{ 0.275,0.275,0.275,1 }}}, // color_inner_selected {{{ 0.275,0.275,0.275,1 }}}, // color_inner_selected
BND_COLOR_TEXT, // color_text BND_COLOR_TEXT, // color_text
BND_COLOR_TEXT_SELECTED, // color_text_selected BND_COLOR_TEXT_SELECTED, // color_text_selected
15, // shade_top 15, // shade_top
-15, // shade_down -15, // shade_down
}, },
@@ -1313,7 +1313,7 @@ static BNDtheme bnd_theme = {
{{{ 0.275,0.275,0.275,1 }}}, // color_inner {{{ 0.275,0.275,0.275,1 }}}, // color_inner
{{{ 0.275,0.275,0.275,1 }}}, // color_inner_selected {{{ 0.275,0.275,0.275,1 }}}, // color_inner_selected
BND_COLOR_TEXT_SELECTED, // color_text BND_COLOR_TEXT_SELECTED, // color_text
{{{ 0.8,0.8,0.8,1 }}}, // color_text_selected {{{ 0.8,0.8,0.8,1 }}}, // color_text_selected
15, // shade_top 15, // shade_top
-15, // shade_down -15, // shade_down
}, },
@@ -1324,7 +1324,7 @@ static BNDtheme bnd_theme = {
{{{ 0.706, 0.706, 0.706,1 }}}, // color_inner {{{ 0.706, 0.706, 0.706,1 }}}, // color_inner
{{{ 0.6, 0.6, 0.6,1 }}}, // color_inner_selected {{{ 0.6, 0.6, 0.6,1 }}}, // color_inner_selected
BND_COLOR_TEXT, // color_text BND_COLOR_TEXT, // color_text
BND_COLOR_TEXT_SELECTED, // color_text_selected BND_COLOR_TEXT_SELECTED, // color_text_selected
-20, // shade_top -20, // shade_top
0, // shade_down 0, // shade_down
}, },
@@ -1335,7 +1335,7 @@ static BNDtheme bnd_theme = {
{{{ 0.706, 0.706, 0.706,1 }}}, // color_inner {{{ 0.706, 0.706, 0.706,1 }}}, // color_inner
{{{ 0.6, 0.6, 0.6,1 }}}, // color_inner_selected {{{ 0.6, 0.6, 0.6,1 }}}, // color_inner_selected
BND_COLOR_TEXT, // color_text BND_COLOR_TEXT, // color_text
BND_COLOR_TEXT_SELECTED, // color_text_selected BND_COLOR_TEXT_SELECTED, // color_text_selected
-20, // shade_top -20, // shade_top
0, // shade_down 0, // shade_down
}, },
@@ -1346,7 +1346,7 @@ static BNDtheme bnd_theme = {
{{{ 0.314, 0.314, 0.314,0.706 }}}, // color_inner {{{ 0.314, 0.314, 0.314,0.706 }}}, // color_inner
{{{ 0.392, 0.392, 0.392,0.706 }}}, // color_inner_selected {{{ 0.392, 0.392, 0.392,0.706 }}}, // color_inner_selected
BND_COLOR_TEXT, // color_text BND_COLOR_TEXT, // color_text
BND_COLOR_TEXT_SELECTED, // color_text_selected BND_COLOR_TEXT_SELECTED, // color_text_selected
5, // shade_top 5, // shade_top
-5, // shade_down -5, // shade_down
}, },
@@ -1357,7 +1357,7 @@ static BNDtheme bnd_theme = {
{{{ 0.098, 0.098, 0.098, 0.902 }}}, // color_inner {{{ 0.098, 0.098, 0.098, 0.902 }}}, // color_inner
{{{ 0.176, 0.176, 0.176, 0.902 }}}, // color_inner_selected {{{ 0.176, 0.176, 0.176, 0.902 }}}, // color_inner_selected
{{{ 0.627, 0.627, 0.627, 1 }}}, // color_text {{{ 0.627, 0.627, 0.627, 1 }}}, // color_text
BND_COLOR_TEXT_SELECTED, // color_text_selected BND_COLOR_TEXT_SELECTED, // color_text_selected
0, // shade_top 0, // shade_top
0, // shade_down 0, // shade_down
}, },
@@ -1368,7 +1368,7 @@ static BNDtheme bnd_theme = {
{{{ 0.098, 0.098, 0.098, 0.902 }}}, // color_inner {{{ 0.098, 0.098, 0.098, 0.902 }}}, // color_inner
{{{ 0.176, 0.176, 0.176, 0.902 }}}, // color_inner_selected {{{ 0.176, 0.176, 0.176, 0.902 }}}, // color_inner_selected
{{{ 0.627, 0.627, 0.627, 1 }}}, // color_text {{{ 0.627, 0.627, 0.627, 1 }}}, // color_text
BND_COLOR_TEXT_SELECTED, // color_text_selected BND_COLOR_TEXT_SELECTED, // color_text_selected
0, // shade_top 0, // shade_top
0, // shade_down 0, // shade_down
}, },
@@ -1379,7 +1379,7 @@ static BNDtheme bnd_theme = {
{{{ 0,0,0,0 }}}, // color_inner {{{ 0,0,0,0 }}}, // color_inner
{{{ 0.337,0.502,0.761,1 }}}, // color_inner_selected {{{ 0.337,0.502,0.761,1 }}}, // color_inner_selected
BND_COLOR_TEXT_SELECTED, // color_text BND_COLOR_TEXT_SELECTED, // color_text
BND_COLOR_TEXT, // color_text_selected BND_COLOR_TEXT, // color_text_selected
38, // shade_top 38, // shade_top
0, // shade_down 0, // shade_down
}, },
@@ -1421,21 +1421,21 @@ void bndSetFont(int font) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void bndLabel(NVGcontext *ctx, void bndLabel(NVGcontext *ctx,
float x, float y, float w, float h, int iconid, const char *label) { float x, float y, float w, float h, int iconid, const char *label) {
bndIconLabelValue(ctx,x,y,w,h,iconid, bndIconLabelValue(ctx,x,y,w,h,iconid,
bnd_theme.regularTheme.textColor, BND_LEFT, bnd_theme.regularTheme.textColor, BND_LEFT,
BND_LABEL_FONT_SIZE, label, NULL); BND_LABEL_FONT_SIZE, label, NULL);
} }
void bndToolButton(NVGcontext *ctx, void bndToolButton(NVGcontext *ctx,
float x, float y, float w, float h, int flags, BNDwidgetState state, float x, float y, float w, float h, int flags, BNDwidgetState state,
int iconid, const char *label) { int iconid, const char *label) {
float cr[4]; float cr[4];
NVGcolor shade_top, shade_down; NVGcolor shade_top, shade_down;
bndSelectCorners(cr, BND_TOOL_RADIUS, flags); bndSelectCorners(cr, BND_TOOL_RADIUS, flags);
bndBevelInset(ctx,x,y,w,h,cr[2],cr[3]); bndBevelInset(ctx,x,y,w,h,cr[2],cr[3]);
bndInnerColors(&shade_top, &shade_down, &bnd_theme.toolTheme, state, 1); bndInnerColors(&shade_top, &shade_down, &bnd_theme.toolTheme, state, 1);
bndInnerBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], shade_top, shade_down); bndInnerBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], shade_top, shade_down);
bndOutlineBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], bndOutlineBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3],
@@ -1445,14 +1445,14 @@ void bndToolButton(NVGcontext *ctx,
BND_LABEL_FONT_SIZE, label, NULL); BND_LABEL_FONT_SIZE, label, NULL);
} }
void bndRadioButton(NVGcontext *ctx, void bndRadioButton(NVGcontext *ctx,
float x, float y, float w, float h, int flags, BNDwidgetState state, float x, float y, float w, float h, int flags, BNDwidgetState state,
int iconid, const char *label) { int iconid, const char *label) {
float cr[4]; float cr[4];
NVGcolor shade_top, shade_down; NVGcolor shade_top, shade_down;
bndSelectCorners(cr, BND_OPTION_RADIUS, flags); bndSelectCorners(cr, BND_OPTION_RADIUS, flags);
bndBevelInset(ctx,x,y,w,h,cr[2],cr[3]); bndBevelInset(ctx,x,y,w,h,cr[2],cr[3]);
bndInnerColors(&shade_top, &shade_down, &bnd_theme.radioTheme, state, 1); bndInnerColors(&shade_top, &shade_down, &bnd_theme.radioTheme, state, 1);
bndInnerBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], shade_top, shade_down); bndInnerBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], shade_top, shade_down);
bndOutlineBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], bndOutlineBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3],
@@ -1468,14 +1468,14 @@ int bndTextFieldTextPosition(NVGcontext *ctx, float x, float y, float w, float h
iconid, BND_LABEL_FONT_SIZE, text, px, py); iconid, BND_LABEL_FONT_SIZE, text, px, py);
} }
void bndTextField(NVGcontext *ctx, void bndTextField(NVGcontext *ctx,
float x, float y, float w, float h, int flags, BNDwidgetState state, float x, float y, float w, float h, int flags, BNDwidgetState state,
int iconid, const char *text, int cbegin, int cend) { int iconid, const char *text, int cbegin, int cend) {
float cr[4]; float cr[4];
NVGcolor shade_top, shade_down; NVGcolor shade_top, shade_down;
bndSelectCorners(cr, BND_TEXT_RADIUS, flags); bndSelectCorners(cr, BND_TEXT_RADIUS, flags);
bndBevelInset(ctx,x,y,w,h,cr[2],cr[3]); bndBevelInset(ctx,x,y,w,h,cr[2],cr[3]);
bndInnerColors(&shade_top, &shade_down, &bnd_theme.textFieldTheme, state, 0); bndInnerColors(&shade_top, &shade_down, &bnd_theme.textFieldTheme, state, 0);
bndInnerBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], shade_top, shade_down); bndInnerBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], shade_top, shade_down);
bndOutlineBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], bndOutlineBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3],
@@ -1484,19 +1484,19 @@ void bndTextField(NVGcontext *ctx,
cend = -1; cend = -1;
} }
bndIconLabelCaret(ctx,x,y,w,h,iconid, bndIconLabelCaret(ctx,x,y,w,h,iconid,
bndTextColor(&bnd_theme.textFieldTheme, state), BND_LABEL_FONT_SIZE, bndTextColor(&bnd_theme.textFieldTheme, state), BND_LABEL_FONT_SIZE,
text, bnd_theme.textFieldTheme.itemColor, cbegin, cend); text, bnd_theme.textFieldTheme.itemColor, cbegin, cend);
} }
void bndOptionButton(NVGcontext *ctx, void bndOptionButton(NVGcontext *ctx,
float x, float y, float w, float h, BNDwidgetState state, float x, float y, float w, float h, BNDwidgetState state,
const char *label) { const char *label) {
float ox, oy; float ox, oy;
NVGcolor shade_top, shade_down; NVGcolor shade_top, shade_down;
ox = x; ox = x;
oy = y+h-BND_OPTION_HEIGHT-3; oy = y+h-BND_OPTION_HEIGHT-3;
bndBevelInset(ctx,ox,oy, bndBevelInset(ctx,ox,oy,
BND_OPTION_WIDTH,BND_OPTION_HEIGHT, BND_OPTION_WIDTH,BND_OPTION_HEIGHT,
BND_OPTION_RADIUS,BND_OPTION_RADIUS); BND_OPTION_RADIUS,BND_OPTION_RADIUS);
@@ -1517,14 +1517,14 @@ void bndOptionButton(NVGcontext *ctx,
BND_LABEL_FONT_SIZE, label, NULL); BND_LABEL_FONT_SIZE, label, NULL);
} }
void bndChoiceButton(NVGcontext *ctx, void bndChoiceButton(NVGcontext *ctx,
float x, float y, float w, float h, int flags, BNDwidgetState state, float x, float y, float w, float h, int flags, BNDwidgetState state,
int iconid, const char *label) { int iconid, const char *label) {
float cr[4]; float cr[4];
NVGcolor shade_top, shade_down; NVGcolor shade_top, shade_down;
bndSelectCorners(cr, BND_OPTION_RADIUS, flags); bndSelectCorners(cr, BND_OPTION_RADIUS, flags);
bndBevelInset(ctx,x,y,w,h,cr[2],cr[3]); bndBevelInset(ctx,x,y,w,h,cr[2],cr[3]);
bndInnerColors(&shade_top, &shade_down, &bnd_theme.choiceTheme, state, 1); bndInnerColors(&shade_top, &shade_down, &bnd_theme.choiceTheme, state, 1);
bndInnerBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], shade_top, shade_down); bndInnerBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], shade_top, shade_down);
bndOutlineBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], bndOutlineBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3],
@@ -1546,14 +1546,14 @@ void bndColorButton(NVGcontext *ctx,
bndTransparent(bnd_theme.toolTheme.outlineColor)); bndTransparent(bnd_theme.toolTheme.outlineColor));
} }
void bndNumberField(NVGcontext *ctx, void bndNumberField(NVGcontext *ctx,
float x, float y, float w, float h, int flags, BNDwidgetState state, float x, float y, float w, float h, int flags, BNDwidgetState state,
const char *label, const char *value) { const char *label, const char *value) {
float cr[4]; float cr[4];
NVGcolor shade_top, shade_down; NVGcolor shade_top, shade_down;
bndSelectCorners(cr, BND_NUMBER_RADIUS, flags); bndSelectCorners(cr, BND_NUMBER_RADIUS, flags);
bndBevelInset(ctx,x,y,w,h,cr[2],cr[3]); bndBevelInset(ctx,x,y,w,h,cr[2],cr[3]);
bndInnerColors(&shade_top, &shade_down, &bnd_theme.numberFieldTheme, state, 0); bndInnerColors(&shade_top, &shade_down, &bnd_theme.numberFieldTheme, state, 0);
bndInnerBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], shade_top, shade_down); bndInnerBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], shade_top, shade_down);
bndOutlineBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], bndOutlineBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3],
@@ -1567,12 +1567,12 @@ void bndNumberField(NVGcontext *ctx,
bndTransparent(bnd_theme.numberFieldTheme.itemColor)); bndTransparent(bnd_theme.numberFieldTheme.itemColor));
} }
void bndSlider(NVGcontext *ctx, void bndSlider(NVGcontext *ctx,
float x, float y, float w, float h, int flags, BNDwidgetState state, float x, float y, float w, float h, int flags, BNDwidgetState state,
float progress, const char *label, const char *value) { float progress, const char *label, const char *value) {
float cr[4]; float cr[4];
NVGcolor shade_top, shade_down; NVGcolor shade_top, shade_down;
bndSelectCorners(cr, BND_NUMBER_RADIUS, flags); bndSelectCorners(cr, BND_NUMBER_RADIUS, flags);
bndBevelInset(ctx,x,y,w,h,cr[2],cr[3]); bndBevelInset(ctx,x,y,w,h,cr[2],cr[3]);
bndInnerColors(&shade_top, &shade_down, &bnd_theme.sliderTheme, state, 0); bndInnerColors(&shade_top, &shade_down, &bnd_theme.sliderTheme, state, 0);
@@ -1588,11 +1588,11 @@ void bndSlider(NVGcontext *ctx,
bnd_theme.sliderTheme.itemColor, bnd_theme.sliderTheme.shadeDown); bnd_theme.sliderTheme.itemColor, bnd_theme.sliderTheme.shadeDown);
shade_down = bndOffsetColor( shade_down = bndOffsetColor(
bnd_theme.sliderTheme.itemColor, bnd_theme.sliderTheme.shadeTop); bnd_theme.sliderTheme.itemColor, bnd_theme.sliderTheme.shadeTop);
} }
nvgScissor(ctx,x,y,8+(w-8)*bnd_clamp(progress,0,1),h); nvgScissor(ctx,x,y,8+(w-8)*bnd_clamp(progress,0,1),h);
bndInnerBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], shade_top, shade_down); bndInnerBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], shade_top, shade_down);
nvgResetScissor(ctx); nvgResetScissor(ctx);
bndOutlineBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3], bndOutlineBox(ctx,x,y,w,h,cr[0],cr[1],cr[2],cr[3],
bndTransparent(bnd_theme.sliderTheme.outlineColor)); bndTransparent(bnd_theme.sliderTheme.outlineColor));
bndIconLabelValue(ctx,x,y,w,h,-1, bndIconLabelValue(ctx,x,y,w,h,-1,
@@ -1600,10 +1600,10 @@ void bndSlider(NVGcontext *ctx,
BND_LABEL_FONT_SIZE, label, value); BND_LABEL_FONT_SIZE, label, value);
} }
void bndScrollBar(NVGcontext *ctx, void bndScrollBar(NVGcontext *ctx,
float x, float y, float w, float h, BNDwidgetState state, float x, float y, float w, float h, BNDwidgetState state,
float offset, float size) { float offset, float size) {
bndBevelInset(ctx,x,y,w,h, bndBevelInset(ctx,x,y,w,h,
BND_SCROLLBAR_RADIUS, BND_SCROLLBAR_RADIUS); BND_SCROLLBAR_RADIUS, BND_SCROLLBAR_RADIUS);
bndInnerBox(ctx,x,y,w,h, bndInnerBox(ctx,x,y,w,h,
@@ -1617,18 +1617,18 @@ void bndScrollBar(NVGcontext *ctx,
BND_SCROLLBAR_RADIUS,BND_SCROLLBAR_RADIUS, BND_SCROLLBAR_RADIUS,BND_SCROLLBAR_RADIUS,
BND_SCROLLBAR_RADIUS,BND_SCROLLBAR_RADIUS, BND_SCROLLBAR_RADIUS,BND_SCROLLBAR_RADIUS,
bndTransparent(bnd_theme.scrollBarTheme.outlineColor)); bndTransparent(bnd_theme.scrollBarTheme.outlineColor));
NVGcolor itemColor = bndOffsetColor( NVGcolor itemColor = bndOffsetColor(
bnd_theme.scrollBarTheme.itemColor, bnd_theme.scrollBarTheme.itemColor,
(state == BND_ACTIVE)?BND_SCROLLBAR_ACTIVE_SHADE:0); (state == BND_ACTIVE)?BND_SCROLLBAR_ACTIVE_SHADE:0);
bndScrollHandleRect(&x,&y,&w,&h,offset,size); bndScrollHandleRect(&x,&y,&w,&h,offset,size);
bndInnerBox(ctx,x,y,w,h, bndInnerBox(ctx,x,y,w,h,
BND_SCROLLBAR_RADIUS,BND_SCROLLBAR_RADIUS, BND_SCROLLBAR_RADIUS,BND_SCROLLBAR_RADIUS,
BND_SCROLLBAR_RADIUS,BND_SCROLLBAR_RADIUS, BND_SCROLLBAR_RADIUS,BND_SCROLLBAR_RADIUS,
bndOffsetColor( bndOffsetColor(
itemColor, 3*bnd_theme.scrollBarTheme.shadeTop), itemColor, 3*bnd_theme.scrollBarTheme.shadeTop),
bndOffsetColor( bndOffsetColor(
itemColor, 3*bnd_theme.scrollBarTheme.shadeDown)); itemColor, 3*bnd_theme.scrollBarTheme.shadeDown));
bndOutlineBox(ctx,x,y,w,h, bndOutlineBox(ctx,x,y,w,h,
@@ -1637,11 +1637,11 @@ void bndScrollBar(NVGcontext *ctx,
bndTransparent(bnd_theme.scrollBarTheme.outlineColor)); bndTransparent(bnd_theme.scrollBarTheme.outlineColor));
} }
void bndMenuBackground(NVGcontext *ctx, void bndMenuBackground(NVGcontext *ctx,
float x, float y, float w, float h, int flags) { float x, float y, float w, float h, int flags) {
float cr[4]; float cr[4];
NVGcolor shade_top, shade_down; NVGcolor shade_top, shade_down;
bndSelectCorners(cr, BND_MENU_RADIUS, flags); bndSelectCorners(cr, BND_MENU_RADIUS, flags);
bndInnerColors(&shade_top, &shade_down, &bnd_theme.menuTheme, bndInnerColors(&shade_top, &shade_down, &bnd_theme.menuTheme,
BND_DEFAULT, 0); BND_DEFAULT, 0);
@@ -1654,7 +1654,7 @@ void bndMenuBackground(NVGcontext *ctx,
void bndTooltipBackground(NVGcontext *ctx, float x, float y, float w, float h) { void bndTooltipBackground(NVGcontext *ctx, float x, float y, float w, float h) {
NVGcolor shade_top, shade_down; NVGcolor shade_top, shade_down;
bndInnerColors(&shade_top, &shade_down, &bnd_theme.tooltipTheme, bndInnerColors(&shade_top, &shade_down, &bnd_theme.tooltipTheme,
BND_DEFAULT, 0); BND_DEFAULT, 0);
bndInnerBox(ctx,x,y,w,h+1, bndInnerBox(ctx,x,y,w,h+1,
@@ -1667,21 +1667,21 @@ void bndTooltipBackground(NVGcontext *ctx, float x, float y, float w, float h) {
BND_SHADOW_FEATHER,BND_SHADOW_ALPHA); BND_SHADOW_FEATHER,BND_SHADOW_ALPHA);
} }
void bndMenuLabel(NVGcontext *ctx, void bndMenuLabel(NVGcontext *ctx,
float x, float y, float w, float h, int iconid, const char *label) { float x, float y, float w, float h, int iconid, const char *label) {
bndIconLabelValue(ctx,x,y,w,h,iconid, bndIconLabelValue(ctx,x,y,w,h,iconid,
bnd_theme.menuTheme.textColor, BND_LEFT, bnd_theme.menuTheme.textColor, BND_LEFT,
BND_LABEL_FONT_SIZE, label, NULL); BND_LABEL_FONT_SIZE, label, NULL);
} }
void bndMenuItem(NVGcontext *ctx, void bndMenuItem(NVGcontext *ctx,
float x, float y, float w, float h, BNDwidgetState state, float x, float y, float w, float h, BNDwidgetState state,
int iconid, const char *label) { int iconid, const char *label) {
if (state != BND_DEFAULT) { if (state != BND_DEFAULT) {
bndInnerBox(ctx,x,y,w,h,0,0,0,0, bndInnerBox(ctx,x,y,w,h,0,0,0,0,
bndOffsetColor(bnd_theme.menuItemTheme.innerSelectedColor, bndOffsetColor(bnd_theme.menuItemTheme.innerSelectedColor,
bnd_theme.menuItemTheme.shadeTop), bnd_theme.menuItemTheme.shadeTop),
bndOffsetColor(bnd_theme.menuItemTheme.innerSelectedColor, bndOffsetColor(bnd_theme.menuItemTheme.innerSelectedColor,
bnd_theme.menuItemTheme.shadeDown)); bnd_theme.menuItemTheme.shadeDown));
state = BND_ACTIVE; state = BND_ACTIVE;
} }
@@ -1706,10 +1706,10 @@ void bndColoredNodeWire(NVGcontext *ctx, float x0, float y0, float x1, float y1,
NVGcolor color0, NVGcolor color1) { NVGcolor color0, NVGcolor color1) {
float length = bnd_fmaxf(fabsf(x1 - x0),fabsf(y1 - y0)); float length = bnd_fmaxf(fabsf(x1 - x0),fabsf(y1 - y0));
float delta = length*(float)bnd_theme.nodeTheme.noodleCurving/10.0f; float delta = length*(float)bnd_theme.nodeTheme.noodleCurving/10.0f;
nvgBeginPath(ctx); nvgBeginPath(ctx);
nvgMoveTo(ctx, x0, y0); nvgMoveTo(ctx, x0, y0);
nvgBezierTo(ctx, nvgBezierTo(ctx,
x0 + delta, y0, x0 + delta, y0,
x1 - delta, y1, x1 - delta, y1,
x1, y1); x1, y1);
@@ -1718,8 +1718,8 @@ void bndColoredNodeWire(NVGcontext *ctx, float x0, float y0, float x1, float y1,
nvgStrokeColor(ctx, colorw); nvgStrokeColor(ctx, colorw);
nvgStrokeWidth(ctx, BND_NODE_WIRE_OUTLINE_WIDTH); nvgStrokeWidth(ctx, BND_NODE_WIRE_OUTLINE_WIDTH);
nvgStroke(ctx); nvgStroke(ctx);
nvgStrokePaint(ctx, nvgLinearGradient(ctx, nvgStrokePaint(ctx, nvgLinearGradient(ctx,
x0, y0, x1, y1, x0, y0, x1, y1,
color0, color0,
color1)); color1));
nvgStrokeWidth(ctx,BND_NODE_WIRE_WIDTH); nvgStrokeWidth(ctx,BND_NODE_WIRE_WIDTH);
@@ -1737,17 +1737,17 @@ void bndNodeBackground(NVGcontext *ctx, float x, float y, float w, float h,
BNDwidgetState state, int iconid, const char *label, NVGcolor titleColor) { BNDwidgetState state, int iconid, const char *label, NVGcolor titleColor) {
bndInnerBox(ctx,x,y,w,BND_NODE_TITLE_HEIGHT+2, bndInnerBox(ctx,x,y,w,BND_NODE_TITLE_HEIGHT+2,
BND_NODE_RADIUS,BND_NODE_RADIUS,0,0, BND_NODE_RADIUS,BND_NODE_RADIUS,0,0,
bndTransparent(bndOffsetColor(titleColor, BND_BEVEL_SHADE)), bndTransparent(bndOffsetColor(titleColor, BND_BEVEL_SHADE)),
bndTransparent(titleColor)); bndTransparent(titleColor));
bndInnerBox(ctx,x,y+float(BND_NODE_TITLE_HEIGHT-1),w,h+2-float(BND_NODE_TITLE_HEIGHT), bndInnerBox(ctx,x,y+float(BND_NODE_TITLE_HEIGHT-1),w,h+2-float(BND_NODE_TITLE_HEIGHT),
0,0,BND_NODE_RADIUS,BND_NODE_RADIUS, 0,0,BND_NODE_RADIUS,BND_NODE_RADIUS,
bndTransparent(bnd_theme.nodeTheme.nodeBackdropColor), bndTransparent(bnd_theme.nodeTheme.nodeBackdropColor),
bndTransparent(bnd_theme.nodeTheme.nodeBackdropColor)); bndTransparent(bnd_theme.nodeTheme.nodeBackdropColor));
bndNodeIconLabel(ctx, bndNodeIconLabel(ctx,
x+float(BND_NODE_ARROW_AREA_WIDTH),y, x+float(BND_NODE_ARROW_AREA_WIDTH),y,
w-float(BND_NODE_ARROW_AREA_WIDTH)-float(BND_NODE_MARGIN_SIDE),BND_NODE_TITLE_HEIGHT, w-float(BND_NODE_ARROW_AREA_WIDTH)-float(BND_NODE_MARGIN_SIDE),BND_NODE_TITLE_HEIGHT,
iconid, bnd_theme.regularTheme.textColor, iconid, bnd_theme.regularTheme.textColor,
bndOffsetColor(titleColor, BND_BEVEL_SHADE), bndOffsetColor(titleColor, BND_BEVEL_SHADE),
BND_LEFT, BND_LABEL_FONT_SIZE, label); BND_LEFT, BND_LABEL_FONT_SIZE, label);
NVGcolor arrowColor; NVGcolor arrowColor;
NVGcolor borderColor; NVGcolor borderColor;
@@ -1770,8 +1770,8 @@ void bndNodeBackground(NVGcontext *ctx, float x, float y, float w, float h,
BND_NODE_RADIUS,BND_NODE_RADIUS,BND_NODE_RADIUS,BND_NODE_RADIUS, BND_NODE_RADIUS,BND_NODE_RADIUS,BND_NODE_RADIUS,BND_NODE_RADIUS,
bndTransparent(borderColor)); bndTransparent(borderColor));
/* /*
bndNodeArrowDown(ctx, bndNodeArrowDown(ctx,
x + BND_NODE_MARGIN_SIDE, y + BND_NODE_TITLE_HEIGHT-4, x + BND_NODE_MARGIN_SIDE, y + BND_NODE_TITLE_HEIGHT-4,
BND_NODE_ARROW_SIZE, arrowColor); BND_NODE_ARROW_SIZE, arrowColor);
*/ */
bndDropShadow(ctx,x,y,w,h,BND_NODE_RADIUS, bndDropShadow(ctx,x,y,w,h,BND_NODE_RADIUS,
@@ -1784,7 +1784,7 @@ void bndSplitterWidgets(NVGcontext *ctx, float x, float y, float w, float h) {
NVGcolor insetDark = bndTransparent( NVGcolor insetDark = bndTransparent(
bndOffsetColor(bnd_theme.backgroundColor, -BND_SPLITTER_SHADE)); bndOffsetColor(bnd_theme.backgroundColor, -BND_SPLITTER_SHADE));
NVGcolor inset = bndTransparent(bnd_theme.backgroundColor); NVGcolor inset = bndTransparent(bnd_theme.backgroundColor);
float x2 = x+w; float x2 = x+w;
float y2 = y+h; float y2 = y+h;
@@ -1795,14 +1795,14 @@ void bndSplitterWidgets(NVGcontext *ctx, float x, float y, float w, float h) {
nvgLineTo(ctx, x+9, y2); nvgLineTo(ctx, x+9, y2);
nvgMoveTo(ctx, x, y2-5); nvgMoveTo(ctx, x, y2-5);
nvgLineTo(ctx, x+5, y2); nvgLineTo(ctx, x+5, y2);
nvgMoveTo(ctx, x2-11, y); nvgMoveTo(ctx, x2-11, y);
nvgLineTo(ctx, x2, y+11); nvgLineTo(ctx, x2, y+11);
nvgMoveTo(ctx, x2-7, y); nvgMoveTo(ctx, x2-7, y);
nvgLineTo(ctx, x2, y+7); nvgLineTo(ctx, x2, y+7);
nvgMoveTo(ctx, x2-3, y); nvgMoveTo(ctx, x2-3, y);
nvgLineTo(ctx, x2, y+3); nvgLineTo(ctx, x2, y+3);
nvgStrokeColor(ctx, insetDark); nvgStrokeColor(ctx, insetDark);
nvgStroke(ctx); nvgStroke(ctx);
@@ -1813,17 +1813,17 @@ void bndSplitterWidgets(NVGcontext *ctx, float x, float y, float w, float h) {
nvgLineTo(ctx, x+7, y2); nvgLineTo(ctx, x+7, y2);
nvgMoveTo(ctx, x, y2-3); nvgMoveTo(ctx, x, y2-3);
nvgLineTo(ctx, x+3, y2); nvgLineTo(ctx, x+3, y2);
nvgMoveTo(ctx, x2-13, y); nvgMoveTo(ctx, x2-13, y);
nvgLineTo(ctx, x2, y+13); nvgLineTo(ctx, x2, y+13);
nvgMoveTo(ctx, x2-9, y); nvgMoveTo(ctx, x2-9, y);
nvgLineTo(ctx, x2, y+9); nvgLineTo(ctx, x2, y+9);
nvgMoveTo(ctx, x2-5, y); nvgMoveTo(ctx, x2-5, y);
nvgLineTo(ctx, x2, y+5); nvgLineTo(ctx, x2, y+5);
nvgStrokeColor(ctx, insetLight); nvgStrokeColor(ctx, insetLight);
nvgStroke(ctx); nvgStroke(ctx);
nvgBeginPath(ctx); nvgBeginPath(ctx);
nvgMoveTo(ctx, x, y2-12); nvgMoveTo(ctx, x, y2-12);
nvgLineTo(ctx, x+12, y2); nvgLineTo(ctx, x+12, y2);
@@ -1831,28 +1831,28 @@ void bndSplitterWidgets(NVGcontext *ctx, float x, float y, float w, float h) {
nvgLineTo(ctx, x+8, y2); nvgLineTo(ctx, x+8, y2);
nvgMoveTo(ctx, x, y2-4); nvgMoveTo(ctx, x, y2-4);
nvgLineTo(ctx, x+4, y2); nvgLineTo(ctx, x+4, y2);
nvgMoveTo(ctx, x2-12, y); nvgMoveTo(ctx, x2-12, y);
nvgLineTo(ctx, x2, y+12); nvgLineTo(ctx, x2, y+12);
nvgMoveTo(ctx, x2-8, y); nvgMoveTo(ctx, x2-8, y);
nvgLineTo(ctx, x2, y+8); nvgLineTo(ctx, x2, y+8);
nvgMoveTo(ctx, x2-4, y); nvgMoveTo(ctx, x2-4, y);
nvgLineTo(ctx, x2, y+4); nvgLineTo(ctx, x2, y+4);
nvgStrokeColor(ctx, inset); nvgStrokeColor(ctx, inset);
nvgStroke(ctx); nvgStroke(ctx);
} }
void bndJoinAreaOverlay(NVGcontext *ctx, float x, float y, float w, float h, void bndJoinAreaOverlay(NVGcontext *ctx, float x, float y, float w, float h,
int vertical, int mirror) { int vertical, int mirror) {
if (vertical) { if (vertical) {
float u = w; float u = w;
w = h; h = u; w = h; h = u;
} }
float s = (w<h)?w:h; float s = (w<h)?w:h;
float x0,y0,x1,y1; float x0,y0,x1,y1;
if (mirror) { if (mirror) {
x0 = w; x0 = w;
@@ -1866,13 +1866,13 @@ void bndJoinAreaOverlay(NVGcontext *ctx, float x, float y, float w, float h,
x1 = w; x1 = w;
y1 = h; y1 = h;
} }
float yc = (y0+y1)*0.5f; float yc = (y0+y1)*0.5f;
float s2 = s/2.0f; float s2 = s/2.0f;
float s4 = s/4.0f; float s4 = s/4.0f;
float s8 = s/8.0f; float s8 = s/8.0f;
float x4 = x0+s4; float x4 = x0+s4;
float points[][2] = { float points[][2] = {
{ x0,y0 }, { x0,y0 },
{ x1,y0 }, { x1,y0 },
@@ -1881,19 +1881,19 @@ void bndJoinAreaOverlay(NVGcontext *ctx, float x, float y, float w, float h,
{ x0,yc+s8 }, { x0,yc+s8 },
{ x4,yc+s8 }, { x4,yc+s8 },
{ x4,yc+s4 }, { x4,yc+s4 },
{ x0+s2,yc }, { x0+s2,yc },
{ x4,yc-s4 }, { x4,yc-s4 },
{ x4,yc-s8 }, { x4,yc-s8 },
{ x0,yc-s8 } { x0,yc-s8 }
}; };
nvgBeginPath(ctx); nvgBeginPath(ctx);
int count = sizeof(points) / (sizeof(float)*2); int count = sizeof(points) / (sizeof(float)*2);
nvgMoveTo(ctx,x+points[0][vertical&1],y+points[0][(vertical&1)^1]); nvgMoveTo(ctx,x+points[0][vertical&1],y+points[0][(vertical&1)^1]);
for (int i = 1; i < count; ++i) { for (int i = 1; i < count; ++i) {
nvgLineTo(ctx,x+points[i][vertical&1],y+points[i][(vertical&1)^1]); nvgLineTo(ctx,x+points[i][vertical&1],y+points[i][(vertical&1)^1]);
} }
nvgFillColor(ctx, nvgRGBAf(0,0,0,0.3)); nvgFillColor(ctx, nvgRGBAf(0,0,0,0.3));
nvgFill(ctx); nvgFill(ctx);
} }
@@ -1933,14 +1933,14 @@ float bndLabelHeight(NVGcontext *ctx, int iconid, const char *label, float width
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void bndRoundedBox(NVGcontext *ctx, float x, float y, float w, float h, void bndRoundedBox(NVGcontext *ctx, float x, float y, float w, float h,
float cr0, float cr1, float cr2, float cr3) { float cr0, float cr1, float cr2, float cr3) {
float d; float d;
w = bnd_fmaxf(0, w); w = bnd_fmaxf(0, w);
h = bnd_fmaxf(0, h); h = bnd_fmaxf(0, h);
d = bnd_fminf(w, h); d = bnd_fminf(w, h);
nvgMoveTo(ctx, x,y+h*0.5f); nvgMoveTo(ctx, x,y+h*0.5f);
nvgArcTo(ctx, x,y, x+w,y, bnd_fminf(cr0, d/2)); nvgArcTo(ctx, x,y, x+w,y, bnd_fminf(cr0, d/2));
nvgArcTo(ctx, x+w,y, x+w,y+h, bnd_fminf(cr1, d/2)); nvgArcTo(ctx, x+w,y, x+w,y+h, bnd_fminf(cr1, d/2));
@@ -1967,12 +1967,12 @@ NVGcolor bndOffsetColor(NVGcolor color, int delta) {
void bndBevel(NVGcontext *ctx, float x, float y, float w, float h) { void bndBevel(NVGcontext *ctx, float x, float y, float w, float h) {
nvgStrokeWidth(ctx, 1); nvgStrokeWidth(ctx, 1);
x += 0.5f; x += 0.5f;
y += 0.5f; y += 0.5f;
w -= 1; w -= 1;
h -= 1; h -= 1;
nvgBeginPath(ctx); nvgBeginPath(ctx);
nvgMoveTo(ctx, x, y+h); nvgMoveTo(ctx, x, y+h);
nvgLineTo(ctx, x+w, y+h); nvgLineTo(ctx, x+w, y+h);
@@ -1980,7 +1980,7 @@ void bndBevel(NVGcontext *ctx, float x, float y, float w, float h) {
nvgStrokeColor(ctx, bndTransparent( nvgStrokeColor(ctx, bndTransparent(
bndOffsetColor(bnd_theme.backgroundColor, -BND_BEVEL_SHADE))); bndOffsetColor(bnd_theme.backgroundColor, -BND_BEVEL_SHADE)));
nvgStroke(ctx); nvgStroke(ctx);
nvgBeginPath(ctx); nvgBeginPath(ctx);
nvgMoveTo(ctx, x, y+h); nvgMoveTo(ctx, x, y+h);
nvgLineTo(ctx, x, y); nvgLineTo(ctx, x, y);
@@ -1993,20 +1993,20 @@ void bndBevel(NVGcontext *ctx, float x, float y, float w, float h) {
void bndBevelInset(NVGcontext *ctx, float x, float y, float w, float h, void bndBevelInset(NVGcontext *ctx, float x, float y, float w, float h,
float cr2, float cr3) { float cr2, float cr3) {
float d; float d;
y -= 0.5f; y -= 0.5f;
d = bnd_fminf(w, h); d = bnd_fminf(w, h);
cr2 = bnd_fminf(cr2, d/2); cr2 = bnd_fminf(cr2, d/2);
cr3 = bnd_fminf(cr3, d/2); cr3 = bnd_fminf(cr3, d/2);
nvgBeginPath(ctx); nvgBeginPath(ctx);
nvgMoveTo(ctx, x+w,y+h-cr2); nvgMoveTo(ctx, x+w,y+h-cr2);
nvgArcTo(ctx, x+w,y+h, x,y+h, cr2); nvgArcTo(ctx, x+w,y+h, x,y+h, cr2);
nvgArcTo(ctx, x,y+h, x,y, cr3); nvgArcTo(ctx, x,y+h, x,y, cr3);
NVGcolor bevelColor = bndOffsetColor(bnd_theme.backgroundColor, NVGcolor bevelColor = bndOffsetColor(bnd_theme.backgroundColor,
BND_INSET_BEVEL_SHADE); BND_INSET_BEVEL_SHADE);
nvgStrokeWidth(ctx, 1); nvgStrokeWidth(ctx, 1);
nvgStrokePaint(ctx, nvgStrokePaint(ctx,
nvgLinearGradient(ctx, nvgLinearGradient(ctx,
@@ -2027,12 +2027,12 @@ void bndBackground(NVGcontext *ctx, float x, float y, float w, float h) {
void bndIcon(NVGcontext *ctx, float x, float y, int iconid) { void bndIcon(NVGcontext *ctx, float x, float y, int iconid) {
int ix, iy, u, v; int ix, iy, u, v;
if (bnd_icon_image < 0) return; // no icons loaded if (bnd_icon_image < 0) return; // no icons loaded
ix = iconid & 0xff; ix = iconid & 0xff;
iy = (iconid>>8) & 0xff; iy = (iconid>>8) & 0xff;
u = BND_ICON_SHEET_OFFSET_X + ix*BND_ICON_SHEET_GRID; u = BND_ICON_SHEET_OFFSET_X + ix*BND_ICON_SHEET_GRID;
v = BND_ICON_SHEET_OFFSET_Y + iy*BND_ICON_SHEET_GRID; v = BND_ICON_SHEET_OFFSET_Y + iy*BND_ICON_SHEET_GRID;
nvgBeginPath(ctx); nvgBeginPath(ctx);
nvgRect(ctx,x,y,BND_ICON_SHEET_RES,BND_ICON_SHEET_RES); nvgRect(ctx,x,y,BND_ICON_SHEET_RES,BND_ICON_SHEET_RES);
nvgFillPaint(ctx, nvgFillPaint(ctx,
@@ -2045,11 +2045,11 @@ void bndIcon(NVGcontext *ctx, float x, float y, int iconid) {
void bndDropShadow(NVGcontext *ctx, float x, float y, float w, float h, void bndDropShadow(NVGcontext *ctx, float x, float y, float w, float h,
float r, float feather, float alpha) { float r, float feather, float alpha) {
nvgBeginPath(ctx); nvgBeginPath(ctx);
y += feather; y += feather;
h -= feather; h -= feather;
nvgMoveTo(ctx, x-feather, y-feather); nvgMoveTo(ctx, x-feather, y-feather);
nvgLineTo(ctx, x, y-feather); nvgLineTo(ctx, x, y-feather);
nvgLineTo(ctx, x, y+h-feather); nvgLineTo(ctx, x, y+h-feather);
@@ -2060,18 +2060,18 @@ void bndDropShadow(NVGcontext *ctx, float x, float y, float w, float h,
nvgLineTo(ctx, x+w+feather, y+h+feather); nvgLineTo(ctx, x+w+feather, y+h+feather);
nvgLineTo(ctx, x-feather, y+h+feather); nvgLineTo(ctx, x-feather, y+h+feather);
nvgClosePath(ctx); nvgClosePath(ctx);
nvgFillPaint(ctx, nvgBoxGradient(ctx, nvgFillPaint(ctx, nvgBoxGradient(ctx,
x - feather*0.5f,y - feather*0.5f, x - feather*0.5f,y - feather*0.5f,
w + feather,h+feather, w + feather,h+feather,
r+feather*0.5f, r+feather*0.5f,
feather, feather,
nvgRGBAf(0,0,0,alpha*alpha), nvgRGBAf(0,0,0,alpha*alpha),
nvgRGBAf(0,0,0,0))); nvgRGBAf(0,0,0,0)));
nvgFill(ctx); nvgFill(ctx);
} }
void bndInnerBox(NVGcontext *ctx, float x, float y, float w, float h, void bndInnerBox(NVGcontext *ctx, float x, float y, float w, float h,
float cr0, float cr1, float cr2, float cr3, float cr0, float cr1, float cr2, float cr3,
NVGcolor shade_top, NVGcolor shade_down) { NVGcolor shade_top, NVGcolor shade_down) {
nvgBeginPath(ctx); nvgBeginPath(ctx);
@@ -2100,7 +2100,7 @@ void bndSelectCorners(float *radiuses, float r, int flags) {
} }
void bndInnerColors( void bndInnerColors(
NVGcolor *shade_top, NVGcolor *shade_down, NVGcolor *shade_top, NVGcolor *shade_down,
const BNDwidgetTheme *theme, BNDwidgetState state, int flipActive) { const BNDwidgetTheme *theme, BNDwidgetState state, int flipActive) {
switch(state) { switch(state) {
@@ -2115,9 +2115,9 @@ void bndInnerColors(
*shade_down = bndOffsetColor(color, theme->shadeDown); *shade_down = bndOffsetColor(color, theme->shadeDown);
} break; } break;
case BND_ACTIVE: { case BND_ACTIVE: {
*shade_top = bndOffsetColor(theme->innerSelectedColor, *shade_top = bndOffsetColor(theme->innerSelectedColor,
flipActive?theme->shadeDown:theme->shadeTop); flipActive?theme->shadeDown:theme->shadeTop);
*shade_down = bndOffsetColor(theme->innerSelectedColor, *shade_down = bndOffsetColor(theme->innerSelectedColor,
flipActive?theme->shadeTop:theme->shadeDown); flipActive?theme->shadeTop:theme->shadeDown);
} break; } break;
} }
@@ -2128,15 +2128,15 @@ NVGcolor bndTextColor(const BNDwidgetTheme *theme, BNDwidgetState state) {
} }
void bndIconLabelValue(NVGcontext *ctx, float x, float y, float w, float h, void bndIconLabelValue(NVGcontext *ctx, float x, float y, float w, float h,
int iconid, NVGcolor color, int align, float fontsize, const char *label, int iconid, NVGcolor color, int align, float fontsize, const char *label,
const char *value) { const char *value) {
float pleft = BND_PAD_LEFT; float pleft = BND_PAD_LEFT;
if (label) { if (label) {
if (iconid >= 0) { if (iconid >= 0) {
bndIcon(ctx,x+4,y+2,iconid); bndIcon(ctx,x+4,y+2,iconid);
pleft += BND_ICON_SHEET_RES; pleft += BND_ICON_SHEET_RES;
} }
if (bnd_font < 0) return; if (bnd_font < 0) return;
nvgFontFaceId(ctx, bnd_font); nvgFontFaceId(ctx, bnd_font);
nvgFontSize(ctx, fontsize); nvgFontSize(ctx, fontsize);
@@ -2146,7 +2146,7 @@ void bndIconLabelValue(NVGcontext *ctx, float x, float y, float w, float h,
float label_width = nvgTextBounds(ctx, 1, 1, label, NULL, NULL); float label_width = nvgTextBounds(ctx, 1, 1, label, NULL, NULL);
float sep_width = nvgTextBounds(ctx, 1, 1, float sep_width = nvgTextBounds(ctx, 1, 1,
BND_LABEL_SEPARATOR, NULL, NULL); BND_LABEL_SEPARATOR, NULL, NULL);
nvgTextAlign(ctx, NVG_ALIGN_LEFT|NVG_ALIGN_BASELINE); nvgTextAlign(ctx, NVG_ALIGN_LEFT|NVG_ALIGN_BASELINE);
x += pleft; x += pleft;
if (align == BND_CENTER) { if (align == BND_CENTER) {
@@ -2161,7 +2161,7 @@ void bndIconLabelValue(NVGcontext *ctx, float x, float y, float w, float h,
x += sep_width; x += sep_width;
nvgText(ctx, x, y, value, NULL); nvgText(ctx, x, y, value, NULL);
} else { } else {
nvgTextAlign(ctx, nvgTextAlign(ctx,
(align==BND_LEFT)?(NVG_ALIGN_LEFT|NVG_ALIGN_BASELINE): (align==BND_LEFT)?(NVG_ALIGN_LEFT|NVG_ALIGN_BASELINE):
(NVG_ALIGN_CENTER|NVG_ALIGN_BASELINE)); (NVG_ALIGN_CENTER|NVG_ALIGN_BASELINE));
nvgTextBox(ctx,x+pleft,y+float(BND_WIDGET_HEIGHT)-BND_TEXT_PAD_DOWN, nvgTextBox(ctx,x+pleft,y+float(BND_WIDGET_HEIGHT)-BND_TEXT_PAD_DOWN,
@@ -2173,7 +2173,7 @@ void bndIconLabelValue(NVGcontext *ctx, float x, float y, float w, float h,
} }
void bndNodeIconLabel(NVGcontext *ctx, float x, float y, float w, float h, void bndNodeIconLabel(NVGcontext *ctx, float x, float y, float w, float h,
int iconid, NVGcolor color, NVGcolor shadowColor, int iconid, NVGcolor color, NVGcolor shadowColor,
int align, float fontsize, const char *label) { int align, float fontsize, const char *label) {
if (label && (bnd_font >= 0)) { if (label && (bnd_font >= 0)) {
nvgFontFaceId(ctx, bnd_font); nvgFontFaceId(ctx, bnd_font);
@@ -2256,7 +2256,7 @@ static void bndCaretPosition(NVGcontext *ctx, float x, float y,
} }
void bndIconLabelCaret(NVGcontext *ctx, float x, float y, float w, float h, void bndIconLabelCaret(NVGcontext *ctx, float x, float y, float w, float h,
int iconid, NVGcolor color, float fontsize, const char *label, int iconid, NVGcolor color, float fontsize, const char *label,
NVGcolor caretcolor, int cbegin, int cend) { NVGcolor caretcolor, int cbegin, int cend) {
float pleft = BND_TEXT_RADIUS; float pleft = BND_TEXT_RADIUS;
if (!label) return; if (!label) return;
@@ -2264,9 +2264,9 @@ void bndIconLabelCaret(NVGcontext *ctx, float x, float y, float w, float h,
bndIcon(ctx,x+4,y+2,iconid); bndIcon(ctx,x+4,y+2,iconid);
pleft += BND_ICON_SHEET_RES; pleft += BND_ICON_SHEET_RES;
} }
if (bnd_font < 0) return; if (bnd_font < 0) return;
x+=pleft; x+=pleft;
y+=BND_WIDGET_HEIGHT-BND_TEXT_PAD_DOWN; y+=BND_WIDGET_HEIGHT-BND_TEXT_PAD_DOWN;
@@ -2289,7 +2289,7 @@ void bndIconLabelCaret(NVGcontext *ctx, float x, float y, float w, float h,
rows, nrows, &c0r, &c0x, &c0y); rows, nrows, &c0r, &c0x, &c0y);
bndCaretPosition(ctx, x, y, desc, lh, label+cend, bndCaretPosition(ctx, x, y, desc, lh, label+cend,
rows, nrows, &c1r, &c1x, &c1y); rows, nrows, &c1r, &c1x, &c1y);
nvgBeginPath(ctx); nvgBeginPath(ctx);
if (cbegin == cend) { if (cbegin == cend) {
nvgFillColor(ctx, nvgRGBf(0.337,0.502,0.761)); nvgFillColor(ctx, nvgRGBf(0.337,0.502,0.761));
@@ -2309,7 +2309,7 @@ void bndIconLabelCaret(NVGcontext *ctx, float x, float y, float w, float h,
} }
nvgFill(ctx); nvgFill(ctx);
} }
nvgBeginPath(ctx); nvgBeginPath(ctx);
nvgFillColor(ctx, color); nvgFillColor(ctx, color);
nvgTextBox(ctx,x,y,w,label, NULL); nvgTextBox(ctx,x,y,w,label, NULL);

View File

@@ -12,7 +12,7 @@ void main()
{ {
vec3 wpos = mul(u_model[0], vec4(a_position, 1.0) ).xyz; vec3 wpos = mul(u_model[0], vec4(a_position, 1.0) ).xyz;
gl_Position = mul(u_viewProj, vec4(wpos, 1.0) ); gl_Position = mul(u_viewProj, vec4(wpos, 1.0) );
vec4 normal = a_normal * 2.0 - 1.0; vec4 normal = a_normal * 2.0 - 1.0;
vec3 wnormal = mul(u_model[0], vec4(normal.xyz, 0.0) ).xyz; vec3 wnormal = mul(u_model[0], vec4(normal.xyz, 0.0) ).xyz;

View File

@@ -23,4 +23,3 @@ void main()
vec4 rgba = vec4(color, (1.0-edge)*opacity); vec4 rgba = vec4(color, (1.0-edge)*opacity);
gl_FragColor = rgba; gl_FragColor = rgba;
} }

View File

@@ -16,4 +16,3 @@ void main()
v_view = u_camPos - mul(u_model[0], vec4(a_position, 1.0) ).xyz; v_view = u_camPos - mul(u_model[0], vec4(a_position, 1.0) ).xyz;
v_bc = a_color1; v_bc = a_color1;
} }

View File

@@ -20,7 +20,7 @@ void main()
// Calculate normal. Note that compressed normal is stored in the vertices // Calculate normal. Note that compressed normal is stored in the vertices
vec3 normalObjectSpace = a_normal.xyz*2.0+-1.0; // Normal is stored in [0,1], remap to [-1,1]. vec3 normalObjectSpace = a_normal.xyz*2.0+-1.0; // Normal is stored in [0,1], remap to [-1,1].
// Transform normal into world space. // Transform normal into world space.
vec3 normalWorldSpace = mul(u_model[0], vec4(normalObjectSpace, 0.0) ).xyz; vec3 normalWorldSpace = mul(u_model[0], vec4(normalObjectSpace, 0.0) ).xyz;
// Normalize to remove (uniform...) scaling, however, recompress // Normalize to remove (uniform...) scaling, however, recompress
v_normal.xyz = normalize(normalWorldSpace)*0.5+0.5; v_normal.xyz = normalize(normalWorldSpace)*0.5+0.5;

View File

@@ -17,7 +17,7 @@ void main()
// Calculate normal. Note that compressed normal is stored in the vertices // Calculate normal. Note that compressed normal is stored in the vertices
vec3 normalObjectSpace = a_normal.xyz*2.0+-1.0; // Normal is stored in [0,1], remap to [-1,1]. vec3 normalObjectSpace = a_normal.xyz*2.0+-1.0; // Normal is stored in [0,1], remap to [-1,1].
// Transform normal into view space. // Transform normal into view space.
v_normal = mul(u_modelView, vec4(normalObjectSpace, 0.0) ).xyz; v_normal = mul(u_modelView, vec4(normalObjectSpace, 0.0) ).xyz;
// Normalize to remove (uniform...) scaling // Normalize to remove (uniform...) scaling
v_normal = normalize(v_normal); v_normal = normalize(v_normal);

View File

@@ -26,7 +26,7 @@ float nrand(in vec2 n)
float n4rand_ss(in vec2 n) float n4rand_ss(in vec2 n)
{ {
float nrnd0 = nrand( n + 0.07*fract( u_parameters.w ) ); float nrnd0 = nrand( n + 0.07*fract( u_parameters.w ) );
float nrnd1 = nrand( n + 0.11*fract( u_parameters.w + 0.573953 ) ); float nrnd1 = nrand( n + 0.11*fract( u_parameters.w + 0.573953 ) );
return 0.23*sqrt(-log(nrnd0+0.00001))*cos(2.0*3.141592*nrnd1)+0.5; return 0.23*sqrt(-log(nrnd0+0.00001))*cos(2.0*3.141592*nrnd1)+0.5;
} }
@@ -40,17 +40,17 @@ void main()
vec3 normal = normalize(v_normal); vec3 normal = normalize(v_normal);
float occulsion = toLinear(texture2D(s_texLightmap, v_texcoord0).r); float occulsion = toLinear(texture2D(s_texLightmap, v_texcoord0).r);
vec3 skyDirection = vec3(0.0, 0.0, 1.0); vec3 skyDirection = vec3(0.0, 0.0, 1.0);
float diffuseSun = max(0.0, dot(normal, normalize(u_sunDirection.xyz))); float diffuseSun = max(0.0, dot(normal, normalize(u_sunDirection.xyz)));
float diffuseSky = 1.0 + 0.5 * dot(normal, skyDirection); float diffuseSky = 1.0 + 0.5 * dot(normal, skyDirection);
vec3 color = diffuseSun * u_sunLuminance.rgb + (diffuseSky * u_skyLuminance.rgb + 0.01) * occulsion; vec3 color = diffuseSun * u_sunLuminance.rgb + (diffuseSky * u_skyLuminance.rgb + 0.01) * occulsion;
color *= 0.5; color *= 0.5;
//color = mix(color, (u_skyLuminance + u_sunLuminance)*0.3, v_fogFactor); //color = mix(color, (u_skyLuminance + u_sunLuminance)*0.3, v_fogFactor);
gl_FragColor.xyz = color * u_parameters.z; gl_FragColor.xyz = color * u_parameters.z;
gl_FragColor.w = 1.0; gl_FragColor.w = 1.0;
float r = n4rand_ss(gl_FragCoord.xy) / 40.0; float r = n4rand_ss(gl_FragCoord.xy) / 40.0;

View File

@@ -6,4 +6,4 @@ vec3 v_viewDir : TEXCOORD2 = vec3(0.0, 0.0, 1.0);
vec3 a_position : POSITION; vec3 a_position : POSITION;
vec4 a_normal : NORMAL; vec4 a_normal : NORMAL;
vec2 a_texcoord0 : TEXCOORD0; vec2 a_texcoord0 : TEXCOORD0;

View File

@@ -51,7 +51,7 @@ void main()
//transform World space aaBox to NDC //transform World space aaBox to NDC
vec4 clipPos = mul( u_viewProj, vec4(boxCorners[i], 1) ); vec4 clipPos = mul( u_viewProj, vec4(boxCorners[i], 1) );
#if BGFX_SHADER_LANGUAGE_GLSL #if BGFX_SHADER_LANGUAGE_GLSL
clipPos.z = 0.5 * ( clipPos.z + clipPos.w ); clipPos.z = 0.5 * ( clipPos.z + clipPos.w );
#endif #endif
clipPos.z = max(clipPos.z, 0); clipPos.z = max(clipPos.z, 0);

View File

@@ -1200,5 +1200,3 @@ ENTRY_IMPLEMENT_MAIN(
, "Adaptive Screen Space Ambient Occlusion." , "Adaptive Screen Space Ambient Occlusion."
, "https://bkaradzic.github.io/bgfx/examples.html#assao" , "https://bkaradzic.github.io/bgfx/examples.html#assao"
); );

View File

@@ -3,11 +3,11 @@
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "bgfx_compute.sh" #include "bgfx_compute.sh"
#include "uniforms.sh" #include "uniforms.sh"
IMAGE2D_WO(s_target, r8, 0); IMAGE2D_WO(s_target, r8, 0);
SAMPLER2DARRAY(s_finalSSAO, 1); SAMPLER2DARRAY(s_finalSSAO, 1);
// unpacking for edges; 2 bits per edge mean 4 gradient values (0, 0.33, 0.66, 1) for smoother transitions! // unpacking for edges; 2 bits per edge mean 4 gradient values (0, 0.33, 0.66, 1) for smoother transitions!
@@ -24,7 +24,7 @@ vec4 UnpackEdges( float _packedVal )
} }
NUM_THREADS(8, 8, 1) NUM_THREADS(8, 8, 1)
void main() void main()
{ {
uvec2 dtID = uvec2(gl_GlobalInvocationID.xy) + uvec2(u_rect.xy); uvec2 dtID = uvec2(gl_GlobalInvocationID.xy) + uvec2(u_rect.xy);
if (all(lessThan(dtID.xy, u_rect.zw) ) ) if (all(lessThan(dtID.xy, u_rect.zw) ) )
@@ -36,7 +36,7 @@ void main()
// calculate index in the four deinterleaved source array texture // calculate index in the four deinterleaved source array texture
int mx = (int(pixPos.x) % 2); int mx = (int(pixPos.x) % 2);
#if BGFX_SHADER_LANGUAGE_GLSL #if BGFX_SHADER_LANGUAGE_GLSL
int dimy = imageSize(s_target).y; int dimy = imageSize(s_target).y;
int my = (int(dimy-1-pixPos.y) % 2); int my = (int(dimy-1-pixPos.y) % 2);
#else #else
int my = (int(pixPos.y) % 2); int my = (int(pixPos.y) % 2);
@@ -47,7 +47,7 @@ void main()
int id = (1-mx) + (1-my)*2; // diagonal int id = (1-mx) + (1-my)*2; // diagonal
vec2 centerVal = texelFetch(s_finalSSAO, ivec3(pixPosHalf, ic), 0 ).xy; vec2 centerVal = texelFetch(s_finalSSAO, ivec3(pixPosHalf, ic), 0 ).xy;
ao = centerVal.x; ao = centerVal.x;
#if 1 // change to 0 if you want to disable last pass high-res blur (for debugging purposes, etc.) #if 1 // change to 0 if you want to disable last pass high-res blur (for debugging purposes, etc.)
@@ -58,7 +58,7 @@ void main()
// convert index shifts to sampling offsets // convert index shifts to sampling offsets
float fmx = float(mx); float fmx = float(mx);
float fmy = float(my); float fmy = float(my);
// in case of an edge, push sampling offsets away from the edge (towards pixel center) // in case of an edge, push sampling offsets away from the edge (towards pixel center)
float fmxe = (edgesLRTB.y - edgesLRTB.x); float fmxe = (edgesLRTB.y - edgesLRTB.x);
float fmye = (edgesLRTB.w - edgesLRTB.z); float fmye = (edgesLRTB.w - edgesLRTB.z);
@@ -100,4 +100,3 @@ void main()
imageStore(s_target, ivec2(dtID.xy), ao.xxxx); imageStore(s_target, ivec2(dtID.xy), ao.xxxx);
} }
} }

View File

@@ -3,14 +3,14 @@
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "bgfx_compute.sh" #include "bgfx_compute.sh"
#include "uniforms.sh" #include "uniforms.sh"
IMAGE2D_WO(s_target, r8, 0); IMAGE2D_WO(s_target, r8, 0);
SAMPLER2DARRAY(s_finalSSAO, 1); SAMPLER2DARRAY(s_finalSSAO, 1);
NUM_THREADS(8, 8, 1) NUM_THREADS(8, 8, 1)
void main() void main()
{ {
uvec2 dtID = uvec2(gl_GlobalInvocationID.xy); uvec2 dtID = uvec2(gl_GlobalInvocationID.xy);

View File

@@ -3,7 +3,7 @@
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "bgfx_compute.sh" #include "bgfx_compute.sh"
#include "uniforms.sh" #include "uniforms.sh"
// progressive poisson-like pattern; x, y are in [-1, 1] range, .z is length( vec2(x,y) ), .w is log2( z ) // progressive poisson-like pattern; x, y are in [-1, 1] range, .z is length( vec2(x,y) ), .w is log2( z )
@@ -49,18 +49,18 @@ CONST(uint g_numTaps[5]) = { 3, 5, 12, 0, 0 };
#define SSAO_DEPTH_MIPS_ENABLE_AT_QUALITY_PRESET (2) // !!warning!! the MIP generation on the C++ side will be enabled on quality preset 2 regardless of this value, so if changing here, change the C++ side too #define SSAO_DEPTH_MIPS_ENABLE_AT_QUALITY_PRESET (2) // !!warning!! the MIP generation on the C++ side will be enabled on quality preset 2 regardless of this value, so if changing here, change the C++ side too
#define SSAO_DEPTH_MIPS_GLOBAL_OFFSET (-4.3) // best noise/quality/performance tradeoff, found empirically #define SSAO_DEPTH_MIPS_GLOBAL_OFFSET (-4.3) // best noise/quality/performance tradeoff, found empirically
// //
// !!warning!! the edge handling is hard-coded to 'disabled' on quality level 0, and enabled above, on the C++ side; while toggling it here will work for // !!warning!! the edge handling is hard-coded to 'disabled' on quality level 0, and enabled above, on the C++ side; while toggling it here will work for
// testing purposes, it will not yield performance gains (or correct results) // testing purposes, it will not yield performance gains (or correct results)
#define SSAO_DEPTH_BASED_EDGES_ENABLE_AT_QUALITY_PRESET (1) #define SSAO_DEPTH_BASED_EDGES_ENABLE_AT_QUALITY_PRESET (1)
// //
#define SSAO_REDUCE_RADIUS_NEAR_SCREEN_BORDER_ENABLE_AT_QUALITY_PRESET (99) // 99 means disabled; only helpful if artifacts at the edges caused by lack of out of screen depth data are not acceptable with the depth sampler in either clamp or mirror modes #define SSAO_REDUCE_RADIUS_NEAR_SCREEN_BORDER_ENABLE_AT_QUALITY_PRESET (99) // 99 means disabled; only helpful if artifacts at the edges caused by lack of out of screen depth data are not acceptable with the depth sampler in either clamp or mirror modes
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SAMPLER2D(s_viewspaceDepthSource, 0); SAMPLER2D(s_viewspaceDepthSource, 0);
SAMPLER2D(s_viewspaceDepthSourceMirror, 1); SAMPLER2D(s_viewspaceDepthSourceMirror, 1);
IMAGE2D_RO(s_normalmapSource, rgba8, 2); IMAGE2D_RO(s_normalmapSource, rgba8, 2);
BUFFER_RO(s_loadCounter, uint, 3); BUFFER_RO(s_loadCounter, uint, 3);
SAMPLER2D(s_importanceMap, 4); SAMPLER2D(s_importanceMap, 4);
IMAGE2D_ARRAY_RO(s_baseSSAO, rg8, 5); IMAGE2D_ARRAY_RO(s_baseSSAO, rg8, 5);
IMAGE2D_ARRAY_WO(s_target, rg8, 6); IMAGE2D_ARRAY_WO(s_target, rg8, 6);
@@ -96,7 +96,7 @@ void CalculateRadiusParameters( const float pixCenterLength, const vec2 pixelDir
// when too close, on-screen sampling disk will grow beyond screen size; limit this to avoid closeup temporal artifacts // when too close, on-screen sampling disk will grow beyond screen size; limit this to avoid closeup temporal artifacts
const float tooCloseLimitMod = saturate( pixCenterLength * u_effectSamplingRadiusNearLimitRec ) * 0.8 + 0.2; const float tooCloseLimitMod = saturate( pixCenterLength * u_effectSamplingRadiusNearLimitRec ) * 0.8 + 0.2;
effectRadius *= tooCloseLimitMod; effectRadius *= tooCloseLimitMod;
// 0.85 is to reduce the radius to allow for more samples on a slope to still stay within influence // 0.85 is to reduce the radius to allow for more samples on a slope to still stay within influence
@@ -169,7 +169,7 @@ void SSAOTapInner( const int qualityLevel, inout float obscuranceSum, inout floa
float obscurance = CalculatePixelObscurance( pixelNormal, hitDelta, falloffCalcMulSq ); float obscurance = CalculatePixelObscurance( pixelNormal, hitDelta, falloffCalcMulSq );
float weight = 1.0; float weight = 1.0;
if( qualityLevel >= SSAO_HALOING_REDUCTION_ENABLE_AT_QUALITY_PRESET ) if( qualityLevel >= SSAO_HALOING_REDUCTION_ENABLE_AT_QUALITY_PRESET )
{ {
//float reduct = max( 0, dot( hitDelta, negViewspaceDir ) ); //float reduct = max( 0, dot( hitDelta, negViewspaceDir ) );
@@ -198,7 +198,7 @@ void SSAOTap( const int qualityLevel, inout float obscuranceSum, inout float wei
// snap to pixel center (more correct obscurance math, avoids artifacts) // snap to pixel center (more correct obscurance math, avoids artifacts)
sampleOffset = round(sampleOffset); sampleOffset = round(sampleOffset);
// calculate MIP based on the sample distance from the centre, similar to as described // calculate MIP based on the sample distance from the centre, similar to as described
// in http://graphics.cs.williams.edu/papers/SAOHPG12/. // in http://graphics.cs.williams.edu/papers/SAOHPG12/.
float mipLevel = ( qualityLevel < SSAO_DEPTH_MIPS_ENABLE_AT_QUALITY_PRESET )?(0):(samplePow2Len + mipOffset); float mipLevel = ( qualityLevel < SSAO_DEPTH_MIPS_ENABLE_AT_QUALITY_PRESET )?(0):(samplePow2Len + mipOffset);
@@ -228,7 +228,7 @@ void SSAOTap( const int qualityLevel, inout float obscuranceSum, inout float wei
} }
// this function is designed to only work with half/half depth at the moment - there's a couple of hardcoded paths that expect pixel/texel size, so it will not work for full res // this function is designed to only work with half/half depth at the moment - there's a couple of hardcoded paths that expect pixel/texel size, so it will not work for full res
void GenerateSSAOShadowsInternal( out float outShadowTerm, out vec4 outEdges, out float outWeight, void GenerateSSAOShadowsInternal( out float outShadowTerm, out vec4 outEdges, out float outWeight,
const vec2 SVPos, const int qualityLevel, bool adaptiveBase) const vec2 SVPos, const int qualityLevel, bool adaptiveBase)
{ {
vec2 SVPosRounded = trunc( SVPos ); vec2 SVPosRounded = trunc( SVPos );
@@ -237,7 +237,7 @@ void GenerateSSAOShadowsInternal( out float outShadowTerm, out vec4 outEdges, ou
const uint numberOfTaps = (adaptiveBase)?(SSAO_ADAPTIVE_TAP_BASE_COUNT) : ( g_numTaps[qualityLevel] ); const uint numberOfTaps = (adaptiveBase)?(SSAO_ADAPTIVE_TAP_BASE_COUNT) : ( g_numTaps[qualityLevel] );
float pixZ, pixLZ, pixTZ, pixRZ, pixBZ; float pixZ, pixLZ, pixTZ, pixRZ, pixBZ;
#if BGFX_SHADER_LANGUAGE_GLSL #if BGFX_SHADER_LANGUAGE_GLSL
vec4 valuesUL = textureGather(s_viewspaceDepthSourceMirror, SVPosRounded * u_halfViewportPixelSize + vec2(0.0,u_halfViewportPixelSize.y), 0).wzyx; vec4 valuesUL = textureGather(s_viewspaceDepthSourceMirror, SVPosRounded * u_halfViewportPixelSize + vec2(0.0,u_halfViewportPixelSize.y), 0).wzyx;
vec4 valuesBR = textureGatherOffset(s_viewspaceDepthSourceMirror, SVPosRounded * u_halfViewportPixelSize + vec2(0.0,u_halfViewportPixelSize.y), ivec2( 1, -1 ), 0).wzyx; vec4 valuesBR = textureGatherOffset(s_viewspaceDepthSourceMirror, SVPosRounded * u_halfViewportPixelSize + vec2(0.0,u_halfViewportPixelSize.y), ivec2( 1, -1 ), 0).wzyx;
#else #else
@@ -246,7 +246,7 @@ void GenerateSSAOShadowsInternal( out float outShadowTerm, out vec4 outEdges, ou
#endif #endif
// get this pixel's viewspace depth // get this pixel's viewspace depth
pixZ = valuesUL.y; pixZ = valuesUL.y;
// get left right top bottom neighbouring pixels for edge detection (gets compiled out on qualityLevel == 0) // get left right top bottom neighbouring pixels for edge detection (gets compiled out on qualityLevel == 0)
pixLZ = valuesUL.x; pixLZ = valuesUL.x;
@@ -450,7 +450,7 @@ void GenerateSSAOShadowsInternal( out float outShadowTerm, out vec4 outEdges, ou
// calculate fadeout (1 close, gradient, 0 far) // calculate fadeout (1 close, gradient, 0 far)
float fadeOut = saturate( pixCenterPos.z * u_effectFadeOutMul + u_effectFadeOutAdd ); float fadeOut = saturate( pixCenterPos.z * u_effectFadeOutMul + u_effectFadeOutAdd );
// Reduce the SSAO shadowing if we're on the edge to remove artifacts on edges (we don't care for the lower quality one) // Reduce the SSAO shadowing if we're on the edge to remove artifacts on edges (we don't care for the lower quality one)
if( !adaptiveBase && (qualityLevel >= SSAO_DEPTH_BASED_EDGES_ENABLE_AT_QUALITY_PRESET) ) if( !adaptiveBase && (qualityLevel >= SSAO_DEPTH_BASED_EDGES_ENABLE_AT_QUALITY_PRESET) )
{ {
@@ -464,20 +464,20 @@ void GenerateSSAOShadowsInternal( out float outShadowTerm, out vec4 outEdges, ou
fadeOut *= saturate( 1.0 - edgeFadeoutFactor ); fadeOut *= saturate( 1.0 - edgeFadeoutFactor );
} }
// same as a bove, but a lot more conservative version // same as a bove, but a lot more conservative version
// fadeOut *= saturate( dot( edgesLRTB, vec4( 0.9, 0.9, 0.9, 0.9 ) ) - 2.6 ); // fadeOut *= saturate( dot( edgesLRTB, vec4( 0.9, 0.9, 0.9, 0.9 ) ) - 2.6 );
// strength // strength
obscurance = u_effectShadowStrength * obscurance; obscurance = u_effectShadowStrength * obscurance;
// clamp // clamp
obscurance = min( obscurance, u_effectShadowClamp ); obscurance = min( obscurance, u_effectShadowClamp );
// fadeout // fadeout
obscurance *= fadeOut; obscurance *= fadeOut;
// conceptually switch to occlusion with the meaning being visibility (grows with visibility, occlusion == 1 implies full visibility), // conceptually switch to occlusion with the meaning being visibility (grows with visibility, occlusion == 1 implies full visibility),
// to be in line with what is more commonly used. // to be in line with what is more commonly used.
float occlusion = 1.0 - obscurance; float occlusion = 1.0 - obscurance;
@@ -492,11 +492,11 @@ void GenerateSSAOShadowsInternal( out float outShadowTerm, out vec4 outEdges, ou
} }
NUM_THREADS(8, 8, 1) NUM_THREADS(8, 8, 1)
void main() void main()
{ {
uvec2 dtID = uvec2(gl_GlobalInvocationID.xy) + uvec2(u_rect.xy); uvec2 dtID = uvec2(gl_GlobalInvocationID.xy) + uvec2(u_rect.xy);
if (all(lessThan(dtID.xy, u_rect.zw) ) ) if (all(lessThan(dtID.xy, u_rect.zw) ) )
{ {
float outShadowTerm; float outShadowTerm;
float outWeight; float outWeight;
vec4 outEdges; vec4 outEdges;

View File

@@ -6,4 +6,4 @@
#define ASSAO_QUALITY 0 #define ASSAO_QUALITY 0
#define ASSAO_ADAPTIVE_BASE false #define ASSAO_ADAPTIVE_BASE false
#include "cs_assao_generate_q.sh" #include "cs_assao_generate_q.sh"

View File

@@ -6,4 +6,4 @@
#define ASSAO_QUALITY 1 #define ASSAO_QUALITY 1
#define ASSAO_ADAPTIVE_BASE false #define ASSAO_ADAPTIVE_BASE false
#include "cs_assao_generate_q.sh" #include "cs_assao_generate_q.sh"

View File

@@ -6,4 +6,4 @@
#define ASSAO_QUALITY 2 #define ASSAO_QUALITY 2
#define ASSAO_ADAPTIVE_BASE false #define ASSAO_ADAPTIVE_BASE false
#include "cs_assao_generate_q.sh" #include "cs_assao_generate_q.sh"

View File

@@ -6,4 +6,4 @@
#define ASSAO_QUALITY 3 #define ASSAO_QUALITY 3
#define ASSAO_ADAPTIVE_BASE false #define ASSAO_ADAPTIVE_BASE false
#include "cs_assao_generate_q.sh" #include "cs_assao_generate_q.sh"

View File

@@ -6,4 +6,4 @@
#define ASSAO_QUALITY 3 #define ASSAO_QUALITY 3
#define ASSAO_ADAPTIVE_BASE true #define ASSAO_ADAPTIVE_BASE true
#include "cs_assao_generate_q.sh" #include "cs_assao_generate_q.sh"

View File

@@ -3,13 +3,13 @@
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "bgfx_compute.sh" #include "bgfx_compute.sh"
#include "uniforms.sh" #include "uniforms.sh"
BUFFER_WO(s_loadCounter, uint, 0); BUFFER_WO(s_loadCounter, uint, 0);
NUM_THREADS(1, 1, 1) NUM_THREADS(1, 1, 1)
void main() void main()
{ {
s_loadCounter[0] = 0; s_loadCounter[0] = 0;
} }

View File

@@ -3,7 +3,7 @@
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "bgfx_compute.sh" #include "bgfx_compute.sh"
#include "uniforms.sh" #include "uniforms.sh"
IMAGE2D_WO(s_target, r8, 0); IMAGE2D_WO(s_target, r8, 0);
@@ -11,7 +11,7 @@ SAMPLER2DARRAY(s_finalSSAO, 1);
// edge-ignorant blur & apply (for the lowest quality level 0) // edge-ignorant blur & apply (for the lowest quality level 0)
NUM_THREADS(8, 8, 1) NUM_THREADS(8, 8, 1)
void main() void main()
{ {
uvec2 dtID = uvec2(gl_GlobalInvocationID.xy) + uvec2(u_rect.xy); uvec2 dtID = uvec2(gl_GlobalInvocationID.xy) + uvec2(u_rect.xy);
if (all(lessThan(dtID.xy, u_rect.zw) ) ) if (all(lessThan(dtID.xy, u_rect.zw) ) )
@@ -26,4 +26,3 @@ void main()
imageStore(s_target, ivec2(dtID.xy), avg.xxxx); imageStore(s_target, ivec2(dtID.xy), avg.xxxx);
} }
} }

View File

@@ -3,15 +3,15 @@
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "bgfx_compute.sh" #include "bgfx_compute.sh"
#include "uniforms.sh" #include "uniforms.sh"
IMAGE2D_ARRAY_WO(s_target, rg8, 0); IMAGE2D_ARRAY_WO(s_target, rg8, 0);
SAMPLER2DARRAY(s_blurInput, 1); SAMPLER2DARRAY(s_blurInput, 1);
// edge-ignorant blur in x and y directions, 9 pixels touched (for the lowest quality level 0) // edge-ignorant blur in x and y directions, 9 pixels touched (for the lowest quality level 0)
NUM_THREADS(8, 8, 1) NUM_THREADS(8, 8, 1)
void main() void main()
{ {
uvec2 dtID = uvec2(gl_GlobalInvocationID.xy) + uvec2(u_rect.xy); uvec2 dtID = uvec2(gl_GlobalInvocationID.xy) + uvec2(u_rect.xy);
if (all(lessThan(dtID.xy, u_rect.zw) ) ) if (all(lessThan(dtID.xy, u_rect.zw) ) )
@@ -34,4 +34,3 @@ void main()
imageStore(s_target, ivec3(dtID.xy,u_layer), vec4(dot( vals, 0.2.xxxx ) + centre.x * 0.2, centre.y, 0.0, 0.0)); imageStore(s_target, ivec3(dtID.xy,u_layer), vec4(dot( vals, 0.2.xxxx ) + centre.x * 0.2, centre.y, 0.0, 0.0));
} }
} }

View File

@@ -3,7 +3,7 @@
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "bgfx_compute.sh" #include "bgfx_compute.sh"
#include "uniforms.sh" #include "uniforms.sh"
IMAGE2D_WO(s_target, r8, 0); IMAGE2D_WO(s_target, r8, 0);
@@ -11,7 +11,7 @@ SAMPLER2DARRAY(s_finalSSAO, 1);
// edge-ignorant blur & apply, skipping half pixels in checkerboard pattern (for the Lowest quality level 0 and Settings::SkipHalfPixelsOnLowQualityLevel == true ) // edge-ignorant blur & apply, skipping half pixels in checkerboard pattern (for the Lowest quality level 0 and Settings::SkipHalfPixelsOnLowQualityLevel == true )
NUM_THREADS(8, 8, 1) NUM_THREADS(8, 8, 1)
void main() void main()
{ {
uvec2 dtID = uvec2(gl_GlobalInvocationID.xy) + uvec2(u_rect.xy); uvec2 dtID = uvec2(gl_GlobalInvocationID.xy) + uvec2(u_rect.xy);
if (all(lessThan(dtID.xy, u_rect.zw) ) ) if (all(lessThan(dtID.xy, u_rect.zw) ) )

View File

@@ -3,7 +3,7 @@
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "bgfx_compute.sh" #include "bgfx_compute.sh"
#include "uniforms.sh" #include "uniforms.sh"
IMAGE2D_WO(s_target, r8, 0); IMAGE2D_WO(s_target, r8, 0);
@@ -14,7 +14,7 @@ SAMPLER2D(s_importanceMap, 1);
CONST(float cSmoothenImportance) = 1.0; CONST(float cSmoothenImportance) = 1.0;
NUM_THREADS(8, 8, 1) NUM_THREADS(8, 8, 1)
void main() void main()
{ {
uvec2 dtID = uvec2(gl_GlobalInvocationID.xy); uvec2 dtID = uvec2(gl_GlobalInvocationID.xy);
@@ -31,7 +31,7 @@ void main()
#if BGFX_SHADER_LANGUAGE_GLSL #if BGFX_SHADER_LANGUAGE_GLSL
halfPixel.y = -halfPixel.y; halfPixel.y = -halfPixel.y;
#endif #endif
vec4 vals; vec4 vals;
vals.x = texture2DLod(s_importanceMap, inUV + vec2( -halfPixel.x * 3, -halfPixel.y ), 0.0 ).x; vals.x = texture2DLod(s_importanceMap, inUV + vec2( -halfPixel.x * 3, -halfPixel.y ), 0.0 ).x;
vals.y = texture2DLod(s_importanceMap, inUV + vec2( +halfPixel.x, -halfPixel.y * 3 ), 0.0 ).x; vals.y = texture2DLod(s_importanceMap, inUV + vec2( +halfPixel.x, -halfPixel.y * 3 ), 0.0 ).x;

View File

@@ -3,7 +3,7 @@
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "bgfx_compute.sh" #include "bgfx_compute.sh"
#include "uniforms.sh" #include "uniforms.sh"
IMAGE2D_WO(s_target, r8, 0); IMAGE2D_WO(s_target, r8, 0);
@@ -14,7 +14,7 @@ CONST(float cSmoothenImportance) = 1.0;
// Shaders below only needed for adaptive quality level // Shaders below only needed for adaptive quality level
NUM_THREADS(8, 8, 1) NUM_THREADS(8, 8, 1)
void main() void main()
{ {
uvec2 dtID = uvec2(gl_GlobalInvocationID.xy); uvec2 dtID = uvec2(gl_GlobalInvocationID.xy);
@@ -40,11 +40,11 @@ void main()
float retVal = mix( maxVal, avgVal, cSmoothenImportance ); float retVal = mix( maxVal, avgVal, cSmoothenImportance );
// sum the average; to avoid overflowing we assume max AO resolution is not bigger than 16384x16384; so quarter res (used here) will be 4096x4096, which leaves us with 8 bits per pixel // sum the average; to avoid overflowing we assume max AO resolution is not bigger than 16384x16384; so quarter res (used here) will be 4096x4096, which leaves us with 8 bits per pixel
uint sum = uint(saturate(retVal) * 255.0 + 0.5); uint sum = uint(saturate(retVal) * 255.0 + 0.5);
// save every 9th to avoid InterlockedAdd congestion - since we're blurring, this is good enough; compensated by multiplying LoadCounterAvgDiv by 9 // save every 9th to avoid InterlockedAdd congestion - since we're blurring, this is good enough; compensated by multiplying LoadCounterAvgDiv by 9
#if BGFX_SHADER_LANGUAGE_GLSL #if BGFX_SHADER_LANGUAGE_GLSL
if( ((dtID.x % 3) + ((dim.y-1-dtID.y) % 3)) == 0 ) if( ((dtID.x % 3) + ((dim.y-1-dtID.y) % 3)) == 0 )
#else #else
if( ((dtID.x % 3) + (dtID.y % 3)) == 0 ) if( ((dtID.x % 3) + (dtID.y % 3)) == 0 )

View File

@@ -3,10 +3,10 @@
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "bgfx_compute.sh" #include "bgfx_compute.sh"
#include "uniforms.sh" #include "uniforms.sh"
IMAGE2D_RO(s_viewspaceDepthSource0, r16f, 0); IMAGE2D_RO(s_viewspaceDepthSource0, r16f, 0);
IMAGE2D_RO(s_viewspaceDepthSource1, r16f, 1); IMAGE2D_RO(s_viewspaceDepthSource1, r16f, 1);
IMAGE2D_RO(s_viewspaceDepthSource2, r16f, 2); IMAGE2D_RO(s_viewspaceDepthSource2, r16f, 2);
IMAGE2D_RO(s_viewspaceDepthSource3, r16f, 3); IMAGE2D_RO(s_viewspaceDepthSource3, r16f, 3);
@@ -26,7 +26,7 @@ void CalculateRadiusParameters( const float pixCenterLength, const vec2 pixelDir
// when too close, on-screen sampling disk will grow beyond screen size; limit this to avoid closeup temporal artifacts // when too close, on-screen sampling disk will grow beyond screen size; limit this to avoid closeup temporal artifacts
const float tooCloseLimitMod = saturate( pixCenterLength * u_effectSamplingRadiusNearLimitRec ) * 0.8 + 0.2; const float tooCloseLimitMod = saturate( pixCenterLength * u_effectSamplingRadiusNearLimitRec ) * 0.8 + 0.2;
effectRadius *= tooCloseLimitMod; effectRadius *= tooCloseLimitMod;
// 0.85 is to reduce the radius to allow for more samples on a slope to still stay within influence // 0.85 is to reduce the radius to allow for more samples on a slope to still stay within influence
@@ -37,13 +37,13 @@ void CalculateRadiusParameters( const float pixCenterLength, const vec2 pixelDir
} }
NUM_THREADS(8, 8, 1) NUM_THREADS(8, 8, 1)
void main() void main()
{ {
uvec2 dtID = uvec2(gl_GlobalInvocationID.xy); uvec2 dtID = uvec2(gl_GlobalInvocationID.xy);
uvec2 dim = uvec2(u_rect.zw); uvec2 dim = uvec2(u_rect.zw);
if (all(lessThan(dtID.xy, dim) ) ) if (all(lessThan(dtID.xy, dim) ) )
{ {
ivec2 baseCoords = ivec2(dtID.xy) * 2; ivec2 baseCoords = ivec2(dtID.xy) * 2;
vec4 depthsArr[4]; vec4 depthsArr[4];
@@ -66,14 +66,14 @@ void main()
depthsArr[3].y = imageLoad(s_viewspaceDepthSource3, baseCoords + ivec2( 1, 0 )).x; depthsArr[3].y = imageLoad(s_viewspaceDepthSource3, baseCoords + ivec2( 1, 0 )).x;
depthsArr[3].z = imageLoad(s_viewspaceDepthSource3, baseCoords + ivec2( 0, 1 )).x; depthsArr[3].z = imageLoad(s_viewspaceDepthSource3, baseCoords + ivec2( 0, 1 )).x;
depthsArr[3].w = imageLoad(s_viewspaceDepthSource3, baseCoords + ivec2( 1, 1 )).x; depthsArr[3].w = imageLoad(s_viewspaceDepthSource3, baseCoords + ivec2( 1, 1 )).x;
const uvec2 SVPosui = uvec2( dtID.xy ); const uvec2 SVPosui = uvec2( dtID.xy );
const uint pseudoRandomA = (SVPosui.x ) + 2 * (SVPosui.y ); const uint pseudoRandomA = (SVPosui.x ) + 2 * (SVPosui.y );
float dummyUnused1; float dummyUnused1;
float dummyUnused2; float dummyUnused2;
float falloffCalcMulSq, falloffCalcAdd; float falloffCalcMulSq, falloffCalcAdd;
UNROLL UNROLL
for( int i = 0; i < 4; i++ ) for( int i = 0; i < 4; i++ )
{ {

View File

@@ -3,12 +3,12 @@
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "bgfx_compute.sh" #include "bgfx_compute.sh"
#include "uniforms.sh" #include "uniforms.sh"
SAMPLER2D(s_depthSource, 0); SAMPLER2D(s_depthSource, 0);
IMAGE2D_WO(s_target0, r16f, 1); IMAGE2D_WO(s_target0, r16f, 1);
IMAGE2D_WO(s_target1, r16f, 2); IMAGE2D_WO(s_target1, r16f, 2);
IMAGE2D_WO(s_target2, r16f, 3); IMAGE2D_WO(s_target2, r16f, 3);
IMAGE2D_WO(s_target3, r16f, 4); IMAGE2D_WO(s_target3, r16f, 4);
@@ -29,15 +29,15 @@ float ScreenSpaceToViewSpaceDepth( float screenDepth )
NUM_THREADS(8, 8, 1) NUM_THREADS(8, 8, 1)
void main() void main()
{ {
uvec2 dtID = uvec2(gl_GlobalInvocationID.xy); uvec2 dtID = uvec2(gl_GlobalInvocationID.xy);
uvec2 dim = imageSize(s_target0).xy; uvec2 dim = imageSize(s_target0).xy;
if (all(lessThan(dtID.xy, dim) ) ) if (all(lessThan(dtID.xy, dim) ) )
{ {
ivec2 baseCoord = ivec2(dtID.xy) * 2; ivec2 baseCoord = ivec2(dtID.xy) * 2;
#if BGFX_SHADER_LANGUAGE_GLSL #if BGFX_SHADER_LANGUAGE_GLSL
float a = texelFetch(s_depthSource, baseCoord + ivec2( 0, 1 ), 0).x; float a = texelFetch(s_depthSource, baseCoord + ivec2( 0, 1 ), 0).x;
float b = texelFetch(s_depthSource, baseCoord + ivec2( 1, 1 ), 0).x; float b = texelFetch(s_depthSource, baseCoord + ivec2( 1, 1 ), 0).x;
float c = texelFetch(s_depthSource, baseCoord + ivec2( 0, 0 ), 0).x; float c = texelFetch(s_depthSource, baseCoord + ivec2( 0, 0 ), 0).x;
@@ -55,4 +55,3 @@ void main()
imageStore(s_target3, ivec2(dtID.xy), ScreenSpaceToViewSpaceDepth( d ).xxxx); imageStore(s_target3, ivec2(dtID.xy), ScreenSpaceToViewSpaceDepth( d ).xxxx);
} }
} }

View File

@@ -3,7 +3,7 @@
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "bgfx_compute.sh" #include "bgfx_compute.sh"
#include "uniforms.sh" #include "uniforms.sh"
SAMPLER2D(s_depthSource, 0); SAMPLER2D(s_depthSource, 0);
@@ -68,12 +68,12 @@ vec3 CalculateNormal( const vec4 edgesLRTB, vec3 pixCenterPos, vec3 pixLPos, vec
pixelNormal += ( acceptedNormals.z ) * cross( pixRPos, pixBPos ); pixelNormal += ( acceptedNormals.z ) * cross( pixRPos, pixBPos );
pixelNormal += ( acceptedNormals.w ) * cross( pixBPos, pixLPos ); pixelNormal += ( acceptedNormals.w ) * cross( pixBPos, pixLPos );
pixelNormal = normalize( pixelNormal ); pixelNormal = normalize( pixelNormal );
return pixelNormal; return pixelNormal;
} }
NUM_THREADS(8, 8, 1) NUM_THREADS(8, 8, 1)
void main() void main()
{ {
uvec2 dtID = uvec2(gl_GlobalInvocationID.xy); uvec2 dtID = uvec2(gl_GlobalInvocationID.xy);
@@ -114,12 +114,12 @@ void main()
#if BGFX_SHADER_LANGUAGE_GLSL #if BGFX_SHADER_LANGUAGE_GLSL
// left 2 // left 2
pixZs[0][1] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( -1, 0 ) ).x ); pixZs[0][1] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( -1, 0 ) ).x );
pixZs[0][2] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( -1, -1 ) ).x ); pixZs[0][2] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( -1, -1 ) ).x );
// right 2 // right 2
pixZs[3][1] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 2, 0 ) ).x ); pixZs[3][1] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 2, 0 ) ).x );
pixZs[3][2] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 2, -1 ) ).x ); pixZs[3][2] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 2, -1 ) ).x );
// top 2 // top 2
pixZs[1][0] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 0, 1 ) ).x ); pixZs[1][0] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 0, 1 ) ).x );
@@ -130,11 +130,11 @@ void main()
pixZs[2][3] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 1, -2 ) ).x ); pixZs[2][3] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 1, -2 ) ).x );
#else #else
// left 2 // left 2
pixZs[0][1] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( -1, 0 ) ).x ); pixZs[0][1] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( -1, 0 ) ).x );
pixZs[0][2] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( -1, 1 ) ).x ); pixZs[0][2] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( -1, 1 ) ).x );
// right 2 // right 2
pixZs[3][1] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 2, 0 ) ).x ); pixZs[3][1] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 2, 0 ) ).x );
pixZs[3][2] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 2, 1 ) ).x ); pixZs[3][2] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 2, 1 ) ).x );
// top 2 // top 2
pixZs[1][0] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 0, -1 ) ).x ); pixZs[1][0] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 0, -1 ) ).x );
pixZs[2][0] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 1, -1 ) ).x ); pixZs[2][0] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 1, -1 ) ).x );
@@ -162,13 +162,13 @@ void main()
// left 2 // left 2
pixPos[0][1] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( -1.0, 0.0), pixZs[0][1] ); pixPos[0][1] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( -1.0, 0.0), pixZs[0][1] );
pixPos[0][2] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( -1.0, 1.0), pixZs[0][2] ); pixPos[0][2] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( -1.0, 1.0), pixZs[0][2] );
// right 2 // right 2
pixPos[3][1] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 2.0, 0.0), pixZs[3][1] ); pixPos[3][1] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 2.0, 0.0), pixZs[3][1] );
pixPos[3][2] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 2.0, 1.0), pixZs[3][2] ); pixPos[3][2] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 2.0, 1.0), pixZs[3][2] );
// top 2 // top 2
pixPos[1][0] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 0.0, -1.0 ), pixZs[1][0] ); pixPos[1][0] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 0.0, -1.0 ), pixZs[1][0] );
pixPos[2][0] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 1.0, -1.0 ), pixZs[2][0] ); pixPos[2][0] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 1.0, -1.0 ), pixZs[2][0] );
// bottom 2 // bottom 2
pixPos[1][3] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 0.0, 2.0 ), pixZs[1][3] ); pixPos[1][3] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 0.0, 2.0 ), pixZs[1][3] );
pixPos[2][3] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 1.0, 2.0 ), pixZs[2][3] ); pixPos[2][3] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 1.0, 2.0 ), pixZs[2][3] );

View File

@@ -3,7 +3,7 @@
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "bgfx_compute.sh" #include "bgfx_compute.sh"
#include "uniforms.sh" #include "uniforms.sh"
SAMPLER2D(s_depthSource, 0); SAMPLER2D(s_depthSource, 0);
@@ -66,12 +66,12 @@ vec3 CalculateNormal( const vec4 edgesLRTB, vec3 pixCenterPos, vec3 pixLPos, vec
pixelNormal += ( acceptedNormals.z ) * cross( pixRPos, pixBPos ); pixelNormal += ( acceptedNormals.z ) * cross( pixRPos, pixBPos );
pixelNormal += ( acceptedNormals.w ) * cross( pixBPos, pixLPos ); pixelNormal += ( acceptedNormals.w ) * cross( pixBPos, pixLPos );
pixelNormal = normalize( pixelNormal ); pixelNormal = normalize( pixelNormal );
return pixelNormal; return pixelNormal;
} }
NUM_THREADS(8, 8, 1) NUM_THREADS(8, 8, 1)
void main() void main()
{ {
uvec2 dtID = uvec2(gl_GlobalInvocationID.xy); uvec2 dtID = uvec2(gl_GlobalInvocationID.xy);
@@ -110,12 +110,12 @@ void main()
pixZs[2][2] = z3; pixZs[2][2] = z3;
#if BGFX_SHADER_LANGUAGE_GLSL #if BGFX_SHADER_LANGUAGE_GLSL
// left 2 // left 2
pixZs[0][1] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( -1, 0 ) ).x ); pixZs[0][1] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( -1, 0 ) ).x );
pixZs[0][2] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( -1, -1 ) ).x ); pixZs[0][2] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( -1, -1 ) ).x );
// right 2 // right 2
pixZs[3][1] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 2, 0 ) ).x ); pixZs[3][1] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 2, 0 ) ).x );
pixZs[3][2] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 2, -1 ) ).x ); pixZs[3][2] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 2, -1 ) ).x );
// top 2 // top 2
pixZs[1][0] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 0, 1 ) ).x ); pixZs[1][0] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 0, 1 ) ).x );
@@ -126,12 +126,12 @@ void main()
pixZs[2][3] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 1, -2 ) ).x ); pixZs[2][3] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 1, -2 ) ).x );
#else #else
// left 2 // left 2
pixZs[0][1] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( -1, 0 ) ).x ); pixZs[0][1] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( -1, 0 ) ).x );
pixZs[0][2] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( -1, 1 ) ).x ); pixZs[0][2] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( -1, 1 ) ).x );
// right 2 // right 2
pixZs[3][1] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 2, 0 ) ).x ); pixZs[3][1] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 2, 0 ) ).x );
pixZs[3][2] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 2, 1 ) ).x ); pixZs[3][2] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 2, 1 ) ).x );
// top 2 // top 2
pixZs[1][0] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 0, -1 ) ).x ); pixZs[1][0] = ScreenSpaceToViewSpaceDepth( texture2DLodOffset(s_depthSource, upperLeftUV, 0.0, ivec2( 0, -1 ) ).x );
@@ -164,13 +164,13 @@ void main()
// left 2 // left 2
pixPos[0][1] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( -1.0, 0.0), pixZs[0][1] ); pixPos[0][1] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( -1.0, 0.0), pixZs[0][1] );
//pixPos[0][2] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( -1.0, 1.0), pixZs[0][2] ); //pixPos[0][2] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( -1.0, 1.0), pixZs[0][2] );
// right 2 // right 2
//pixPos[3][1] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 2.0, 0.0), pixZs[3][1] ); //pixPos[3][1] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 2.0, 0.0), pixZs[3][1] );
pixPos[3][2] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 2.0, 1.0), pixZs[3][2] ); pixPos[3][2] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 2.0, 1.0), pixZs[3][2] );
// top 2 // top 2
pixPos[1][0] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 0.0, -1.0 ), pixZs[1][0] ); pixPos[1][0] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 0.0, -1.0 ), pixZs[1][0] );
//pixPos[2][0] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 1.0, -1.0 ), pixZs[2][0] ); //pixPos[2][0] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 1.0, -1.0 ), pixZs[2][0] );
// bottom 2 // bottom 2
//pixPos[1][3] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 0.0, 2.0 ), pixZs[1][3] ); //pixPos[1][3] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 0.0, 2.0 ), pixZs[1][3] );
pixPos[2][3] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 1.0, 2.0 ), pixZs[2][3] ); pixPos[2][3] = NDCToViewspace( upperLeftUV + viewportPixelSize * vec2( 1.0, 2.0 ), pixZs[2][3] );

View File

@@ -3,7 +3,7 @@
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "bgfx_compute.sh" #include "bgfx_compute.sh"
#include "uniforms.sh" #include "uniforms.sh"
SAMPLER2D(s_depthSource, 0); SAMPLER2D(s_depthSource, 0);
@@ -25,7 +25,7 @@ float ScreenSpaceToViewSpaceDepth( float screenDepth )
} }
NUM_THREADS(8, 8, 1) NUM_THREADS(8, 8, 1)
void main() void main()
{ {
uvec2 dtID = uvec2(gl_GlobalInvocationID.xy); uvec2 dtID = uvec2(gl_GlobalInvocationID.xy);
@@ -33,7 +33,7 @@ void main()
if (all(lessThan(dtID.xy, dim) ) ) if (all(lessThan(dtID.xy, dim) ) )
{ {
ivec2 baseCoord = ivec2(dtID.xy) * 2; ivec2 baseCoord = ivec2(dtID.xy) * 2;
#if BGFX_SHADER_LANGUAGE_GLSL #if BGFX_SHADER_LANGUAGE_GLSL
float a = texelFetch(s_depthSource, baseCoord + ivec2( 0, 1 ), 0).x; float a = texelFetch(s_depthSource, baseCoord + ivec2( 0, 1 ), 0).x;
float d = texelFetch(s_depthSource, baseCoord + ivec2( 1, 0 ), 0).x; float d = texelFetch(s_depthSource, baseCoord + ivec2( 1, 0 ), 0).x;
#else #else
@@ -45,4 +45,3 @@ void main()
imageStore(s_target1, ivec2(dtID.xy), ScreenSpaceToViewSpaceDepth( d ).xxxx); imageStore(s_target1, ivec2(dtID.xy), ScreenSpaceToViewSpaceDepth( d ).xxxx);
} }
} }

View File

@@ -3,7 +3,7 @@
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "bgfx_compute.sh" #include "bgfx_compute.sh"
#include "uniforms.sh" #include "uniforms.sh"
IMAGE2D_ARRAY_WO(s_target, rg8, 0); IMAGE2D_ARRAY_WO(s_target, rg8, 0);
@@ -27,7 +27,7 @@ vec4 UnpackEdges( float _packedVal )
void AddSample( float ssaoValue, float edgeValue, inout float sum, inout float sumWeight ) void AddSample( float ssaoValue, float edgeValue, inout float sum, inout float sumWeight )
{ {
float weight = edgeValue; float weight = edgeValue;
sum += (weight * ssaoValue); sum += (weight * ssaoValue);
sumWeight += weight; sumWeight += weight;
@@ -70,7 +70,7 @@ vec2 SampleBlurred( ivec2 inPos, vec2 coord )
// edge-sensitive blur // edge-sensitive blur
NUM_THREADS(8, 8, 1) NUM_THREADS(8, 8, 1)
void main() void main()
{ {
uvec2 dtID = uvec2(gl_GlobalInvocationID.xy) + uvec2(u_rect.xy); uvec2 dtID = uvec2(gl_GlobalInvocationID.xy) + uvec2(u_rect.xy);
if (all(lessThan(dtID.xy, u_rect.zw) ) ) if (all(lessThan(dtID.xy, u_rect.zw) ) )
@@ -79,4 +79,3 @@ void main()
imageStore(s_target, ivec3(dtID.xy, u_layer), SampleBlurred( ivec2(dtID.xy), inUV ).xyyy); imageStore(s_target, ivec3(dtID.xy, u_layer), SampleBlurred( ivec2(dtID.xy), inUV ).xyyy);
} }
} }

View File

@@ -3,7 +3,7 @@
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
#include "bgfx_compute.sh" #include "bgfx_compute.sh"
#include "uniforms.sh" #include "uniforms.sh"
IMAGE2D_ARRAY_WO(s_target, rg8, 0); IMAGE2D_ARRAY_WO(s_target, rg8, 0);
@@ -27,7 +27,7 @@ vec4 UnpackEdges( float _packedVal )
void AddSample( float ssaoValue, float edgeValue, inout float sum, inout float sumWeight ) void AddSample( float ssaoValue, float edgeValue, inout float sum, inout float sumWeight )
{ {
float weight = edgeValue; float weight = edgeValue;
sum += (weight * ssaoValue); sum += (weight * ssaoValue);
sumWeight += weight; sumWeight += weight;
@@ -71,7 +71,7 @@ vec2 SampleBlurredWide(vec3 coord)
// edge-sensitive blur (wider kernel) // edge-sensitive blur (wider kernel)
NUM_THREADS(8, 8, 1) NUM_THREADS(8, 8, 1)
void main() void main()
{ {
uvec2 dtID = uvec2(gl_GlobalInvocationID.xy) + uvec2(u_rect.xy); uvec2 dtID = uvec2(gl_GlobalInvocationID.xy) + uvec2(u_rect.xy);
if (all(lessThan(dtID.xy, u_rect.zw) ) ) if (all(lessThan(dtID.xy, u_rect.zw) ) )
@@ -80,4 +80,3 @@ void main()
imageStore(s_target, ivec3(dtID.xy,u_layer), SampleBlurredWide(vec3(inUV,0.0)).xyyy); imageStore(s_target, ivec3(dtID.xy,u_layer), SampleBlurredWide(vec3(inUV,0.0)).xyyy);
} }
} }

View File

@@ -29,7 +29,7 @@ void main()
// Expand out normal // Expand out normal
n = n*2.0-1.0; n = n*2.0-1.0;
vec3 l = normalize(vec3(-0.8,0.75,-1.0)); vec3 l = normalize(vec3(-0.8,0.75,-1.0));
light = max(0.0,dot(n,l)) * 1.2+ 0.3; light = max(0.0,dot(n,l)) * 1.2+ 0.3;
} }
float ao = 1.0; float ao = 1.0;
@@ -39,5 +39,4 @@ void main()
} }
gl_FragColor = vec4(albedoColor * light * ao, 1.0f); gl_FragColor = vec4(albedoColor * light * ao, 1.0f);
} }

View File

@@ -1,8 +1,8 @@
uniform vec4 u_params[19]; uniform vec4 u_params[19];
uniform vec4 u_rect; uniform vec4 u_rect;
#define u_viewportPixelSize u_params[0].xy #define u_viewportPixelSize u_params[0].xy
#define u_halfViewportPixelSize u_params[0].zw #define u_halfViewportPixelSize u_params[0].zw
#define u_depthUnpackConsts u_params[1].xy #define u_depthUnpackConsts u_params[1].xy
#define u_ndcToViewMul u_params[2].xy #define u_ndcToViewMul u_params[2].xy
#define u_ndcToViewAdd u_params[2].zw #define u_ndcToViewAdd u_params[2].zw

View File

@@ -3,5 +3,4 @@ vec2 a_texcoord0 : TEXCOORD0;
vec3 a_normal : NORMAL; vec3 a_normal : NORMAL;
vec2 v_texcoord0 : TEXCOORD0; vec2 v_texcoord0 : TEXCOORD0;
vec3 v_normal : NORMAL = vec3(0.0, 0.0, 1.0); vec3 v_normal : NORMAL = vec3(0.0, 0.0, 1.0);

View File

@@ -11,6 +11,5 @@ $output v_texcoord0
void main() void main()
{ {
gl_Position = mul(u_modelViewProj, vec4(a_position.xyz, 1.0) ); gl_Position = mul(u_modelViewProj, vec4(a_position.xyz, 1.0) );
v_texcoord0 = a_texcoord0; v_texcoord0 = a_texcoord0;
} }

View File

@@ -18,7 +18,7 @@ void main()
// Calculate normal. Note that compressed normal is stored in the vertices // Calculate normal. Note that compressed normal is stored in the vertices
vec3 normalObjectSpace = a_normal.xyz*2.0+-1.0; // Normal is stored in [0,1], remap to [-1,1]. vec3 normalObjectSpace = a_normal.xyz*2.0+-1.0; // Normal is stored in [0,1], remap to [-1,1].
// Transform normal into world space. // Transform normal into world space.
vec3 normalWorldSpace = mul(u_model[0], vec4(normalObjectSpace, 0.0) ).xyz; vec3 normalWorldSpace = mul(u_model[0], vec4(normalObjectSpace, 0.0) ).xyz;
// Normalize to remove (uniform...) scaling, however, recompress // Normalize to remove (uniform...) scaling, however, recompress
v_normal.xyz = normalize(normalWorldSpace)*0.5+0.5; v_normal.xyz = normalize(normalWorldSpace)*0.5+0.5;

View File

@@ -20,5 +20,5 @@ void main()
float mip = floor(MipLevel(v_texcoord0.xy, VirtualTextureSize) - MipBias); float mip = floor(MipLevel(v_texcoord0.xy, VirtualTextureSize) - MipBias);
mip = clamp(mip, 0, mipCount); mip = clamp(mip, 0, mipCount);
vec2 offset = floor(v_texcoord0.xy * PageTableSize); vec2 offset = floor(v_texcoord0.xy * PageTableSize);
gl_FragColor = vec4(floor(vec3(offset / exp2(mip), mip)) / 255.0, 1.0); gl_FragColor = vec4(floor(vec3(offset / exp2(mip), mip)) / 255.0, 1.0);
} }

View File

@@ -9,8 +9,8 @@ $input v_texcoord0
* Reference(s): * Reference(s):
* - Based on Virtual Texture Demo by Brad Blanchard * - Based on Virtual Texture Demo by Brad Blanchard
* http://web.archive.org/web/20190103162638/http://linedef.com/virtual-texture-demo.html * http://web.archive.org/web/20190103162638/http://linedef.com/virtual-texture-demo.html
*/ */
#include "../common/common.sh" #include "../common/common.sh"
#include "virtualtexture.sh" #include "virtualtexture.sh"
@@ -18,4 +18,3 @@ void main()
{ {
gl_FragColor = VirtualTexture(v_texcoord0.xy); gl_FragColor = VirtualTexture(v_texcoord0.xy);
} }

View File

@@ -2,7 +2,7 @@
* Copyright 2011-2024 Branimir Karadzic. All rights reserved. * Copyright 2011-2024 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
/* /*
* Reference(s): * Reference(s):
* - Based on Virtual Texture Demo by Brad Blanchard * - Based on Virtual Texture Demo by Brad Blanchard
@@ -33,8 +33,8 @@ float MipLevel( vec2 uv, float size )
return max( 0.5 * log2( d ), 0 ); return max( 0.5 * log2( d ), 0 );
} }
// This function samples the page table and returns the page's // This function samples the page table and returns the page's
// position and mip level. // position and mip level.
vec3 SampleTable( vec2 uv, float mip ) vec3 SampleTable( vec2 uv, float mip )
{ {
vec2 offset = fract( uv * PageTableSize ) / PageTableSize; vec2 offset = fract( uv * PageTableSize ) / PageTableSize;

View File

@@ -11,5 +11,3 @@ uniform vec4 u_params[2];
#define COMPUTE_THREAD_COUNT 32u #define COMPUTE_THREAD_COUNT 32u
#define UPDATE_INDIRECT_VALUE_DIVIDE 32u #define UPDATE_INDIRECT_VALUE_DIVIDE 32u

View File

@@ -74,7 +74,7 @@ void main()
vec4 sampleColor = texture2D(s_color, sampleTexCoord); vec4 sampleColor = texture2D(s_color, sampleTexCoord);
vec3 sampleNormal = NormalDecode(texture2D(s_normal, sampleTexCoord).xyz); vec3 sampleNormal = NormalDecode(texture2D(s_normal, sampleTexCoord).xyz);
float normalWeight = pow(saturate(dot(normal, sampleNormal)), u_sigmaNormal); float normalWeight = pow(saturate(dot(normal, sampleNormal)), u_sigmaNormal);
float sampleDepth = texture2D(s_depth, sampleTexCoord).x; float sampleDepth = texture2D(s_depth, sampleTexCoord).x;
float depthDelta = depth - sampleDepth; float depthDelta = depth - sampleDepth;
float depthWeight = exp(-abs(depthDelta) / max(1e-5, u_sigmaDepth*u_sigmaDepth)); float depthWeight = exp(-abs(depthDelta) / max(1e-5, u_sigmaDepth*u_sigmaDepth));

View File

@@ -39,7 +39,7 @@ vec3 FindNearestDepth(sampler2D _depthSampler, vec2 _texCoord) {
vec3 tcd7 = vec3(coord, texture2D(_depthSampler, coord).x); vec3 tcd7 = vec3(coord, texture2D(_depthSampler, coord).x);
coord = _texCoord + du + dv; coord = _texCoord + du + dv;
vec3 tcd8 = vec3(coord, texture2D(_depthSampler, coord).x); vec3 tcd8 = vec3(coord, texture2D(_depthSampler, coord).x);
vec3 minTcd = tcd0; vec3 minTcd = tcd0;
if (tcd1.z < minTcd.z) minTcd = tcd1; if (tcd1.z < minTcd.z) minTcd = tcd1;
if (tcd2.z < minTcd.z) minTcd = tcd2; if (tcd2.z < minTcd.z) minTcd = tcd2;
@@ -86,7 +86,7 @@ void main()
vec2 texCoordPrev = GetTexCoordPrevious(texCoord, velocity); vec2 texCoordPrev = GetTexCoordPrevious(texCoord, velocity);
vec3 colorPrev = texture2D(s_previousColor, texCoordPrev).xyz; vec3 colorPrev = texture2D(s_previousColor, texCoordPrev).xyz;
// Sample local neighborhood for variance clipping // Sample local neighborhood for variance clipping
vec2 du = vec2(u_viewTexel.x, 0.0); vec2 du = vec2(u_viewTexel.x, 0.0);
vec2 dv = vec2(0.0, u_viewTexel.y); vec2 dv = vec2(0.0, u_viewTexel.y);

View File

@@ -46,7 +46,7 @@ vec2 float32x3_to_oct(vec3 v) {
// Project the sphere onto the octahedron, and then onto the xy plane // Project the sphere onto the octahedron, and then onto the xy plane
vec2 p = v.xy * (1.0 / (abs(v.x) + abs(v.y) + abs(v.z))); vec2 p = v.xy * (1.0 / (abs(v.x) + abs(v.y) + abs(v.z)));
// Reflect the folds of the lower hemisphere over the diagonals // Reflect the folds of the lower hemisphere over the diagonals
return (v.z <= 0.0) ? ((1.0 - abs(p.yx)) * signNotZero(p)) : p; return (v.z <= 0.0) ? ((1.0 - abs(p.yx)) * signNotZero(p)) : p;
} }

View File

@@ -22,7 +22,7 @@ mat3 cotangentFrame(vec3 N, vec3 p, vec2 uv)
vec3 dp1perp = cross(N, dp1); vec3 dp1perp = cross(N, dp1);
vec3 T = dp2perp * duv1.x + dp1perp * duv2.x; vec3 T = dp2perp * duv1.x + dp1perp * duv2.x;
vec3 B = dp2perp * duv1.y + dp1perp * duv2.y; vec3 B = dp2perp * duv1.y + dp1perp * duv2.y;
// construct a scale-invariant frame // construct a scale-invariant frame
float invMax = inversesqrt(max(dot(T,T), dot(B,B))); float invMax = inversesqrt(max(dot(T,T), dot(B,B)));
return mat3(T*invMax, B*invMax, N); return mat3(T*invMax, B*invMax, N);
@@ -34,13 +34,13 @@ void main()
// get vertex normal // get vertex normal
vec3 normal = normalize(v_normal); vec3 normal = normalize(v_normal);
// get normal map normal, unpack, and calculate z // get normal map normal, unpack, and calculate z
vec3 normalMap; vec3 normalMap;
normalMap.xy = texture2D(s_normal, v_texcoord0).xy; normalMap.xy = texture2D(s_normal, v_texcoord0).xy;
normalMap.xy = normalMap.xy * 2.0 - 1.0; normalMap.xy = normalMap.xy * 2.0 - 1.0;
normalMap.z = sqrt(1.0 - dot(normalMap.xy, normalMap.xy)); normalMap.z = sqrt(1.0 - dot(normalMap.xy, normalMap.xy));
// swap x and y, because the brick texture looks flipped, don't copy this... // swap x and y, because the brick texture looks flipped, don't copy this...
normalMap.xy = normalMap.yx; normalMap.xy = normalMap.yx;
@@ -48,7 +48,7 @@ void main()
vec3 pos = v_texcoord1.xyz; // contains world space pos vec3 pos = v_texcoord1.xyz; // contains world space pos
mat3 TBN = cotangentFrame(normal, pos, v_texcoord0); mat3 TBN = cotangentFrame(normal, pos, v_texcoord0);
vec3 bumpedNormal = normalize(instMul(TBN, normalMap)); vec3 bumpedNormal = normalize(instMul(TBN, normalMap));
// need some proxy for roughness value w/o roughness texture // need some proxy for roughness value w/o roughness texture
// assume horizontal (blue) normal map is smooth, and then // assume horizontal (blue) normal map is smooth, and then
// modulate with albedo for some higher frequency detail // modulate with albedo for some higher frequency detail

View File

@@ -46,7 +46,7 @@ vec2 float32x3_to_oct(vec3 v) {
// Project the sphere onto the octahedron, and then onto the xy plane // Project the sphere onto the octahedron, and then onto the xy plane
vec2 p = v.xy * (1.0 / (abs(v.x) + abs(v.y) + abs(v.z))); vec2 p = v.xy * (1.0 / (abs(v.x) + abs(v.y) + abs(v.z)));
// Reflect the folds of the lower hemisphere over the diagonals // Reflect the folds of the lower hemisphere over the diagonals
return (v.z <= 0.0) ? ((1.0 - abs(p.yx)) * signNotZero(p)) : p; return (v.z <= 0.0) ? ((1.0 - abs(p.yx)) * signNotZero(p)) : p;
} }

View File

@@ -91,7 +91,7 @@ float BokehShapeFromAngle (float lobeCount, float radiusMin, float radiusDelta2x
return 1.0f; return 1.0f;
} }
// divide edge into some number of lobes // divide edge into some number of lobes
float invPeriod = lobeCount / (2.0 * 3.1415926); float invPeriod = lobeCount / (2.0 * 3.1415926);
float periodFraction = fract(angle * invPeriod + rotation); float periodFraction = fract(angle * invPeriod + rotation);

View File

@@ -32,7 +32,7 @@ mat3 cotangentFrame(vec3 N, vec3 p, vec2 uv)
vec3 dp1perp = cross(N, dp1); vec3 dp1perp = cross(N, dp1);
vec3 T = dp2perp * duv1.x + dp1perp * duv2.x; vec3 T = dp2perp * duv1.x + dp1perp * duv2.x;
vec3 B = dp2perp * duv1.y + dp1perp * duv2.y; vec3 B = dp2perp * duv1.y + dp1perp * duv2.y;
// construct a scale-invariant frame // construct a scale-invariant frame
float invMax = inversesqrt(max(dot(T,T), dot(B,B))); float invMax = inversesqrt(max(dot(T,T), dot(B,B)));
return mat3(T*invMax, B*invMax, N); return mat3(T*invMax, B*invMax, N);
@@ -44,13 +44,13 @@ void main()
// get vertex normal // get vertex normal
vec3 normal = normalize(v_normal); vec3 normal = normalize(v_normal);
// get normal map normal, unpack, and calculate z // get normal map normal, unpack, and calculate z
vec3 normalMap; vec3 normalMap;
normalMap.xy = texture2D(s_normal, v_texcoord0).xy; normalMap.xy = texture2D(s_normal, v_texcoord0).xy;
normalMap.xy = normalMap.xy * 2.0 - 1.0; normalMap.xy = normalMap.xy * 2.0 - 1.0;
normalMap.z = sqrt(1.0 - dot(normalMap.xy, normalMap.xy)); normalMap.z = sqrt(1.0 - dot(normalMap.xy, normalMap.xy));
// swap x and y, because the brick texture looks flipped, don't copy this... // swap x and y, because the brick texture looks flipped, don't copy this...
normalMap.xy = -normalMap.yx; normalMap.xy = -normalMap.yx;

View File

@@ -249,7 +249,7 @@
//------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------
// TODO // TODO
// ==== // ====
// - Replace transcendentals with manual versions. // - Replace transcendentals with manual versions.
//============================================================================================================================== //==============================================================================================================================
#ifdef A_GCC #ifdef A_GCC
A_STATIC AD1 AAbsD1(AD1 a){return __builtin_fabs(a);} A_STATIC AD1 AAbsD1(AD1 a){return __builtin_fabs(a);}
@@ -310,7 +310,7 @@
A_STATIC AL1 AMaxL1(AL1 a,AL1 b){return a>b?a:b;} A_STATIC AL1 AMaxL1(AL1 a,AL1 b){return a>b?a:b;}
A_STATIC AU1 AMaxU1(AU1 a,AU1 b){return a>b?a:b;} A_STATIC AU1 AMaxU1(AU1 a,AU1 b){return a>b?a:b;}
//------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------
// These follow the convention that A integer types don't have signage, until they are operated on. // These follow the convention that A integer types don't have signage, until they are operated on.
A_STATIC AL1 AMaxSL1(AL1 a,AL1 b){return (ASL1_(a)>ASL1_(b))?a:b;} A_STATIC AL1 AMaxSL1(AL1 a,AL1 b){return (ASL1_(a)>ASL1_(b))?a:b;}
A_STATIC AU1 AMaxSU1(AU1 a,AU1 b){return (ASU1_(a)>ASU1_(b))?a:b;} A_STATIC AU1 AMaxSU1(AU1 a,AU1 b){return (ASU1_(a)>ASU1_(b))?a:b;}
//------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------
@@ -1071,7 +1071,7 @@
#define AU1_AH1_AF1(a) AU1_AH1_AF1_x(AF1(a)) #define AU1_AH1_AF1(a) AU1_AH1_AF1_x(AF1(a))
//------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------
AU1 AU1_AH2_AF2_x(AF2 a){return f32tof16(a.x)|(f32tof16(a.y)<<16);} AU1 AU1_AH2_AF2_x(AF2 a){return f32tof16(a.x)|(f32tof16(a.y)<<16);}
#define AU1_AH2_AF2(a) AU1_AH2_AF2_x(AF2(a)) #define AU1_AH2_AF2(a) AU1_AH2_AF2_x(AF2(a))
#define AU1_AB4Unorm_AF4(x) D3DCOLORtoUBYTE4(AF4(x)) #define AU1_AB4Unorm_AF4(x) D3DCOLORtoUBYTE4(AF4(x))
//------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------
AF2 AF2_AH2_AU1_x(AU1 x){return AF2(f16tof32(x&0xFFFF),f16tof32(x>>16));} AF2 AF2_AH2_AU1_x(AU1 x){return AF2(f16tof32(x&0xFFFF),f16tof32(x>>16));}
@@ -1588,7 +1588,7 @@
// - V_CVT_F32_UBYTE{0,1,2,3} - Unsigned byte to float. // - V_CVT_F32_UBYTE{0,1,2,3} - Unsigned byte to float.
// - V_CVT_PKACC_U8_F32 - Float to unsigned byte (does bit-field insert into 32-bit integer). // - V_CVT_PKACC_U8_F32 - Float to unsigned byte (does bit-field insert into 32-bit integer).
// V_PERM_B32 does byte packing with ability to zero fill bytes as well. // V_PERM_B32 does byte packing with ability to zero fill bytes as well.
// - Can pull out byte values from two sources, and zero fill upper 8-bits of packed hi and lo. // - Can pull out byte values from two sources, and zero fill upper 8-bits of packed hi and lo.
//------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------
// BYTE : FLOAT - ABuc{0,1,2,3}{To,From}U1() - Designed for V_CVT_F32_UBYTE* and V_CVT_PKACCUM_U8_F32 ops. // BYTE : FLOAT - ABuc{0,1,2,3}{To,From}U1() - Designed for V_CVT_F32_UBYTE* and V_CVT_PKACCUM_U8_F32 ops.
// ==== ===== // ==== =====
@@ -1683,8 +1683,8 @@
// ENCODING (without zero-based encoding) // ENCODING (without zero-based encoding)
// ======== // ========
// 0 = unused (can be used to mean something else) // 0 = unused (can be used to mean something else)
// 1 = lowest value // 1 = lowest value
// 128 = exact zero center (zero based encoding // 128 = exact zero center (zero based encoding
// 255 = highest value // 255 = highest value
//------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------
// Zero-based [Zb] flips the MSB bit of the byte (making 128 "exact zero" actually zero). // Zero-based [Zb] flips the MSB bit of the byte (making 128 "exact zero" actually zero).
@@ -1696,8 +1696,8 @@
// 1 : -126/512 // 1 : -126/512
// 2 : -125/512 // 2 : -125/512
// ... // ...
// 128 : 0 // 128 : 0
// ... // ...
// 255 : 127/512 // 255 : 127/512
// : 1/4 (just outside the encoding range) // : 1/4 (just outside the encoding range)
//============================================================================================================================== //==============================================================================================================================
@@ -1918,7 +1918,7 @@
// - Parabolic takes 8 clocks and 8 issue slots (only fract is non-packed). // - Parabolic takes 8 clocks and 8 issue slots (only fract is non-packed).
AH1 APSinH1(AH1 x){return x*abs(x)-x;} AH1 APSinH1(AH1 x){return x*abs(x)-x;}
AH2 APSinH2(AH2 x){return x*abs(x)-x;} // AND,FMA AH2 APSinH2(AH2 x){return x*abs(x)-x;} // AND,FMA
AH1 APCosH1(AH1 x){x=AFractH1(x*AH1_(0.5)+AH1_(0.75));x=x*AH1_(2.0)-AH1_(1.0);return APSinH1(x);} AH1 APCosH1(AH1 x){x=AFractH1(x*AH1_(0.5)+AH1_(0.75));x=x*AH1_(2.0)-AH1_(1.0);return APSinH1(x);}
AH2 APCosH2(AH2 x){x=AFractH2(x*AH2_(0.5)+AH2_(0.75));x=x*AH2_(2.0)-AH2_(1.0);return APSinH2(x);} // 3x FMA, 2xFRACT, AND AH2 APCosH2(AH2 x){x=AFractH2(x*AH2_(0.5)+AH2_(0.75));x=x*AH2_(2.0)-AH2_(1.0);return APSinH2(x);} // 3x FMA, 2xFRACT, AND
AH2 APSinCosH1(AH1 x){AH1 y=AFractH1(x*AH1_(0.5)+AH1_(0.75));y=y*AH1_(2.0)-AH1_(1.0);return APSinH2(AH2(x,y));} AH2 APSinCosH1(AH1 x){AH1 y=AFractH1(x*AH1_(0.5)+AH1_(0.75));y=y*AH1_(2.0)-AH1_(1.0);return APSinH2(AH2(x,y));}
#endif #endif
@@ -2152,9 +2152,9 @@
return clamp(j.xxx,c*j.yyy,pow(c,j.zzz)*k.xxx+k.yyy);} return clamp(j.xxx,c*j.yyy,pow(c,j.zzz)*k.xxx+k.yyy);}
//------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------
// Note 'rcpX' is '1/x', where the 'x' is what would be used in AFromGamma(). // Note 'rcpX' is '1/x', where the 'x' is what would be used in AFromGamma().
AF1 AToGammaF1(AF1 c,AF1 rcpX){return pow(c,AF1_(rcpX));} AF1 AToGammaF1(AF1 c,AF1 rcpX){return pow(c,AF1_(rcpX));}
AF2 AToGammaF2(AF2 c,AF1 rcpX){return pow(c,AF2_(rcpX));} AF2 AToGammaF2(AF2 c,AF1 rcpX){return pow(c,AF2_(rcpX));}
AF3 AToGammaF3(AF3 c,AF1 rcpX){return pow(c,AF3_(rcpX));} AF3 AToGammaF3(AF3 c,AF1 rcpX){return pow(c,AF3_(rcpX));}
//------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------
AF1 AToPqF1(AF1 x){AF1 p=pow(x,AF1_(0.159302)); AF1 AToPqF1(AF1 x){AF1 p=pow(x,AF1_(0.159302));
return pow((AF1_(0.835938)+AF1_(18.8516)*p)/(AF1_(1.0)+AF1_(18.6875)*p),AF1_(78.8438));} return pow((AF1_(0.835938)+AF1_(18.8516)*p)/(AF1_(1.0)+AF1_(18.6875)*p),AF1_(78.8438));}
@@ -2188,9 +2188,9 @@
AF3 AFrom709F3(AF3 c){AF3 j=AF3(0.081/4.5,1.0/4.5,1.0/0.45);AF2 k=AF2(1.0/1.099,0.099/1.099); AF3 AFrom709F3(AF3 c){AF3 j=AF3(0.081/4.5,1.0/4.5,1.0/0.45);AF2 k=AF2(1.0/1.099,0.099/1.099);
return AZolSelF3(AZolSignedF3(c-j.xxx),c*j.yyy,pow(c*k.xxx+k.yyy,j.zzz));} return AZolSelF3(AZolSignedF3(c-j.xxx),c*j.yyy,pow(c*k.xxx+k.yyy,j.zzz));}
//------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------
AF1 AFromGammaF1(AF1 c,AF1 x){return pow(c,AF1_(x));} AF1 AFromGammaF1(AF1 c,AF1 x){return pow(c,AF1_(x));}
AF2 AFromGammaF2(AF2 c,AF1 x){return pow(c,AF2_(x));} AF2 AFromGammaF2(AF2 c,AF1 x){return pow(c,AF2_(x));}
AF3 AFromGammaF3(AF3 c,AF1 x){return pow(c,AF3_(x));} AF3 AFromGammaF3(AF3 c,AF1 x){return pow(c,AF3_(x));}
//------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------
AF1 AFromPqF1(AF1 x){AF1 p=pow(x,AF1_(0.0126833)); AF1 AFromPqF1(AF1 x){AF1 p=pow(x,AF1_(0.0126833));
return pow(ASatF1(p-AF1_(0.835938))/(AF1_(18.8516)-AF1_(18.6875)*p),AF1_(6.27739));} return pow(ASatF1(p-AF1_(0.835938))/(AF1_(18.8516)-AF1_(18.6875)*p),AF1_(6.27739));}
@@ -2292,14 +2292,14 @@
// Details, // Details,
// LANE TO 8x8 MAPPING // LANE TO 8x8 MAPPING
// =================== // ===================
// 00 01 08 09 10 11 18 19 // 00 01 08 09 10 11 18 19
// 02 03 0a 0b 12 13 1a 1b // 02 03 0a 0b 12 13 1a 1b
// 04 05 0c 0d 14 15 1c 1d // 04 05 0c 0d 14 15 1c 1d
// 06 07 0e 0f 16 17 1e 1f // 06 07 0e 0f 16 17 1e 1f
// 20 21 28 29 30 31 38 39 // 20 21 28 29 30 31 38 39
// 22 23 2a 2b 32 33 3a 3b // 22 23 2a 2b 32 33 3a 3b
// 24 25 2c 2d 34 35 3c 3d // 24 25 2c 2d 34 35 3c 3d
// 26 27 2e 2f 36 37 3e 3f // 26 27 2e 2f 36 37 3e 3f
AU2 ARmpRed8x8(AU1 a){return AU2(ABfiM(ABfe(a,2u,3u),a,1u),ABfiM(ABfe(a,3u,3u),ABfe(a,1u,2u),2u));} AU2 ARmpRed8x8(AU1 a){return AU2(ABfiM(ABfe(a,2u,3u),a,1u),ABfiM(ABfe(a,3u,3u),ABfe(a,1u,2u),2u));}
//============================================================================================================================== //==============================================================================================================================
#ifdef A_HALF #ifdef A_HALF
@@ -2356,7 +2356,7 @@
// ... // ...
// 1023 = 2^(-14)*(1-2^(-10)) = 2^(-14)*(1-1/1024) ... last denormal value // 1023 = 2^(-14)*(1-2^(-10)) = 2^(-14)*(1-1/1024) ... last denormal value
// 1024 = 2^(-14) = 1/16384 .......................... first normal value that still maps to integers // 1024 = 2^(-14) = 1/16384 .......................... first normal value that still maps to integers
// 2047 .............................................. last normal value that still maps to integers // 2047 .............................................. last normal value that still maps to integers
// Scaling limits, // Scaling limits,
// 2^15 = 32768 ...................................... largest power of 2 scaling // 2^15 = 32768 ...................................... largest power of 2 scaling
// Largest pow2 conversion mapping is at *32768, // Largest pow2 conversion mapping is at *32768,

View File

@@ -35,12 +35,12 @@
// ===== // =====
// FSR is a collection of algorithms relating to generating a higher resolution image. // FSR is a collection of algorithms relating to generating a higher resolution image.
// This specific header focuses on single-image non-temporal image scaling, and related tools. // This specific header focuses on single-image non-temporal image scaling, and related tools.
// //
// The core functions are EASU and RCAS: // The core functions are EASU and RCAS:
// [EASU] Edge Adaptive Spatial Upsampling ....... 1x to 4x area range spatial scaling, clamped adaptive elliptical filter. // [EASU] Edge Adaptive Spatial Upsampling ....... 1x to 4x area range spatial scaling, clamped adaptive elliptical filter.
// [RCAS] Robust Contrast Adaptive Sharpening .... A non-scaling variation on CAS. // [RCAS] Robust Contrast Adaptive Sharpening .... A non-scaling variation on CAS.
// RCAS needs to be applied after EASU as a separate pass. // RCAS needs to be applied after EASU as a separate pass.
// //
// Optional utility functions are: // Optional utility functions are:
// [LFGA] Linear Film Grain Applicator ........... Tool to apply film grain after scaling. // [LFGA] Linear Film Grain Applicator ........... Tool to apply film grain after scaling.
// [SRTM] Simple Reversible Tone-Mapper .......... Linear HDR {0 to FP16_MAX} to {0 to 1} and back. // [SRTM] Simple Reversible Tone-Mapper .......... Linear HDR {0 to FP16_MAX} to {0 to 1} and back.
@@ -80,7 +80,7 @@
// and limits output to the minimum and maximum of that neighborhood. // and limits output to the minimum and maximum of that neighborhood.
//------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------
// Input image requirements: // Input image requirements:
// //
// Color needs to be encoded as 3 channel[red, green, blue](e.g.XYZ not supported) // Color needs to be encoded as 3 channel[red, green, blue](e.g.XYZ not supported)
// Each channel needs to be in the range[0, 1] // Each channel needs to be in the range[0, 1]
// Any color primaries are supported // Any color primaries are supported
@@ -90,11 +90,11 @@
// There should be no noise in the input that is not at input pixel granularity // There should be no noise in the input that is not at input pixel granularity
// For performance purposes, use 32bpp formats // For performance purposes, use 32bpp formats
//------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------
// Best to apply EASU at the end of the frame after tonemapping // Best to apply EASU at the end of the frame after tonemapping
// but before film grain or composite of the UI. // but before film grain or composite of the UI.
//------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------
// Example of including this header for D3D HLSL : // Example of including this header for D3D HLSL :
// //
// #define A_GPU 1 // #define A_GPU 1
// #define A_HLSL 1 // #define A_HLSL 1
// #define A_HALF 1 // #define A_HALF 1
@@ -103,9 +103,9 @@
// #define FSR_RCAS_H 1 // #define FSR_RCAS_H 1
// //declare input callbacks // //declare input callbacks
// #include "ffx_fsr1.h" // #include "ffx_fsr1.h"
// //
// Example of including this header for Vulkan GLSL : // Example of including this header for Vulkan GLSL :
// //
// #define A_GPU 1 // #define A_GPU 1
// #define A_GLSL 1 // #define A_GLSL 1
// #define A_HALF 1 // #define A_HALF 1
@@ -114,9 +114,9 @@
// #define FSR_RCAS_H 1 // #define FSR_RCAS_H 1
// //declare input callbacks // //declare input callbacks
// #include "ffx_fsr1.h" // #include "ffx_fsr1.h"
// //
// Example of including this header for Vulkan HLSL : // Example of including this header for Vulkan HLSL :
// //
// #define A_GPU 1 // #define A_GPU 1
// #define A_HLSL 1 // #define A_HLSL 1
// #define A_HLSL_6_2 1 // #define A_HLSL_6_2 1
@@ -127,11 +127,11 @@
// #define FSR_RCAS_H 1 // #define FSR_RCAS_H 1
// //declare input callbacks // //declare input callbacks
// #include "ffx_fsr1.h" // #include "ffx_fsr1.h"
// //
// Example of declaring the required input callbacks for GLSL : // Example of declaring the required input callbacks for GLSL :
// The callbacks need to gather4 for each color channel using the specified texture coordinate 'p'. // The callbacks need to gather4 for each color channel using the specified texture coordinate 'p'.
// EASU uses gather4 to reduce position computation logic and for free Arrays of Structures to Structures of Arrays conversion. // EASU uses gather4 to reduce position computation logic and for free Arrays of Structures to Structures of Arrays conversion.
// //
// AH4 FsrEasuRH(AF2 p){return AH4(textureGather(sampler2D(tex,sam),p,0));} // AH4 FsrEasuRH(AF2 p){return AH4(textureGather(sampler2D(tex,sam),p,0));}
// AH4 FsrEasuGH(AF2 p){return AH4(textureGather(sampler2D(tex,sam),p,1));} // AH4 FsrEasuGH(AF2 p){return AH4(textureGather(sampler2D(tex,sam),p,1));}
// AH4 FsrEasuBH(AF2 p){return AH4(textureGather(sampler2D(tex,sam),p,2));} // AH4 FsrEasuBH(AF2 p){return AH4(textureGather(sampler2D(tex,sam),p,2));}
@@ -611,7 +611,7 @@ A_STATIC void FsrEasuConOffset(
// RCAS is based on the following logic. // RCAS is based on the following logic.
// RCAS uses a 5 tap filter in a cross pattern (same as CAS), // RCAS uses a 5 tap filter in a cross pattern (same as CAS),
// w n // w n
// w 1 w for taps w m e // w 1 w for taps w m e
// w s // w s
// Where 'w' is the negative lobe weight. // Where 'w' is the negative lobe weight.
// output = (w*(n+e+w+s)+m)/(4*w+1) // output = (w*(n+e+w+s)+m)/(4*w+1)
@@ -630,16 +630,16 @@ A_STATIC void FsrEasuConOffset(
// This is used as a noise detection filter, to reduce the effect of RCAS on grain, and focus on real edges. // This is used as a noise detection filter, to reduce the effect of RCAS on grain, and focus on real edges.
// //
// GLSL example for the required callbacks : // GLSL example for the required callbacks :
// //
// AH4 FsrRcasLoadH(ASW2 p){return AH4(imageLoad(imgSrc,ASU2(p)));} // AH4 FsrRcasLoadH(ASW2 p){return AH4(imageLoad(imgSrc,ASU2(p)));}
// void FsrRcasInputH(inout AH1 r,inout AH1 g,inout AH1 b) // void FsrRcasInputH(inout AH1 r,inout AH1 g,inout AH1 b)
// { // {
// //do any simple input color conversions here or leave empty if none needed // //do any simple input color conversions here or leave empty if none needed
// } // }
// //
// FsrRcasCon need to be called from the CPU or GPU to set up constants. // FsrRcasCon need to be called from the CPU or GPU to set up constants.
// Including a GPU example here, the 'con' value would be stored out to a constant buffer. // Including a GPU example here, the 'con' value would be stored out to a constant buffer.
// //
// AU4 con; // AU4 con;
// FsrRcasCon(con, // FsrRcasCon(con,
// 0.0); // The scale is {0.0 := maximum sharpness, to N>0, where N is the number of stops (halving) of the reduction of sharpness}. // 0.0); // The scale is {0.0 := maximum sharpness, to N>0, where N is the number of stops (halving) of the reduction of sharpness}.
@@ -691,7 +691,7 @@ AF1 sharpness){
AU2 ip, // Integer pixel position in output. AU2 ip, // Integer pixel position in output.
AU4 con){ // Constant generated by RcasSetup(). AU4 con){ // Constant generated by RcasSetup().
// Algorithm uses minimal 3x3 pixel neighborhood. // Algorithm uses minimal 3x3 pixel neighborhood.
// b // b
// d e f // d e f
// h // h
ASU2 sp=ASU2(ip); ASU2 sp=ASU2(ip);
@@ -766,7 +766,7 @@ AF1 sharpness){
pixR=(lobe*bR+lobe*dR+lobe*hR+lobe*fR+eR)*rcpL; pixR=(lobe*bR+lobe*dR+lobe*hR+lobe*fR+eR)*rcpL;
pixG=(lobe*bG+lobe*dG+lobe*hG+lobe*fG+eG)*rcpL; pixG=(lobe*bG+lobe*dG+lobe*hG+lobe*fG+eG)*rcpL;
pixB=(lobe*bB+lobe*dB+lobe*hB+lobe*fB+eB)*rcpL; pixB=(lobe*bB+lobe*dB+lobe*hB+lobe*fB+eB)*rcpL;
return;} return;}
#endif #endif
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -789,7 +789,7 @@ AF1 sharpness){
AU2 ip, // Integer pixel position in output. AU2 ip, // Integer pixel position in output.
AU4 con){ // Constant generated by RcasSetup(). AU4 con){ // Constant generated by RcasSetup().
// Sharpening algorithm uses minimal 3x3 pixel neighborhood. // Sharpening algorithm uses minimal 3x3 pixel neighborhood.
// b // b
// d e f // d e f
// h // h
ASW2 sp=ASW2(ip); ASW2 sp=ASW2(ip);

View File

@@ -31,7 +31,7 @@ mat3 cotangentFrame(vec3 N, vec3 p, vec2 uv)
vec3 dp1perp = cross(N, dp1); vec3 dp1perp = cross(N, dp1);
vec3 T = dp2perp * duv1.x + dp1perp * duv2.x; vec3 T = dp2perp * duv1.x + dp1perp * duv2.x;
vec3 B = dp2perp * duv1.y + dp1perp * duv2.y; vec3 B = dp2perp * duv1.y + dp1perp * duv2.y;
// construct a scale-invariant frame // construct a scale-invariant frame
float invMax = inversesqrt(max(dot(T,T), dot(B,B))); float invMax = inversesqrt(max(dot(T,T), dot(B,B)));
return mat3(T*invMax, B*invMax, N); return mat3(T*invMax, B*invMax, N);
@@ -43,13 +43,13 @@ void main()
// get vertex normal // get vertex normal
vec3 normal = normalize(v_normal); vec3 normal = normalize(v_normal);
// get normal map normal, unpack, and calculate z // get normal map normal, unpack, and calculate z
vec3 normalMap; vec3 normalMap;
normalMap.xy = texture2D(s_normal, v_texcoord0).xy; normalMap.xy = texture2D(s_normal, v_texcoord0).xy;
normalMap.xy = normalMap.xy * 2.0 - 1.0; normalMap.xy = normalMap.xy * 2.0 - 1.0;
normalMap.z = sqrt(1.0 - dot(normalMap.xy, normalMap.xy)); normalMap.z = sqrt(1.0 - dot(normalMap.xy, normalMap.xy));
// swap x and y, because the brick texture looks flipped, don't copy this... // swap x and y, because the brick texture looks flipped, don't copy this...
normalMap.xy = -normalMap.yx; normalMap.xy = -normalMap.yx;

View File

@@ -4,18 +4,18 @@ $input v_position, v_texcoord0
* Copyright 2022 Preetish Kakkar. All rights reserved. * Copyright 2022 Preetish Kakkar. All rights reserved.
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */
/* /*
Most of the code is inspired/ported from https://github.com/mmikk/hextile-demo/blob/main/hextile-demo/shader_lighting.hlsl Most of the code is inspired/ported from https://github.com/mmikk/hextile-demo/blob/main/hextile-demo/shader_lighting.hlsl
The basic idea behind the algorithm is to use tiling & blending schema but instead of regular linear blending, the algorithm uses blending operator that prevents visual artifacts caused by linear blending The basic idea behind the algorithm is to use tiling & blending schema but instead of regular linear blending, the algorithm uses blending operator that prevents visual artifacts caused by linear blending
We partition the uv-space on a triangle grid and compute the local triangle and the barycentric coordinates inside the triangle. We use a hash function to associate a random offset with each vertex of the triangle We partition the uv-space on a triangle grid and compute the local triangle and the barycentric coordinates inside the triangle. We use a hash function to associate a random offset with each vertex of the triangle
grid and use this random offset to fetch the example texture. grid and use this random offset to fetch the example texture.
Finally, we blend the result using the barycentric coordinates as blending weights. Finally, we blend the result using the barycentric coordinates as blending weights.
*/ */
#include "../common/common.sh" #include "../common/common.sh"
@@ -56,7 +56,7 @@ mat2 LoadRot2x2(vec2 idx, float rotStrength)
float angle = abs(idx.x * idx.y) + abs(idx.x + idx.y) + M_PI; float angle = abs(idx.x * idx.y) + abs(idx.x + idx.y) + M_PI;
// remap to +/-pi // remap to +/-pi
//angle = fmod(angle, 2.0*M_PI); //angle = fmod(angle, 2.0*M_PI);
if (angle < 0.0) angle += 2.0 * M_PI; if (angle < 0.0) angle += 2.0 * M_PI;
if (angle > M_PI) angle -= 2.0 * M_PI; if (angle > M_PI) angle -= 2.0 * M_PI;
@@ -108,7 +108,7 @@ void TriangleGrid(out float w1, out float w2, out float w3,
vec2 uv) vec2 uv)
{ {
// Scaling of the input // Scaling of the input
uv *= 2.0 * sqrt(3.0); // controls the size of the input with respect to the size of the tiles. uv *= 2.0 * sqrt(3.0); // controls the size of the input with respect to the size of the tiles.
// Skew input space into simplex triangle grid // Skew input space into simplex triangle grid
const mat2 gridToSkewedGrid = const mat2 gridToSkewedGrid =
@@ -157,7 +157,7 @@ void hex2colTex(out vec4 color, out vec3 weights, vec2 uv,
vec2 uv3 = mul(uv - cen3, rot3) + cen3 + hash(vertex3); vec2 uv3 = mul(uv - cen3, rot3) + cen3 + hash(vertex3);
// Fetch input // Fetch input
// We could simply use texture2D function, however, the screen space derivatives could be broken // We could simply use texture2D function, however, the screen space derivatives could be broken
// since we are using random offsets, we use texture2DGrad to make sure that we pass correct derivatives explicitly. // since we are using random offsets, we use texture2DGrad to make sure that we pass correct derivatives explicitly.
vec4 c1 = texture2DGrad(s_trx_d, uv1, vec4 c1 = texture2DGrad(s_trx_d, uv1,
mul(dSTdx, rot1), mul(dSTdy, rot1)); mul(dSTdx, rot1), mul(dSTdy, rot1));
@@ -175,7 +175,7 @@ void hex2colTex(out vec4 color, out vec3 weights, vec2 uv,
W /= (W.x + W.y + W.z); W /= (W.x + W.y + W.z);
if (r != 0.5) W = Gain3(W, r); if (r != 0.5) W = Gain3(W, r);
// blend weights with color linearly // blend weights with color linearly
// histogram preserving blending will be better but requires precompution step to create histogram texture // histogram preserving blending will be better but requires precompution step to create histogram texture
color = W.x * c1 + W.y * c2 + W.z * c3; color = W.x * c1 + W.y * c2 + W.z * c3;
weights = ProduceHexWeights(W.xyz, vertex1, vertex2, vertex3); weights = ProduceHexWeights(W.xyz, vertex1, vertex2, vertex3);
@@ -202,16 +202,16 @@ void main()
vec3 sp = GetTileRate() * surfPosInWorld; vec3 sp = GetTileRate() * surfPosInWorld;
vec2 uv0 = vec2(sp.x, sp.z); vec2 uv0 = vec2(sp.x, sp.z);
if(u_useRegularTiling > 0.0) if(u_useRegularTiling > 0.0)
{ {
gl_FragColor = vec4(texture2D(s_trx_d, uv0.xy)); gl_FragColor = vec4(texture2D(s_trx_d, uv0.xy));
} }
else else
{ {
vec3 color, weights; vec3 color, weights;
FetchColorAndWeight(color, weights, uv0); FetchColorAndWeight(color, weights, uv0);
if (u_showWeights > 0.0) if (u_showWeights > 0.0)
{ {
gl_FragColor = vec4(weights, 1.0); gl_FragColor = vec4(weights, 1.0);
@@ -222,5 +222,5 @@ void main()
} }
} }
} }

View File

@@ -7585,4 +7585,3 @@ vn -0.567090 0.776659 -0.274245
vn -0.672016 0.735228 0.088511 vn -0.672016 0.735228 0.088511
vn -0.516133 0.848043 0.120122 vn -0.516133 0.848043 0.120122
vn -0.398125 0.839839 -0.369008 vn -0.398125 0.839839 -0.369008

View File

@@ -5291,4 +5291,3 @@ vn -0.516133 0.848043 0.120122
vn -0.294180 0.754159 -0.587114 vn -0.294180 0.754159 -0.587114
vn -0.371250 0.704178 -0.605233 vn -0.371250 0.704178 -0.605233
vn -0.672016 0.735228 0.088511 vn -0.672016 0.735228 0.088511

View File

@@ -2609,4 +2609,3 @@ vn -0.516133 0.848043 0.120122
vn -0.294180 0.754159 -0.587114 vn -0.294180 0.754159 -0.587114
vn -0.523407 0.573721 -0.629991 vn -0.523407 0.573721 -0.629991
vn -0.741276 0.667292 0.072325 vn -0.741276 0.667292 0.072325

View File

@@ -1,4 +1,4 @@
/* /*
* Copyright 2013 Jeremie Roy. All rights reserved. * Copyright 2013 Jeremie Roy. All rights reserved.
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/ */

View File

@@ -522,7 +522,7 @@ float FontManager::getKerning(FontHandle _handle, CodePoint _prevCodePoint, Code
if (isValid(cachedFont.masterFontHandle)) if (isValid(cachedFont.masterFontHandle))
{ {
CachedFont& baseFont = m_cachedFonts[cachedFont.masterFontHandle.idx]; CachedFont& baseFont = m_cachedFonts[cachedFont.masterFontHandle.idx];
return baseFont.trueTypeFont->m_scale return baseFont.trueTypeFont->m_scale
* stbtt_GetCodepointKernAdvance(&baseFont.trueTypeFont->m_font, _prevCodePoint, _codePoint) * stbtt_GetCodepointKernAdvance(&baseFont.trueTypeFont->m_font, _prevCodePoint, _codePoint)
* cachedFont.fontInfo.scale; * cachedFont.fontInfo.scale;
} }

View File

@@ -9,7 +9,7 @@ uniform vec4 u_params;
#define u_distanceMultiplier u_params.y #define u_distanceMultiplier u_params.y
void main() void main()
{ {
vec4 color = textureCube(s_texColor, v_texcoord0.xyz); vec4 color = textureCube(s_texColor, v_texcoord0.xyz);
int index = int(v_texcoord0.w*4.0 + 0.5); int index = int(v_texcoord0.w*4.0 + 0.5);
float rgba[4]; float rgba[4];

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de> // Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>
// See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details. // See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
// //
// Permission is hereby granted, free of charge, to any person obtaining a // Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"), // copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation // to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, // the rights to use, copy, modify, merge, publish, distribute, sublicense,

View File

@@ -7,5 +7,5 @@ SAMPLER2D(s_tex, 0);
void main() void main()
{ {
vec4 texel = texture2D(s_tex, v_texcoord0); vec4 texel = texture2D(s_tex, v_texcoord0);
gl_FragColor = texel * v_color0; gl_FragColor = texel * v_color0;
} }

View File

@@ -10,4 +10,3 @@ void main()
v_texcoord0 = a_texcoord0; v_texcoord0 = a_texcoord0;
v_color0 = a_color0; v_color0 = a_color0;
} }

View File

@@ -1 +1 @@
* *

View File

@@ -1 +1 @@
* *

View File

@@ -1,4 +1,4 @@
Stripped down from project Gutenberg's Stripped down from project Gutenberg's
"The Adventures of Sherlock Holmes", by Arthur Conan Doyle "The Adventures of Sherlock Holmes", by Arthur Conan Doyle
This eBook is for the use of anyone anywhere at no cost and with This eBook is for the use of anyone anywhere at no cost and with
@@ -1133,4 +1133,4 @@ of Bohemia, and how the best plans of Mr. Sherlock Holmes were
beaten by a woman's wit. He used to make merry over the beaten by a woman's wit. He used to make merry over the
cleverness of women, but I have not heard him do it of late. And cleverness of women, but I have not heard him do it of late. And
when he speaks of Irene Adler, or when he refers to her when he speaks of Irene Adler, or when he refers to her
photograph, it is always under the honourable title of the woman. photograph, it is always under the honourable title of the woman.

View File

@@ -550,7 +550,7 @@ typedef struct bgfx_caps_limits_s
typedef struct bgfx_caps_s typedef struct bgfx_caps_s
{ {
bgfx_renderer_type_t rendererType; /** Renderer backend type. See: `bgfx::RendererType` */ bgfx_renderer_type_t rendererType; /** Renderer backend type. See: `bgfx::RendererType` */
/** /**
* Supported functionality. * Supported functionality.
* @attention See `BGFX_CAPS_*` flags at https://bkaradzic.github.io/bgfx/bgfx.html#available-caps * @attention See `BGFX_CAPS_*` flags at https://bkaradzic.github.io/bgfx/bgfx.html#available-caps
@@ -563,7 +563,7 @@ typedef struct bgfx_caps_s
uint8_t numGPUs; /** Number of enumerated GPUs. */ uint8_t numGPUs; /** Number of enumerated GPUs. */
bgfx_caps_gpu_t gpu[4]; /** Enumerated GPUs. */ bgfx_caps_gpu_t gpu[4]; /** Enumerated GPUs. */
bgfx_caps_limits_t limits; /** Renderer runtime limits. */ bgfx_caps_limits_t limits; /** Renderer runtime limits. */
/** /**
* Supported texture format capabilities flags: * Supported texture format capabilities flags:
* - `BGFX_CAPS_FORMAT_TEXTURE_NONE` - Texture format is not supported. * - `BGFX_CAPS_FORMAT_TEXTURE_NONE` - Texture format is not supported.
@@ -611,25 +611,25 @@ typedef struct bgfx_internal_data_s
typedef struct bgfx_platform_data_s typedef struct bgfx_platform_data_s
{ {
void* ndt; /** Native display type (*nix specific). */ void* ndt; /** Native display type (*nix specific). */
/** /**
* Native window handle. If `NULL`, bgfx will create a headless * Native window handle. If `NULL`, bgfx will create a headless
* context/device, provided the rendering API supports it. * context/device, provided the rendering API supports it.
*/ */
void* nwh; void* nwh;
/** /**
* GL context, D3D device, or Vulkan device. If `NULL`, bgfx * GL context, D3D device, or Vulkan device. If `NULL`, bgfx
* will create context/device. * will create context/device.
*/ */
void* context; void* context;
/** /**
* GL back-buffer, or D3D render target view. If `NULL` bgfx will * GL back-buffer, or D3D render target view. If `NULL` bgfx will
* create back-buffer color surface. * create back-buffer color surface.
*/ */
void* backBuffer; void* backBuffer;
/** /**
* Backbuffer depth/stencil. If `NULL`, bgfx will create a back-buffer * Backbuffer depth/stencil. If `NULL`, bgfx will create a back-buffer
* depth/stencil surface. * depth/stencil surface.
@@ -674,14 +674,14 @@ typedef struct bgfx_init_limits_s
*/ */
typedef struct bgfx_init_s typedef struct bgfx_init_s
{ {
/** /**
* Select rendering backend. When set to RendererType::Count * Select rendering backend. When set to RendererType::Count
* a default rendering backend will be selected appropriate to the platform. * a default rendering backend will be selected appropriate to the platform.
* See: `bgfx::RendererType` * See: `bgfx::RendererType`
*/ */
bgfx_renderer_type_t type; bgfx_renderer_type_t type;
/** /**
* Vendor PCI ID. If set to `BGFX_PCI_ID_NONE`, discrete and integrated * Vendor PCI ID. If set to `BGFX_PCI_ID_NONE`, discrete and integrated
* GPUs will be prioritised. * GPUs will be prioritised.
@@ -694,7 +694,7 @@ typedef struct bgfx_init_s
* - `BGFX_PCI_ID_MICROSOFT` - Microsoft adapter. * - `BGFX_PCI_ID_MICROSOFT` - Microsoft adapter.
*/ */
uint16_t vendorId; uint16_t vendorId;
/** /**
* Device ID. If set to 0 it will select first device, or device with * Device ID. If set to 0 it will select first device, or device with
* matching ID. * matching ID.
@@ -706,13 +706,13 @@ typedef struct bgfx_init_s
bgfx_platform_data_t platformData; /** Platform data. */ bgfx_platform_data_t platformData; /** Platform data. */
bgfx_resolution_t resolution; /** Backbuffer resolution and reset parameters. See: `bgfx::Resolution`. */ bgfx_resolution_t resolution; /** Backbuffer resolution and reset parameters. See: `bgfx::Resolution`. */
bgfx_init_limits_t limits; /** Configurable runtime limits parameters. */ bgfx_init_limits_t limits; /** Configurable runtime limits parameters. */
/** /**
* Provide application specific callback interface. * Provide application specific callback interface.
* See: `bgfx::CallbackI` * See: `bgfx::CallbackI`
*/ */
bgfx_callback_interface_t* callback; bgfx_callback_interface_t* callback;
/** /**
* Custom allocator. When a custom allocator is not * Custom allocator. When a custom allocator is not
* specified, bgfx uses the CRT allocator. Bgfx assumes * specified, bgfx uses the CRT allocator. Bgfx assumes

File diff suppressed because it is too large Load Diff

View File

@@ -27,57 +27,57 @@ pragma(inline,true) nothrow @nogc pure @safe{
StateBlend_ blendFuncSeparate(StateBlend_ srcRGB, StateBlend_ dstRGB, StateBlend_ srcA, StateBlend_ dstA){ StateBlend_ blendFuncSeparate(StateBlend_ srcRGB, StateBlend_ dstRGB, StateBlend_ srcA, StateBlend_ dstA){
return (srcRGB | ((dstRGB) << 4)) | ((srcA | (dstA << 4)) << 8); return (srcRGB | ((dstRGB) << 4)) | ((srcA | (dstA << 4)) << 8);
} }
///Blend equation separate. ///Blend equation separate.
StateBlendEquation_ blendEquationSeparate(StateBlendEquation_ equationRGB, StateBlendEquation_ equationA){ StateBlendEquation_ blendEquationSeparate(StateBlendEquation_ equationRGB, StateBlendEquation_ equationA){
return equationRGB | (equationA << 3); return equationRGB | (equationA << 3);
} }
///Blend function. ///Blend function.
StateBlend_ blendFunc(StateBlend_ src, StateBlend_ dst){ return blendFuncSeparate(src, dst, src, dst); } StateBlend_ blendFunc(StateBlend_ src, StateBlend_ dst){ return blendFuncSeparate(src, dst, src, dst); }
///Blend equation. ///Blend equation.
StateBlendEquation_ blendEquation(StateBlendEquation_ equation){ return blendEquationSeparate(equation, equation); } StateBlendEquation_ blendEquation(StateBlendEquation_ equation){ return blendEquationSeparate(equation, equation); }
///Utility predefined blend modes. ///Utility predefined blend modes.
enum StateBlendFunc: StateBlend_{ enum StateBlendFunc: StateBlend_{
///Additive blending. ///Additive blending.
add = blendFunc(StateBlend.one, StateBlend.one), add = blendFunc(StateBlend.one, StateBlend.one),
///Alpha blend. ///Alpha blend.
alpha = blendFunc(StateBlend.srcAlpha, StateBlend.invSrcAlpha), alpha = blendFunc(StateBlend.srcAlpha, StateBlend.invSrcAlpha),
///Selects darker color of blend. ///Selects darker color of blend.
darken = blendFunc(StateBlend.one, StateBlend.one) | blendEquation(StateBlendEquation.min), darken = blendFunc(StateBlend.one, StateBlend.one) | blendEquation(StateBlendEquation.min),
///Selects lighter color of blend. ///Selects lighter color of blend.
lighten = blendFunc(StateBlend.one, StateBlend.one) | blendEquation(StateBlendEquation.max), lighten = blendFunc(StateBlend.one, StateBlend.one) | blendEquation(StateBlendEquation.max),
///Multiplies colors. ///Multiplies colors.
multiply = blendFunc(StateBlend.dstColor, StateBlend.zero), multiply = blendFunc(StateBlend.dstColor, StateBlend.zero),
///Opaque pixels will cover the pixels directly below them without any math or algorithm applied to them. ///Opaque pixels will cover the pixels directly below them without any math or algorithm applied to them.
normal = blendFunc(StateBlend.one, StateBlend.invSrcAlpha), normal = blendFunc(StateBlend.one, StateBlend.invSrcAlpha),
///Multiplies the inverse of the blend and base colors. ///Multiplies the inverse of the blend and base colors.
screen = blendFunc(StateBlend.one, StateBlend.invSrcColor), screen = blendFunc(StateBlend.one, StateBlend.invSrcColor),
///Decreases the brightness of the base color based on the value of the blend color. ///Decreases the brightness of the base color based on the value of the blend color.
linearBurn = blendFunc(StateBlend.dstColor, StateBlend.invDstColor) | blendEquation(StateBlendEquation.sub), linearBurn = blendFunc(StateBlend.dstColor, StateBlend.invDstColor) | blendEquation(StateBlendEquation.sub),
} }
StateBlend_ blendFuncRTx(StateBlend_ src, StateBlend_ dst){ StateBlend_ blendFuncRTx(StateBlend_ src, StateBlend_ dst){
return cast(uint)(src >> StateBlend.shift) | (cast(uint)(dst >> StateBlend.shift) << 4); return cast(uint)(src >> StateBlend.shift) | (cast(uint)(dst >> StateBlend.shift) << 4);
} }
StateBlend_ blendFuncRTxE(StateBlend_ src, StateBlend_ dst, StateBlendEquation_ equation){ StateBlend_ blendFuncRTxE(StateBlend_ src, StateBlend_ dst, StateBlendEquation_ equation){
return blendFuncRTx(src, dst) | (cast(uint)(equation >> StateBlendEquation.shift) << 8); return blendFuncRTx(src, dst) | (cast(uint)(equation >> StateBlendEquation.shift) << 8);
} }
StateBlend_ blendFuncRT1(StateBlend_ src, StateBlend_ dst){ return blendFuncRTx(src, dst) << 0; } StateBlend_ blendFuncRT1(StateBlend_ src, StateBlend_ dst){ return blendFuncRTx(src, dst) << 0; }
StateBlend_ blendFuncRT2(StateBlend_ src, StateBlend_ dst){ return blendFuncRTx(src, dst) << 11; } StateBlend_ blendFuncRT2(StateBlend_ src, StateBlend_ dst){ return blendFuncRTx(src, dst) << 11; }
StateBlend_ blendFuncRT3(StateBlend_ src, StateBlend_ dst){ return blendFuncRTx(src, dst) << 22; } StateBlend_ blendFuncRT3(StateBlend_ src, StateBlend_ dst){ return blendFuncRTx(src, dst) << 22; }
StateBlend_ blendFuncRT1E(StateBlend_ src, StateBlend_ dst, StateBlendEquation_ equation){ StateBlend_ blendFuncRT1E(StateBlend_ src, StateBlend_ dst, StateBlendEquation_ equation){
return blendFuncRTxE(src, dst, equation) << 0; return blendFuncRTxE(src, dst, equation) << 0;
} }
@@ -111,7 +111,7 @@ local dKeywords = {"abstract", "alias", "align", "asm", "assert", "auto", "bool"
local function contains(table, val) local function contains(table, val)
for i=1,#table do for i=1,#table do
if table[i] == val then if table[i] == val then
return true return true
end end
end end
@@ -216,7 +216,7 @@ local function hexStr(val, bits)
str = str:sub(0, i) .. "_" .. str:sub(i+1) str = str:sub(0, i) .. "_" .. str:sub(i+1)
i = i + 5 i = i + 5
end end
return "0x" .. str return "0x" .. str
end end
@@ -272,7 +272,7 @@ local function convSomeType(arg, isFnArg)
type = type:gsub("const%s+([A-Za-z_][A-Za-z0-9_]*)%s*%*", "const(%1)*") --change `const x*` to `const(x)*` type = type:gsub("const%s+([A-Za-z_][A-Za-z0-9_]*)%s*%*", "const(%1)*") --change `const x*` to `const(x)*`
type = abbrevsToUpper(type) type = abbrevsToUpper(type)
end end
return type return type
end end
@@ -289,9 +289,9 @@ local valSubs = {
UINT8_MAX = "ubyte.max", UINT8_MAX = "ubyte.max",
UINT16_MAX = "ushort.max", UINT16_MAX = "ushort.max",
UINT32_MAX = "uint.max", UINT32_MAX = "uint.max",
BGFX_INVALID_HANDLE = "invalidHandle", BGFX_INVALID_HANDLE = "invalidHandle",
BGFX_DISCARD_ALL = "Discard.all", BGFX_DISCARD_ALL = "Discard.all",
BGFX_BUFFER_NONE = "Buffer.none", BGFX_BUFFER_NONE = "Buffer.none",
BGFX_STENCIL_NONE = "Stencil.none", BGFX_STENCIL_NONE = "Stencil.none",
@@ -318,7 +318,7 @@ local function convVal(arg, type)
val = val:gsub("INT32_MAX", "int.max") val = val:gsub("INT32_MAX", "int.max")
end end
val = convArray(val) val = convArray(val)
return val return val
end end
@@ -359,7 +359,7 @@ local function genStructMemberFn(func) --NOTE: this does not work on nested stru
line = line:gsub("@(%l)(%l+)", function(a, b) return a:upper() .. b .. ":" end) line = line:gsub("@(%l)(%l+)", function(a, b) return a:upper() .. b .. ":" end)
table.insert(st.fns, line) table.insert(st.fns, line)
end end
local hasParamsComments = false local hasParamsComments = false
for _, arg in ipairs(func.args) do for _, arg in ipairs(func.args) do
if arg.comment ~= nil then if arg.comment ~= nil then
@@ -367,11 +367,11 @@ local function genStructMemberFn(func) --NOTE: this does not work on nested stru
break break
end end
end end
if hasParamsComments then if hasParamsComments then
table.insert(st.fns, "Params:") table.insert(st.fns, "Params:")
end end
for _, arg in ipairs(func.args) do for _, arg in ipairs(func.args) do
if arg.comment ~= nil then if arg.comment ~= nil then
table.insert(st.fns, "\t" .. toIntlEnUncond(convName(arg.name:sub(2))) .. " = " .. arg.comment[1]) table.insert(st.fns, "\t" .. toIntlEnUncond(convName(arg.name:sub(2))) .. " = " .. arg.comment[1])
@@ -382,10 +382,10 @@ local function genStructMemberFn(func) --NOTE: this does not work on nested stru
end end
end end
end end
table.insert(st.fns, "*/") table.insert(st.fns, "*/")
end end
local args = {} local args = {}
for _, arg in ipairs(func.args) do for _, arg in ipairs(func.args) do
local def = "" local def = ""
@@ -398,14 +398,14 @@ local function genStructMemberFn(func) --NOTE: this does not work on nested stru
table.insert(args, convFnArgType(arg) .. " " .. toIntlEnUncond(convName(arg.name:sub(2))) .. def) table.insert(args, convFnArgType(arg) .. " " .. toIntlEnUncond(convName(arg.name:sub(2))) .. def)
end end
end end
if func.const ~= nil then if func.const ~= nil then
attribs = "const" attribs = "const"
end end
if attribs ~= "" then if attribs ~= "" then
attribs = ", memAttr: q{" .. attribs .. "}" attribs = ", memAttr: q{" .. attribs .. "}"
end end
table.insert(st.fns, string.format("{q{%s}, q{%s}, q{%s}, ext: `C++`%s},", convType(func.ret), func.name, table.concat(args, ", "), attribs)) table.insert(st.fns, string.format("{q{%s}, q{%s}, q{%s}, ext: `C++`%s},", convType(func.ret), func.name, table.concat(args, ", "), attribs))
end end
end end
@@ -431,7 +431,7 @@ function gen.gen()
local idx = 1; local idx = 1;
local r = template:gsub("$([a-zA-Z_]+)", function(what) local r = template:gsub("$([a-zA-Z_]+)", function(what)
local tmp = {} local tmp = {}
local ind_end = template:find("$"..what, idx, true) local ind_end = template:find("$"..what, idx, true)
local ind_start = ind_end local ind_start = ind_end
for j = 1, ind_end-1 do for j = 1, ind_end-1 do
@@ -442,9 +442,9 @@ function gen.gen()
break break
end end
end end
indent = string.sub(template, ind_start+1, ind_end-1) indent = string.sub(template, ind_start+1, ind_end-1)
if what == "version" then if what == "version" then
return genVersion() return genVersion()
elseif what == "structs" then elseif what == "structs" then
@@ -498,13 +498,13 @@ function converter.structs(st, name, topLvl)
for _, line in ipairs(st.comments) do for _, line in ipairs(st.comments) do
yield(line) yield(line)
end end
if topLvl then if topLvl then
yield("extern(C++, \"bgfx\") struct " .. name .. "{") yield("extern(C++, \"bgfx\") struct " .. name .. "{")
else else
yield("extern(C++) struct " .. name .. "{") yield("extern(C++) struct " .. name .. "{")
end end
local subN = 0 local subN = 0
for _, subStruct in ipairs(st.subs) do for _, subStruct in ipairs(st.subs) do
subN = subN + 1 subN = subN + 1
@@ -521,11 +521,11 @@ function converter.structs(st, name, topLvl)
if subN > 0 then if subN > 0 then
yield("\t") yield("\t")
end end
for _, line in ipairs(st.fields) do for _, line in ipairs(st.fields) do
yield(line) yield(line)
end end
if #st.fns > 0 then if #st.fns > 0 then
membersWithFns = membersWithFns .. name .. ", " membersWithFns = membersWithFns .. name .. ", "
yield("\textern(D) mixin(joinFnBinds((){") yield("\textern(D) mixin(joinFnBinds((){")
@@ -537,7 +537,7 @@ function converter.structs(st, name, topLvl)
yield("\t\treturn ret;") yield("\t\treturn ret;")
yield("\t}()));") yield("\t}()));")
end end
yield("}") yield("}")
end end
@@ -553,13 +553,13 @@ function converter.types(typ)
yield("*/") yield("*/")
end end
end end
if typ.handle then ---hnadle if typ.handle then ---hnadle
yield("extern(C++, \"bgfx\") struct " .. typ.name .. "{") yield("extern(C++, \"bgfx\") struct " .. typ.name .. "{")
yield("\tushort idx;") yield("\tushort idx;")
yield("}") yield("}")
--yield(typ.name .. " invalidHandle(){ return " .. typ.name .. "(ushort.max); }") --yield(typ.name .. " invalidHandle(){ return " .. typ.name .. "(ushort.max); }")
-- For some reason, this has never worked, so I'm commenting it out just in case it does start working suddenly. :P -- For some reason, this has never worked, so I'm commenting it out just in case it does start working suddenly. :P
--[[ --[[
elseif typ.funcptr then elseif typ.funcptr then
@@ -571,16 +571,16 @@ function converter.types(typ)
table.insert(args, convFnArgType(arg) .. " " .. convName(arg.name:sub(2)) .. def) table.insert(args, convFnArgType(arg) .. " " .. convName(arg.name:sub(2)) .. def)
end end
end end
yield(string.format("alias %s = extern(C++) %s function(%s);", typ.name, convType(typ.ret), table.concat(args, ", "))) yield(string.format("alias %s = extern(C++) %s function(%s);", typ.name, convType(typ.ret), table.concat(args, ", ")))
--]] --]]
elseif typ.enum then elseif typ.enum then
local typeName = abbrevsToUpper(typ.name:gsub("::Enum", "")) local typeName = abbrevsToUpper(typ.name:gsub("::Enum", ""))
local otherName = string.format("bgfx.fakeenum.%s.Enum", typ.name:gsub("::Enum", "")) local otherName = string.format("bgfx.fakeenum.%s.Enum", typ.name:gsub("::Enum", ""))
yield("enum " .. typeName .. ": " .. otherName .. "{") yield("enum " .. typeName .. ": " .. otherName .. "{")
table.insert(enumTypes, typeName) table.insert(enumTypes, typeName)
local vals = "" local vals = ""
for idx, enum in ipairs(typ.enum) do for idx, enum in ipairs(typ.enum) do
local comments = "" local comments = ""
@@ -598,13 +598,13 @@ function converter.types(typ)
local name = convName(toCamelCase(enum.name)) local name = convName(toCamelCase(enum.name))
yield("\t" .. name .. " = " .. otherName .. "." .. name .. ",") yield("\t" .. name .. " = " .. otherName .. "." .. name .. ",")
vals = vals .. name .. "," vals = vals .. name .. ","
local intlName = toIntlEn(enum.name) local intlName = toIntlEn(enum.name)
if intlName ~= nil then if intlName ~= nil then
yield("\t" .. convName(toCamelCase(intlName)) .. " = " .. otherName .. "." .. name .. ",") yield("\t" .. convName(toCamelCase(intlName)) .. " = " .. otherName .. "." .. name .. ",")
end end
end end
gen.fakeEnumFile = gen.fakeEnumFile .. string.format([[ gen.fakeEnumFile = gen.fakeEnumFile .. string.format([[
extern(C++, "bgfx") package final abstract class %s{ extern(C++, "bgfx") package final abstract class %s{
enum Enum{ enum Enum{
@@ -612,16 +612,16 @@ extern(C++, "bgfx") package final abstract class %s{
} }
} }
]], typeName, vals) ]], typeName, vals)
yield("\t" .. "count = " .. otherName .. ".count,") yield("\t" .. "count = " .. otherName .. ".count,")
yield("}") yield("}")
elseif typ.bits ~= nil then elseif typ.bits ~= nil then
local typeName = convName(typ.name) local typeName = convName(typ.name)
if typeName == "Caps" then if typeName == "Caps" then
typeName = "CapFlags" typeName = "CapFlags"
end end
local enumType = "uint" local enumType = "uint"
if typ.bits == 64 then if typ.bits == 64 then
enumType = "ulong" enumType = "ulong"
@@ -632,7 +632,7 @@ extern(C++, "bgfx") package final abstract class %s{
elseif typ.bits == 8 then elseif typ.bits == 8 then
enumType = "ubyte" enumType = "ubyte"
end end
local maxLen = 0 local maxLen = 0
if typ.shift then if typ.shift then
maxLen = string.len("shift") maxLen = string.len("shift")
@@ -642,10 +642,10 @@ extern(C++, "bgfx") package final abstract class %s{
for _, flag in ipairs(typ.flag) do for _, flag in ipairs(typ.flag) do
maxLen = math.max(maxLen, flag.name:len()) maxLen = math.max(maxLen, flag.name:len())
end end
yield("alias " .. typeName .. "_ = " .. enumType .. ";") yield("alias " .. typeName .. "_ = " .. enumType .. ";")
yield("enum " .. typeName .. ": " .. typeName .. "_{") yield("enum " .. typeName .. ": " .. typeName .. "_{")
local function getValOr(name) local function getValOr(name)
local t = typeName local t = typeName
if typeName == "State" then if typeName == "State" then
@@ -685,7 +685,7 @@ extern(C++, "bgfx") package final abstract class %s{
end end
return abbrevsToUpper(t) .. "." .. convName(toCamelCase(name)) return abbrevsToUpper(t) .. "." .. convName(toCamelCase(name))
end end
for idx, flag in ipairs(typ.flag) do for idx, flag in ipairs(typ.flag) do
local value = flag.value local value = flag.value
if value ~= nil then if value ~= nil then
@@ -699,7 +699,7 @@ extern(C++, "bgfx") package final abstract class %s{
end end
end end
end end
local comments = "" local comments = ""
if flag.comment ~= nil then if flag.comment ~= nil then
if #flag.comment == 1 then if #flag.comment == 1 then
@@ -712,17 +712,17 @@ extern(C++, "bgfx") package final abstract class %s{
yield("\t*/") yield("\t*/")
end end
end end
local name = convName(toCamelCase(flag.name)) local name = convName(toCamelCase(flag.name))
yield("\t" .. name .. string.rep(" ", maxLen+2 - name:len()) .. "= " .. value .. "," .. comments) yield("\t" .. name .. string.rep(" ", maxLen+2 - name:len()) .. "= " .. value .. "," .. comments)
local intlName = toIntlEn(name) local intlName = toIntlEn(name)
if intlName ~= nil then if intlName ~= nil then
intlName = intlName intlName = intlName
yield("\t" .. intlName .. string.rep(" ", maxLen+2 - intlName:len()) .. "= " .. name .. ",") yield("\t" .. intlName .. string.rep(" ", maxLen+2 - intlName:len()) .. "= " .. name .. ",")
end end
end end
if typ.shift then if typ.shift then
local name = convName("shift") local name = convName("shift")
local value = typ.shift local value = typ.shift
@@ -742,12 +742,12 @@ extern(C++, "bgfx") package final abstract class %s{
yield("\t" .. name .. string.rep(" ", maxLen+2 - name:len()) .. "= " .. value .. "," .. comments) yield("\t" .. name .. string.rep(" ", maxLen+2 - name:len()) .. "= " .. value .. "," .. comments)
end end
yield("}") yield("}")
local intlName = toIntlEn(typeName) local intlName = toIntlEn(typeName)
if intlName ~= nil then if intlName ~= nil then
yield("alias " .. intlName .. " = " .. typeName .. ";") yield("alias " .. intlName .. " = " .. typeName .. ";")
end end
if typ.helper then if typ.helper then
yield(string.format( yield(string.format(
"%s_ to%s(%s v) nothrow @nogc pure @safe{ return (v << %s) & %s; }", "%s_ to%s(%s v) nothrow @nogc pure @safe{ return (v << %s) & %s; }",
@@ -762,7 +762,7 @@ extern(C++, "bgfx") package final abstract class %s{
end end
elseif typ.struct ~= nil then elseif typ.struct ~= nil then
local st = {name = typ.name, comments = {}, fields = {}, fns = {}, subs = {}} local st = {name = typ.name, comments = {}, fields = {}, fns = {}, subs = {}}
if typ.comments ~= nil then if typ.comments ~= nil then
if #typ.comments == 1 then if #typ.comments == 1 then
table.insert(st.comments, "///" .. typ.comments[1]) table.insert(st.comments, "///" .. typ.comments[1])
@@ -774,7 +774,7 @@ extern(C++, "bgfx") package final abstract class %s{
table.insert(st.comments, "*/") table.insert(st.comments, "*/")
end end
end end
for _, member in ipairs(typ.struct) do for _, member in ipairs(typ.struct) do
local comments = "" local comments = ""
if member.comment ~= nil then if member.comment ~= nil then
@@ -793,11 +793,11 @@ extern(C++, "bgfx") package final abstract class %s{
end end
table.insert(st.fields, "\t" .. convStructMember(member) .. ";" .. comments) table.insert(st.fields, "\t" .. convStructMember(member) .. ";" .. comments)
end end
if typ.ctor ~= nil and typ.name ~= "PlatformData" then if typ.ctor ~= nil and typ.name ~= "PlatformData" then
table.insert(st.fns, "{q{void}, q{this}, q{}, ext: `C++`},") table.insert(st.fns, "{q{void}, q{this}, q{}, ext: `C++`},")
end end
if typ.namespace ~= nil then --if this is a sub-struct if typ.namespace ~= nil then --if this is a sub-struct
if allStructs[typ.namespace] ~= nil then if allStructs[typ.namespace] ~= nil then
table.insert(allStructs[typ.namespace].subs, st) table.insert(allStructs[typ.namespace].subs, st)
@@ -828,7 +828,7 @@ function converter.funcs(func)
line = line:gsub("@(%l)(%l+)", function(a, b) return a:upper() .. b .. ":" end) line = line:gsub("@(%l)(%l+)", function(a, b) return a:upper() .. b .. ":" end)
yield("* " .. line) yield("* " .. line)
end end
local hasParamsComments = false local hasParamsComments = false
for _, arg in ipairs(func.args) do for _, arg in ipairs(func.args) do
if arg.comment ~= nil then if arg.comment ~= nil then
@@ -836,11 +836,11 @@ function converter.funcs(func)
break break
end end
end end
if hasParamsComments then if hasParamsComments then
yield("Params:") yield("Params:")
end end
for _, arg in ipairs(func.args) do for _, arg in ipairs(func.args) do
if arg.comment ~= nil then if arg.comment ~= nil then
yield("\t" .. toIntlEnUncond(convName(arg.name:sub(2))) .. " = " .. arg.comment[1]) yield("\t" .. toIntlEnUncond(convName(arg.name:sub(2))) .. " = " .. arg.comment[1])
@@ -851,10 +851,10 @@ function converter.funcs(func)
end end
end end
end end
yield("*/") yield("*/")
end end
local args = {} local args = {}
for _, arg in ipairs(func.args) do for _, arg in ipairs(func.args) do
local def = "" local def = ""
@@ -867,11 +867,11 @@ function converter.funcs(func)
table.insert(args, convFnArgType(arg) .. " " .. toIntlEnUncond(convName(arg.name:sub(2))) .. def) table.insert(args, convFnArgType(arg) .. " " .. toIntlEnUncond(convName(arg.name:sub(2))) .. def)
end end
end end
if attribs ~= "" then if attribs ~= "" then
attribs = ", memAttr: q{" .. attribs .. "}" attribs = ", memAttr: q{" .. attribs .. "}"
end end
yield(string.format("{q{%s}, q{%s}, q{%s}, ext: `%s`%s},", convType(func.ret), func.name, table.concat(args, ", "), extern, attribs)) yield(string.format("{q{%s}, q{%s}, q{%s}, ext: `%s`%s},", convType(func.ret), func.name, table.concat(args, ", "), extern, attribs))
end end
end end

View File

@@ -101,7 +101,7 @@
#define IMAGE2D_WO( _name, _format, _reg) \ #define IMAGE2D_WO( _name, _format, _reg) \
WRITEONLY FORMAT(_format) RWTexture2D<COMP_ ## _format> _name : REGISTER(u, _reg); \ WRITEONLY FORMAT(_format) RWTexture2D<COMP_ ## _format> _name : REGISTER(u, _reg); \
#define UIMAGE2D_WO(_name, _format, _reg) IMAGE2D_WO(_name, _format, _reg) #define UIMAGE2D_WO(_name, _format, _reg) IMAGE2D_WO(_name, _format, _reg)
#define IMAGE2D_RW( _name, _format, _reg) \ #define IMAGE2D_RW( _name, _format, _reg) \

View File

@@ -482,7 +482,7 @@ namespace bgfx
scd.SwapEffect = _scd.swapEffect; scd.SwapEffect = _scd.swapEffect;
scd.AlphaMode = _scd.alphaMode; scd.AlphaMode = _scd.alphaMode;
scd.Flags = _scd.flags; scd.Flags = _scd.flags;
#if BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS #if BX_PLATFORM_LINUX || BX_PLATFORM_WINDOWS
IDXGIFactory5* factory5; IDXGIFactory5* factory5;
hr = m_factory->QueryInterface(IID_IDXGIFactory5, (void**)&factory5); hr = m_factory->QueryInterface(IID_IDXGIFactory5, (void**)&factory5);

View File

@@ -1072,7 +1072,7 @@ namespace bgfx { namespace mtl
void resize(FrameBufferMtl &_frameBuffer, uint32_t _width, uint32_t _height, uint32_t _flags, uint32_t _maximumDrawableCount); void resize(FrameBufferMtl &_frameBuffer, uint32_t _width, uint32_t _height, uint32_t _flags, uint32_t _maximumDrawableCount);
id <MTLTexture> currentDrawableTexture(); id <MTLTexture> currentDrawableTexture();
CAMetalLayer* m_metalLayer; CAMetalLayer* m_metalLayer;
#if BX_PLATFORM_VISIONOS #if BX_PLATFORM_VISIONOS
cp_layer_renderer_t m_layerRenderer; cp_layer_renderer_t m_layerRenderer;

View File

@@ -1 +1 @@
* *

View File

@@ -1 +1 @@
* *

View File

@@ -1 +1 @@
* *

View File

@@ -61,4 +61,4 @@ void main()
gl_FragColor.xyz = evalSh(nn); gl_FragColor.xyz = evalSh(nn);
gl_FragColor.w = 1.0; gl_FragColor.w = 1.0;
} }

Some files were not shown because too many files have changed in this diff Show More