glsl-out: make the cs adjustment to also flip Y

This commit is contained in:
Dzmitry Malyshau
2021-06-29 02:18:56 -04:00
parent ba066c83e7
commit 68a2efd3c5
3 changed files with 4 additions and 4 deletions

View File

@@ -130,7 +130,7 @@ bitflags::bitflags! {
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
pub struct WriterFlags: u32 {
/// Extend output Z from (0,1) to (-1,1).
/// Flip output Y and extend Z from (0,1) to (-1,1).
const ADJUST_COORDINATE_SPACE = 0x1;
/// Supports GL_EXT_texture_shadow_lod on the host, which provides
/// additional functions on shadows and arrays of shadows.
@@ -1520,7 +1520,7 @@ impl<'a, W: Write> Writer<'a, W> {
{
writeln!(
self.out,
"gl_Position.z = gl_Position.z * 2.0 - gl_Position.w;",
"gl_Position.yz = vec2(-gl_Position.y, gl_Position.z * 2.0 - gl_Position.w);",
)?;
write!(self.out, "{}", INDENT.repeat(indent))?;
}

View File

@@ -49,7 +49,7 @@ void main() {
type10 _tmp_return = type10(_expr10, _expr11, _expr12, _expr13, _expr14);
_vs2fs_location0 = _tmp_return.member;
gl_Position = _tmp_return.gen_gl_Position;
gl_Position.z = gl_Position.z * 2.0 - gl_Position.w;
gl_Position.yz = vec2(-gl_Position.y, gl_Position.z * 2.0 - gl_Position.w);
return;
}

View File

@@ -17,7 +17,7 @@ void main() {
VertexOutput _tmp_return = VertexOutput(uv, vec4((1.2 * pos), 0.0, 1.0));
_vs2fs_location0 = _tmp_return.uv;
gl_Position = _tmp_return.position;
gl_Position.z = gl_Position.z * 2.0 - gl_Position.w;
gl_Position.yz = vec2(-gl_Position.y, gl_Position.z * 2.0 - gl_Position.w);
return;
}