Ogre Version: : 1 12 13:
Operating System: :Linux Tumbleweed:
Render System: :OpenGL3+
Hello, I have this Dirt wall tile for my game , prepared in blender and exported by ogre-exporter:
Here it is how itlooks in ogre-meshviewer [ Clearly it works here !]
Here it how it looks in the game menu, after being copied over with proper materials and shaders to respective directories ?
What might be wrong ? I suspect tangents , but they are properly recreated with code :
Code: Select all
if(!Ogre::MeshManager::getSingleton().resourceExists(meshName,"Graphics"))
Ogre::MeshManager::getSingleton().load(meshName,"Graphics");
Ogre::MeshPtr meshPtr = Ogre::MeshManager::getSingleton().getByName(meshName,"Graphics");
unsigned short src, dest;
if (!meshPtr->suggestTangentVectorBuildParams(Ogre::VES_TANGENT, src, dest))
{
meshPtr->buildTangentVectors(Ogre::VES_TANGENT, src, dest);
}
Ogre::Entity* ent = mSceneManager->createEntity(entityName, meshPtr);
Clearly the fragment program does not kick in.... but there is not a trace of error in Ogre.log
Code: Select all
// Dirt
// import RTSS/NormalMapping_MultiPass from "RTShaderSystem.material"
vertex_program myDirtTileVertexShader glsl
{
source DirtTile.vert
default_params
{
param_named_auto projectionMatrix projection_matrix
param_named_auto viewMatrix view_matrix
param_named_auto worldMatrix world_matrix
param_named_auto lightMatrix texture_worldviewproj_matrix
}
}
fragment_program myDirtTileFragmentShader glsl
{
source DirtTile.frag
default_params
{
param_named_auto ambientLightColour ambient_light_colour
param_named_auto lightDiffuseColour light_diffuse_colour 0.0
param_named_auto lightSpecularColour light_specular_colour 0.0
param_named_auto lightPos light_position 0.0 0.0 0.0 0.0
param_named_auto cameraPosition camera_position
param_named_auto diffuseSurface surface_diffuse_colour
param_named shadowingEnabled bool false
}
}
material Dirt //: RTSS/NormalMapping_MultiPass
{
technique
{
pass
{
vertex_program_ref myDirtTileVertexShader
{
}
fragment_program_ref myDirtTileFragmentShader
{
param_named decalmap int 0
param_named normalmap int 1
param_named shadowmap int 2
}
// We use blending, so that we can see the underlying texture.
texture_unit decalmap
{
texture Dirt.png
}
texture_unit normalmap
{
texture DirtNormal.png
}
texture_unit shadowmap
{
content_type shadow
tex_address_mode clamp
filtering bilinear
}
}
}
Code: Select all
#version 330 core
uniform sampler2D decalmap;
uniform sampler2D normalmap;
uniform sampler2D shadowmap;
uniform vec4 ambientLightColour;
uniform vec4 lightDiffuseColour;
uniform vec4 lightSpecularColour;
uniform vec4 lightPos;
uniform vec4 cameraPosition;
uniform vec4 diffuseSurface;
uniform bool shadowingEnabled;
in vec2 out_UV0;
in vec2 out_UV1;
in vec3 FragPos;
in vec4 VertexPos;
in mat3 TBN;
out vec4 color;
void main (void)
{
vec3 texelColor = texture(decalmap, out_UV0.st).rgb;
// compute Normal
vec3 Normal = texture(normalmap, out_UV1.st).rgb;
Normal.xyz = 2 * Normal.xyz - (1.0,1.0,1.0);
Normal = normalize(TBN * Normal);
vec4 shadow = vec4(1.0, 1.0, 1.0,1.0);
vec4 tmpVertexPos = VertexPos;
// compute shadowmap
if(shadowingEnabled){
if(tmpVertexPos.z > 0 ){
tmpVertexPos /= tmpVertexPos.w;
shadow = texture(shadowmap, tmpVertexPos.xy);
}
}
// compute lightDir
vec3 lightDir = normalize(lightPos.xyz - FragPos*lightPos.w);
// compute Specular
vec3 viewDirection = normalize( cameraPosition.xyz - FragPos);
vec3 reflectedLightDirection = normalize(reflect(-1.0*lightDir.xyz,Normal));
float spec = max(dot(reflectedLightDirection, viewDirection ), 0.0) ;
spec = pow(spec,16);
vec3 specular = spec * lightSpecularColour.rgb;
// compute Diffuse
float diff = max(dot(lightDir,Normal), 0.0);
vec3 diffuse = diff * lightDiffuseColour.rgb;
vec3 result;
// precompute the lighting term
vec3 lightingTerm = (diffuse + specular + ambientLightColour.rgb/2.0 )*shadow.rgb;
if(diffuseSurface != vec4(1.0,1.0,1.0,1.0))
result = lightingTerm * mix(texelColor, diffuseSurface.rgb,0.5);
else
result = lightingTerm * texelColor;
color = vec4(result.xyz, 1.0);
}
EDIT: I have tried diffrent materials , but they don't work as expect, I always recive one color blob....