Fix shadows missing.
This commit is contained in:
parent
77049c5bed
commit
0cc5a3d320
9
assets/Materials/Light.j3m
Normal file
9
assets/Materials/Light.j3m
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
Material My Material : Common/MatDefs/Light/Lighting.j3md {
|
||||||
|
MaterialParameters {
|
||||||
|
Ambient : 1.0 1.0 1.0 1.0
|
||||||
|
Diffuse : 0.6 0.0 0.6 1.0
|
||||||
|
VertexLighting : false
|
||||||
|
}
|
||||||
|
AdditionalRenderState {
|
||||||
|
}
|
||||||
|
}
|
34
assets/Materials/newMatDef.j3md
Normal file
34
assets/Materials/newMatDef.j3md
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
MaterialDef Simple {
|
||||||
|
MaterialParameters {
|
||||||
|
Color Color
|
||||||
|
}
|
||||||
|
Technique {
|
||||||
|
WorldParameters {
|
||||||
|
WorldViewProjectionMatrix
|
||||||
|
}
|
||||||
|
VertexShaderNodes {
|
||||||
|
ShaderNode CommonVert {
|
||||||
|
Definition : CommonVert : Common/MatDefs/ShaderNodes/Common/CommonVert.j3sn
|
||||||
|
InputMappings {
|
||||||
|
worldViewProjectionMatrix = WorldParam.WorldViewProjectionMatrix
|
||||||
|
modelPosition = Global.position.xyz
|
||||||
|
}
|
||||||
|
OutputMappings {
|
||||||
|
Global.position = projPosition
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FragmentShaderNodes {
|
||||||
|
ShaderNode ColorMult {
|
||||||
|
Definition : ColorMult : Common/MatDefs/ShaderNodes/Basic/ColorMult.j3sn
|
||||||
|
InputMappings {
|
||||||
|
color1 = MatParam.Color
|
||||||
|
color2 = Global.color
|
||||||
|
}
|
||||||
|
OutputMappings {
|
||||||
|
Global.color = outColor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
BIN
assets/Materials/neweffect_gradient.png
Normal file
BIN
assets/Materials/neweffect_gradient.png
Normal file
Binary file not shown.
Binary file not shown.
@ -22,7 +22,10 @@ import com.jme3.material.Material;
|
|||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.post.FilterPostProcessor;
|
import com.jme3.post.FilterPostProcessor;
|
||||||
|
import com.jme3.post.ssao.SSAOFilter;
|
||||||
import com.jme3.renderer.ViewPort;
|
import com.jme3.renderer.ViewPort;
|
||||||
|
import com.jme3.renderer.queue.RenderQueue;
|
||||||
|
import com.jme3.renderer.queue.RenderQueue.ShadowMode;
|
||||||
import com.jme3.scene.Geometry;
|
import com.jme3.scene.Geometry;
|
||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import com.jme3.scene.Spatial;
|
import com.jme3.scene.Spatial;
|
||||||
@ -65,11 +68,16 @@ public class RunLevel extends BaseAppState
|
|||||||
this.viewPort = this.app.getViewPort();
|
this.viewPort = this.app.getViewPort();
|
||||||
this.physics = this.stateManager.getState(BulletAppState.class);
|
this.physics = this.stateManager.getState(BulletAppState.class);
|
||||||
|
|
||||||
|
//rootNode.setShadowMode(ShadowMode.CastAndReceive);
|
||||||
|
|
||||||
//BulletAppState bulletAppState = new BulletAppState();
|
//BulletAppState bulletAppState = new BulletAppState();
|
||||||
//this.stateManager.attach(bulletAppState);
|
//this.stateManager.attach(bulletAppState);
|
||||||
|
|
||||||
|
DirectionalLight sceneLight = new DirectionalLight(new Vector3f(-0.57735026f, -0.57735026f, -0.57735026f));
|
||||||
|
|
||||||
Node reflectedScene = new Node("Reflected Scene");
|
Node reflectedScene = new Node("Reflected Scene");
|
||||||
rootNode.attachChild(reflectedScene);
|
rootNode.attachChild(reflectedScene);
|
||||||
|
//rootNode.addLight(sceneLight);
|
||||||
Spatial TestLevel = assetManager.loadModel("Scenes/TestLevel.j3o");
|
Spatial TestLevel = assetManager.loadModel("Scenes/TestLevel.j3o");
|
||||||
Node world = (Node)TestLevel;
|
Node world = (Node)TestLevel;
|
||||||
//TestLevel.addControl(new RigidBodyControl(0));
|
//TestLevel.addControl(new RigidBodyControl(0));
|
||||||
@ -83,10 +91,10 @@ public class RunLevel extends BaseAppState
|
|||||||
playerNode.addControl(new PlayableCharacter());
|
playerNode.addControl(new PlayableCharacter());
|
||||||
playerNode.setUserData("Level", world);
|
playerNode.setUserData("Level", world);
|
||||||
|
|
||||||
for (int i=0;i<500;i++) {
|
for (int i=0;i<100;i++) {
|
||||||
Node sphereNode = new Node();
|
Node sphereNode = new Node();
|
||||||
Geometry sphere = new Geometry("PhysicsSphere",new Sphere((int)(Math.random()*10)+3,(int)(Math.random()*10)+3,3f));
|
Geometry sphere = new Geometry("PhysicsSphere",new Sphere((int)(Math.random()*10)+3,(int)(Math.random()*10)+3,3f));
|
||||||
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
|
Material mat = new Material(assetManager, "Materials/newMatDef.j3md");
|
||||||
mat.setColor("Color", ColorRGBA.randomColor());
|
mat.setColor("Color", ColorRGBA.randomColor());
|
||||||
sphere.setMaterial(mat);
|
sphere.setMaterial(mat);
|
||||||
sphere.setLocalTranslation(0.01f,1.5f,0.01f);
|
sphere.setLocalTranslation(0.01f,1.5f,0.01f);
|
||||||
@ -97,8 +105,12 @@ public class RunLevel extends BaseAppState
|
|||||||
}
|
}
|
||||||
|
|
||||||
ChaseCamera chaseCam = new ChaseCamera(this.app.getCamera(), player, inputManager);
|
ChaseCamera chaseCam = new ChaseCamera(this.app.getCamera(), player, inputManager);
|
||||||
|
chaseCam.setLookAtOffset(new Vector3f(0,2.5f,0));
|
||||||
|
//this.app.getCamera().setFrustumPerspective(this.app.getCamera().getFr, aspect, near, far);
|
||||||
|
//this.app.getCamera().setFrustumPerspective(90, 16f/9, 0, 2000f);
|
||||||
|
//float fov = 50;
|
||||||
|
//float aspect = (float)this.app.getCamera().getWidth() / (float)this.app.getCamera().getHeight();
|
||||||
|
//this.app.getCamera().setFrustumPerspective(fov, aspect, this.app.getCamera().getFrustumNear(), this.app.getCamera().getFrustumFar());
|
||||||
//channel.setLoopMode(LoopMode.Cycle);
|
//channel.setLoopMode(LoopMode.Cycle);
|
||||||
//world.attachChild(playerNode);
|
//world.attachChild(playerNode);
|
||||||
|
|
||||||
@ -109,13 +121,13 @@ public class RunLevel extends BaseAppState
|
|||||||
playerNode.addControl(chaseCam);
|
playerNode.addControl(chaseCam);
|
||||||
playerNode.move(0.01f,3f,0.01f);
|
playerNode.move(0.01f,3f,0.01f);
|
||||||
|
|
||||||
DirectionalLight sceneLight = new DirectionalLight(new Vector3f(-0.57735026f, -0.57735026f, -0.57735026f));
|
|
||||||
|
|
||||||
//System.out.println(world.getChildren());
|
//System.out.println(world.getChildren());
|
||||||
|
//.addLight(sceneLight);
|
||||||
|
//world.addLight(sceneLight);
|
||||||
|
reflectedScene.addLight(sceneLight);
|
||||||
reflectedScene.attachChild(world);
|
reflectedScene.attachChild(world);
|
||||||
reflectedScene.attachChild(TestLevel);
|
reflectedScene.attachChild(TestLevel);
|
||||||
reflectedScene.attachChild(playerNode);
|
reflectedScene.attachChild(playerNode);
|
||||||
reflectedScene.addLight(sceneLight);
|
|
||||||
reflectedScene.attachChild(SkyFactory.createSky(assetManager,"Textures/Sky/Bright/BrightSky.dds",false));
|
reflectedScene.attachChild(SkyFactory.createSky(assetManager,"Textures/Sky/Bright/BrightSky.dds",false));
|
||||||
|
|
||||||
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
|
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
|
||||||
@ -124,18 +136,23 @@ public class RunLevel extends BaseAppState
|
|||||||
WaterFilter water = new WaterFilter(reflectedScene, lightDir);
|
WaterFilter water = new WaterFilter(reflectedScene, lightDir);
|
||||||
water.setWaterHeight(-1.5f);
|
water.setWaterHeight(-1.5f);
|
||||||
fpp.addFilter(water);
|
fpp.addFilter(water);
|
||||||
|
final int SHADOWMAP_SIZE=4096;
|
||||||
|
|
||||||
final int SHADOWMAP_SIZE=1024;
|
/*DirectionalLightShadowRenderer dlsr = new DirectionalLightShadowRenderer(assetManager, SHADOWMAP_SIZE, 4);
|
||||||
DirectionalLightShadowRenderer dlsr = new DirectionalLightShadowRenderer(assetManager, SHADOWMAP_SIZE, 3);
|
|
||||||
dlsr.setLight(sceneLight);
|
dlsr.setLight(sceneLight);
|
||||||
viewPort.addProcessor(dlsr);
|
viewPort.addProcessor(dlsr);*/
|
||||||
|
|
||||||
DirectionalLightShadowFilter dlsf = new DirectionalLightShadowFilter(assetManager, SHADOWMAP_SIZE, 3);
|
DirectionalLightShadowFilter dlsf = new DirectionalLightShadowFilter(assetManager, SHADOWMAP_SIZE, 4);
|
||||||
dlsf.setLight(sceneLight);
|
dlsf.setLight(sceneLight);
|
||||||
dlsf.setEnabled(true);
|
dlsf.setEnabled(true);
|
||||||
fpp.addFilter(dlsf);
|
fpp.addFilter(dlsf);
|
||||||
viewPort.addProcessor(fpp);
|
viewPort.addProcessor(fpp);
|
||||||
|
|
||||||
|
/*
|
||||||
|
SSAOFilter ssaoFilter = new SSAOFilter(12.94f, 43.92f, 0.33f, 0.61f);
|
||||||
|
fpp.addFilter(ssaoFilter);
|
||||||
|
viewPort.addProcessor(fpp);*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -9,6 +9,8 @@ import com.jme3.math.Ray;
|
|||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.renderer.RenderManager;
|
import com.jme3.renderer.RenderManager;
|
||||||
import com.jme3.renderer.ViewPort;
|
import com.jme3.renderer.ViewPort;
|
||||||
|
import com.jme3.renderer.queue.RenderQueue;
|
||||||
|
import com.jme3.renderer.queue.RenderQueue.ShadowMode;
|
||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import com.jme3.scene.Spatial;
|
import com.jme3.scene.Spatial;
|
||||||
import com.jme3.scene.control.AbstractControl;
|
import com.jme3.scene.control.AbstractControl;
|
||||||
@ -42,7 +44,7 @@ public class PhysicsControl extends AbstractControl implements Savable, Cloneabl
|
|||||||
@Override
|
@Override
|
||||||
public void setSpatial(Spatial spatial) {
|
public void setSpatial(Spatial spatial) {
|
||||||
super.setSpatial(spatial);
|
super.setSpatial(spatial);
|
||||||
|
spatial.setShadowMode(ShadowMode.CastAndReceive);
|
||||||
spatial.setUserData("Level", levelData);
|
spatial.setUserData("Level", levelData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +113,7 @@ public class PhysicsControl extends AbstractControl implements Savable, Cloneabl
|
|||||||
|
|
||||||
boolean isOnGround() {
|
boolean isOnGround() {
|
||||||
if (vspd>0) {
|
if (vspd>0) {
|
||||||
System.out.println(vspd);
|
//System.out.println(vspd);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CollisionResults results = new CollisionResults();
|
CollisionResults results = new CollisionResults();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user