I am porting some materials to 3.0 that used to work on 2.1 and I have encountered an issue where the rendering doesn't seem to take alpha channel of the texture into account.
Code: Select all
// GLSL shaders
vertex_program sh_portal_vs_GLSL glsl
{
source sh_portal_vs.glsl
}
fragment_program sh_portal_ps_GLSL glsl
{
source sh_portal_fs.glsl
}
// GLSLES shaders
vertex_program sh_portal_vs_GLSLES glsles
{
source sh_portal_vs.glsles
}
fragment_program sh_portal_ps_GLSLES glsles
{
source sh_portal_fs.glsles
}
// VK shaders
vertex_program sh_portal_vs_VK glslvk
{
source sh_portal_vs.glsl
}
fragment_program sh_portal_ps_VK glslvk
{
source sh_portal_fs.glsl
}
// HLSL shaders
vertex_program sh_portal_vs_HLSL hlsl
{
source sh_portal_vs.hlsl
entry_point main
target vs_5_0 vs_4_0 vs_4_0_level_9_1 vs_4_0_level_9_3
}
fragment_program sh_portal_ps_HLSL hlsl
{
source sh_portal_fs.hlsl
entry_point main
target ps_5_0 ps_4_0 ps_4_0_level_9_1 ps_4_0_level_9_3
}
// Metal shaders
vertex_program sh_portal_vs_Metal metal
{
source sh_portal_vs.metal
}
fragment_program sh_portal_ps_Metal metal
{
source sh_portal_fs.metal
shader_reflection_pair_hint sh_portal_vs_Metal
}
// Unified definitions
vertex_program sh_portal_vs unified
{
delegate sh_portal_vs_HLSL
delegate sh_portal_vs_GLSL
delegate sh_portal_vs_GLSLES
delegate sh_portal_vs_Metal
delegate sh_portal_vs_VK
default_params
{
param_named_auto matWorldViewProjection worldviewproj_matrix
}
}
fragment_program sh_portal_ps unified
{
delegate sh_portal_ps_HLSL
delegate sh_portal_ps_GLSL
delegate sh_portal_ps_GLSLES
delegate sh_portal_ps_Metal
delegate sh_portal_ps_VK
default_params
{
param_named_auto fSinTime0_X sintime_0_x 1.0
param_named blurAmount float4 1.0 1.0 1.0 1.0
}
}
material portal_mat
{
technique
{
pass
{
depth_check on
depth_write on
cull_hardware none
scene_blend src_alpha one_minus_src_alpha
vertex_program_ref sh_portal_vs
{
}
fragment_program_ref sh_portal_ps
{
}
texture_unit
{
texture portal_done1.png
}
}
}
}
Shaders code vs:
Code: Select all
#version ogre_glsl_ver_330
vulkan_layout( OGRE_POSITION ) in vec3 vertex;
vulkan_layout( OGRE_DIFFUSE )in vec4 colour;
vulkan_layout( OGRE_TEXCOORD0 ) in vec2 uv0;
vulkan( layout( ogre_P0 ) uniform Params { )
uniform mat4 matWorldViewProjection;
vulkan( }; )
vulkan_layout( location = 0 )
out block
{
vec2 uv;
vec4 color;
} outVs;
void main()
{
gl_Position = matWorldViewProjection * vec4(vertex, 1.0);
outVs.color = colour;
outVs.uv = uv0;
}
Shader code ps:
Code: Select all
#version ogre_glsl_ver_330
vulkan_layout( ogre_t0 ) uniform texture2D portalTexture;
vulkan( layout( ogre_s0 ) uniform sampler texSampler );
vulkan( layout( ogre_P0 ) uniform Params { )
uniform vec4 blurAmount;
uniform float fSinTime0_X;
vulkan( }; )
vulkan_layout( location = 0 )
in block
{
in vec2 uv;
in vec4 color;
} inPs;
vulkan_layout( location = 0 )
out vec4 o_fragColor;
void main()
{
int i;
vec4 tmpOutColor;
float diffuseGlowFactor;
vec2 offsets[4];
offsets[0] = vec2(-1.8, -1.8);
offsets[1] = vec2(-1.8, 1.8);
offsets[2] = vec2(1.8, -1.8);
offsets[3] = vec2(1.8, 1.8);
tmpOutColor = texture( vkSampler2D( portalTexture, texSampler ), inPs.uv );
diffuseGlowFactor = 0.0113 * (2.0 - max( tmpOutColor.r, tmpOutColor.g ));
for (i = 0; i < 4; i++) {
tmpOutColor += inPs.color * texture( vkSampler2D( portalTexture, texSampler ), inPs.uv + fSinTime0_X * blurAmount.x * diffuseGlowFactor * offsets[i] );
}
tmpOutColor *= vec4(0.25, 0.25, 0.25, 1.0);
o_fragColor = tmpOutColor;
}
I suspect the issue is that the png file texture's alpha channel is not read properly.
Later edit: Nope. Vk returns texture format VK_FORMAT_R8G8B8A8_UNORM so the alpha channel is there.