mirror of
https://github.com/overte-org/overte.git
synced 2025-08-13 08:18:03 +02:00
Merge pull request #4737 from samcake/temp1
Fix the shadow Bug on Mac and the errors on shader compilation
This commit is contained in:
commit
62ba82198c
13 changed files with 74 additions and 61 deletions
|
@ -74,6 +74,19 @@ GLBackend::GLFramebuffer* GLBackend::syncGPUObject(const Framebuffer& framebuffe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if (GPU_FEATURE_PROFILE == GPU_LEGACY)
|
||||||
|
// for reasons that i don;t understand yet, it seems that on mac gl, a fbo must have a color buffer...
|
||||||
|
else {
|
||||||
|
GLuint renderBuffer = 0;
|
||||||
|
glGenRenderbuffers(1, &renderBuffer);
|
||||||
|
glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer);
|
||||||
|
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA, framebuffer.getWidth(), framebuffer.getHeight());
|
||||||
|
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||||
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderBuffer);
|
||||||
|
CHECK_GL_ERROR();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if (framebuffer.hasDepthStencil()) {
|
if (framebuffer.hasDepthStencil()) {
|
||||||
auto surface = framebuffer.getDepthStencilBuffer();
|
auto surface = framebuffer.getDepthStencilBuffer();
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
uniform sampler2D diffuseMap;
|
uniform sampler2D diffuseMap;
|
||||||
|
|
||||||
// the interpolated normal
|
// the interpolated normal
|
||||||
varying vec4 normal;
|
varying vec4 interpolatedNormal;
|
||||||
|
|
||||||
varying vec3 color;
|
varying vec3 color;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ void main(void) {
|
||||||
Material mat = getMaterial();
|
Material mat = getMaterial();
|
||||||
|
|
||||||
packDeferredFragment(
|
packDeferredFragment(
|
||||||
normalize(normal.xyz),
|
normalize(interpolatedNormal.xyz),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
||||||
getMaterialDiffuse(mat) * diffuse.rgb * color,
|
getMaterialDiffuse(mat) * diffuse.rgb * color,
|
||||||
getMaterialSpecular(mat),
|
getMaterialSpecular(mat),
|
||||||
|
|
|
@ -20,7 +20,7 @@ const int MAX_TEXCOORDS = 2;
|
||||||
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
|
uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
|
||||||
|
|
||||||
// the interpolated normal
|
// the interpolated normal
|
||||||
varying vec4 normal;
|
varying vec4 interpolatedNormal;
|
||||||
|
|
||||||
varying vec3 color;
|
varying vec3 color;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ void main(void) {
|
||||||
TransformCamera cam = getTransformCamera();
|
TransformCamera cam = getTransformCamera();
|
||||||
TransformObject obj = getTransformObject();
|
TransformObject obj = getTransformObject();
|
||||||
<$transformModelToClipPos(cam, obj, gl_Vertex, gl_Position)$>
|
<$transformModelToClipPos(cam, obj, gl_Vertex, gl_Position)$>
|
||||||
<$transformModelToEyeDir(cam, obj, gl_Normal, normal.xyz)$>
|
<$transformModelToEyeDir(cam, obj, gl_Normal, interpolatedNormal.xyz)$>
|
||||||
|
|
||||||
normal = vec4(normalize(normal.xyz), 0.0);
|
interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ uniform sampler2D emissiveMap;
|
||||||
uniform vec2 emissiveParams;
|
uniform vec2 emissiveParams;
|
||||||
|
|
||||||
// the interpolated normal
|
// the interpolated normal
|
||||||
varying vec4 normal;
|
varying vec4 interpolatedNormal;
|
||||||
|
|
||||||
varying vec3 color;
|
varying vec3 color;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ void main(void) {
|
||||||
Material mat = getMaterial();
|
Material mat = getMaterial();
|
||||||
|
|
||||||
packDeferredFragmentLightmap(
|
packDeferredFragmentLightmap(
|
||||||
normalize(normal.xyz),
|
normalize(interpolatedNormal.xyz),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
||||||
getMaterialDiffuse(mat) * diffuse.rgb * color,
|
getMaterialDiffuse(mat) * diffuse.rgb * color,
|
||||||
getMaterialSpecular(mat),
|
getMaterialSpecular(mat),
|
||||||
|
|
|
@ -23,7 +23,7 @@ uniform mat4 texcoordMatrices[MAX_TEXCOORDS];
|
||||||
attribute vec2 texcoord1;
|
attribute vec2 texcoord1;
|
||||||
|
|
||||||
// the interpolated normal
|
// the interpolated normal
|
||||||
varying vec4 normal;
|
varying vec4 interpolatedNormal;
|
||||||
|
|
||||||
// the interpolated texcoord1
|
// the interpolated texcoord1
|
||||||
varying vec2 interpolatedTexcoord1;
|
varying vec2 interpolatedTexcoord1;
|
||||||
|
@ -44,8 +44,8 @@ void main(void) {
|
||||||
TransformCamera cam = getTransformCamera();
|
TransformCamera cam = getTransformCamera();
|
||||||
TransformObject obj = getTransformObject();
|
TransformObject obj = getTransformObject();
|
||||||
<$transformModelToClipPos(cam, obj, gl_Vertex, gl_Position)$>
|
<$transformModelToClipPos(cam, obj, gl_Vertex, gl_Position)$>
|
||||||
<$transformModelToEyeDir(cam, obj, gl_Normal, normal.xyz)$>
|
<$transformModelToEyeDir(cam, obj, gl_Normal, interpolatedNormal.xyz)$>
|
||||||
|
|
||||||
normal = vec4(normalize(normal.xyz), 0.0);
|
interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ uniform vec2 emissiveParams;
|
||||||
uniform sampler2D specularMap;
|
uniform sampler2D specularMap;
|
||||||
|
|
||||||
// the interpolated normal
|
// the interpolated normal
|
||||||
varying vec4 normal;
|
varying vec4 interpolatedNormal;
|
||||||
|
|
||||||
varying vec2 interpolatedTexcoord1;
|
varying vec2 interpolatedTexcoord1;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ void main(void) {
|
||||||
Material mat = getMaterial();
|
Material mat = getMaterial();
|
||||||
|
|
||||||
packDeferredFragmentLightmap(
|
packDeferredFragmentLightmap(
|
||||||
normalize(normal.xyz),
|
normalize(interpolatedNormal.xyz),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
||||||
getMaterialDiffuse(mat) * diffuse.rgb * color,
|
getMaterialDiffuse(mat) * diffuse.rgb * color,
|
||||||
specular, // no use of getMaterialSpecular(mat)
|
specular, // no use of getMaterialSpecular(mat)
|
||||||
|
|
|
@ -23,7 +23,7 @@ uniform sampler2D diffuseMap;
|
||||||
uniform sampler2D specularMap;
|
uniform sampler2D specularMap;
|
||||||
|
|
||||||
// the interpolated normal
|
// the interpolated normal
|
||||||
varying vec4 normal;
|
varying vec4 interpolatedNormal;
|
||||||
|
|
||||||
varying vec3 color;
|
varying vec3 color;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ void main(void) {
|
||||||
Material mat = getMaterial();
|
Material mat = getMaterial();
|
||||||
|
|
||||||
packDeferredFragment(
|
packDeferredFragment(
|
||||||
normalize(normal.xyz),
|
normalize(interpolatedNormal.xyz),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
||||||
getMaterialDiffuse(mat) * diffuse.rgb * color,
|
getMaterialDiffuse(mat) * diffuse.rgb * color,
|
||||||
specular, //getMaterialSpecular(mat),
|
specular, //getMaterialSpecular(mat),
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
// the diffuse texture
|
// the diffuse texture
|
||||||
uniform sampler2D diffuseMap;
|
uniform sampler2D diffuseMap;
|
||||||
|
|
||||||
varying vec4 normal;
|
varying vec4 interpolatedNormal;
|
||||||
|
|
||||||
varying vec3 color;
|
varying vec3 color;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ void main(void) {
|
||||||
Material mat = getMaterial();
|
Material mat = getMaterial();
|
||||||
|
|
||||||
packDeferredFragmentTranslucent(
|
packDeferredFragmentTranslucent(
|
||||||
normalize(normal.xyz),
|
normalize(interpolatedNormal.xyz),
|
||||||
getMaterialOpacity(mat) * diffuse.a,
|
getMaterialOpacity(mat) * diffuse.a,
|
||||||
getMaterialDiffuse(mat) * diffuse.rgb * color,
|
getMaterialDiffuse(mat) * diffuse.rgb * color,
|
||||||
getMaterialSpecular(mat),
|
getMaterialSpecular(mat),
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
<@include DeferredBufferWrite.slh@>
|
<@include DeferredBufferWrite.slh@>
|
||||||
|
|
||||||
// the interpolated normal
|
// the interpolated normal
|
||||||
varying vec4 normal;
|
varying vec4 interpolatedNormal;
|
||||||
|
|
||||||
// the glow intensity
|
// the glow intensity
|
||||||
//uniform float glowIntensity;
|
//uniform float glowIntensity;
|
||||||
|
@ -28,7 +28,7 @@ void main(void) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
packDeferredFragment(
|
packDeferredFragment(
|
||||||
normalize(normal.xyz),
|
normalize(interpolatedNormal.xyz),
|
||||||
glowIntensity,
|
glowIntensity,
|
||||||
gl_Color.rgb,
|
gl_Color.rgb,
|
||||||
gl_FrontMaterial.specular.rgb,
|
gl_FrontMaterial.specular.rgb,
|
||||||
|
|
|
@ -13,11 +13,11 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
// the interpolated normal
|
// the interpolated normal
|
||||||
varying vec4 normal;
|
varying vec4 interpolatedNormal;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
// transform and store the normal for interpolation
|
// transform and store the normal for interpolation
|
||||||
normal = normalize(gl_ModelViewMatrix * vec4(gl_Normal, 0.0));
|
interpolatedNormal = normalize(gl_ModelViewMatrix * vec4(gl_Normal, 0.0));
|
||||||
|
|
||||||
// pass along the diffuse color
|
// pass along the diffuse color
|
||||||
gl_FrontColor = gl_Color;
|
gl_FrontColor = gl_Color;
|
||||||
|
|
|
@ -26,18 +26,18 @@ attribute vec4 clusterIndices;
|
||||||
attribute vec4 clusterWeights;
|
attribute vec4 clusterWeights;
|
||||||
|
|
||||||
// the interpolated normal
|
// the interpolated normal
|
||||||
varying vec4 normal;
|
varying vec4 interpolatedNormal;
|
||||||
|
|
||||||
varying vec3 color;
|
varying vec3 color;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
|
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
|
||||||
normal = vec4(0.0, 0.0, 0.0, 0.0);
|
interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0);
|
||||||
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
|
for (int i = 0; i < INDICES_PER_VERTEX; i++) {
|
||||||
mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])];
|
mat4 clusterMatrix = clusterMatrices[int(clusterIndices[i])];
|
||||||
float clusterWeight = clusterWeights[i];
|
float clusterWeight = clusterWeights[i];
|
||||||
position += clusterMatrix * gl_Vertex * clusterWeight;
|
position += clusterMatrix * gl_Vertex * clusterWeight;
|
||||||
normal += clusterMatrix * vec4(gl_Normal, 0.0) * clusterWeight;
|
interpolatedNormal += clusterMatrix * vec4(gl_Normal, 0.0) * clusterWeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
// pass along the diffuse color
|
// pass along the diffuse color
|
||||||
|
@ -50,7 +50,7 @@ void main(void) {
|
||||||
TransformCamera cam = getTransformCamera();
|
TransformCamera cam = getTransformCamera();
|
||||||
TransformObject obj = getTransformObject();
|
TransformObject obj = getTransformObject();
|
||||||
<$transformModelToClipPos(cam, obj, position, gl_Position)$>
|
<$transformModelToClipPos(cam, obj, position, gl_Position)$>
|
||||||
<$transformModelToEyeDir(cam, obj, normal.xyz, normal.xyz)$>
|
<$transformModelToEyeDir(cam, obj, interpolatedNormal.xyz, interpolatedNormal.xyz)$>
|
||||||
|
|
||||||
normal = vec4(normalize(normal.xyz), 0.0);
|
interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue