Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added options of shaders with GLSL150 #597

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,10 +1,12 @@
#import "Common/ShaderLib/GLSLCompat.glsllib"

uniform sampler2D m_Texture; // this should hold the texture rendered by the horizontal blur pass
uniform float m_Size;
uniform float m_Scale;

varying vec2 texCoord;

void main(){
void main() {
float blurSize = m_Scale/m_Size;
vec4 sum = vec4(0.0);

Expand Down
Expand Up @@ -7,6 +7,14 @@ MaterialDef Bloom {
Float Scale
}

Technique {
VertexShader GLSL150: Common/MatDefs/Post/Post.vert
FragmentShader GLSL150: Common/MatDefs/Blur/HGaussianBlur.frag

WorldParameters {
}
}

Technique {
VertexShader GLSL100: Common/MatDefs/Post/Post.vert
FragmentShader GLSL100: Common/MatDefs/Blur/HGaussianBlur.frag
Expand Down
33 changes: 17 additions & 16 deletions jme3-core/src/main/resources/Common/MatDefs/Blur/VGaussianBlur.frag
@@ -1,25 +1,26 @@
#import "Common/ShaderLib/GLSLCompat.glsllib"

uniform sampler2D m_Texture; // this should hold the texture rendered by the horizontal blur pass
uniform float m_Size;
uniform float m_Scale;
varying vec2 texCoord;

void main(void) {

float blurSize = m_Scale/m_Size;
vec4 sum = vec4(0.0);

void main(void)
{ float blurSize = m_Scale/m_Size;
vec4 sum = vec4(0.0);

// blur in y (vertical)
// take nine samples, with the distance blurSize between them
sum += texture2D(m_Texture, vec2(texCoord.x, texCoord.y - 4.0*blurSize)) * 0.06;
sum += texture2D(m_Texture, vec2(texCoord.x, texCoord.y - 3.0*blurSize)) * 0.09;
sum += texture2D(m_Texture, vec2(texCoord.x, texCoord.y - 2.0*blurSize)) * 0.12;
sum += texture2D(m_Texture, vec2(texCoord.x, texCoord.y - blurSize)) * 0.15;
sum += texture2D(m_Texture, vec2(texCoord.x, texCoord.y)) * 0.16;
sum += texture2D(m_Texture, vec2(texCoord.x, texCoord.y + blurSize)) * 0.15;
sum += texture2D(m_Texture, vec2(texCoord.x, texCoord.y + 2.0*blurSize)) * 0.12;
sum += texture2D(m_Texture, vec2(texCoord.x, texCoord.y + 3.0*blurSize)) * 0.09;
sum += texture2D(m_Texture, vec2(texCoord.x, texCoord.y + 4.0*blurSize)) * 0.06;
// blur in y (vertical)
// take nine samples, with the distance blurSize between them
sum += texture2D(m_Texture, vec2(texCoord.x, texCoord.y - 4.0*blurSize)) * 0.06;
sum += texture2D(m_Texture, vec2(texCoord.x, texCoord.y - 3.0*blurSize)) * 0.09;
sum += texture2D(m_Texture, vec2(texCoord.x, texCoord.y - 2.0*blurSize)) * 0.12;
sum += texture2D(m_Texture, vec2(texCoord.x, texCoord.y - blurSize)) * 0.15;
sum += texture2D(m_Texture, vec2(texCoord.x, texCoord.y)) * 0.16;
sum += texture2D(m_Texture, vec2(texCoord.x, texCoord.y + blurSize)) * 0.15;
sum += texture2D(m_Texture, vec2(texCoord.x, texCoord.y + 2.0*blurSize)) * 0.12;
sum += texture2D(m_Texture, vec2(texCoord.x, texCoord.y + 3.0*blurSize)) * 0.09;
sum += texture2D(m_Texture, vec2(texCoord.x, texCoord.y + 4.0*blurSize)) * 0.06;

gl_FragColor = sum;
gl_FragColor = sum;
}
Expand Up @@ -7,6 +7,14 @@ MaterialDef Bloom {
Float Scale
}

Technique {
VertexShader GLSL150: Common/MatDefs/Post/Post.vert
FragmentShader GLSL150: Common/MatDefs/Blur/VGaussianBlur.frag

WorldParameters {
}
}

Technique {
VertexShader GLSL100: Common/MatDefs/Post/Post.vert
FragmentShader GLSL100: Common/MatDefs/Blur/VGaussianBlur.frag
Expand Down
5 changes: 3 additions & 2 deletions jme3-core/src/main/resources/Common/MatDefs/Hdr/LogLum.frag
@@ -1,3 +1,4 @@
#import "Common/ShaderLib/GLSLCompat.glsllib"
#import "Common/ShaderLib/Hdr.glsllib"

uniform sampler2D m_Texture;
Expand All @@ -9,7 +10,7 @@ varying vec2 texCoord;
uniform float m_NumPixels;
#endif

vec4 blocks(vec2 halfBlockSize, vec2 pixelSize, float numPixels){
vec4 blocks(vec2 halfBlockSize, vec2 pixelSize, float numPixels) {
vec2 startUV = texCoord - halfBlockSize;
vec2 endUV = texCoord + halfBlockSize;

Expand Down Expand Up @@ -43,7 +44,7 @@ vec4 blocks(vec2 halfBlockSize, vec2 pixelSize, float numPixels){
return sum;
}

vec4 fetch(){
vec4 fetch() {
vec4 color = texture2D(m_Texture, texCoord);
#ifdef ENCODE_LUM
return HDR_EncodeLum(HDR_GetLum(color.rgb));
Expand Down
18 changes: 17 additions & 1 deletion jme3-core/src/main/resources/Common/MatDefs/Hdr/LogLum.j3md
Expand Up @@ -11,6 +11,23 @@ MaterialDef Log Lum 2D {
Boolean ComputeMax
}

Technique {
VertexShader GLSL150: Common/MatDefs/Gui/Gui.vert
FragmentShader GLSL150: Common/MatDefs/Hdr/LogLum.frag

WorldParameters {
WorldViewProjectionMatrix
}

Defines {
TEXTURE
ENCODE_LUM : EncodeLum
DECODE_LUM : DecodeLum
BLOCKS : Blocks
COMPUTE_MAX : ComputeMax
}
}

Technique {
VertexShader GLSL100: Common/MatDefs/Gui/Gui.vert
FragmentShader GLSL100: Common/MatDefs/Hdr/LogLum.frag
Expand All @@ -27,5 +44,4 @@ MaterialDef Log Lum 2D {
COMPUTE_MAX : ComputeMax
}
}

}
2 changes: 2 additions & 0 deletions jme3-effects/src/main/resources/Common/MatDefs/Post/Post.vert
@@ -1,3 +1,5 @@
#import "Common/ShaderLib/GLSLCompat.glsllib"

attribute vec4 inPosition;
attribute vec2 inTexCoord;

Expand Down