Opendungeons-plus: Depth test issue

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
paul424
Gnome
Posts: 314
Joined: Thu May 24, 2012 7:16 pm
x 13

Opendungeons-plus: Depth test issue

Post by paul424 »

Ogre Version: :1.12.13:
Operating System: :Linux Tumbleweed:
Render System: :GL3+:
See that tiny gold pot ?
It should be behind that dirt tile , inside that corridor -- that is occluded by the dirt tile.
I mix RTSS and custom vertex and pixel shaders.
Image

Code: Select all

Ogre.log (optional)
rpgplayerrobin
Gnoll
Posts: 619
Joined: Wed Mar 18, 2009 3:03 am
x 353

Re: Opendungeons-plus: Depth test issue

Post by rpgplayerrobin »

How does the material and fragment+vertex shaders look for the gold pot?
I would guess that is has disabled depth write or something like that.

User avatar
paul424
Gnome
Posts: 314
Joined: Thu May 24, 2012 7:16 pm
x 13

Re: Opendungeons-plus: Depth test issue

Post by paul424 »

Code: Select all

// Goldstacks genrated by blender2ogre 0.6.0
import RTSS/NormalMapping_MultiPass from "RTShaderSystem.material"
material Goldstacks : RTSS/NormalMapping_MultiPass
{
    receive_shadows on

technique
{
    pass lighting
    {
        // Override the normal map.
        rtshader_system
        {
            lighting_stage normal_map GoldStacksNormal.png
        }
    }

    pass decal
    {
        ambient 0.8 0.8 0.8 1.0
        diffuse 0.65 0.65 0.65 1.0
        specular 0.15 0.15 0.15 0.0 2.0
        emissive 0.1 0.1 0.1 0.0

        texture_unit decalmap
        {
            texture GoldStacks.png
            tex_address_mode wrap
            scale 1.0 1.0
            colour_op modulate
        }
    }
}
}
User avatar
paul424
Gnome
Posts: 314
Joined: Thu May 24, 2012 7:16 pm
x 13

Re: Opendungeons-plus: Depth test issue

Post by paul424 »

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 } } } }

AND also :

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); }

and vertex shader :

Code: Select all

#include "PerlinNoise.glsl" 

uniform    mat4 projectionMatrix;
uniform    mat4 viewMatrix;
uniform    mat4 worldMatrix;
uniform    mat4 lightMatrix;

layout (location = 0) in vec4 position;
layout (location = 2)  in vec3 normal;
layout (location = 14) in vec3 tangent;
 
layout (location = 8) in vec2 uv_0;
layout (location = 8) in vec2 uv_1;

out vec2 out_UV0;
out vec2 out_UV1;

out vec3 FragPos;
out vec4 VertexPos; 
 
out mat3 TBN;
 
float freq = 3.1415; 
 
vec3 deform(vec3 pos) {
    pos.x += perlin(pos.x,pos.y);
    pos.y += perlin(pos.y,pos.x);
    return pos;
}
 
 
void main() {
    // compute world space position, tangent, bitangent
    vec3 P = (worldMatrix * position).xyz;
    vec3 T = normalize(vec3(worldMatrix * vec4(tangent, 0.0)));
    vec3 B = normalize(vec3(worldMatrix * vec4(cross(tangent, normal), 0.0))); 
 
// apply deformation
vec3 PT = deform(P + T);
vec3 PB = deform(P + B);
P = deform(P);

// compute tangent frame
T = normalize(PT - P);
B = normalize(PB - P);
vec3 N = cross(B, T);
TBN = mat3(T, B, N);
 
gl_Position = projectionMatrix * viewMatrix * vec4(P, 1.0);
FragPos = P;
 
out_UV0 = uv_0;
out_UV1 = uv_1;
VertexPos = lightMatrix * position;    
}  
rpgplayerrobin
Gnoll
Posts: 619
Joined: Wed Mar 18, 2009 3:03 am
x 353

Re: Opendungeons-plus: Depth test issue

Post by rpgplayerrobin »

Unfortunately I cannot see anything in the materials/shaders that might be incorrect.

You will have to either:

  • Try to identify more of the problem yourself.
    Like, does it only happen when you mix the custom shaders and the RTSS?
    What happens if you only use RTSS or only use custom shaders?
    There is so much to test regarding this which other people might need in order for them to help.

  • Create a minimal scene which has the exact issue.
    That way other people can also help and you might even figure out what is wrong yourself.
    It might even be a bug in Ogre which can be fixed.

  • Debug it with a graphics debugger, which can debug each and every pixel on the screen and why it renders it above the other mesh (like the Visual Studio one for Direct3D11 called Graphics Debugger).
    Maybe that might be hard to do on Linux, but you might find an alternative.

Post Reply