testScene.blend: https://gist.github.com/riccardobl/38de2113eb379f04d7880be85165a4f4/raw/62d9e323949d6314c94063af208d41a9995890e5/testScene.blend
Last active
July 6, 2016 12:14
-
-
Save riccardobl/38de2113eb379f04d7880be85165a4f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MaterialDef Mat { | |
MaterialParameters { | |
} | |
Technique { | |
LightMode SinglePass | |
VertexShader GLSL400: shader.glsl | |
FragmentShader GLSL400: shader.glsl | |
TessellationEvaluationShader GLSL400: shader.glsl | |
TessellationControlShader GLSL400: shader.glsl | |
GeometryShader GLSL400: shader.glsl | |
WorldParameters { | |
ViewMatrix | |
WorldViewProjectionMatrix | |
} | |
Defines { | |
VERTEX_COLOR : UseVertexColor | |
VERTEX_LIGHTING : VertexLighting | |
MATERIAL_COLORS : UseMaterialColors | |
DIFFUSEMAP : DiffuseMap | |
NORMALMAP : NormalMap | |
SPECULARMAP : SpecularMap | |
PARALLAXMAP : ParallaxMap | |
NORMALMAP_PARALLAX : PackedNormalParallax | |
STEEP_PARALLAX : SteepParallax | |
ALPHAMAP : AlphaMap | |
COLORRAMP : ColorRamp | |
LIGHTMAP : LightMap | |
SEPARATE_TEXCOORD : SeparateTexCoord | |
DISCARD_ALPHA : AlphaDiscardThreshold | |
USE_REFLECTION : EnvMap | |
SPHERE_MAP : EnvMapAsSphereMap | |
NUM_BONES : NumberOfBones | |
INSTANCING : UseInstancing | |
} | |
} | |
Technique PreShadow { | |
VertexShader GLSL100 : Common/MatDefs/Shadow/PreShadow.vert | |
FragmentShader GLSL100 : Common/MatDefs/Shadow/PreShadow.frag | |
WorldParameters { | |
WorldViewProjectionMatrix | |
WorldViewMatrix | |
ViewProjectionMatrix | |
ViewMatrix | |
} | |
Defines { | |
DISCARD_ALPHA : AlphaDiscardThreshold | |
NUM_BONES : NumberOfBones | |
INSTANCING : UseInstancing | |
} | |
} | |
Technique PostShadow { | |
VertexShader GLSL150: Common/MatDefs/Shadow/PostShadow.vert | |
FragmentShader GLSL150: Common/MatDefs/Shadow/PostShadow.frag | |
WorldParameters { | |
WorldViewProjectionMatrix | |
WorldMatrix | |
ViewProjectionMatrix | |
ViewMatrix | |
NormalMatrix | |
} | |
Defines { | |
HARDWARE_SHADOWS : HardwareShadows | |
FILTER_MODE : FilterMode | |
PCFEDGE : PCFEdge | |
DISCARD_ALPHA : AlphaDiscardThreshold | |
SHADOWMAP_SIZE : ShadowMapSize | |
FADE : FadeInfo | |
PSSM : Splits | |
POINTLIGHT : LightViewProjectionMatrix5 | |
NUM_BONES : NumberOfBones | |
INSTANCING : UseInstancing | |
BACKFACE_SHADOWS: BackfaceShadows | |
} | |
ForcedRenderState { | |
Blend Modulate | |
DepthWrite Off | |
PolyOffset -0.1 0 | |
} | |
} | |
Technique PostShadow{ | |
VertexShader GLSL100: Common/MatDefs/Shadow/PostShadow.vert | |
FragmentShader GLSL100: Common/MatDefs/Shadow/PostShadow.frag | |
WorldParameters { | |
WorldViewProjectionMatrix | |
WorldMatrix | |
ViewProjectionMatrix | |
ViewMatrix | |
NormalMatrix | |
} | |
Defines { | |
HARDWARE_SHADOWS : HardwareShadows | |
FILTER_MODE : FilterMode | |
PCFEDGE : PCFEdge | |
DISCARD_ALPHA : AlphaDiscardThreshold | |
SHADOWMAP_SIZE : ShadowMapSize | |
FADE : FadeInfo | |
PSSM : Splits | |
POINTLIGHT : LightViewProjectionMatrix5 | |
NUM_BONES : NumberOfBones | |
INSTANCING : UseInstancing | |
} | |
ForcedRenderState { | |
Blend Modulate | |
DepthWrite Off | |
PolyOffset -0.1 0 | |
} | |
} | |
Technique PreNormalPass { | |
VertexShader GLSL100 : Common/MatDefs/SSAO/normal.vert | |
FragmentShader GLSL100 : Common/MatDefs/SSAO/normal.frag | |
WorldParameters { | |
WorldViewProjectionMatrix | |
WorldViewMatrix | |
NormalMatrix | |
ViewProjectionMatrix | |
ViewMatrix | |
} | |
Defines { | |
DIFFUSEMAP_ALPHA : DiffuseMap | |
NUM_BONES : NumberOfBones | |
INSTANCING : UseInstancing | |
} | |
} | |
Technique PreNormalPassDerivative { | |
VertexShader GLSL100 : Common/MatDefs/MSSAO/normal.vert | |
FragmentShader GLSL100 : Common/MatDefs/MSSAO/normal.frag | |
WorldParameters { | |
WorldViewProjectionMatrix | |
WorldViewMatrix | |
NormalMatrix | |
ViewProjectionMatrix | |
ViewMatrix | |
} | |
Defines { | |
DIFFUSEMAP_ALPHA : DiffuseMap | |
NUM_BONES : NumberOfBones | |
INSTANCING : UseInstancing | |
} | |
} | |
Technique GBuf { | |
VertexShader GLSL100: Common/MatDefs/Light/GBuf.vert | |
FragmentShader GLSL100: Common/MatDefs/Light/GBuf.frag | |
WorldParameters { | |
WorldViewProjectionMatrix | |
NormalMatrix | |
WorldViewMatrix | |
WorldMatrix | |
} | |
Defines { | |
VERTEX_COLOR : UseVertexColor | |
MATERIAL_COLORS : UseMaterialColors | |
DIFFUSEMAP : DiffuseMap | |
NORMALMAP : NormalMap | |
SPECULARMAP : SpecularMap | |
PARALLAXMAP : ParallaxMap | |
} | |
} | |
Technique Glow { | |
VertexShader GLSL100: Common/MatDefs/Misc/Unshaded.vert | |
FragmentShader GLSL100: Common/MatDefs/Light/Glow.frag | |
WorldParameters { | |
WorldViewProjectionMatrix | |
ViewProjectionMatrix | |
ViewMatrix | |
} | |
Defines { | |
NEED_TEXCOORD1 | |
HAS_GLOWMAP : GlowMap | |
HAS_GLOWCOLOR : GlowColor | |
NUM_BONES : NumberOfBones | |
INSTANCING : UseInstancing | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef VERTEX_SHADER | |
uniform mat4 g_WorldViewProjectionMatrix; | |
in vec3 inPosition; | |
out vec3 Position; | |
void main(){ | |
Position=inPosition; | |
gl_Position = g_WorldViewProjectionMatrix * vec4(Position, 1.0); | |
} | |
#endif | |
#ifdef TESSELLATIONCONTROL_SHADER | |
layout(vertices=3) out; | |
uniform vec3 g_CameraPosition; | |
in vec3 Position[]; | |
out vec3 tPosition[]; | |
void main(){ | |
if (gl_InvocationID == 0){ | |
gl_TessLevelInner[0]=2; | |
gl_TessLevelOuter[0]=2; | |
gl_TessLevelOuter[1]=2; | |
gl_TessLevelOuter[2]=2; | |
} | |
tPosition[gl_InvocationID]=Position[gl_InvocationID]; | |
} | |
#endif | |
#ifdef TESSELLATIONEVALUATION_SHADER | |
uniform mat4 g_WorldViewProjectionMatrix; | |
layout (triangles,equal_spacing,ccw) in; | |
#define Bc(a,b,c) (gl_TessCoord.x*a+gl_TessCoord.y*b+gl_TessCoord.z*c) | |
in vec3 tPosition[]; | |
void main(){ | |
gl_Position=g_WorldViewProjectionMatrix*vec4(Bc(tPosition[0],tPosition[1],tPosition[2]),1); | |
} | |
#endif | |
#ifdef GEOMETRY_SHADER | |
layout(triangles) in; | |
layout(triangle_strip, max_vertices = 3) out; | |
out vec3 vBC; | |
vec3 barycentricC[] = {vec3(0, 0, 1), vec3(1, 0, 0), vec3(0, 1, 0)}; | |
void main(void) { | |
for (int i = 0; i < gl_in.length(); ++i) { | |
gl_Position = gl_in[i].gl_Position; | |
vBC = barycentricC[i]; | |
EmitVertex(); | |
} | |
EndPrimitive(); | |
} | |
#endif | |
#ifdef FRAGMENT_SHADER | |
in vec3 vBC; | |
void main(){ | |
if(any(lessThan(vBC, vec3(0.02)))) gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); | |
else gl_FragColor=vec4(0,1,0,1); | |
} | |
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.jme3.app.SimpleApplication; | |
import com.jme3.light.DirectionalLight; | |
import com.jme3.light.Light; | |
import com.jme3.light.LightList; | |
import com.jme3.material.Material; | |
import com.jme3.math.ColorRGBA; | |
import com.jme3.math.Vector3f; | |
import com.jme3.post.FilterPostProcessor; | |
import com.jme3.renderer.queue.RenderQueue.ShadowMode; | |
import com.jme3.scene.Geometry; | |
import com.jme3.scene.Mesh.Mode; | |
import com.jme3.scene.Spatial; | |
import com.jme3.shadow.AbstractShadowFilter; | |
import com.jme3.shadow.CompareMode; | |
import com.jme3.shadow.DirectionalLightShadowFilter; | |
import com.jme3.shadow.EdgeFilteringMode; | |
public class ShadowFGLRXCrashTestCase extends SimpleApplication { | |
// ################################ | |
final boolean useShadow=true; | |
// ################################ | |
private void configureShadow(AbstractShadowFilter filter) { | |
filter.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON); | |
filter.setShadowCompareMode(CompareMode.Hardware); | |
} | |
public static void main(String[] args) { | |
ShadowFGLRXCrashTestCase app = new ShadowFGLRXCrashTestCase(); | |
app.start(); | |
} | |
@Override | |
public void simpleInitApp() { | |
FilterPostProcessor fpp=new FilterPostProcessor(getAssetManager()); | |
viewPort.addProcessor(fpp); | |
flyCam.setMoveSpeed(150); | |
flyCam.setDragToRotate(true); | |
Spatial scene=assetManager.loadModel("testScene.blend"); | |
rootNode.attachChild(scene); | |
scene.depthFirstTraversal(s->{ | |
if(s instanceof Geometry){ | |
Geometry g=(Geometry)s; | |
g.setMaterial(new Material(assetManager,"material.j3md")); | |
g.setShadowMode(ShadowMode.CastAndReceive); | |
g.getMesh().setMode(Mode.Patch); | |
g.getMesh().setPatchVertexCount(3); | |
} | |
LightList lights=s.getLocalLightList(); | |
for(Light l:lights){ | |
if(l instanceof DirectionalLight){ | |
s.removeLight(l); | |
} | |
} | |
}); | |
if(useShadow){ | |
DirectionalLight sun = new DirectionalLight(); | |
sun.setColor(ColorRGBA.White); | |
sun.setDirection(new Vector3f(-.5f,-.5f,-.5f).normalizeLocal()); | |
rootNode.addLight(sun); | |
DirectionalLightShadowFilter shadow=new DirectionalLightShadowFilter(assetManager,1024,3); | |
shadow.setLight(sun); | |
configureShadow(shadow); | |
fpp.addFilter(shadow); | |
shadow.setEnabled(true); | |
} | |
} | |
@Override | |
public void simpleUpdate(float tpf) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment