- Fixed parallax distortion thanks to Survivor

- Used a quad in TestParallax instead of a grid

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9173 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 13 years ago
parent bb9b2ea5ce
commit 26ffa11655
  1. 3
      engine/src/core-data/Common/MatDefs/Light/Lighting.frag
  2. 3
      engine/src/core-data/Common/MatDefs/Light/Lighting.vert
  3. 20
      engine/src/test/jme3test/material/TestParallax.java

@ -249,8 +249,9 @@ void main(){
#else
vec4 lightDir = vLightDir;
lightDir.xyz = normalize(lightDir.xyz);
vec3 viewDir = normalize(vViewDir);
vec2 light = computeLighting(normal, vViewDir.xyz, lightDir.xyz) * spotFallOff;
vec2 light = computeLighting(normal, viewDir, lightDir.xyz) * spotFallOff;
#ifdef COLORRAMP
diffuseColor.rgb *= texture2D(m_ColorRamp, vec2(light.x, 0.0)).rgb;
specularColor.rgb *= texture2D(m_ColorRamp, vec2(light.y, 0.0)).rgb;

@ -158,7 +158,8 @@ void main(){
mat3 tbnMat = mat3(wvTangent, wvBinormal * -inTangent.w,wvNormal);
//vPosition = wvPosition * tbnMat;
vViewDir = viewDir * tbnMat;
//vViewDir = viewDir * tbnMat;
vViewDir = -wvPosition * tbnMat;
lightComputeDir(wvPosition, lightColor, wvLightPos, vLightDir);
vLightDir.xyz = (vLightDir.xyz * tbnMat).xyz;
#elif !defined(VERTEX_LIGHTING)

@ -45,6 +45,7 @@ import com.jme3.renderer.queue.RenderQueue.ShadowMode;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Quad;
import com.jme3.texture.Texture.WrapMode;
import com.jme3.util.SkyFactory;
import com.jme3.util.TangentBinormalGenerator;
@ -78,12 +79,21 @@ public class TestParallax extends SimpleApplication {
mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat);
mat.setFloat("Shininess", 0);
Node floorGeom = (Node) assetManager.loadAsset("Models/WaterTest/WaterTest.mesh.xml");
Geometry g = ((Geometry) floorGeom.getChild(0));
g.getMesh().scaleTextureCoordinates(new Vector2f(10, 10));
// Node floorGeom = (Node) assetManager.loadAsset("Models/WaterTest/WaterTest.mesh.xml");
//Geometry g = ((Geometry) floorGeom.getChild(0));
//g.getMesh().scaleTextureCoordinates(new Vector2f(10, 10));
Node floorGeom = new Node("floorGeom");
Quad q = new Quad(100, 100);
q.scaleTextureCoordinates(new Vector2f(10, 10));
Geometry g = new Geometry("geom", q);
g.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
floorGeom.attachChild(g);
TangentBinormalGenerator.generate(floorGeom);
floorGeom.setLocalTranslation(0, 22, 0);
floorGeom.setLocalScale(100);
floorGeom.setLocalTranslation(-50, 22, 60);
//floorGeom.setLocalScale(100);
floorGeom.setMaterial(mat);
rootNode.attachChild(floorGeom);

Loading…
Cancel
Save