Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Laszlo Agocs
qtrhi
Commits
60983959
Commit
60983959
authored
Mar 20, 2019
by
Laszlo Agocs
Browse files
Fix shadowmap example for Metal
parent
8b8c7752
Changes
12
Show whitespace changes
Inline
Side-by-side
examples/rhi/shadowmap/buildshaders.bat
View file @
60983959
qsb
--glsl
120
--hlsl
50
--msl
12
-c
shadowmap
.vert
-o
shadowmap
.vert.qsb
qsb
--glsl
120
--hlsl
50
--msl
12
-c
shadowmap
.frag
-o
shadowmap
.frag.qsb
qsb
--glsl
120
--hlsl
50
--msl
12
-c
light
.vert
-o
light
.vert.qsb
qsb
--glsl
120
--hlsl
50
--msl
12
-c
light
.frag
-o
light
.frag.qsb
qsb
--glsl
120
--hlsl
50
--msl
12
-c
main
.vert
-o
main
.vert.qsb
qsb
--glsl
120
--hlsl
50
--msl
12
-c
main
.frag
-o
main
.frag.qsb
examples/rhi/shadowmap/buildshaders.sh
0 → 100755
View file @
60983959
qsb
--glsl
120
--hlsl
50
--msl
12 shadowmap.vert
-o
shadowmap.vert.qsb
qsb
--glsl
120
--hlsl
50
--msl
12 shadowmap.frag
-o
shadowmap.frag.qsb
qsb
--glsl
120
--hlsl
50
--msl
12 main.vert
-o
main.vert.qsb
qsb
--glsl
120
--hlsl
50
--msl
12 main.frag
-o
main.frag.qsb
examples/rhi/shadowmap/light.frag.qsb
deleted
100644 → 0
View file @
8b8c7752
File deleted
examples/rhi/shadowmap/light.vert.qsb
deleted
100644 → 0
View file @
8b8c7752
File deleted
examples/rhi/shadowmap/
light
.frag
→
examples/rhi/shadowmap/
main
.frag
View file @
60983959
...
...
@@ -17,7 +17,11 @@ void main()
{
vec4
adjustedLcVertPos
=
vLCVertPos
;
adjustedLcVertPos
.
z
-=
0
.
0001
;
// bias to avoid acne
float
sc
=
textureProj
(
shadowMap
,
adjustedLcVertPos
);
// no textureProj, that seems to end up not doing the perspective divide for z (?)
vec3
v
=
adjustedLcVertPos
.
xyz
/
adjustedLcVertPos
.
w
;
float
sc
=
texture
(
shadowMap
,
v
);
// sampler is comparison enabled so compares to z
float
shadowFactor
=
0
.
2
;
if
(
sc
>
0
||
ubuf
.
useShadow
==
0
)
shadowFactor
=
1
.
0
;
...
...
examples/rhi/shadowmap/main.frag.qsb
0 → 100644
View file @
60983959
File added
examples/rhi/shadowmap/
light
.vert
→
examples/rhi/shadowmap/
main
.vert
View file @
60983959
File moved
examples/rhi/shadowmap/main.vert.qsb
0 → 100644
View file @
60983959
File added
examples/rhi/shadowmap/shadowmap.cpp
View file @
60983959
...
...
@@ -128,8 +128,8 @@ void Window::customInit()
d
.
ps
=
m_r
->
newGraphicsPipeline
();
d
.
releasePool
<<
d
.
ps
;
d
.
ps
->
setShaderStages
({
{
QRhiGraphicsShaderStage
::
Vertex
,
getShader
(
QLatin1String
(
":/
light
.vert.qsb"
))
},
{
QRhiGraphicsShaderStage
::
Fragment
,
getShader
(
QLatin1String
(
":/
light
.frag.qsb"
))
}
{
QRhiGraphicsShaderStage
::
Vertex
,
getShader
(
QLatin1String
(
":/
main
.vert.qsb"
))
},
{
QRhiGraphicsShaderStage
::
Fragment
,
getShader
(
QLatin1String
(
":/
main
.frag.qsb"
))
}
});
d
.
ps
->
setDepthTest
(
true
);
d
.
ps
->
setDepthWrite
(
true
);
...
...
@@ -225,7 +225,7 @@ void Window::customRender()
if
(
m_r
->
isClipDepthZeroToOne
())
{
// convert x, y [-1, 1] -> [0, 1]
*
sbp
++
=
0.5
f
;
*
sbp
++
=
0.0
f
;
*
sbp
++
=
0.0
f
;
*
sbp
++
=
0.0
f
;
*
sbp
++
=
0.0
f
;
*
sbp
++
=
0.5
f
;
*
sbp
++
=
0.0
f
;
*
sbp
++
=
0.0
f
;
*
sbp
++
=
0.0
f
;
*
sbp
++
=
m_r
->
isYUpInNDC
()
?
-
0.5
f
:
0.5
f
;
*
sbp
++
=
0.0
f
;
*
sbp
++
=
0.0
f
;
*
sbp
++
=
0.0
f
;
*
sbp
++
=
0.0
f
;
*
sbp
++
=
1.0
f
;
*
sbp
++
=
0.0
f
;
*
sbp
++
=
0.5
f
;
*
sbp
++
=
0.5
f
;
*
sbp
++
=
0.0
f
;
*
sbp
++
=
1.0
f
;
}
else
{
...
...
examples/rhi/shadowmap/shadowmap.frag.qsb
View file @
60983959
No preview for this file type
examples/rhi/shadowmap/shadowmap.qrc
View file @
60983959
...
...
@@ -2,7 +2,7 @@
<qresource>
<file>
shadowmap.vert.qsb
</file>
<file>
shadowmap.frag.qsb
</file>
<file>
light
.vert.qsb
</file>
<file>
light
.frag.qsb
</file>
<file>
main
.vert.qsb
</file>
<file>
main
.frag.qsb
</file>
</qresource>
</RCC>
examples/rhi/shadowmap/shadowmap.vert.qsb
View file @
60983959
No preview for this file type
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment