Oki , I ended up having this , learning from
https://learnopengl.com/Advanced-Lighti ... al-Mapping
Code: Select all
// Gold genrated by blender2ogre 0.6.0
// import RTSS/NormalMapping_MultiPass from "RTShaderSystem.material"
vertex_program myVertexShader glsl
{
source distortion.vert
default_params
{
param_named_auto projectionMatrix projection_matrix
param_named_auto viewMatrix view_matrix
param_named_auto worldMatrix world_matrix
}
}
fragment_program myFragmentShader glsl
{
source distortion.frag
default_params
{
// param_named_auto surfaceAmbient surfaceAmbient 1.0 1.0 1.0 1.0
param_named_auto lightColour light_diffuse_colour 0 0 0
param_named_auto lightPos light_position 0 0 0
}
}
material Gold //: RTSS/NormalMapping_MultiPass
{
// receive_shadows on
technique
{
pass zero
{
vertex_program_ref myVertexShader
{
}
fragment_program_ref myFragmentShader
{
param_named decalmap int 0
param_named normalmap int 1
}
texture_unit
{
texture Gold.png
}
texture_unit
{
texture GoldNormal.png
}
}
}
}
Code: Select all
#version 330 core
uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;
uniform mat4 worldMatrix;
layout (location = 0) in vec4 aPos;
layout (location = 2) in vec3 aNormal;
layout (location = 14) in vec3 aTangent;
layout (location = 8) in vec2 uv_0;
layout (location = 9) in vec2 uv_1;
out vec2 out_UV0;
out vec2 out_UV1;
out vec3 FragPos;
out mat3 TBN;
float freq = 3.14;
void main()
{
vec4 worldPos = worldMatrix * aPos;
worldPos.z *= (1 + sin((worldPos.x + 2*worldPos.y ) * freq)/8.0);
vec3 T = normalize(vec3( worldMatrix * vec4(aTangent, 0.0)));
vec3 N = normalize(vec3( worldMatrix * vec4(aNormal, 0.0)));
vec3 B = cross(T,N);
gl_Position = projectionMatrix * viewMatrix * vec4(worldPos.xyz, 1.0);
FragPos = worldPos.xyz;
TBN = mat3(T, B, N);
out_UV0 = uv_0;
out_UV1 = uv_1;
}
Code: Select all
#version 330 core
#extension GL_ARB_separate_shader_objects: enable
#extension GL_ARB_texture_rectangle: enable
uniform sampler2D myTexture;
uniform sampler2D m_NormalMap;
uniform vec4 surfaceAmbient;
uniform vec3 lightColour;
uniform vec3 lightPos;
in vec2 out_UV0;
in vec2 out_UV1;
in vec3 FragPos;
in VS_OUT {
mat3 TBN;
} fs_in;
out vec4 color;
void main (void)
{
vec3 texelColor = texture(myTexture, out_UV0).rgb;
vec3 Normal = texture(m_NormalMap, out_UV1).rgb;
Normal.xy = 2 * Normal.xy - (1.0,1.0);
Normal = normalize(fs_in.TBN * Normal);
vec3 lightDir = normalize(lightPos - FragPos);
float diff = max(dot(Normal, lightDir), 0.0);
vec3 diffuse = diff * lightColour;
vec3 result = (diffuse /*+ surfaceAmbient.rgb*/ ) * texelColor;
color = vec4(result.xyz, 1.0);
}
1) it works only with Ogre Renderer GLSL, and not GLSL3+ ( with the second it crashes with frame (22:01:09) (StackTraceUnix) [CRITICAL] (StackTraceUnix.cpp:207) [bt]: (1) /usr/local/lib/OGRE/RenderSystem_GL3Plus.so.1.12.9 : Ogre::GLSLMonolithicProgram::buildGLUniformReferences()+0x3a [0x7fcd4c4b7b0a]
yuck... )
What does it make conformat to GLSL and not GLSL3+ ?