Probleme with a glsl shader

hello, I have a problem with the glsl

my shader is "ok" in the the "Shaderdesigner" but "jme" impossible that

it appears the same way


package jmetest.effects;

import com.jme.app.SimpleGame;
import com.jme.app.SimplePassGame;
import com.jme.image.Texture;
import com.jme.image.Texture2D;
import com.jme.math.FastMath;
import com.jme.math.Quaternion;
import com.jme.math.Vector2f;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.renderer.pass.RenderPass;
import com.jme.scene.Node;
import com.jme.scene.shape.Quad;
import com.jme.scene.shape.Sphere;
import com.jme.scene.state.GLSLShaderObjectsState;
import com.jme.scene.state.TextureState;
import com.jme.util.TextureManager;

public class GLSLTest extends SimpleGame
{
   
   
   Vector3f LightPosition = new Vector3f() ;
   float MaterialThickness ;
   Vector3f ExtinctionCoefficient = new Vector3f() ;
   ColorRGBA LightColor  = new ColorRGBA();
   ColorRGBA BaseColor  = new ColorRGBA();
   ColorRGBA SpecColor = new ColorRGBA();   // speculaire
    float SpecPower;  // puisance de speculaire
    float RimScalar;
    private Quaternion rotQuat = new Quaternion();
    private Vector3f axis = new Vector3f(1, 1, 0);
    private float angle = 0;
    Texture base_tex ;
    Texture Normal ;
    Texture Base_Height;
    float u_invRad;
    Node furryNode  = new Node();
  
    Vector2f cBumpSize  = new  Vector2f();
   
   @Override
   protected void simpleInitGame()
   {
      LightPosition.x = 0 ;
      LightPosition.y = 0 ;
      LightPosition.z = -10 ;
      
      ExtinctionCoefficient.x = 4 ;
      ExtinctionCoefficient.y = 2 ;
      ExtinctionCoefficient.z = 3 ;
      
      MaterialThickness = 0.0f ;
      
      LightColor.b = 1;
      LightColor.g = 1;
      LightColor.b = 1;
      LightColor.a = 1;
      
      BaseColor.b = 0.925f;
      BaseColor.g = 0.905f;
      BaseColor.b = 0.884f;
      BaseColor.a = 1;
      
      SpecColor.b = 0.845f;
      SpecColor.g = 0.830f;
      SpecColor.b = 0.830f;
      SpecColor.a = 1;
      
      SpecPower = 0.5f;
      
       RimScalar  = 0.060f;
      
       u_invRad = 0.2f ;
     
       cBumpSize.x = 0.04200005f;
       cBumpSize.y =-0.04999996f;
      
      display.setTitle( "GLSL" );
       display.getRenderer().setBackgroundColor(new ColorRGBA( 0.0f, 0.0f, 1.0f, 0.5f ));
       
        Sphere s = buildSphere();
        furryNode.attachChild(s) ;
        rootNode.attachChild(furryNode);
        rootNode.updateRenderState();
   }
   
   private Sphere buildSphere()
   {
      Sphere sphere = new Sphere("sphere1",32,32,4);
      //sphere.setLocalScale(18f);
     // Quad  sphere = new Quad("waterQuad", 8, 8);
      GLSLShaderObjectsState so = display.getRenderer()
        .createGLSLShaderObjectsState();

      // Check is GLSL is supported on current hardware.
      if (!so.isSupported())
      {
      quit();
      }
       TextureState ts = display.getRenderer().createTextureState();
         ts.setEnabled(true);
        base_tex = TextureManager.loadTexture(
               GLSLTest.class.getClassLoader().getResource(//uvfauteuil_Circle.tga
                     "com/jmex/effects/glsl/data/testsss.jpg"),Texture.MinificationFilter.Trilinear,
                   Texture.MagnificationFilter.Bilinear);
        base_tex.setEnvironmentalMapMode(Texture.EnvironmentalMapMode.ObjectLinear);
       base_tex.setWrap(Texture.WrapMode.Repeat);
          Normal = TextureManager.loadTexture(
               GLSLTest.class.getClassLoader().getResource(//uvfauteuil_Circle.tga
                     "com/jmex/effects/glsl/data/testsssnm.jpg"),Texture.MinificationFilter.Trilinear,
                   Texture.MagnificationFilter.Bilinear);
          Normal.setEnvironmentalMapMode(Texture.EnvironmentalMapMode.ObjectLinear);
         Normal.setWrap(Texture.WrapMode.Repeat);
          Base_Height = TextureManager.loadTexture(
               GLSLTest.class.getClassLoader().getResource(//uvfauteuil_Circle.tga
                     "com/jmex/effects/glsl/data/testssslm.jpg"),Texture.MinificationFilter.Trilinear,
                   Texture.MagnificationFilter.Bilinear);
          Base_Height.setEnvironmentalMapMode(Texture.EnvironmentalMapMode.ObjectLinear);
         Base_Height.setWrap(Texture.WrapMode.Repeat);
         ts.setTexture(base_tex,0);
         ts.setTexture(Normal,1);
         ts.setTexture(Base_Height,2);
        
         sphere.setRenderState(ts);
        
         so.load(GLSLTest.class.getClassLoader().getResource("com/jmex/effects/glsl/data/sss.vert"),
              GLSLTest.class.getClassLoader().getResource("com/jmex/effects/glsl/data/sss.frag"));
       
       
      so.setUniform("LightPosition", LightPosition);   
      so.setUniform("MaterialThickness",MaterialThickness);
      so.setUniform("ExtinctionCoefficient", ExtinctionCoefficient); 
      so.setUniform("LightColor", LightColor);
      so.setUniform("BaseColor", BaseColor);
      so.setUniform("SpecColor", SpecColor);
      so.setUniform("SpecPower", SpecPower);
      so.setUniform("RimScalar", RimScalar);
      
       so.setUniform("base_tex", 0);
      so.setUniform("Normal", 1);
      so.setUniform("Base_Height", 2);
      so.setUniform("u_invRad",u_invRad);
      so.setUniform("cBumpSize",cBumpSize);
      
      so.setEnabled(true);
      
      sphere.updateRenderState();
      
      sphere.updateGeometricState(0, true);
      
   
      sphere.setRenderState(so);
      sphere.updateRenderState();
      
      return sphere;
   }
     protected void simpleUpdate() {
           if (tpf < 1) {
               angle = angle + (tpf * 25);
               if (angle > 360) {
                   angle = 0;
               }
           }

           rotQuat.fromAngleNormalAxis(angle * FastMath.DEG_TO_RAD, axis);
           furryNode.setLocalRotation(rotQuat);
          
       }
   public static void main(String []args)
   {
      GLSLTest app = new GLSLTest();
   //   app.setDialogBehaviour(ALWAYS_SHOW_PROPS_DIALOG);
      app.start();
   }
}



what the problem ?

in Shaderdesigner :



in jme


can you post the shaders as well?

vertex :


uniform sampler2D Base_Height;

   // Set light-position
   uniform vec3 LightPosition;

attribute vec3 tangent;
attribute vec3 binormal;

// inverse light radius ie.. 1.0/light radius;
uniform float u_invRad;

varying   vec3 g_lightVec;
varying   vec3 g_viewVec;

   // Varying variables to be sent to Fragment Shader
   varying vec3 worldNormal, eyeVec, lightVec, vertPos, lightPos;
   
   void subScatterVS(in vec4 ecVert)
   {
       lightVec = LightPosition - ecVert.xyz;
       eyeVec = -ecVert.xyz;
       vertPos = ecVert.xyz;
       lightPos = LightPosition;
   }
   

   
   void main()
   {
       worldNormal = gl_NormalMatrix * gl_Normal;
   
       vec4 ecPos = gl_ModelViewProjectionMatrix * gl_Vertex;
   
       // Call function to set varyings for subscatter FS
       subScatterVS(ecPos);
   
       //Transform vertex by modelview and projection matrices
       gl_Position = ecPos ;
   
       //Forward current texture coordinates after applying texture matrix
       gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0 ;
      

   gl_Position = ftransform();
   gl_TexCoord[0] = gl_MultiTexCoord0;
   
   mat3 TBN_Matrix = gl_NormalMatrix * mat3(tangent, binormal, gl_Normal);
   vec4 mv_Vertex = gl_ModelViewMatrix * gl_Vertex;
   g_viewVec = vec3(-mv_Vertex) * TBN_Matrix;   
   vec4 light = gl_ModelViewMatrix * gl_LightSource[0].position;
   vec3 lightVec = u_invRad * (light.xyz - mv_Vertex.xyz);
   g_lightVec = lightVec * TBN_Matrix;
   
      
   }



pixel :


   // Variables for lighting properties
   uniform float MaterialThickness; //epaiseur
   uniform vec3 ExtinctionCoefficient; // Will show as X Y and Z ports in QC, but actually represent RGB values. absorvitivit

i don't see where in your initial code you are passing the tangent and binormal attributes for the shader…

i typically use this to pass mesh tangents and binormals to shaders



// get the glsl shader object state
GLSLShaderObjectsState   shaderState = object.getRenderState(RenderState.StateType.GLSLShaderObjects);
   
// populate the tangent and binormal buffers
TangentBinormalGenerator.generate(mesh);

// set the shader attributes
shaderState.setAttributePointer("tangent", 3, true, 0, mesh.getTangentBuffer());    shaderState.setAttributePointer("binormal", 3, true, 0, mesh.getBinormalBuffer());


so I made my way you shown but now my whole sphere and black

I began to take well to the shader?




GLSLShaderObjectsState sos=(GLSLShaderObjectsState) sphere.getRenderState(RenderState.StateType.GLSLShaderObjects);

      // set the shader attributes
      TangentBinormalGenerator.generate(sphere);


// set the shader attributes
sos.setAttributePointer("tangent", 3, true, 0, sphere.getTangentBuffer());    
sos.setAttributePointer("binormal", 3, true, 0, sphere.getBinormalBuffer());



can you pm the source code, shaders and resources you are using and i'll try to debug it for you…

Part of the answer

I put a toon shader it works properly



but before I put a parallax shader bump is in the example of "shader designer" it does not work the black sphere appears there are 2 attributes

binormal and tangent

i used the jme normal mapping shader and the object appears ok…

is this meant to be a fur shader?

not there is a shader that supposed to be and marble should be like the first photo of my post have anything with a fur shader

can you post a picture of the result please?