Skip to content

Commit

Permalink
Discard writes to outside of texture bounds
Browse files Browse the repository at this point in the history
According to GLSL spec calling imageStore with coordinates outside of
texture bounds has no effect, but on Intel GPUs it actually results in
writes inside the texture, causing an incorrect result. Now the writes
are bounds-checked.
  • Loading branch information
naavis committed Aug 26, 2021
1 parent 98c8cde commit b353191
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Fixed

- Writes to the outside of the result texture end up back inside the texture
on some Intel GPUs on Linux. Now they are correctly discarded again.

## 4.0.0 - 2021-08-25

### Added
Expand Down
3 changes: 3 additions & 0 deletions src/haloray-core/resources/shaders/raytrace.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,9 @@ void main(void)
vec2 projected = camera.focalLength * projectionFunction * vec2(aspectRatio * cos(polarAngle), sin(polarAngle));
vec2 normalizedCoordinates = 0.5 + projected;

if (any(lessThanEqual(normalizedCoordinates, vec2(0.0))) || any(greaterThanEqual(normalizedCoordinates, vec2(1.0))))
return;

float sunRadiance;
if (atmosphereEnabled == 1)
{
Expand Down

0 comments on commit b353191

Please sign in to comment.