Shader Node

Hi guys,

i a work on shadows project. Currently ive done shadows using jogl in eclipse. But i want to use JME. I am preparing for it.

I have already written my shader files in last project.

Lets say i have something like the code down below. Is it possible to rewrite it to the Shader node or should i just use this shader file and forget about using shader node?

I get it how to use variables like vec4 etc…, but i dont know how to rewrite struct or the method like calculelight so it works with Shadow node…

The example code :

#version 330
in vec2 texCoord;
in vec3 normal;
in vec3 worldPosition;
in vec4 shadowCoord;
vec2 poissonDisk[4] = vec2[](
  vec2( -0.94201624, -0.39906216 ),
  vec2( 0.94558609, -0.76890725 ),
  vec2( -0.094184101, -0.92938870 ),
  vec2( 0.34495938, 0.29387760 )
);
struct BaseLight
{
 vec3 color;
 float intensity;
};

struct DirectionalLight
{
	BaseLight base;
	vec3 direction;
};

uniform sampler2D shadowSampler;
uniform sampler2D textureSampler;
uniform vec3 baseColor;
uniform vec3 ambientLight; 
uniform float specularIntensity;
uniform float specularExp;
uniform vec3 eyePosition;
uniform DirectionalLight drLight;

vec4 calculateLight(BaseLight base, vec3 direction, vec3 normal)
{

	float diffuse =  dot(normal, -direction);
	
	vec4 diffuseColor = vec4(0,0,0,0);
	vec4 specularColor = vec4(0,0,0,0);
	if(diffuse > 0.0){
		diffuseColor = vec4(base.color, 1.0) * base.intensity * diffuse;
		vec3 directionToEye = normalize(eyePosition - worldPosition);
		
		vec3 reflectDirection = normalize(reflect(direction, normal));
		
		float specularFactor = dot(directionToEye,reflectDirection);
		specularFactor = pow(specularFactor, specularExp);
		
		if(specularFactor > 0.0){
		 	specularColor = vec4(base.color,1) * specularIntensity * specularFactor;
		
		}
	}
	
	return diffuseColor + specularColor;
}

vec4 calculateDirectionalLight(DirectionalLight drLight, vec3 normal)
{
	return calculateLight(drLight.base, -drLight.direction, normal);
}

void main() {

vec4 color = vec4(baseColor,1);
vec4 totalLight = vec4(ambientLight,1);

vec3 normaln = normalize(normal);
float cosTheta = clamp(dot(normal,drLight.direction),0,1);
float bias = 0.0008 * tan(acos(cosTheta));
bias = clamp(bias, 0, 0.01);
float shadow = 1.0;
	if(shadowCoord.w > 0.0){
	for (int i=0;i<4;i++){
    if ( texture( shadowSampler, shadowCoord.xy + poissonDisk[i]/2000.0 ).z   <  shadowCoord.z - bias){
       shadow -= 0.2;
    }
	}
	}
vec4 textureColor = texture(textureSampler, texCoord.xy);
if(textureColor != vec4(0.0,0.0,0.0,1.0)){
    color *= textureColor;
}
color *= shadow;

totalLight += calculateDirectionalLight(drLight, normaln);
gl_FragColor = color * totalLight;
}