-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- No default VR device parameteres inside raylib - VR device parameter should be provided by user - VR distortion shader should be provided by user
- Loading branch information
Showing
5 changed files
with
201 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#version 330 | ||
|
||
in vec2 fragTexCoord; | ||
in vec4 fragColor; | ||
out vec4 finalColor; | ||
|
||
uniform sampler2D texture0; | ||
uniform vec2 leftLensCenter = vec2(0.288, 0.5); | ||
uniform vec2 rightLensCenter = vec2(0.712, 0.5); | ||
uniform vec2 leftScreenCenter = vec2(0.25, 0.5); | ||
uniform vec2 rightScreenCenter = vec2(0.75, 0.5); | ||
uniform vec2 scale = vec2(0.25, 0.45); | ||
uniform vec2 scaleIn = vec2(4, 2.2222); | ||
uniform vec4 hmdWarpParam = vec4(1, 0.22, 0.24, 0); | ||
uniform vec4 chromaAbParam = vec4(0.996, -0.004, 1.014, 0.0); | ||
|
||
void main() | ||
{ | ||
vec2 lensCenter = fragTexCoord.x < 0.5? leftLensCenter : rightLensCenter; | ||
vec2 screenCenter = fragTexCoord.x < 0.5? leftScreenCenter : rightScreenCenter; | ||
vec2 theta = (fragTexCoord - lensCenter)*scaleIn; | ||
float rSq = theta.x*theta.x + theta.y*theta.y; | ||
vec2 theta1 = theta*(hmdWarpParam.x + hmdWarpParam.y*rSq + hmdWarpParam.z*rSq*rSq + hmdWarpParam.w*rSq*rSq*rSq); | ||
vec2 thetaBlue = theta1*(chromaAbParam.z + chromaAbParam.w*rSq); | ||
vec2 tcBlue = lensCenter + scale*thetaBlue; | ||
|
||
if (any(bvec2(clamp(tcBlue, screenCenter - vec2(0.25, 0.5), screenCenter + vec2(0.25, 0.5)) - tcBlue))) | ||
{ | ||
finalColor = vec4(0.0, 0.0, 0.0, 1.0); | ||
} | ||
else | ||
{ | ||
float blue = texture(texture0, tcBlue).b; | ||
vec2 tcGreen = lensCenter + scale*theta1; | ||
float green = texture(texture0, tcGreen).g; | ||
|
||
vec2 thetaRed = theta1*(chromaAbParam.x + chromaAbParam.y*rSq); | ||
vec2 tcRed = lensCenter + scale*thetaRed; | ||
|
||
float red = texture(texture0, tcRed).r; | ||
finalColor = vec4(red, green, blue, 1.0); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.