Commit 3cad506b authored by Jonas Strandstedt's avatar Jonas Strandstedt
Browse files

PowerScaling modifications

- Started working on PowerScaling with some initial changes
- Faking the stars by blending with the abuffer
- Changed texture filtering for planets, looks better in my opinion
parent e4a8e870
master content/2012EventProfile elumenati/spout-implementation elumenati/spoutImplementation feature/2012Fieldlines feature/DSGWrapper feature/WSA feature/apollo-missions feature/arrow-renderable feature/asset-helper feature/asset-meta-update-part2 feature/asset-require feature/atmosphere-stars-rendering feature/bufferTransferTestings feature/camera-control-during-path feature/camera-path-stability feature/cef-update feature/change-renderbin-runtime feature/cmake feature/codegen-lua feature/codegen-lua-jenkins feature/compile-times feature/direction-hint-renderable feature/downscaledATM feature/du-meshes-selection feature/dynamicRootGraph feature/fieldlines feature/gamma-correction feature/geojson feature/geojson-renderable feature/getting-started-tour feature/grid-labels feature/grids-update feature/gui-mouseinteraction-fix feature/horizons-framework feature/horizons-unit-tests feature/iSWA feature/idle-behavior-updates feature/imageTestKeys2Actions feature/jenkins-codegen feature/jenkins-fix feature/jenkins-timeout feature/juice feature/jwst-pointing feature/jwst-trail-update feature/jwst-update feature/kameleonvolume-merge feature/labels-rendering feature/location-measure feature/macos feature/mars-moons feature/mas-model feature/missions feature/model-opacity feature/molecule_rendering feature/mollwide-projection feature/muicontroller feature/multiple-endpoints feature/multiresvolume feature/orientation-check feature/paper-atmosphere feature/properties-visibility feature/renderable-enabled-event feature/rover-visualization feature/roverterrain feature/roverterrain-mergefix feature/satellites feature/saturn-shepherd-moons feature/science-on-the-sphere feature/sgct-framebuffer-fixes feature/sgct-gui feature/sgct-gui-editable feature/sgct-gui-jenkins feature/sgct-json feature/sgct-ui feature/side-by-side-removal feature/skybrowser feature/skybrowser-cleanup feature/skybrowser-drag-and-drop feature/skybrowser-reload feature/solarbrowsing feature/spacecraft-instruments feature/spaceweather-stream feature/spice-update feature/state-with-time feature/tileprovider-minlevel feature/tileproviders feature/tle-bodymass feature/touchEventListener feature/transparency-rendering-last feature/ubuntu2204 feature/unit-tests feature/updateTSP feature/userproperties feature/various-changes feature/video-on-globe feature/visual-testing feature/visual-testing-try2 feature/volume-fixes feature/warnings feature/wormhole feature/xbox-update hotfix/scaling integration/atm-paper-fixes-2 integration/moon-mars-show integration/paper-atmosphere issue/1043 issue/1161 issue/1279 issue/1366-2 issue/1479 issue/1559 issue/1607 issue/1666 issue/1707 issue/1751 issue/1814 issue/1827 issue/1842 issue/1845 issue/1851 issue/1905 issue/1908 issue/1910 issue/1911 issue/1964 issue/1989 issue/1995 issue/2029 issue/2055 issue/2093 issue/2111 issue/2118 issue/2121 issue/2127 issue/2133 issue/2137 issue/2194 issue/2207 issue/2209 issue/2212 issue/2236 issue/2259 issue/2261 issue/2266 issue/2269 issue/843 issue/888 issue/hdrModels jenkins/1 jenkins/2 jenkins/2286 jenkins/utah-test-1 project/2021-wisdome-installation project/climate project/exoplanet-explorer project/exoplanets-expert-tool project/lights-2020-installation project/spaceship-installation project/spvl rc/0.18.1 temp/skybrowser-animation-fixes-merge thesis/2017/mars-rover-visualization thesis/2018/data-loader thesis/2018/dsn thesis/2018/flightcontroller thesis/2018/mas-model thesis/2019/spaceDebris thesis/2019/spaceweather-stream thesis/2020/software-integration thesis/2020/sonification thesis/2021/airtraffic thesis/2021/fieldlines thesis/2021/multiuser-collab thesis/2021/multiuser-collab3 thesis/2021/skybrowser thesis/2022/climate thesis/2022/cosmic-view thesis/2022/fieldline-rendering thesis/2022/remote-streaming thesis/2022/software-integration thesis/2022/software-integration_dod thesis/2022/software-integration_receive-ra-dec thesis/2022/software-integration_refactor-simp thesis/2022/software-integration_velocity-support thesis/2022/streaming 0 vislabs/release/2.1 research/dynamic-scene-graph research/atmospheres releases/v0.18.0 releases/v0.17.2 releases/v0.17.1 releases/v0.17.0 releases/v0.16.1 releases/v0.16.0 releases/v0.15.2 releases/v0.15.1 releases/v0.15.0 releases/v0.14.1 releases/v0.14.0 releases/v0.13.0 releases/v0.12.0 releases/v0.11.1 releases/v0.11.0 releases/v0.10.0 releases/v0.9.0 releases/v0.8.0 releases/v0.7.0 releases/v0.6.0 releases/v0.5.0 releases/v0.4.0 releases/v0.3.4 releases/v0.3.3 releases/v0.3.2 releases/v0.3.1 releases/v0.3.0 releases/v0.2.1 releases/v0.2.0 releases/v0.1.0 releases/v0.0.1 releases/prerelease/pluto-palooza-2015 releases/prerelease/newhorizons-2016 releases/prerelease/newhorizons-2015 releases/prerelease/kulturnatten-2016 releases/prerelease/ips-2016 releases/prerelease/imersa-2015 releases/prerelease/eurovis-2016 releases/prerelease/earth-day-2017 releases/prerelease/ccmc-2016 releases/prerelease/astronomylive-2017 releases/prerelease/astc-2017 releases/prerelease/agu-2016 releases/beta/beta-9 releases/beta/beta-8 releases/beta/beta-7 releases/beta/beta-5 releases/beta/beta-4_2 releases/beta/beta-4 releases/beta/beta-3 releases/beta/beta-2 releases/beta/beta-1_2 releases/beta/beta-1 rc/ccmc-panelreview dev/fc-port-change beta/beta-4_2 beta/beta-4 beta/beta-3 beta/beta-2 beta/beta-1_2 beta/beta-1
No related merge requests found
Showing with 121 additions and 247 deletions
+121 -247
......@@ -5,6 +5,8 @@
</Settings>
<Node address="localhost" port="20401">
<Window fullScreen="false" fxaa="false">
<Stereo type="anaglyph_red_cyan" />
<Stereo type="none" />
<!-- <Res x="4096" y="2304" /> -->
<!-- <Res x="1920" y="1080" /> -->
......
ghoul @ 7431cfdf
Subproject commit 44fec6ce6f9f214269c764f4a950dab8ccc127a4
Subproject commit 7431cfdf88483dab8498306938b8a4e9c182d7cc
......@@ -44,6 +44,8 @@ namespace openspace {
class ABuffer: public ABuffer_I {
public:
static const int MAX_LAYERS = 32;
ABuffer();
virtual ~ABuffer();
virtual void resolve();
......
......@@ -62,6 +62,8 @@ private:
Camera* _mainCamera;
SceneGraph* _sceneGraph;
ABuffer* _abuffer;
void generateGlslConfig();
};
} // namespace openspace
......
......@@ -34,7 +34,7 @@ layout (binding = 0, offset = 0) uniform atomic_uint atomicCounterBuffer;
layout (binding = 0, r32ui) uniform uimage2D anchorPointerTexture;
layout (binding = 1, rgba32ui) uniform uimageBuffer fragmentTexture;
#define _MAX_LAYERS_ 16
#define _MAX_LAYERS_ 64
#define _SCREEN_WIDTH_ 1280
#define _SCREEN_HEIGHT_ 720
#endif
......
......@@ -35,7 +35,11 @@
#define ZTYPE ZDEPTH
// Maximum number of fragments
#ifdef MAX_LAYERS
#define MAX_FRAGMENTS MAX_LAYERS
#else
#define MAX_FRAGMENTS 16 // The size of the local fragment list
#endif
// #define VISUALIZE_TRANSFERFUNCTIONS //
#define USE_JITTERING //
// #define USE_COLORNORMALIZATION //
......@@ -269,6 +273,11 @@ vec4 calculate_final_color(uint frag_count) {
// final_color = vec4(1.0,1.0,1.0,1.0);
// }
// if(frag_count > 12) {
// final_color = vec4(1.0,0.0,1.0,1.0);
// }
#ifdef USE_COLORNORMALIZATION
final_color.rgb = final_color.rgb * final_color.a;
final_color.a = 1.0;
......
......@@ -26,6 +26,7 @@
#define POWERSCALING_MATH_HGLSL
const float k = 10.0;
const float FLT_MAX = 1e38; // Not max but large enough for the purpose
vec4 psc_addition(vec4 v1, vec4 v2) {
float ds = v2.w - v1.w;
......@@ -38,4 +39,18 @@ vec4 psc_addition(vec4 v1, vec4 v2) {
}
}
vec4 z_normalization(vec4 v_in) {
vec4 v_out = v_in;
if(v_out.z > 0.0) {
v_out.z = 1;
} else if(v_out.z < 0.0) {
v_out.z = 1;
} else {
float tmp = max(max(abs(v_out.x), abs(v_out.y)),0);
if(tmp == 0.0)
v_out.s = FLT_MAX;
}
return v_out;
}
#endif
\ No newline at end of file
......@@ -28,10 +28,11 @@
// Observable universe is 10^27m, setting the far value to extremely high, aka 30!! ERMAHGERD!
const float k = 10.0;
const float s_far = 27.0f; //= gl_DepthRange.far; // 40
const float s_farcutoff = 12.0f;
const float s_nearcutoff = 7.00f;
const float s_near = 0.00f;// gl_DepthRange.near; // 0.1
const float s_near = 1.00f;// gl_DepthRange.near; // 0.1
vec4 psc_normlization(vec4 invec) {
......@@ -56,7 +57,8 @@ float pscDepth(vec4 position) {
} else {
depth = position.w+log(abs(position.z));
}
depth = (position.w+log(abs(position.z)))/pow(k, position.w);
// depth = (position.w+log(abs(position.z)))/pow(k, position.w);
// DEBUG
float depth_orig = depth;
......@@ -84,6 +86,7 @@ float pscDepth(vec4 position) {
depth = (depth - s_near) / (s_far - s_near);
}
// return 1.0;
return depth;
}
......
......@@ -46,20 +46,22 @@ vec4 psc_scaling(vec4 v1, vec2 v2) {
}
}
vec4 pscTransform(vec4 vertexPosition, mat4 modelTransform) {
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
vec4 position = psc_addition(vec4(local_vertex_pos,vertexPosition.w),objpos);
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
position = psc_addition(position,vec4(-campos.xyz,campos.w));
vertexPosition = psc_addition(vertexPosition,vec4(-campos.xyz,campos.w));
// rotate the camera
local_vertex_pos = mat3(camrot) * position.xyz;
position = vec4(local_vertex_pos, position.w);
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
......@@ -68,7 +70,12 @@ vec4 pscTransform(vec4 vertexPosition, mat4 modelTransform) {
// project using the rescaled coordinates,
//vec4 vs_position_rescaled = psc_scaling(position, scaling);
return psc_to_meter(position, scaling);
tmp = psc_to_meter(tmp, scaling);
// tmp.z *= 2.0;
// return vertexPosition;
return tmp;
}
#endif
\ No newline at end of file
......@@ -27,7 +27,7 @@
uniform int volumeType;
in vec3 vPosition;
in vec3 worldPosition;
in vec4 worldPosition;
in float s;
#include "ABuffer/abufferStruct.hglsl"
......@@ -36,7 +36,7 @@ in float s;
void main() {
vec4 fragColor = vec4(vPosition+0.5, 1.0);
vec4 position = vec4(worldPosition,s);
vec4 position = worldPosition;
float depth = pscDepth(position);
gl_FragDepth = depth;
......
......@@ -30,7 +30,7 @@ uniform mat4 modelViewProjection;
uniform mat4 modelTransform;
out vec3 vPosition;
out vec3 worldPosition;
out vec4 worldPosition;
out float s;
#include "PowerScaling/powerScaling_vs.hglsl"
......@@ -41,16 +41,15 @@ void main() {
//vs_stp = in_position.xyz;
vPosition = vertPosition.xyz;
worldPosition = vertPosition;
// this is wrong for the normal. The normal transform is the transposed inverse of the model transform
//vs_normal = normalize(modelTransform * vec4(in_normal,0));
vec4 position = pscTransform(vertPosition, modelTransform);
worldPosition = position.xyz;
s = position.w;
vec4 position = pscTransform(worldPosition, modelTransform);
// project the position to view space
gl_Position = modelViewProjection * position;
gl_Position = z_normalization(modelViewProjection * position);
// vPosition = vertPosition.xyz;
// worldPosition = (modelTransform *vec4(vPosition, 1.0)).xyz;
......
......@@ -7,12 +7,10 @@ The above copyright notice and this permission notice shall be included in all c
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.
*/
#version 400 core
#version 430 core
uniform mat4 ViewProjection;
uniform mat4 ModelTransform;
uniform vec4 campos;
uniform vec4 objpos;
uniform vec4 gridColor;
in vec2 vs_st;
......@@ -20,80 +18,17 @@ in vec2 vs_st;
in vec4 vs_normal;
in vec4 vs_position;
out vec4 diffuse;
const float k = 10.0;
vec4 psc_normlization(vec4 invec) {
float xymax = max(invec.x,invec.y);
if(invec.z > 0.0f || invec.z < 0.0f) {
return invec / abs(invec.z);
} else if (xymax != 0.0f) {
return invec / xymax;
} else {
return invec / -.0;
}
}
#include "ABuffer/abufferStruct.hglsl"
#include "ABuffer/abufferAddToBuffer.hglsl"
#include "PowerScaling/powerScaling_fs.hglsl"
// out vec4 diffuse;
void main()
{
// Observable universe is 10^27m, setting the far value to extremely high, aka 30!! ERMAHGERD!
float s_far = 40.0; //= gl_DepthRange.far; // 40
float s_farcutoff = 12.0;
float s_nearcutoff = 7.0;
float s_near = 0.0f;// gl_DepthRange.near; // 0.1
float depth;
// the value can be normalized to 1
vec4 p = vs_position;
if(vs_position.w <= 0.5) {
//depth = abs(vs_position.z * pow(10, vs_position.w)) / pow(k,s_far);
depth = (vs_position.w+log(abs(vs_position.z)))/pow(k, vs_position.w);
} else if(vs_position.w < 3.0) {
depth = vs_position.w+log(abs(vs_position.z))/pow(k, vs_position.w);
} else {
depth = vs_position.w+log(abs(vs_position.z));
}
// DEBUG
float depth_orig = depth;
float x = 0.0f;
float cutoffs = 0.0;
float orig_z = vs_position.z;
// calculate a normalized depth [0.0 1.0]
if((depth > s_near && depth <= s_nearcutoff) || (depth > s_farcutoff && depth < s_far)) {
// completely linear interpolation [s_near .. depth .. s_far]
depth = (depth - s_near) / (s_far - s_near);
} else if(depth > s_nearcutoff && depth < s_farcutoff) {
// DEBUG
cutoffs = 1.0;
// interpolate [10^s_nearcutoff .. 10^depth .. 10^s_farcutoff]
// calculate between 0..1 where the depth is
x = (pow(10,depth) - pow(10, s_nearcutoff)) / (pow(10,s_farcutoff) - pow(10, s_nearcutoff));
// remap the depth to the 0..1 depth buffer
depth = s_nearcutoff + x * (s_farcutoff - s_nearcutoff);
depth = (depth - s_near) / (s_far - s_near);
} else {
// where am I?
// do I need to be discarded?
// discard;
}
// set the depth
gl_FragDepth = depth;
//gl_FragDepth = depth;
//gl_FragDepth = 0.5;
// color
......@@ -105,11 +40,23 @@ void main()
//diffuse = vec4(depth*5,0.0, 0.0, 1.0);
//diffuse = vec4(vs_position.w,0.0, 0.0, 1.0);
vec4 diffuse = vec4(1,0,0,1);
if( floor(vs_st[0]) == -2){
diffuse = gridColor*2.f;
}else{
diffuse = gridColor;
}
diffuse = gridColor;
vec4 position = vs_position;
float depth = pscDepth(position);
// gl_FragDepth = depth;
//ABufferStruct_t frag = createGeometryFragment(vec4(1,0,0,1), position, depth);
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
addToBuffer(frag);
discard;
}
\ No newline at end of file
......@@ -19,14 +19,10 @@ 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.
*/
#version 400 core
#version 430 core
uniform mat4 ViewProjection;
uniform mat4 ModelTransform;
uniform vec4 campos;
uniform mat4 camrot;
uniform vec2 scaling;
uniform vec4 objpos;
uniform vec4 gridColor;
layout(location = 0) in vec4 in_position;
......@@ -39,33 +35,7 @@ out vec3 vs_stp;
out vec4 vs_normal;
out vec4 vs_position;
const float k = 10.0;
const float dgr_to_rad = 0.0174532925;
vec4 psc_addition(vec4 v1, vec4 v2) {
float ds = v2.w - v1.w;
if(ds >= 0) {
float p = pow(k,-ds);
return vec4(v1.x*p + v2.x, v1.y*p + v2.y, v1.z*p + v2.z, v2.w);
} else {
float p = pow(k,ds);
return vec4(v1.x + v2.x*p, v1.y + v2.y*p, v1.z + v2.z*p, v1.w);
}
}
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);
}
}
#include "PowerScaling/powerScaling_vs.hglsl"
void main()
{
......@@ -74,35 +44,14 @@ void main()
//vs_stp = in_position.xyz;
vs_normal = normalize(ModelTransform * vec4(in_normal,0));
// fetch model and view translation
//vec4 vertex_translate = ModelTransform[3];
// rotate and scale vertex with model transform and add the translation
vec3 local_vertex_pos = mat3(ModelTransform) * in_position.xyz;
//vec4 lvp = ModelTransform * in_position;
vec4 tmp = in_position;
// PSC addition; local vertex position and the object power scaled world position
vs_position = psc_addition(vec4(local_vertex_pos,in_position.w),objpos);
//vs_position = psc_addition(lvp,objpos);
// PSC addition; rotated and viewscaled vertex and the cmaeras negative position
vs_position = psc_addition(vs_position,vec4(-campos.xyz,campos.w));
// this is wrong for the normal. The normal transform is the transposed inverse of the model transform
vs_normal = normalize(ModelTransform * vec4(in_normal,0));
// rotate the camera
local_vertex_pos = mat3(camrot) * vs_position.xyz;
vs_position = vec4(local_vertex_pos, vs_position.w);
//vs_position = camrot* vs_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(vs_position, scaling);
vec4 vs_position_rescaled = psc_to_meter(vs_position, scaling);
//vs_position = vs_position_rescaled;
// project the position to view space
gl_Position = ViewProjection * vs_position_rescaled;
vec4 position = pscTransform(tmp, ModelTransform);
vs_position = tmp;
position = ViewProjection * position;
gl_Position = z_normalization(position);
}
\ No newline at end of file
......@@ -29,8 +29,7 @@ uniform sampler2D texture1;
in vec2 vs_st;
in vec4 vs_normal;
in vec3 vs_position;
in float s;
in vec4 vs_position;
#include "ABuffer/abufferStruct.hglsl"
#include "ABuffer/abufferAddToBuffer.hglsl"
......@@ -38,10 +37,14 @@ in float s;
void main()
{
vec4 position = vec4(vs_position,s);
vec4 position = vs_position;
float depth = pscDepth(position);
vec4 diffuse = texture(texture1, vs_st);
// if(position.w > 9.0) {
// diffuse = vec4(1,0,0,1);
// }
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
addToBuffer(frag);
......
......@@ -33,9 +33,8 @@ layout(location = 1) in vec2 in_st;
layout(location = 2) in vec3 in_normal;
out vec2 vs_st;
out vec3 vs_stp;
out vec4 vs_normal;
out vec3 vs_position;
out vec4 vs_position;
out float s;
#include "PowerScaling/powerScaling_vs.hglsl"
......@@ -45,14 +44,14 @@ void main()
// set variables
vs_st = in_st;
//vs_stp = in_position.xyz;
vs_position = in_position;
vec4 tmp = in_position;
// this is wrong for the normal. The normal transform is the transposed inverse of the model transform
vs_normal = normalize(ModelTransform * vec4(in_normal,0));
vec4 position = pscTransform(in_position, ModelTransform);
vs_position = position.xyz;
s = position.w;
// project the position to view space
gl_Position = ViewProjection * position;
vec4 position = pscTransform(tmp, ModelTransform);
vs_position = tmp;
position = ViewProjection * position;
gl_Position = z_normalization(position);
}
\ No newline at end of file
......@@ -8,7 +8,7 @@ in vec2 texCoord;
layout(location = 2) in vec3 ge_brightness;
//out vec4 diffuse;
out vec4 diffuse;
#include "ABuffer/abufferStruct.hglsl"
......@@ -48,20 +48,22 @@ void main(void)
//glEnable(GL_BLEND);
//glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE);
vec4 color = bv2rgb(ge_brightness[0])/1.1;
//color.rgb = 1/ color.rgb;
color.a = 1-color.a;
vec4 diffuse = texture2D(texture1, texCoord)*color;
// color.rgb = 1/ color.rgb;
// color.a = 1-color.a;
diffuse = texture2D(texture1, texCoord)*color;
//diffuse = vec4(1,1,0,1);
///diffuse = vec4(Color, 1.0);
vec4 position = vs_position;
float depth = pscDepth(position);
gl_FragDepth = depth;
gl_FragDepth = 10.0;
//ABufferStruct_t frag = createGeometryFragment(vec4(1,0,0,1), position, depth);
ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
addToBuffer(frag);
//ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth);
//addToBuffer(frag);
discard;
//discard;
}
\ No newline at end of file
......@@ -21,6 +21,7 @@ layout(location = 2) out vec3 ge_brightness[];
layout(triangle_strip, max_vertices = 4) out;
out vec2 texCoord;
out vec4 vs_position;
uniform mat4 projection; // we do this after distance computation.
......@@ -63,7 +64,9 @@ void main(){
for(int i = 0; i < 4; i++){
vec4 p1 = P;
p1.xy += spriteSize *(corners[i] - vec2(0.5));
gl_Position = projection * p1; // projection here
vs_position = p1;
gl_Position = projection * p1;
// gl_Position = z_normalization(projection * p1); // projection here
texCoord = corners[i];
EmitVertex();
}
......
......@@ -11,40 +11,10 @@ uniform sampler2D texture1;
layout(location = 0) in vec4 in_position;
layout(location = 2) in vec3 in_brightness;
out vec4 vs_position;
out vec3 vs_brightness;
out vec4 psc_position;
out vec4 cam_position;
/*
const float k = 10.0;
const float dgr_to_rad = 0.0174532925;
vec4 psc_addition(vec4 v1, vec4 v2) {
float ds = v2.w - v1.w;
if(ds >= 0) {
float p = pow(k,-ds);
return vec4(v1.x*p + v2.x, v1.y*p + v2.y, v1.z*p + v2.z, v2.w);
} else {
float p = pow(k,ds);
return vec4(v1.x + v2.x*p, v1.y + v2.y*p, v1.z + v2.z*p, v1.w);
}
}
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);
}
}
*/
#include "PowerScaling/powerScaling_vs.hglsl"
......@@ -52,51 +22,13 @@ void main(){
vs_brightness = in_brightness;
psc_position = in_position;
cam_position = campos;
/*
// rotate and scale vertex with model transform and add the translation
vec3 local_vertex_pos = mat3(ModelTransform) * in_position.xyz;
//vec4 lvp = ModelTransform * in_position;
// PSC addition; local vertex position and the object power scaled world position
vs_position = psc_addition(vec4(local_vertex_pos,in_position.w),objpos);
//vs_position = psc_addition(lvp,objpos);
// PSC addition; rotated and viewscaled vertex and the cmaeras negative position
vs_position = psc_addition(vs_position,vec4(-campos.xyz,campos.w));
// rotate the camera
local_vertex_pos = mat3(camrot) * vs_position.xyz;
vs_position = vec4(local_vertex_pos, vs_position.w);
//vs_position = camrot * vs_position;
// project using the rescaled coordinates,
//vec4 vs_position_rescaled = psc_scaling(vs_position, scaling);
//psc_position = vs_position;
// individual scaling per point, needs fix.
//vec2 scaling = vec2(1.0, -in_position.w);
vec4 vs_position_rescaled = psc_to_meter(vs_position, scaling);
//vs_position = vs_position_rescaled;
// project the position to view space
//gl_Position = ViewProjection * vs_position_rescaled;
gl_Position = view * model * vs_position_rescaled;
*/
/*psc_position = view * model * vs_position_rescaled;
gl_Position = psc_position; /// reduntant way but easier to go back. */
// this is wrong for the normal. The normal transform is the transposed inverse of the model transform
//vs_normal = normalize(modelTransform * vec4(in_normal,0));
vec4 position = pscTransform(in_position, ModelTransform);
// project the position to view space
//gl_Position = ViewProjection * position;
gl_Position = view * model * position;
vec4 tmp = in_position;
vec4 position = pscTransform(tmp, ModelTransform);
// psc_position = tmp;
position = view * model * position;
// gl_Position = z_normalization(position);
gl_Position = position;
}
\ No newline at end of file
......@@ -85,10 +85,12 @@ bool ABuffer::initializeABuffer() {
ghoul::filesystem::File* f = new ghoul::filesystem::File(path, false);
f->setCallback(shaderCallback);
_shaderFiles.push_back(f);
};
addFunc("${SHADERS}/ABuffer/abufferSort.hglsl");
};
addFunc("${SHADERS}/ABuffer/constants.hglsl");
addFunc("${SHADERS}/ABuffer/abufferSort.hglsl");
addFunc("${SHADERS}/ABuffer/abufferAddToBuffer.hglsl");
addFunc("${SHADERS}/ABuffer/abufferStruct.hglsl");
addFunc("${SHADERS}/ABuffer/abufferStruct.hglsl");
addFunc("${SHADERS}/PowerScaling/powerScaling_fs.hglsl");
addFunc("${SHADERS}/PowerScaling/powerScaling_fs.hglsl");
addFunc("${SHADERS}/PowerScaling/powerScaling_vs.hglsl");
addFunc("${SHADERS}/PowerScaling/powerScalingMath.hglsl");
......
......@@ -32,8 +32,6 @@
#include <fstream>
#include <string>
#define MAX_LAYERS 10
namespace {
std::string _loggerCat = "ABufferSingleLinked";
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment