I am trying to render text, I tried to pass the FreeType bitmap buffer to the shader as:
- Only red channel as 0-255
- Only red channel as 0-1.0
- RGBA as 0-255
- RGBA as 0-1.0
I always get the same results. I am using this as shader, the commented code lines are previous attempts.
material {
name : TextMaterial,
shadingModel : unlit,
culling: none,
blending: transparent,
parameters : [
{
type : sampler2d,
name : texture
},
{
type : float,
name : minEdge
},
{
type : float,
name : maxEdge
}
],
requires : [position, uv0]
}
fragment {
void material(inout MaterialInputs material) {
prepareMaterial(material);
//vec3 textColor = vec3(0.0, 0.0, .0);
//vec4 clr = texture(materialParams_texture, getUV0());
//float distance = clr.r;
//if( distance < materialParams.minEdge )
// material.baseColor = vec4(textColor, 0.0 );
//else if( distance > materialParams.maxEdge )
// material.baseColor = vec4(textColor, 1.0);
//else{
//
//}
//float alpha = smoothstep(materialParams.minEdge,
// materialParams.maxEdge,
// distance);
//material.baseColor = vec4(textColor, alpha);
//if( distance > .5 )
// material.baseColor = vec4(textColor, distance);
//else
// material.baseColor = vec4( vec3(0.0, 0.0, .0), 0.0);
vec4 clr = texture(materialParams_texture, getUV0());
material.baseColor = clr;
}
}
Here is the sampler I am using, but I tried all the parameter combinations to no avail
filament::TextureSampler sampler(
filament::TextureSampler::MinFilter::LINEAR_MIPMAP_LINEAR,
filament::TextureSampler::MagFilter::NEAREST,
filament::TextureSampler::WrapMode::CLAMP_TO_EDGE
);
sampler.setWrapModeS(filament::TextureSampler::WrapMode::REPEAT);
sampler.setWrapModeT(filament::TextureSampler::WrapMode::REPEAT);
For large font sizes I get good rendering quality, but no so much for smaller font size, the included images are for font size 111, and 22


I only tried this on Windows 10 with a "nvidia gtx 1050 ti" GPU
I am trying to render text, I tried to pass the FreeType bitmap buffer to the shader as:
I always get the same results. I am using this as shader, the commented code lines are previous attempts.
Here is the sampler I am using, but I tried all the parameter combinations to no avail
For large font sizes I get good rendering quality, but no so much for smaller font size, the included images are for font size 111, and 22
I only tried this on Windows 10 with a "nvidia gtx 1050 ti" GPU