Bad effect for mesh with transparent PNG texture

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
machineonpointer
Kobold
Posts: 35
Joined: Fri Dec 06, 2013 4:15 am

Bad effect for mesh with transparent PNG texture

Post by machineonpointer »

I tried for many material paramters and searched google. The following two materials with texture unit show output
the original png color. But only the material using shader reaches the ideal effect.
There is a slightly transparent background with the environmental light color using material in METHOD2 without shader....

Must I use the shader to render the mesh with transparent material?

METHOD 1
////////////////////////fragment shader////////////////////////////////////////////
#version 100
precision mediump float;

uniform sampler2D RT;
varying vec4 oUv0;

void main(void)
{
gl_FragColor = texture2D(RT, oUv0.xy);
}

////////////////vertex shader////////////////////////
#version 100

precision mediump int;
precision mediump float;

uniform mat4 worldViewProj;

attribute vec4 position;
attribute vec4 uv0;

varying vec4 oUv0;

void main()
{
gl_Position = worldViewProj * position;
oUv0 = uv0;
}


///////////////////material using shaders//////////////////////
material magnetHaloMtl
{
technique
{
pass magnetHaloMtl
{
alpha_to_coverage off
colour_write on
cull_hardware clockwise
depth_check on
depth_func less_equal
depth_write on
illumination_stage
light_clip_planes off
light_scissor off
lighting off
normalise_normals off
polygon_mode solid
scene_blend alpha_blend
shading gouraud
transparent_sorting on

fragment_program_ref diffuseTex_FP_glsles
{
}
vertex_program_ref diffuseTex_VP_glsles
{
}
texture_unit RT
{
texture magnetBkg.png
tex_address_mode clamp
colour_op alpha_blend
}
}
}
}



METHOD 2
//////////////////////////////////////material without shader///////////////////////
material magnetHaloMtl
{
technique
{
pass magnetHaloMtl
{
alpha_to_coverage off
colour_write on
cull_hardware clockwise
depth_check on
depth_func less_equal
depth_write on
illumination_stage
light_clip_planes off
light_scissor off
lighting off
normalise_normals off
polygon_mode solid
scene_blend alpha_blend
shading gouraud
transparent_sorting on

texture_unit
{
texture magnetBkg.png
tex_address_mode clamp
colour_op alpha_blend
}
}
}
}
User avatar
c6burns
Beholder
Posts: 1512
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines
x 138

Re: Bad effect for mesh with transparent PNG texture

Post by c6burns »

You are actually using shaders with both materials, because you are using GLES2 are you not?
machineonpointer
Kobold
Posts: 35
Joined: Fri Dec 06, 2013 4:15 am

Re: Bad effect for mesh with transparent PNG texture

Post by machineonpointer »

c6burns wrote:You are actually using shaders with both materials, because you are using GLES2 are you not?
Yes, I'm using GLES2. So the shaders ogred generated automatically is different from the one specified explicitly?
For gles2 it seems hard to reach good result without integrating shaders in material explicitly.
User avatar
c6burns
Beholder
Posts: 1512
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines
x 138

Re: Bad effect for mesh with transparent PNG texture

Post by c6burns »

RTSS is cool for prototyping and has some useful features otherwise, but I use my own shaders for production. Although, you can cache the RTSS shaders to inspect them after they are generated, and you can directly modify the functions of the shader library to suit your needs.
machineonpointer
Kobold
Posts: 35
Joined: Fri Dec 06, 2013 4:15 am

Re: Bad effect for mesh with transparent PNG texture

Post by machineonpointer »

c6burns wrote:RTSS is cool for prototyping and has some useful features otherwise, but I use my own shaders for production. Although, you can cache the RTSS shaders to inspect them after they are generated, and you can directly modify the functions of the shader library to suit your needs.
So for gles2 do you use shader for every material? It's not a small work, especially for particle system for which the color of particle need to be changed timely.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Bad effect for mesh with transparent PNG texture

Post by Kojack »

GLES2 (and DirectX 11 and OpenGL 3+) can't work without shaders, every material needs them (not ogre's fault, that's just how opengles2 works).
The RTSS (Run Time Shader System) should be able to generate them for you if you enable it, but I never use it myself (I prefer to write my own shaders when needed), so I can't really say much about it.
There's info on it here: http://www.ogre3d.org/tikiwiki/tiki-ind ... der+System
User avatar
c6burns
Beholder
Posts: 1512
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines
x 138

Re: Bad effect for mesh with transparent PNG texture

Post by c6burns »

Yes I have a shader for every single material. Graphics APIs are all moving away from FFP. You either write a bunch of specialized shaders, or write an uber shader, or write a shader generator.

In terms of particles, most particle systems adjust vertex colour with their colour affector. So you take that attribute in the vertex program and pass it as varying to the fragment. Ogre does text colours the same way.
Post Reply