Hi,
I get an error message if I start the engine with e.g. 4x multisample anti-aliasing and the depth of field filter.
System specs:
Windows 7 64 Bit
AMD ATI Radeon 290x @ Catalyst 14.12
JME built from GitHub => last commit from May 7, 2015
I got following error message:
Uncaught exception thrown in Thread[jME3 Main,5,main]
RendererException: compile error in: ShaderSource[name=Common/MatDefs/Post/DepthOfField15.frag, defines, type=Fragment, language=GLSL150]
Fragment shader failed to compile with the following errors:
ERROR: 0:102: error(#202) No matching overloaded function found: getColor
ERROR: 0:102: error(#160) Cannot convert from: “const float” to: “highp 4-component vector of vec4”
ERROR: 0:157: error(#202) No matching overloaded function found: getColor
ERROR: 0:158: error(#202) No matching overloaded function found: getColor
ERROR: 0:159: error(#202) No matching overloaded function found: getColor
ERROR: 0:160: error(#202) No matching overloaded function found: getColor
ERROR: 0:161: error(#202) No matching overloaded function found: getColor
ERROR: 0:162: error(#202) No matching overloaded function found: getColor
ERROR: 0:163: error(#202) No matching overloaded function found: getColor
ERROR: 0:164: error(#202) No matching overloaded function found: getColor
ERROR: 0:165: error(#202) No matching overloaded function found: getColor
ERROR: 0:166: error(#202) No matching overloaded function found: getColor
ERROR: 0:167: error(#202) No matching overloaded function found: getColor
ERROR: 0:168: error(#202) No matching overloaded function found: getColor
ERROR: error(#273) 14 compilation errors. No code generated
I have notice that the bloom filter was also active before the DoF filter. Without the bloom filter it seems to work but it looks like the color buffer was not cleared or so.
without fpp.setNumSamples(4) the bloom and DoF flter works fine together.
Mai 08, 2015 9:52:02 AM com.jme3.system.JmeDesktopSystem initialize
INFORMATION: Running on jMonkeyEngine 3.1.0 (snapshot-github)
Branch: master
Git Hash: 64ba479
Build Date: 2015-05-07
Mai 08, 2015 9:52:02 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFORMATION: LWJGL 2.9.3 context running on thread jME3 Main
Graphics Adapter: aticfx64
Driver Version: 8.17.10.1333
Scaling Factor: 1
Mai 08, 2015 9:52:03 AM com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFORMATION: OpenGL Renderer Information
Profile: Compatibility
Mai 08, 2015 9:52:03 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFORMATION: Audio Device: OpenAL Soft
Mai 08, 2015 9:52:03 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFORMATION: Audio Vendor: OpenAL Community
Mai 08, 2015 9:52:03 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFORMATION: Audio Renderer: OpenAL Soft
Mai 08, 2015 9:52:03 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFORMATION: Audio Version: 1.1 ALSOFT 1.15.1
Mai 08, 2015 9:52:03 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFORMATION: ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_loopback
Mai 08, 2015 9:52:03 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFORMATION: AL extensions: AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_source_latency
Mai 08, 2015 9:52:03 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFORMATION: AudioRenderer supports 64 channels
Mai 08, 2015 9:52:03 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
WARNUNG: Pausing audio device not supported.
Mai 08, 2015 9:52:03 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFORMATION: Audio effect extension version: 1.0
Mai 08, 2015 9:52:03 AM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFORMATION: Audio max auxilary sends: 4
Mai 08, 2015 9:52:04 AM com.jme3.renderer.opengl.GLRenderer updateShaderSourceData
WARNUNG: Bad compile of:
1 #version 150 core
2 #define RESOLVE_DEPTH_MS 4
3 // – begin import Common/ShaderLib/MultiSample.glsllib –
4 #extension GL_ARB_texture_multisample : enable
5
6 uniform int m_NumSamples;
7 uniform int m_NumSamplesDepth;
8
9 #ifdef RESOLVE_MS
10 #define COLORTEXTURE sampler2DMS
11 #else
12 #define COLORTEXTURE sampler2D
13 #endif
14
15 #ifdef RESOLVE_DEPTH_MS
16 #define DEPTHTEXTURE sampler2DMS
17 #else
18 #define DEPTHTEXTURE sampler2D
19 #endif
20
21 // NOTE: Only define multisample functions if multisample is available and is being used!
22 #if defined(GL_ARB_texture_multisample) && (defined(RESOLVE_MS) || defined(RESOLVE_DEPTH_MS))
23 vec4 textureFetch(in sampler2DMS tex,in vec2 texC, in int numSamples){
24 ivec2 iTexC = ivec2(texC * vec2(textureSize(tex)));
25 vec4 color = vec4(0.0);
26 for (int i = 0; i < numSamples; i++){
27 color += texelFetch(tex, iTexC, i);
28 }
29 return color / float(numSamples);
30 }
31
32 vec4 fetchTextureSample(in sampler2DMS tex,in vec2 texC,in int sample){
33 ivec2 iTexC = ivec2(texC * vec2(textureSize(tex)));
34 return texelFetch(tex, iTexC, sample);
35 }
36
37 vec4 getColor(in sampler2DMS tex, in vec2 texC){
38 return textureFetch(tex, texC, m_NumSamples);
39 }
40
41 vec4 getColorSingle(in sampler2DMS tex, in vec2 texC){
42 ivec2 iTexC = ivec2(texC * vec2(textureSize(tex)));
43 return texelFetch(tex, iTexC, 0);
44 }
45
46 vec4 getDepth(in sampler2DMS tex,in vec2 texC){
47 return textureFetch(tex,texC,m_NumSamplesDepth);
48 }
49
50 #elifVERSION >= 150
51
52 vec4 fetchTextureSample(in sampler2D tex,in vec2 texC,in int sample){
53 return texture(tex,texC);
54 }
55
56 vec4 getColor(in sampler2D tex, in vec2 texC){
57 return texture(tex,texC);
58 }
59
60 vec4 getColorSingle(in sampler2D tex, in vec2 texC){
61 return texture(tex, texC);
62 }
63
64 vec4 getDepth(in sampler2D tex,in vec2 texC){
65 return texture(tex,texC);
66 }
67
68 #else
69
70 vec4 fetchTextureSample(in sampler2D tex,in vec2 texC,in int sample){
71 return texture2D(tex,texC);
72 }
73
74 vec4 getColor(in sampler2D tex, in vec2 texC){
75 return texture2D(tex,texC);
76 }
77
78 vec4 getColorSingle(in sampler2D tex, in vec2 texC){
79 return texture2D(tex, texC);
80 }
81
82 vec4 getDepth(in sampler2D tex,in vec2 texC){
83 return texture2D(tex,texC);
84 }
85
86 #endif
87 // – end import Common/ShaderLib/MultiSample.glsllib –
88
89 uniform COLORTEXTURE m_Texture;
90 uniform DEPTHTEXTURE m_DepthTexture;
91 varying vec2 texCoord;
92
93 uniform float m_FocusRange;
94 uniform float m_FocusDistance;
95 uniform float m_XScale;
96 uniform float m_YScale;
97
98 vec2 m_NearFar = vec2( 0.1, 1000.0 );
99
100 void main() {
101
102 vec4 texVal = getColor( m_Texture, texCoord );
103
104 float zBuffer = getDepth( m_DepthTexture, texCoord ).r;
105
106 //
107 // z_buffer_value = a + b / z;
108 //
109 // Where:
110 // a = zFar / ( zFar - zNear )
111 // b = zFar * zNear / ( zNear - zFar )
112 // z = distance from the eye to the object
113 //
114 // Which means:
115 // zb - a = b / z;
116 // z * (zb - a) = b
117 // z = b / (zb - a)
118 //
119 float a = m_NearFar.y / (m_NearFar.y - m_NearFar.x);
120 float b = m_NearFar.y * m_NearFar.x / (m_NearFar.x - m_NearFar.y);
121 float z = b / (zBuffer - a);
122
123 // Above could be the same for any depth-based filter
124
125 // We want to be purely focused right at
126 // m_FocusDistance and be purely unfocused
127 // at +/- m_FocusRange to either side of that.
128 float unfocus = min( 1.0, abs( z - m_FocusDistance ) / m_FocusRange );
129
130 if( unfocus < 0.2 ) {
131 // If we are mostly in focus then don’t bother with the
132 // convolution filter
133 gl_FragColor = texVal;
134 } else {
135 // Perform a wide convolution filter and we scatter it
136 // a bit to avoid some texture look-ups. Instead of
137 // a full 5x5 (25-1 lookups) we’ll skip every other one
138 // to only perform 12.
139 // 1 0 1 0 1
140 // 0 1 0 1 0
141 // 1 0 x 0 1
142 // 0 1 0 1 0
143 // 1 0 1 0 1
144 //
145 // You can get away with 8 just around the outside but
146 // it looks more jittery to me.
147
148 vec4 sum = vec4(0.0);
149
150 float x = texCoord.x;
151 float y = texCoord.y;
152
153 float xScale = m_XScale;
154 float yScale = m_YScale;
155
156 // In order from lower left to right, depending on how you look at it
157 sum += getColor( m_Texture, vec2(x - 2.0 * xScale, y - 2.0 * yScale) );
158 sum += getColor( m_Texture, vec2(x - 0.0 * xScale, y - 2.0 * yScale) );
159 sum += getColor( m_Texture, vec2(x + 2.0 * xScale, y - 2.0 * yScale) );
160 sum += getColor( m_Texture, vec2(x - 1.0 * xScale, y - 1.0 * yScale) );
161 sum += getColor( m_Texture, vec2(x + 1.0 * xScale, y - 1.0 * yScale) );
162 sum += getColor( m_Texture, vec2(x - 2.0 * xScale, y - 0.0 * yScale) );
163 sum += getColor( m_Texture, vec2(x + 2.0 * xScale, y - 0.0 * yScale) );
164 sum += getColor( m_Texture, vec2(x - 1.0 * xScale, y + 1.0 * yScale) );
165 sum += getColor( m_Texture, vec2(x + 1.0 * xScale, y + 1.0 * yScale) );
166 sum += getColor( m_Texture, vec2(x - 2.0 * xScale, y + 2.0 * yScale) );
167 sum += getColor( m_Texture, vec2(x - 0.0 * xScale, y + 2.0 * yScale) );
168 sum += getColor( m_Texture, vec2(x + 2.0 * xScale, y + 2.0 * yScale) );
169
170 sum = sum / 12.0;
171
172 gl_FragColor = mix( texVal, sum, unfocus );
173
174 // I used this for debugging the range
175 // gl_FragColor.r = unfocus;
176 }
177 }
Mai 08, 2015 9:52:06 AM com.jme3.app.Application handleError
SCHWERWIEGEND: Uncaught exception thrown in Thread[jME3 Main,5,main]
com.jme3.renderer.RendererException: compile error in: ShaderSource[name=Common/MatDefs/Post/DepthOfField15.frag, defines, type=Fragment, language=GLSL150]
Fragment shader failed to compile with the following errors:
ERROR: 0:102: error(#202) No matching overloaded function found: getColor
ERROR: 0:102: error(#160) Cannot convert from: “const float” to: “highp 4-component vector of vec4”
ERROR: 0:157: error(#202) No matching overloaded function found: getColor
ERROR: 0:158: error(#202) No matching overloaded function found: getColor
ERROR: 0:159: error(#202) No matching overloaded function found: getColor
ERROR: 0:160: error(#202) No matching overloaded function found: getColor
ERROR: 0:161: error(#202) No matching overloaded function found: getColor
ERROR: 0:162: error(#202) No matching overloaded function found: getColor
ERROR: 0:163: error(#202) No matching overloaded function found: getColor
ERROR: 0:164: error(#202) No matching overloaded function found: getColor
ERROR: 0:165: error(#202) No matching overloaded function found: getColor
ERROR: 0:166: error(#202) No matching overloaded function found: getColor
ERROR: 0:167: error(#202) No matching overloaded function found: getColor
ERROR: 0:168: error(#202) No matching overloaded function found: getColor
ERROR: error(#273) 14 compilation errors. No code generated
at com.jme3.renderer.opengl.GLRenderer.updateShaderSourceData(GLRenderer.java:1131)
at com.jme3.renderer.opengl.GLRenderer.updateShaderData(GLRenderer.java:1158)
at com.jme3.renderer.opengl.GLRenderer.setShader(GLRenderer.java:1222)
at com.jme3.material.Material.render(Material.java:1214)
at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:568)
at com.jme3.post.FilterPostProcessor.renderProcessing(FilterPostProcessor.java:217)
at com.jme3.post.FilterPostProcessor.renderFilterChain(FilterPostProcessor.java:294)
at com.jme3.post.FilterPostProcessor.postFrame(FilterPostProcessor.java:308)
at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1035)
at com.jme3.renderer.RenderManager.render(RenderManager.java:1078)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:260)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:152)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:192)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:233)
at java.lang.Thread.run(Thread.java:745)
ok got it.
Depth is never resolved, as the backbuffer is, so you can have a single sample backbuffer while stille having a multisampled depthbuffer. In that case we’d have to declare both functions.
Not sure why it works on nvidia though.
If either both or neither are supposed to be defined, then what is the purpose of having both of them instead of just one?
I just checked this shader with the GLSL reference compiler from Khronos, seems that they have a bug where sampler2D and sampler2DMS types are treated as the same type.
E.g.
This compiles okay, even though sampler2D and sampler2DMS are different types. This doesn’t work if you change sampler2DMS to some other type of sampler, like sampler2DArray or sampler3D, which is weird.
And I’ve been too quick to apply the given patch.
Filter output should never be MS because the first pass will resolve MS from the back buffer.
This patch though prevented to have RESOLVE_DEPTH_MS and RESOLVE_MS have different values, whereas it’s a totaly valid case.
The issue is in how we declare the functions with this type. I guess we shouldn’t make the test and always decalre the functions with both types. the selection will be done by the compiler depending on the defines COLORTEXTURE and DEPTHTEXTURE.
@alrik I committed a fix, could you test again please?
I commited a fix and it shoudl work, but since it doesn’t crash on my side I’d rather be sure.