scenerygraphics / scenery

Flexible VR Visualisation for Volumetric and Geometric Data on the Java VM, powered by Kotlin and Vulkan.
https://scenery.graphics
GNU Lesser General Public License v3.0
128 stars 31 forks source link

Issues with shader extensions on GL 4.1 #93

Closed kephale closed 6 years ago

kephale commented 6 years ago

On my MBP, when just trying to open a scenery window in SciView:

[SciJava-30b43d59-Thread-0] INFO OpenGLRenderer - Loaded Deferred Shading (Deferred Shading, with HDR postprocessing and FXAA
ClearGLWindow: GLProfile[GL4/GL4.hw]
[SciJava-30b43d59-Thread-0-FPSAWTAnimator#00-Timer0] INFO OpenGLRenderer - OpenGLRenderer: 512 x 512 on AMD Radeon R9 M370X OpenGL Engine, 4.1 ATI-1.51.8
[SciJava-30b43d59-Thread-0-FPSAWTAnimator#00-Timer0] INFO OpenGLRenderer - Creating render framebuffer GeometryBuffer for pass Scene
[SciJava-30b43d59-Thread-0-FPSAWTAnimator#00-Timer0] INFO OpenGLRenderer -  + attachment Position, RGBA_Float32
[SciJava-30b43d59-Thread-0-FPSAWTAnimator#00-Timer0] INFO OpenGLRenderer -  + attachment Normal, RG_Float16
[SciJava-30b43d59-Thread-0-FPSAWTAnimator#00-Timer0] INFO OpenGLRenderer -  + attachment DiffuseAlbedo, RGBA_UInt8
[SciJava-30b43d59-Thread-0-FPSAWTAnimator#00-Timer0] INFO OpenGLRenderer -  + attachment ZBuffer, Depth32
[SciJava-30b43d59-Thread-0-FPSAWTAnimator#00-Timer0] INFO OpenGLShaderModule - Getting 0 for shaders/DefaultDeferred.vert.spv (size: 3/3)
[SciJava-30b43d59-Thread-0-FPSAWTAnimator#00-Timer0] INFO OpenGLShaderModule - Getting 1 for shaders/DefaultDeferred.vert.spv (size: 3/3)
[SciJava-30b43d59-Thread-0-FPSAWTAnimator#00-Timer0] INFO OpenGLShaderModule - Getting 2 for shaders/DefaultDeferred.vert.spv (size: 3/3)
[SciJava-30b43d59-Thread-0-FPSAWTAnimator#00-Timer0] WARN OpenGLShaderModule - Shader compilation log:
[SciJava-30b43d59-Thread-0-FPSAWTAnimator#00-Timer0] WARN OpenGLShaderModule - GLShader [mShaderId=1, mShaderType=VertexShader]:
ERROR: 0:48: Invalid use of layout 'location'
ERROR: 0:82: Use of undeclared identifier 'Vertex'
ERROR: 0:83: Use of undeclared identifier 'Vertex'
ERROR: 0:84: Use of undeclared identifier 'Vertex'

[SciJava-30b43d59-Thread-0-FPSAWTAnimator#00-Timer0] ERROR OpenGLShaderModule - Shader code follows:
[SciJava-30b43d59-Thread-0-FPSAWTAnimator#00-Timer0] ERROR OpenGLShaderModule - --------------------
#version 410
#extension GL_ARB_separate_shader_objects : enable
#ifdef GL_ARB_shading_language_420pack
#extension GL_ARB_shading_language_420pack : require
#endif

struct Light
{
    float Linear;
    float Quadratic;
    float Intensity;
    float Radius;
    vec4 Position;
    vec4 Color;
};

 uniform VRParameters
{
    mat4 projectionMatrices[2];
    mat4 headShift;
    float IPD;
    int stereoEnabled;
} vrParameters;

 uniform LightParameters
{
    mat4 ViewMatrix;
    vec3 CamPosition;
    int numLights;
    Light lights[1024];
} _54;

 uniform Matrices
{
    mat4 ModelMatrix;
    mat4 NormalMatrix;
    mat4 ProjectionMatrix;
    int isBillboard;
} ubo;

struct currentEye_t
{
    int eye;
};

uniform currentEye_t currentEye;

layout(location = 0) out VertexData
{
    vec3 FragPosition;
    vec3 Normal;
    vec2 TexCoord;
} Vertex;

layout(location = 1) in vec3 vertexNormal;
layout(location = 2) in vec2 vertexTexCoord;
layout(location = 0) in vec3 vertexPosition;

void main()
{
    mat4 headToEye = vrParameters.headShift;
    headToEye[3].x -= (float(currentEye.eye) * vrParameters.IPD);
    mat4 _63 = (_54.ViewMatrix * float(vrParameters.stereoEnabled ^ 1)) * ubo.ModelMatrix;
    mat4 _74 = ((headToEye * float(vrParameters.stereoEnabled)) * _54.ViewMatrix) * ubo.ModelMatrix;
    mat4 mv = mat4(_63[0] + _74[0], _63[1] + _74[1], _63[2] + _74[2], _63[3] + _74[3]);
    mat4 _95 = ubo.ProjectionMatrix * float(vrParameters.stereoEnabled ^ 1);
    mat4 _103 = vrParameters.projectionMatrices[currentEye.eye] * float(vrParameters.stereoEnabled);
    mat4 projectionMatrix = mat4(_95[0] + _103[0], _95[1] + _103[1], _95[2] + _103[2], _95[3] + _103[3]);
    if (ubo.isBillboard > 0)
    {
        mv[0].x = 1.0;
        mv[0].y = 0.0;
        mv[0].z = 0.0;
        mv[1].x = 0.0;
        mv[1].y = 1.0;
        mv[1].z = 0.0;
        mv[2].x = 0.0;
        mv[2].y = 0.0;
        mv[2].z = 1.0;
    }
    mat4 nMVP = projectionMatrix * mv;
    Vertex.Normal = mat3(vec3(ubo.NormalMatrix[0].x, ubo.NormalMatrix[0].y, ubo.NormalMatrix[0].z), vec3(ubo.NormalMatrix[1].x, ubo.NormalMatrix[1].y, ubo.NormalMatrix[1].z), vec3(ubo.NormalMatrix[2].x, ubo.NormalMatrix[2].y, ubo.NormalMatrix[2].z)) * normalize(vertexNormal);
    Vertex.TexCoord = vertexTexCoord;
    Vertex.FragPosition = vec3((ubo.ModelMatrix * vec4(vertexPosition, 1.0)).xyz);
    gl_Position = nMVP * vec4(vertexPosition, 1.0);
    gl_Position.z = 2.0 * gl_Position.z - gl_Position.w;
}
skalarproduktraum commented 6 years ago

worksforme, #wontfix

No, just kidding. I'll look into it, it is actually supposed to work like that.

kephale commented 6 years ago

Oh does this work on your MBP too? I tried everything aside from a completely fresh clone/rebuild...

skalarproduktraum commented 6 years ago

Oh, apologies, there was indeed something I had missed. The issue should be fixed with 6ef43a6. Please reopen if the problem persists.

Sorry again!