- FilterPostProcessor no longer use a different camera to render the fulscreen quad. This greatly simplify the multiviewport filtering handling and global uniform matrix will now be usable in fliter's shaders, because it uses the same cam as the back buffer scene.
- Changed the post.vert and post15.vert to do a very basic projection to screen, saves a 16 float uniform and replace 4 matrices multiplication with 4 MAD operations per filter. - Used ResolutionInverse instead of Resolution in FXAA to multiply instead of dividing once per pixel - Same in CartoonEdge - LightScattering now uses the standard post.vert and post15.vert - Various cleanups in SSAO git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10750 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
0bb9822322
commit
afa9376b26
@ -12,7 +12,6 @@ MaterialDef Bloom {
|
||||
FragmentShader GLSL100: Common/MatDefs/Blur/HGaussianBlur.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
}
|
||||
}
|
@ -14,7 +14,6 @@ MaterialDef Radial Blur {
|
||||
FragmentShader GLSL150: Common/MatDefs/Blur/RadialBlur15.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
|
||||
Defines {
|
||||
@ -27,7 +26,6 @@ MaterialDef Radial Blur {
|
||||
FragmentShader GLSL120: Common/MatDefs/Blur/RadialBlur.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
}
|
||||
}
|
@ -12,7 +12,6 @@ MaterialDef Bloom {
|
||||
FragmentShader GLSL100: Common/MatDefs/Blur/VGaussianBlur.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
}
|
||||
}
|
@ -14,7 +14,6 @@ MaterialDef Bloom {
|
||||
FragmentShader GLSL150: Common/MatDefs/Post/bloomExtract15.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
|
||||
Defines {
|
||||
@ -29,7 +28,6 @@ MaterialDef Bloom {
|
||||
FragmentShader GLSL100: Common/MatDefs/Post/bloomExtract.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
|
||||
Defines {
|
||||
|
@ -12,7 +12,6 @@ MaterialDef Bloom Final {
|
||||
FragmentShader GLSL150: Common/MatDefs/Post/bloomFinal15.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
|
||||
Defines {
|
||||
@ -25,7 +24,6 @@ MaterialDef Bloom Final {
|
||||
FragmentShader GLSL100: Common/MatDefs/Post/bloomFinal.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ uniform sampler2D m_Texture;
|
||||
uniform sampler2D m_NormalsTexture;
|
||||
uniform sampler2D m_DepthTexture;
|
||||
|
||||
uniform vec2 g_Resolution;
|
||||
uniform vec2 g_ResolutionInverse;
|
||||
|
||||
vec4 fetchNormalDepth(vec2 tc){
|
||||
vec4 nd;
|
||||
@ -27,7 +27,7 @@ vec4 fetchNormalDepth(vec2 tc){
|
||||
void main(){
|
||||
vec3 color = texture2D(m_Texture, texCoord).rgb;
|
||||
|
||||
vec2 edgeOffset = vec2(m_EdgeWidth) / g_Resolution;
|
||||
vec2 edgeOffset = vec2(m_EdgeWidth) * g_ResolutionInverse;
|
||||
|
||||
vec4 n1 = fetchNormalDepth(texCoord + vec2(-1.0, -1.0) * edgeOffset);
|
||||
vec4 n2 = fetchNormalDepth(texCoord + vec2( 1.0, 1.0) * edgeOffset);
|
||||
|
@ -20,9 +20,8 @@ MaterialDef Cartoon Edge {
|
||||
FragmentShader GLSL150: Common/MatDefs/Post/CartoonEdge15.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
WorldViewMatrix
|
||||
Resolution
|
||||
ResolutionInverse
|
||||
}
|
||||
|
||||
Defines {
|
||||
@ -37,9 +36,8 @@ MaterialDef Cartoon Edge {
|
||||
FragmentShader GLSL100: Common/MatDefs/Post/CartoonEdge.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
WorldViewMatrix
|
||||
Resolution
|
||||
ResolutionInverse
|
||||
}
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ uniform COLORTEXTURE m_Texture;
|
||||
uniform DEPTHTEXTURE m_DepthTexture;
|
||||
|
||||
uniform sampler2D m_NormalsTexture;
|
||||
uniform vec2 g_Resolution;
|
||||
uniform vec2 g_ResolutionInverse;
|
||||
|
||||
uniform vec4 m_EdgeColor;
|
||||
|
||||
@ -30,7 +30,7 @@ vec4 fetchNormalDepth(vec2 tc){
|
||||
void main(){
|
||||
vec3 color = getColor(m_Texture, texCoord).rgb;
|
||||
|
||||
vec2 edgeOffset = vec2(m_EdgeWidth) / textureSize(m_NormalsTexture, 0);
|
||||
vec2 edgeOffset = vec2(m_EdgeWidth) * g_ResolutionInverse;
|
||||
vec4 n1 = fetchNormalDepth(texCoord + vec2(-1.0, -1.0) * edgeOffset);
|
||||
vec4 n2 = fetchNormalDepth(texCoord + vec2( 1.0, 1.0) * edgeOffset);
|
||||
vec4 n3 = fetchNormalDepth(texCoord + vec2(-1.0, 1.0) * edgeOffset);
|
||||
|
@ -12,7 +12,6 @@ MaterialDef Default GUI {
|
||||
FragmentShader GLSL150: Common/MatDefs/Post/Compose15.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
|
||||
Defines {
|
||||
@ -26,7 +25,6 @@ MaterialDef Default GUI {
|
||||
FragmentShader GLSL100: Common/MatDefs/Post/Compose.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ MaterialDef CrossHatch {
|
||||
FragmentShader GLSL150: Common/MatDefs/Post/CrossHatch15.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@ MaterialDef Depth Of Field {
|
||||
FragmentShader GLSL100: Common/MatDefs/Post/DepthOfField.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
uniform sampler2D m_Texture;
|
||||
uniform vec2 g_Resolution;
|
||||
uniform vec2 g_ResolutionInverse;
|
||||
|
||||
uniform float m_VxOffset;
|
||||
uniform float m_SpanMax;
|
||||
@ -83,6 +83,6 @@ vec3 FxaaPixelShader(
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 rcpFrame = vec2(1.0) / g_Resolution;
|
||||
gl_FragColor = vec4(FxaaPixelShader(posPos, m_Texture, rcpFrame), 1.0);
|
||||
|
||||
gl_FragColor = vec4(FxaaPixelShader(posPos, m_Texture, g_ResolutionInverse), 1.0);
|
||||
}
|
@ -11,8 +11,7 @@ MaterialDef FXAA {
|
||||
VertexShader GLSL100: Common/MatDefs/Post/FXAA.vert
|
||||
FragmentShader GLSL100: Common/MatDefs/Post/FXAA.frag
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
Resolution
|
||||
ResolutionInverse
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
uniform mat4 g_WorldViewProjectionMatrix;
|
||||
uniform vec2 g_Resolution;
|
||||
uniform vec2 g_ResolutionInverse;
|
||||
|
||||
uniform float m_SubPixelShift;
|
||||
|
||||
@ -12,8 +12,7 @@ varying vec4 posPos;
|
||||
void main() {
|
||||
vec2 pos = (g_WorldViewProjectionMatrix * inPosition).xy;
|
||||
gl_Position = vec4(pos, 0.0, 1.0);
|
||||
texCoord = inTexCoord;
|
||||
vec2 rcpFrame = vec2(1.0) / g_Resolution;
|
||||
texCoord = inTexCoord;
|
||||
posPos.xy = inTexCoord.xy;
|
||||
posPos.zw = inTexCoord.xy - (rcpFrame * vec2(0.5 + m_SubPixelShift));
|
||||
posPos.zw = inTexCoord.xy - (g_ResolutionInverse * vec2(0.5 + m_SubPixelShift));
|
||||
}
|
@ -11,7 +11,6 @@ MaterialDef Fade {
|
||||
FragmentShader GLSL150: Common/MatDefs/Post/Fade15.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
|
||||
Defines {
|
||||
@ -24,7 +23,6 @@ MaterialDef Fade {
|
||||
FragmentShader GLSL100: Common/MatDefs/Post/Fade.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
}
|
||||
}
|
@ -15,7 +15,6 @@ MaterialDef Fade {
|
||||
FragmentShader GLSL150: Common/MatDefs/Post/Fog15.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
|
||||
Defines {
|
||||
@ -29,7 +28,6 @@ MaterialDef Fade {
|
||||
FragmentShader GLSL100: Common/MatDefs/Post/Fog.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
}
|
||||
}
|
@ -12,7 +12,6 @@ MaterialDef GammaCorrection {
|
||||
FragmentShader GLSL150: Common/MatDefs/Post/GammaCorrection15.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
|
||||
Defines {
|
||||
@ -25,7 +24,6 @@ MaterialDef GammaCorrection {
|
||||
FragmentShader GLSL100: Common/MatDefs/Post/GammaCorrection.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
|
||||
Defines {
|
||||
|
@ -5,8 +5,8 @@ uniform float m_BlurStart;
|
||||
uniform float m_BlurWidth;
|
||||
uniform float m_LightDensity;
|
||||
uniform bool m_Display;
|
||||
uniform vec3 m_LightPosition;
|
||||
|
||||
varying vec2 lightPos;
|
||||
varying vec2 texCoord;
|
||||
|
||||
void main(void)
|
||||
@ -16,12 +16,12 @@ void main(void)
|
||||
vec4 colorRes= texture2D(m_Texture,texCoord);
|
||||
float factor=(m_BlurWidth/float(m_NbSamples-1.0));
|
||||
float scale;
|
||||
vec2 texCoo=texCoord-lightPos;
|
||||
vec2 texCoo=texCoord - m_LightPosition.xy;
|
||||
vec2 scaledCoord;
|
||||
vec4 res = vec4(0.0);
|
||||
for(int i=0; i<m_NbSamples; i++) {
|
||||
scale = i * factor + m_BlurStart ;
|
||||
scaledCoord=texCoo*scale+lightPos;
|
||||
scaledCoord=texCoo*scale + m_LightPosition.xy;
|
||||
if(texture2D(m_DepthTexture,scaledCoord).r==1.0){
|
||||
res += texture2D(m_Texture,scaledCoord);
|
||||
}
|
||||
|
@ -14,11 +14,10 @@ MaterialDef Light Scattering {
|
||||
}
|
||||
|
||||
Technique {
|
||||
VertexShader GLSL150: Common/MatDefs/Post/LightScattering15.vert
|
||||
VertexShader GLSL150: Common/MatDefs/Post/Post15.vert
|
||||
FragmentShader GLSL150: Common/MatDefs/Post/LightScattering15.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
WorldParameters {
|
||||
}
|
||||
|
||||
Defines {
|
||||
@ -28,11 +27,10 @@ MaterialDef Light Scattering {
|
||||
}
|
||||
|
||||
Technique {
|
||||
VertexShader GLSL120: Common/MatDefs/Post/LightScattering.vert
|
||||
VertexShader GLSL120: Common/MatDefs/Post/Post.vert
|
||||
FragmentShader GLSL120: Common/MatDefs/Post/LightScattering.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
WorldParameters {
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
uniform mat4 g_WorldViewProjectionMatrix;
|
||||
uniform vec3 m_LightPosition;
|
||||
|
||||
attribute vec4 inPosition;
|
||||
attribute vec2 inTexCoord;
|
||||
varying vec2 texCoord;
|
||||
varying vec2 lightPos;
|
||||
|
||||
void main() {
|
||||
vec2 pos = (g_WorldViewProjectionMatrix * inPosition).xy;
|
||||
gl_Position = vec4(pos, 0.0, 1.0);
|
||||
lightPos=m_LightPosition.xy;
|
||||
texCoord = inTexCoord;
|
||||
}
|
@ -8,9 +8,10 @@ uniform float m_BlurStart;
|
||||
uniform float m_BlurWidth;
|
||||
uniform float m_LightDensity;
|
||||
uniform bool m_Display;
|
||||
uniform vec3 m_LightPosition;
|
||||
|
||||
in vec2 lightPos;
|
||||
in vec2 texCoord;
|
||||
out vec4 fragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
@ -19,12 +20,12 @@ void main(void)
|
||||
vec4 colorRes= getColor(m_Texture,texCoord);
|
||||
float factor=(m_BlurWidth/float(m_NbSamples-1.0));
|
||||
float scale;
|
||||
vec2 texCoo=texCoord-lightPos;
|
||||
vec2 texCoo=texCoord - m_LightPosition.xy;
|
||||
vec2 scaledCoord;
|
||||
vec4 res = vec4(0.0);
|
||||
for(int i=0; i<m_NbSamples; i++) {
|
||||
scale = i * factor + m_BlurStart ;
|
||||
scaledCoord=texCoo*scale+lightPos;
|
||||
scaledCoord=texCoo*scale + m_LightPosition.xy;
|
||||
if(fetchTextureSample(m_DepthTexture, scaledCoord,0).r==1.0){
|
||||
res += fetchTextureSample(m_Texture,scaledCoord,0);
|
||||
}
|
||||
@ -32,8 +33,8 @@ void main(void)
|
||||
res /= m_NbSamples;
|
||||
|
||||
//Blend the original color with the averaged pixels
|
||||
gl_FragColor =mix( colorRes, res, m_LightDensity);
|
||||
fragColor = mix( colorRes, res, m_LightDensity);
|
||||
}else{
|
||||
gl_FragColor= getColor(m_Texture,texCoord);
|
||||
fragColor = getColor(m_Texture,texCoord);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
uniform mat4 g_WorldViewProjectionMatrix;
|
||||
//uniform mat4 g_WorldViewProjectionMatrix;
|
||||
uniform vec2 g_Resolution;
|
||||
uniform vec4 g_ViewPort;
|
||||
uniform vec3 m_LightPosition;
|
||||
|
||||
in vec4 inPosition;
|
||||
@ -7,7 +9,7 @@ out vec2 texCoord;
|
||||
out vec2 lightPos;
|
||||
|
||||
void main() {
|
||||
vec2 pos = (g_WorldViewProjectionMatrix * inPosition).xy;
|
||||
vec2 pos = inPosition.xy* 2.0 - 1.0;
|
||||
gl_Position = vec4(pos, 0.0, 1.0);
|
||||
lightPos=m_LightPosition.xy;
|
||||
texCoord = inTexCoord;
|
||||
|
@ -12,7 +12,6 @@ MaterialDef Default GUI {
|
||||
FragmentShader GLSL150: Common/MatDefs/Post/Overlay15.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
|
||||
Defines {
|
||||
@ -25,8 +24,7 @@ MaterialDef Default GUI {
|
||||
VertexShader GLSL100: Common/MatDefs/Post/Post.vert
|
||||
FragmentShader GLSL100: Common/MatDefs/Post/Overlay.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
WorldParameters {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
uniform mat4 g_WorldViewProjectionMatrix;
|
||||
|
||||
attribute vec4 inPosition;
|
||||
attribute vec2 inTexCoord;
|
||||
|
||||
varying vec2 texCoord;
|
||||
|
||||
void main() {
|
||||
vec2 pos = (g_WorldViewProjectionMatrix * inPosition).xy;
|
||||
void main() {
|
||||
vec2 pos = inPosition.xy * 2.0 - 1.0;
|
||||
gl_Position = vec4(pos, 0.0, 1.0);
|
||||
texCoord = inTexCoord;
|
||||
}
|
@ -1,12 +1,10 @@
|
||||
uniform mat4 g_WorldViewProjectionMatrix;
|
||||
|
||||
in vec4 inPosition;
|
||||
in vec2 inTexCoord;
|
||||
|
||||
out vec2 texCoord;
|
||||
|
||||
void main() {
|
||||
vec2 pos = (g_WorldViewProjectionMatrix * inPosition).xy;
|
||||
vec2 pos = inPosition.xy * 2.0 - 1.0;
|
||||
gl_Position = vec4(pos, 0.0, 1.0);
|
||||
texCoord = inTexCoord;
|
||||
}
|
@ -13,7 +13,6 @@ MaterialDef Posterization {
|
||||
FragmentShader GLSL150: Common/MatDefs/Post/Posterization15.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,8 +20,7 @@ MaterialDef Posterization {
|
||||
VertexShader GLSL100: Common/MatDefs/Post/Post.vert
|
||||
FragmentShader GLSL100: Common/MatDefs/Post/Posterization.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
WorldParameters {
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ uniform vec2 g_Resolution;
|
||||
uniform vec2 m_FrustumNearFar;
|
||||
uniform sampler2D m_Texture;
|
||||
uniform sampler2D m_Normals;
|
||||
uniform sampler2D m_RandomMap;
|
||||
uniform sampler2D m_DepthTexture;
|
||||
uniform vec3 m_FrustumCorner;
|
||||
uniform float m_SampleRadius;
|
||||
@ -32,9 +33,9 @@ vec3 getNormal(in vec2 uv){
|
||||
return normalize(texture2D(m_Normals, uv).xyz * 2.0 - 1.0);
|
||||
}
|
||||
|
||||
vec2 getRandom(in vec2 uv){
|
||||
float rand=(fract(uv.x*(g_Resolution.x/2.0))*0.25)+(fract(uv.y*(g_Resolution.y/2.0))*0.5);
|
||||
return normalize(vec2(rand,rand));
|
||||
vec2 getRandom(in vec2 uv){
|
||||
vec4 rand=texture2D(m_RandomMap,g_Resolution.zw * uv / 128.0 * 3.0)*2.0 -1.0;
|
||||
return normalize(rand.xy);
|
||||
}
|
||||
|
||||
float doAmbientOcclusion(in vec2 tc, in vec3 pos, in vec3 norm){
|
||||
|
@ -20,8 +20,7 @@ MaterialDef SSAO {
|
||||
VertexShader GLSL150: Common/MatDefs/Post/Post15.vert
|
||||
FragmentShader GLSL150: Common/MatDefs/SSAO/ssao15.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
WorldParameters {
|
||||
WorldViewMatrix
|
||||
Resolution
|
||||
}
|
||||
@ -37,10 +36,8 @@ MaterialDef SSAO {
|
||||
FragmentShader GLSL120: Common/MatDefs/SSAO/ssao.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
WorldViewMatrix
|
||||
Resolution
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -16,6 +16,8 @@ uniform vec2[4] m_Samples;
|
||||
|
||||
in vec2 texCoord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
float depthv;
|
||||
|
||||
vec3 getPosition(in vec2 uv){
|
||||
@ -36,7 +38,7 @@ vec3 getNormal(in vec2 uv){
|
||||
|
||||
vec2 getRandom(in vec2 uv){
|
||||
//float rand=(fract(uv.x*(g_Resolution.x/2.0))*0.25)+(fract(uv.y*(g_Resolution.y/2.0))*0.5);
|
||||
vec4 rand=texture2D(m_RandomMap,g_Resolution * uv / 128.0 * 3.0)*2.0 -1.0;
|
||||
vec4 rand=texture2D(m_RandomMap, g_Resolution * uv / 128.0 * 3.0)*2.0 -1.0;
|
||||
|
||||
return normalize(rand.xy);
|
||||
}
|
||||
@ -64,7 +66,7 @@ void main(){
|
||||
vec3 position = getPosition(texCoord);
|
||||
//optimization, do not calculate AO if depth is 1
|
||||
if(depthv==1.0){
|
||||
gl_FragColor=vec4(1.0);
|
||||
fragColor = vec4(1.0);
|
||||
return;
|
||||
}
|
||||
vec3 normal = getNormal(texCoord);
|
||||
@ -88,6 +90,6 @@ void main(){
|
||||
ao /= float(iterations) * 4.0;
|
||||
result = 1.0-ao;
|
||||
|
||||
gl_FragColor=vec4(result,result,result, 1.0);
|
||||
fragColor = vec4(result,result,result, 1.0);
|
||||
|
||||
}
|
@ -18,9 +18,7 @@ MaterialDef SSAOBlur {
|
||||
FragmentShader GLSL150: Common/MatDefs/SSAO/ssaoBlur15.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
WorldViewMatrix
|
||||
Resolution
|
||||
}
|
||||
|
||||
Defines {
|
||||
@ -35,11 +33,8 @@ MaterialDef SSAOBlur {
|
||||
VertexShader GLSL120: Common/MatDefs/Post/Post.vert
|
||||
FragmentShader GLSL120: Common/MatDefs/SSAO/ssaoBlur.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
WorldParameters {
|
||||
WorldViewMatrix
|
||||
Resolution
|
||||
|
||||
}
|
||||
|
||||
Defines {
|
||||
|
@ -3,7 +3,6 @@
|
||||
uniform COLORTEXTURE m_Texture;
|
||||
uniform DEPTHTEXTURE m_DepthTexture;
|
||||
uniform sampler2D m_SSAOMap;
|
||||
uniform vec2 g_Resolution;
|
||||
uniform bool m_UseOnlyAo;
|
||||
uniform bool m_UseAo;
|
||||
uniform float m_XScale;
|
||||
@ -33,33 +32,6 @@ float readDepth(in vec2 uv){
|
||||
const float epsilon = 0.005;
|
||||
|
||||
|
||||
/*
|
||||
const int kernelSize=7;
|
||||
|
||||
vec4 bilateralFilter() {
|
||||
vec4 color = vec4(0.0);
|
||||
|
||||
vec2 sample;
|
||||
float sum = 0.0;
|
||||
float coefZ;
|
||||
float Zp = readDepth(texCoord);
|
||||
|
||||
for(int i = -(kernelSize-1); i <= (kernelSize-1); i+=2) {
|
||||
for(int j = -(kernelSize-1); j <= (kernelSize-1); j+=2) {
|
||||
sample = texCoord + vec2(i,j) / g_Resolution;
|
||||
float zTmp =readDepth(sample);
|
||||
coefZ = 1.0 / (epsilon + abs(Zp - zTmp));
|
||||
sum += coefZ;
|
||||
|
||||
color += coefZ * texture2D(m_SSAOMap,sample);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return color / sum;
|
||||
}
|
||||
*/
|
||||
|
||||
vec4 convolutionFilter(){
|
||||
vec4 sum = vec4(0.0);
|
||||
|
||||
|
@ -56,7 +56,6 @@ MaterialDef Advanced Water {
|
||||
FragmentShader GLSL150 : Common/MatDefs/Water/Water15.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
|
||||
Defines {
|
||||
@ -78,7 +77,6 @@ MaterialDef Advanced Water {
|
||||
FragmentShader GLSL120 : Common/MatDefs/Water/Water.frag
|
||||
|
||||
WorldParameters {
|
||||
WorldViewProjectionMatrix
|
||||
}
|
||||
Defines {
|
||||
ENABLE_RIPPLES : UseRipples
|
||||
|
@ -63,8 +63,7 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
|
||||
private Texture2D filterTexture;
|
||||
private Texture2D depthTexture;
|
||||
private List<Filter> filters = new ArrayList<Filter>();
|
||||
private AssetManager assetManager;
|
||||
private Camera filterCam = new Camera(1, 1);
|
||||
private AssetManager assetManager;
|
||||
private Picture fsQuad;
|
||||
private boolean computeDepth = false;
|
||||
private FrameBuffer outputBuffer;
|
||||
@ -78,7 +77,7 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
|
||||
private int originalHeight;
|
||||
private int lastFilterIndex = -1;
|
||||
private boolean cameraInit = false;
|
||||
private boolean clearColor= true;
|
||||
private boolean multiView = false;
|
||||
|
||||
/**
|
||||
* Create a FilterProcessor
|
||||
@ -135,7 +134,9 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
|
||||
renderer = rm.getRenderer();
|
||||
viewPort = vp;
|
||||
fsQuad = new Picture("filter full screen quad");
|
||||
|
||||
fsQuad.setWidth(1);
|
||||
fsQuad.setHeight(1);
|
||||
|
||||
Camera cam = vp.getCamera();
|
||||
|
||||
//save view port diensions
|
||||
@ -176,29 +177,23 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
|
||||
* @param mat
|
||||
*/
|
||||
private void renderProcessing(Renderer r, FrameBuffer buff, Material mat) {
|
||||
if (buff == outputBuffer) {
|
||||
fsQuad.setWidth(width);
|
||||
fsQuad.setHeight(height);
|
||||
filterCam.resize(originalWidth, originalHeight, true);
|
||||
fsQuad.setPosition(left * originalWidth, bottom * originalHeight);
|
||||
} else {
|
||||
fsQuad.setWidth(buff.getWidth());
|
||||
fsQuad.setHeight(buff.getHeight());
|
||||
filterCam.resize(buff.getWidth(), buff.getHeight(), true);
|
||||
fsQuad.setPosition(0, 0);
|
||||
if (buff == outputBuffer && multiView) {
|
||||
viewPort.getCamera().resize(originalWidth, originalHeight, false);
|
||||
viewPort.getCamera().setViewPort(left, right, bottom, top);
|
||||
viewPort.getCamera().update();
|
||||
renderManager.setCamera( viewPort.getCamera(), false);
|
||||
}
|
||||
|
||||
if (mat.getAdditionalRenderState().isDepthWrite()) {
|
||||
mat.getAdditionalRenderState().setDepthTest(false);
|
||||
mat.getAdditionalRenderState().setDepthWrite(false);
|
||||
}
|
||||
|
||||
|
||||
fsQuad.setMaterial(mat);
|
||||
fsQuad.updateGeometricState();
|
||||
|
||||
renderManager.setCamera(filterCam, true);
|
||||
|
||||
r.setFrameBuffer(buff);
|
||||
r.clearBuffers(clearColor, true, true);
|
||||
r.clearBuffers(true, true, true);
|
||||
renderManager.renderGeometry(fsQuad);
|
||||
|
||||
}
|
||||
@ -216,8 +211,7 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Picture pic = new Picture("debug");
|
||||
}
|
||||
|
||||
/**
|
||||
* iterate through the filter list and renders filters
|
||||
@ -317,11 +311,14 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
|
||||
} else {
|
||||
viewPort.setOutputFrameBuffer(renderFrameBuffer);
|
||||
}
|
||||
//init of the camera if it wasn't already
|
||||
if (!cameraInit) {
|
||||
viewPort.getCamera().resize(width, height, true);
|
||||
//if we are ina multiview situation we need to resize the camera
|
||||
//to the viewportsize so that the backbuffer is rendered correctly
|
||||
if (multiView) {
|
||||
viewPort.getCamera().resize(width, height, false);
|
||||
viewPort.getCamera().setViewPort(0, 1, 0, 1);
|
||||
}
|
||||
viewPort.getCamera().update();
|
||||
renderManager.setCamera(viewPort.getCamera(), false);
|
||||
}
|
||||
}
|
||||
|
||||
for (Iterator<Filter> it = filters.iterator(); it.hasNext();) {
|
||||
@ -376,8 +373,8 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
|
||||
}
|
||||
|
||||
public void reshape(ViewPort vp, int w, int h) {
|
||||
//this has no effect at first init but is useful when resizing the canvas with multi views
|
||||
Camera cam = vp.getCamera();
|
||||
//this has no effect at first init but is useful when resizing the canvas with multi views
|
||||
cam.setViewPort(left, right, bottom, top);
|
||||
//resizing the camera to fit the new viewport and saving original dimensions
|
||||
cam.resize(w, h, false);
|
||||
@ -387,24 +384,20 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
|
||||
bottom = cam.getViewPortBottom();
|
||||
originalWidth = w;
|
||||
originalHeight = h;
|
||||
cam.setViewPort(0, 1, 0, 1);
|
||||
|
||||
//computing real dimension of the viewport and resizing he camera
|
||||
//computing real dimension of the viewport and resizing the camera
|
||||
width = (int) (w * (Math.abs(right - left)));
|
||||
height = (int) (h * (Math.abs(bottom - top)));
|
||||
width = Math.max(1, width);
|
||||
height = Math.max(1, height);
|
||||
|
||||
//Testing original versus actual viewport dimension.
|
||||
//If they are different we are in a multiview situation and color from other view port must not be cleared.
|
||||
//However, not clearing the color can cause issues when AlphaToCoverage is active on the renderer.
|
||||
//If they are different we are in a multiview situation and
|
||||
//camera must be handled differently
|
||||
if(originalWidth!=width || originalHeight!=height){
|
||||
clearColor = false;
|
||||
}else{
|
||||
clearColor = true;
|
||||
multiView = true;
|
||||
}
|
||||
|
||||
cam.resize(width, height, false);
|
||||
|
||||
cameraInit = true;
|
||||
computeDepth = false;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user