Changed standard lighting to blinn phong instead of phong only

experimental
Nehon 10 years ago
parent c3ab5b3748
commit 21179dc132
  1. 2
      jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.frag
  2. 2
      jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.vert
  3. 2
      jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.frag
  4. 2
      jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.vert
  5. 16
      jme3-core/src/main/resources/Common/ShaderLib/BlinnPhongLighting.glsllib
  6. 14
      jme3-examples/src/main/java/jme3test/light/TestSimpleLighting.java

@ -1,7 +1,7 @@
#import "Common/ShaderLib/Parallax.glsllib"
#import "Common/ShaderLib/Optics.glsllib"
#ifndef VERTEX_LIGHTING
#import "Common/ShaderLib/PhongLighting.glsllib"
#import "Common/ShaderLib/BlinnPhongLighting.glsllib"
#import "Common/ShaderLib/Lighting.glsllib"
#endif

@ -2,7 +2,7 @@
#import "Common/ShaderLib/Skinning.glsllib"
#import "Common/ShaderLib/Lighting.glsllib"
#ifdef VERTEX_LIGHTING
#import "Common/ShaderLib/PhongLighting.glsllib"
#import "Common/ShaderLib/BlinnPhongLighting.glsllib"
#endif

@ -1,7 +1,7 @@
#import "Common/ShaderLib/Parallax.glsllib"
#import "Common/ShaderLib/Optics.glsllib"
#ifndef VERTEX_LIGHTING
#import "Common/ShaderLib/PhongLighting.glsllib"
#import "Common/ShaderLib/BlinnPhongLighting.glsllib"
#import "Common/ShaderLib/Lighting.glsllib"
#endif

@ -2,7 +2,7 @@
#import "Common/ShaderLib/Skinning.glsllib"
#import "Common/ShaderLib/Lighting.glsllib"
#ifdef VERTEX_LIGHTING
#import "Common/ShaderLib/PhongLighting.glsllib"
#import "Common/ShaderLib/BlinnPhongLighting.glsllib"
#endif

@ -1,20 +1,30 @@
/*Standard Phong ligting*/
/*Blinn Phong ligting*/
/*
* Computes diffuse factor
* Computes diffuse factor (Lambert)
*/
float lightComputeDiffuse(in vec3 norm, in vec3 lightdir){
return max(0.0, dot(norm, lightdir));
}
/*
* Computes specular factor
* Computes specular factor (blinn phong)
*/
float lightComputeSpecular(in vec3 norm, in vec3 viewdir, in vec3 lightdir, in float shiny){
vec3 H = normalize(viewdir + lightdir);
float HdotN = max(0.0, dot(H, norm));
return pow(HdotN, shiny);
}
/*
*Computes standard phong specular lighting
*/
float lightComputeSpecularPhong(in vec3 norm, in vec3 viewdir, in vec3 lightdir, in float shiny){
vec3 R = reflect(-lightdir, norm);
return pow(max(dot(R, viewdir), 0.0), shiny);
}
/*
* Computes diffuse and specular factors and pack them in a vec2 (x=diffuse, y=specular)
*/

@ -38,9 +38,11 @@ import com.jme3.light.PointLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Sphere;
import com.jme3.util.MaterialDebugAppState;
import com.jme3.util.TangentBinormalGenerator;
public class TestSimpleLighting extends SimpleApplication {
@ -62,8 +64,10 @@ public class TestSimpleLighting extends SimpleApplication {
teapot.setLocalScale(2f);
Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
// mat.selectTechnique("GBuf");
mat.setFloat("Shininess", 12);
mat.setFloat("Shininess", 25);
mat.setBoolean("UseMaterialColors", true);
cam.setLocation(new Vector3f(0.015041917f, 0.4572918f, 5.2874837f));
cam.setRotation(new Quaternion(-1.8875003E-4f, 0.99882424f, 0.04832061f, 0.0039016632f));
// mat.setTexture("ColorRamp", assetManager.loadTexture("Textures/ColorRamp/cloudy.png"));
//
@ -95,6 +99,14 @@ public class TestSimpleLighting extends SimpleApplication {
dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
dl.setColor(ColorRGBA.Green);
rootNode.addLight(dl);
MaterialDebugAppState debug = new MaterialDebugAppState();
debug.registerBinding("Common/ShaderLib/BlinnPhongLighting.glsllib", teapot);
stateManager.attach(debug);
setPauseOnLostFocus(false);
flyCam.setDragToRotate(true);
}
@Override

Loading…
Cancel
Save