mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-24 13:08:49 -05:00
906470f28e
Update Ghoul repository
81 lines
3.8 KiB
Plaintext
81 lines
3.8 KiB
Plaintext
/*****************************************************************************************
|
|
* *
|
|
* OpenSpace *
|
|
* *
|
|
* Copyright (c) 2014 *
|
|
* *
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
|
* software and associated documentation files (the "Software"), to deal in the Software *
|
|
* without restriction, including without limitation the rights to use, copy, modify, *
|
|
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
|
* permit persons to whom the Software is furnished to do so, subject to the following *
|
|
* conditions: *
|
|
* *
|
|
* The above copyright notice and this permission notice shall be included in all copies *
|
|
* or substantial portions of the Software. *
|
|
* *
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
|
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
|
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
|
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
|
****************************************************************************************/
|
|
|
|
#ifndef POWERSCALING_VS_H_HGLSL
|
|
#define POWERSCALING_VS_H_HGLSL
|
|
|
|
uniform vec4 campos;
|
|
uniform mat4 camrot;
|
|
uniform vec2 scaling;
|
|
uniform vec4 objpos;
|
|
|
|
#include "powerScalingMath.hglsl"
|
|
|
|
vec4 psc_to_meter(vec4 v1, vec2 v2) {
|
|
float factor = v2.x * pow(k,v2.y + v1.w);
|
|
return vec4(v1.xyz * factor, 1.0);
|
|
}
|
|
|
|
vec4 psc_scaling(vec4 v1, vec2 v2) {
|
|
float ds = v2.y - v1.w;
|
|
if(ds >= 0) {
|
|
return vec4(v1.xyz * v2.x * pow(k,v1.w), v2.y);
|
|
} else {
|
|
return vec4(v1.xyz * v2.x * pow(k,v2.y), v1.w);
|
|
}
|
|
}
|
|
|
|
vec4 pscTransform(inout vec4 vertexPosition, mat4 modelTransform) {
|
|
vec3 local_vertex_pos = mat3(modelTransform) * vertexPosition.xyz;
|
|
//vec4 lvp = ModelTransform * vertexPosition;
|
|
|
|
// PSC addition; local vertex position and the object power scaled world position
|
|
vertexPosition = psc_addition(vec4(local_vertex_pos,vertexPosition.w),objpos);
|
|
//position = psc_addition(lvp,objpos);
|
|
|
|
// PSC addition; rotated and viewscaled vertex and the cmaeras negative position
|
|
vertexPosition = psc_addition(vertexPosition,vec4(-campos.xyz,campos.w));
|
|
|
|
// rotate the camera
|
|
vertexPosition.xyz = mat3(camrot) * vertexPosition.xyz;
|
|
vec4 tmp = vertexPosition;
|
|
vertexPosition = psc_scaling(vertexPosition, scaling);
|
|
//position = vec4(local_vertex_pos, position.w);
|
|
//position = camrot* position;
|
|
|
|
// rescales the scene to fit inside the view frustum
|
|
// is set from the main program, but these are decent values
|
|
// scaling = vec2(1.0, -8.0);
|
|
|
|
// project using the rescaled coordinates,
|
|
//vec4 vs_position_rescaled = psc_scaling(position, scaling);
|
|
tmp = psc_to_meter(tmp, scaling);
|
|
|
|
// tmp.z *= 2.0;
|
|
|
|
// return vertexPosition;
|
|
return tmp;
|
|
}
|
|
|
|
#endif |