1 #extension GL_ARB_texture_multisample : enable 2 3 uniform int m_NumSamples; 4 uniform int m_NumSamplesDepth; 5 6 #ifdef RESOLVE_MS 7 #define COLORTEXTURE sampler2DMS 8 #else 9 #define COLORTEXTURE sampler2D 10 #endif 11 12 #ifdef RESOLVE_DEPTH_MS 13 #define DEPTHTEXTURE sampler2DMS 14 #else 15 #define DEPTHTEXTURE sampler2D 16 #endif 17 18 // NOTE: Only define multisample functions if multisample is available and is being used! 19 #if defined(GL_ARB_texture_multisample) && (defined(RESOLVE_MS) || defined(RESOLVE_DEPTH_MS)) 20 vec4 textureFetch(in sampler2DMS tex,in vec2 texC, in int numSamples){ 21 ivec2 iTexC = ivec2(texC * textureSize(tex)); 22 vec4 color = vec4(0.0); 23 for (int i = 0; i < numSamples; i++){ 24 color += texelFetch(tex, iTexC, i); 25 } 26 return color / numSamples; 27 } 28 29 vec4 fetchTextureSample(in sampler2DMS tex,in vec2 texC,in int sample){ 30 ivec2 iTexC = ivec2(texC * textureSize(tex)); 31 return texelFetch(tex, iTexC, sample); 32 } 33 34 vec4 getColor(in sampler2DMS tex, in vec2 texC){ 35 return textureFetch(tex, texC, m_NumSamples); 36 } 37 38 vec4 getColorSingle(in sampler2DMS tex, in vec2 texC){ 39 ivec2 iTexC = ivec2(texC * textureSize(tex)); 40 return texelFetch(tex, iTexC, 0); 41 } 42 43 vec4 getDepth(in sampler2DMS tex,in vec2 texC){ 44 return textureFetch(tex,texC,m_NumSamplesDepth); 45 } 46 #endif 47 48 vec4 fetchTextureSample(in sampler2D tex,in vec2 texC,in int sample){ 49 return texture2D(tex,texC); 50 } 51 52 vec4 getColor(in sampler2D tex, in vec2 texC){ 53 return texture2D(tex,texC); 54 } 55 56 vec4 getColorSingle(in sampler2D tex, in vec2 texC){ 57 return texture2D(tex, texC); 58 } 59 60 vec4 getDepth(in sampler2D tex,in vec2 texC){ 61 return texture2D(tex,texC); 62 }