mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-25 16:46:17 +00:00
54 lines
1.8 KiB
Text
54 lines
1.8 KiB
Text
/************************************************************************************
|
|
|
|
Filename : pp_oculus_vr.cg
|
|
Content : Barrel fragment program ported from Oculus SDK Samples to Cg
|
|
Created : July 01, 2013
|
|
Modified by : Jan Boon (Kaetemi)
|
|
|
|
Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
void pp_oculus_vr(
|
|
// Per fragment parameters
|
|
float2 texCoord : TEXCOORD0,
|
|
|
|
// Fragment program constants
|
|
uniform float2 cLensCenter,
|
|
uniform float2 cScreenCenter,
|
|
uniform float2 cScale,
|
|
uniform float2 cScaleIn,
|
|
uniform float4 cHmdWarpParam,
|
|
uniform sampler2D cTex0 : TEX0,
|
|
|
|
// Output color
|
|
out float4 oCol : COLOR)
|
|
{
|
|
float2 theta = (texCoord - cLensCenter) * cScaleIn; // Scales to [-1, 1]
|
|
float rSq = theta.x * theta.x + theta.y * theta.y;
|
|
float2 theta1 = theta * (cHmdWarpParam.x + cHmdWarpParam.y * rSq +
|
|
cHmdWarpParam.z * rSq * rSq + cHmdWarpParam.w * rSq * rSq * rSq);
|
|
float2 tc = cLensCenter + cScale * theta1;
|
|
|
|
if (!all(equal(clamp(tc, cScreenCenter-float2(0.25,0.5), cScreenCenter+float2(0.25,0.5)), tc)))
|
|
{
|
|
oCol = float4(0, 0, 0, 0);
|
|
}
|
|
else
|
|
{
|
|
oCol = tex2D(cTex0, tc);
|
|
}
|
|
}
|