Changed standard lighting to blinn phong instead of phong only
This commit is contained in:
parent
c3ab5b3748
commit
21179dc132
@ -1,7 +1,7 @@
|
|||||||
#import "Common/ShaderLib/Parallax.glsllib"
|
#import "Common/ShaderLib/Parallax.glsllib"
|
||||||
#import "Common/ShaderLib/Optics.glsllib"
|
#import "Common/ShaderLib/Optics.glsllib"
|
||||||
#ifndef VERTEX_LIGHTING
|
#ifndef VERTEX_LIGHTING
|
||||||
#import "Common/ShaderLib/PhongLighting.glsllib"
|
#import "Common/ShaderLib/BlinnPhongLighting.glsllib"
|
||||||
#import "Common/ShaderLib/Lighting.glsllib"
|
#import "Common/ShaderLib/Lighting.glsllib"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#import "Common/ShaderLib/Skinning.glsllib"
|
#import "Common/ShaderLib/Skinning.glsllib"
|
||||||
#import "Common/ShaderLib/Lighting.glsllib"
|
#import "Common/ShaderLib/Lighting.glsllib"
|
||||||
#ifdef VERTEX_LIGHTING
|
#ifdef VERTEX_LIGHTING
|
||||||
#import "Common/ShaderLib/PhongLighting.glsllib"
|
#import "Common/ShaderLib/BlinnPhongLighting.glsllib"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#import "Common/ShaderLib/Parallax.glsllib"
|
#import "Common/ShaderLib/Parallax.glsllib"
|
||||||
#import "Common/ShaderLib/Optics.glsllib"
|
#import "Common/ShaderLib/Optics.glsllib"
|
||||||
#ifndef VERTEX_LIGHTING
|
#ifndef VERTEX_LIGHTING
|
||||||
#import "Common/ShaderLib/PhongLighting.glsllib"
|
#import "Common/ShaderLib/BlinnPhongLighting.glsllib"
|
||||||
#import "Common/ShaderLib/Lighting.glsllib"
|
#import "Common/ShaderLib/Lighting.glsllib"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#import "Common/ShaderLib/Skinning.glsllib"
|
#import "Common/ShaderLib/Skinning.glsllib"
|
||||||
#import "Common/ShaderLib/Lighting.glsllib"
|
#import "Common/ShaderLib/Lighting.glsllib"
|
||||||
#ifdef VERTEX_LIGHTING
|
#ifdef VERTEX_LIGHTING
|
||||||
#import "Common/ShaderLib/PhongLighting.glsllib"
|
#import "Common/ShaderLib/BlinnPhongLighting.glsllib"
|
||||||
#endif
|
#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){
|
float lightComputeDiffuse(in vec3 norm, in vec3 lightdir){
|
||||||
return max(0.0, dot(norm, 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){
|
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);
|
vec3 R = reflect(-lightdir, norm);
|
||||||
return pow(max(dot(R, viewdir), 0.0), shiny);
|
return pow(max(dot(R, viewdir), 0.0), shiny);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Computes diffuse and specular factors and pack them in a vec2 (x=diffuse, y=specular)
|
* 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.material.Material;
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
import com.jme3.math.FastMath;
|
import com.jme3.math.FastMath;
|
||||||
|
import com.jme3.math.Quaternion;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.scene.Geometry;
|
import com.jme3.scene.Geometry;
|
||||||
import com.jme3.scene.shape.Sphere;
|
import com.jme3.scene.shape.Sphere;
|
||||||
|
import com.jme3.util.MaterialDebugAppState;
|
||||||
import com.jme3.util.TangentBinormalGenerator;
|
import com.jme3.util.TangentBinormalGenerator;
|
||||||
|
|
||||||
public class TestSimpleLighting extends SimpleApplication {
|
public class TestSimpleLighting extends SimpleApplication {
|
||||||
@ -62,8 +64,10 @@ public class TestSimpleLighting extends SimpleApplication {
|
|||||||
teapot.setLocalScale(2f);
|
teapot.setLocalScale(2f);
|
||||||
Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
|
Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
|
||||||
// mat.selectTechnique("GBuf");
|
// mat.selectTechnique("GBuf");
|
||||||
mat.setFloat("Shininess", 12);
|
mat.setFloat("Shininess", 25);
|
||||||
mat.setBoolean("UseMaterialColors", true);
|
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"));
|
// 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.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
|
||||||
dl.setColor(ColorRGBA.Green);
|
dl.setColor(ColorRGBA.Green);
|
||||||
rootNode.addLight(dl);
|
rootNode.addLight(dl);
|
||||||
|
|
||||||
|
|
||||||
|
MaterialDebugAppState debug = new MaterialDebugAppState();
|
||||||
|
debug.registerBinding("Common/ShaderLib/BlinnPhongLighting.glsllib", teapot);
|
||||||
|
stateManager.attach(debug);
|
||||||
|
setPauseOnLostFocus(false);
|
||||||
|
flyCam.setDragToRotate(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user