holas jMonkeys,
as the title suggests, I’m having trouble getting TextureArrays to work with MultiSampling.
First off a question to make sure i actually understand what jme provides out of the box in terms of multisampling:
The “Samples” setting in the default settings dialogue as well as the specific set- and get-methods for samples in the AppSettings-class are only relevant for FilterPostProcessors.
Other materials like Unshaded and Lighting as well as anything else does not make use of the samples setting?
Sure also filterPostProcessors dont make use of this settings “out of the box”, you have to explicitly set this value, but you get what i mean
Assuming this is true, is there no point in multisampling when drawing objects or is it just not build in?
I can see some pixels not drawn correctly on my voxel terrain when i set samples greater than 1 since i only use FXAA when samples is 1.
The WaterFilter seems to make use of multisampling, so does my FogShader and both seem to work also for samples greater than 1.
However, when i tried to add multisampling capability to the voxelshader i only ended up with fully black drawn chunks.
Here is my attempt:
I start my fragment shader with this (basically adopted from the MultiSampling.glsllib)
#extension GL_ARB_texture_multisample : enable
#if defined(GL_ARB_texture_multisample) && defined(RESOLVE_MS)
#define COLORTEXTURE sampler2DMSArray
vec4 fetchTextureSample(in sampler2DMSArray tex,in vec3 texC,in int sampleId){
ivec3 iTexC = ivec3(texC.xy * vec2(textureSize(tex)), texC.z);
return texelFetch(tex, iTexC, sampleId);
}
#else
#define COLORTEXTURE sampler2DArray
vec4 fetchTextureSample(in sampler2DArray tex,in vec3 texC,in int sampleId){
return texture(tex,texC);
}
#endif
uniform COLORTEXTURE m_TextureArray;
later in the shader i read the color like so:
vec4 texColor = fetchTextureSample(m_TextureArray, finalTexCoord, sampleNum);
when i change the vec4 fetchTextureSample(in sampler2DMSArray tex,in vec3 texC,in int sampleId) to:
#define COLORTEXTURE sampler2DArray
vec4 fetchTextureSample(in sampler2DArray tex,in vec3 texC,in int sampleId){
return texture(tex,texC);
}
and basically disable the multisampling, the colors reappear and everything look as expected except for the few aliased pixels that i try to eliminate
from what i get, texelFetch expects the coords in texelSpace or what its called, meaning not 0-1 but 0-SIZE, thus the ivec3 with the transformation
i already played around with the texcoord values that i provide the fetchTextureSample() method with. Since the chunks are perfectly black i thought it might be the 3rd component (the texture layer) thats wrong but i dont see how they should differ
Also i read that for multisampling, the texture array should not have mipmaps, but either the mipmaps are generated silently behind the scenes or turning it off actually doesnt change anything, since i still get black chunks. in case the code for setting up the textureArrays is relevant i can post it too
As always, thanks a lot for any idea and many greetings from the shire,
samwise