Recent

Author Topic: Font renderer and Phong shader not applied in TextOutAngle  (Read 1878 times)

winni

  • Hero Member
  • *****
  • Posts: 590
Font renderer and Phong shader not applied in TextOutAngle
« on: December 02, 2019, 05:36:26 pm »
New version - new bugs!

I refer to the attached image.
Create a font renderer and his shader.
Do a simple TextOut. Everything is fine as shown by "TEST".

Use the same unchanged Font with renderer and shader with TextOutAngle -
they are not applied. You can see it in the Mickey-Mouse-Style "LAZARUS".

This worked in 9.x

Have not looked for the reason. Perhaps somebody else?

Winni

winni

  • Hero Member
  • *****
  • Posts: 590
Re: Font renderer and Phong shader not applied in TextOutAngle
« Reply #1 on: December 03, 2019, 02:16:25 pm »
@circular

I have traced which wrong deviation TextOutAngle takes:

BGRAdefaultbitmap.TextOutAngle; virtual
BGRATextFX.TBGRATextEffectFontRenderer.InternalTextOut 

Here it takes a wrong junction:

Code: Pascal  [Select]
  1. if (FFont.Orientation <> 0) or (not ShaderActuallyActive and not ShadowActuallyVisible and not OutlineActuallyVisible) then
  2.     begin
  3.     inherited InternalTextOut(ADest,x,y,sUTF8,c,texture,align,AShowPrefix,ARightToLeft);
  4.   end else      

The inherited InternalTextOut leads to

Code: Pascal  [Select]
  1. BGRAText.InternalTextOut

where it of course looses the renderer and shader.

So the if condition in above shown code is buggy.
I just replaced it for a test and have set it to false and: renderer and shader apperared,
but no angles - of course.

So please look for this line:

if (FFont.Orientation <> 0) or (not ShaderActuallyActive and not  ......

Or ask George Boole ....

This is the hard way to learn the internals of BGRA!
But the code is easy to read! Good structure!

Winni

« Last Edit: December 03, 2019, 02:20:32 pm by winni »

circular

  • Hero Member
  • *****
  • Posts: 3049
    • Personal webpage
Re: Font renderer and Phong shader not applied in TextOutAngle
« Reply #2 on: December 04, 2019, 04:59:56 pm »
Hi

I am not sure it worked before. In my memory, phong shading was never supported with angle.

I think I did not do it because I was not sure it would be used. That would be some new development. Though as I did the same with vectorial text of LazPaint layers, I have an rough idea how to implement it.
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 3049
    • Personal webpage
Re: Font renderer and Phong shader not applied in TextOutAngle
« Reply #3 on: December 04, 2019, 05:01:04 pm »
This is the hard way to learn the internals of BGRA!
But the code is easy to read! Good structure!
:D I tried to make a structure as much as possible.
Conscience is the debugger of the mind

winni

  • Hero Member
  • *****
  • Posts: 590
Re: Font renderer and Phong shader not applied in TextOutAngle
« Reply #4 on: December 04, 2019, 05:14:07 pm »
Hi Circular!

You got a broken memory chip in the brain .... :D

I made the Mickey-Mouse-Style "LAZARUS" summer '19 with BGRAbitmap 9.9.3.
Everything worked fine, renderer and phong were shown as in simple TextOut.
I have updated to 10.6.4 and suddenly it is broken.
So you must have implemented it.

So take a look at 9.9.x - there must be somewhere the solution.

Winni



circular

  • Hero Member
  • *****
  • Posts: 3049
    • Personal webpage
Re: Font renderer and Phong shader not applied in TextOutAngle
« Reply #5 on: December 04, 2019, 05:16:23 pm »
Broken memory. :D

Ok I will look.

Where is the mickey code?
Conscience is the debugger of the mind

winni

  • Hero Member
  • *****
  • Posts: 590
Re: Font renderer and Phong shader not applied in TextOutAngle
« Reply #6 on: December 04, 2019, 05:32:28 pm »
Here it is

Code: Pascal  [Select]
  1.    .....
  2. const angle=15;
  3.       top=25;
  4.       name='LAZARUS';
  5.       Ari = 'Arial';
  6. var
  7.    .....
  8.  
  9.      dest := TBGRABitmap.create(300, 80,CSSSkyBlue);
  10.      SetFineFont(dest,[fsBold],55,Ari);
  11.      shader := TPhongShading.Create;
  12.      renderer := TBGRATextEffectFontRenderer.Create(shader,True);
  13.      dest.FontRenderer := renderer;
  14.      shader.LightPositionZ := 80;
  15.      shader.LightSourceIntensity := 250;
  16.      shader.LightPosition := Point(150,0);
  17.      shader.SpecularFactor := 0.5;
  18.      renderer.OutlineVisible := true;
  19.      renderer.OutlineWidth := 2;
  20.      renderer.OuterOutlineOnly := false;
  21.      renderer.OutlineColor := CSSDarkSlateBlue;
  22.      ts := dest.TextSize(name);
  23.      x := dest.width div 2 - ts.cx div 2;
  24.      startx := x;
  25.      s := name;
  26.      
  27. for i := 1 to length(s) do // only ASCII
  28.       begin
  29.        case i mod 4 of
  30.             1,3: dest.TextOutAngle(x,top,   -10,copy (s,i,1),CSSRed,taLeftJustify);
  31.             2:   dest.TextOutAngle(x-7,top+5, +angle*10,copy(s,i,1),CSSRed,taLeftJustify);
  32.             0:   dest.TextOutAngle(x+7,top-5, -angle*10,copy(s,i,1),CSSRed,taLeftJustify);
  33.          end; // case
  34.          x := x+dest.TextSize(copy(s,i,1)).cx-9;
  35.      end;
  36. .....

Winni
« Last Edit: December 04, 2019, 05:39:08 pm by winni »

circular

  • Hero Member
  • *****
  • Posts: 3049
    • Personal webpage
Re: Font renderer and Phong shader not applied in TextOutAngle
« Reply #7 on: December 04, 2019, 11:32:35 pm »
Ok. I was more thinking about working code. A project, or something I can just copy and paste as it is.
Conscience is the debugger of the mind

winni

  • Hero Member
  • *****
  • Posts: 590
Re: Font renderer and Phong shader not applied in TextOutAngle
« Reply #8 on: December 04, 2019, 11:40:35 pm »
@circular

Ok, I'm gonna make you a little demo Project!

Winni

winni

  • Hero Member
  • *****
  • Posts: 590
Re: Font renderer and Phong shader not applied in TextOutAngle
« Reply #9 on: December 05, 2019, 12:05:07 am »
@circular

I made you a little demo project - see attachment

Winni

circular

  • Hero Member
  • *****
  • Posts: 3049
    • Personal webpage
Re: Font renderer and Phong shader not applied in TextOutAngle
« Reply #10 on: December 05, 2019, 07:51:37 pm »
Thanks.

Ok so my memory chip is not so broken. Phong did not work in this case on old BGRABitmap 9.9.3 though it did draw the outline.

I am going to fix this outline and well while I am at it, make the Phong work.
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 3049
    • Personal webpage
Re: Font renderer and Phong shader not applied in TextOutAngle
« Reply #11 on: December 05, 2019, 10:03:44 pm »
Hi!

I've fixed on dev-bgrabitmap branch the outline and added phong and shadow support with rotated and outlined text.

Can you have a try?

 8-)
Conscience is the debugger of the mind

winni

  • Hero Member
  • *****
  • Posts: 590
Re: Font renderer and Phong shader not applied in TextOutAngle
« Reply #12 on: December 06, 2019, 01:19:08 am »
Bravo circular!

Everything works like it should. Nice rendering an nice phong shade!

But you detect my errors now:

If you apply  a shader and a renderer and then do a textout (without angle) with an empty string you will get an exception with "Path is empty".
I think you should spend somewhere an exit.

So I now find my errors ....

Thanx a very lot!

Winni

circular

  • Hero Member
  • *****
  • Posts: 3049
    • Personal webpage
Re: Font renderer and Phong shader not applied in TextOutAngle
« Reply #13 on: December 06, 2019, 06:40:43 pm »
Thanks for the feedback.

I fixed the empty string case.

Thanks for the
So I now find my errors ....
Not sure what you're saying.
Conscience is the debugger of the mind

winni

  • Hero Member
  • *****
  • Posts: 590
Re: Font renderer and Phong shader not applied in TextOutAngle
« Reply #14 on: December 06, 2019, 08:48:27 pm »
@circular:

Just: without your bug (Empty Path) I would not have dectected my nonsense (TextOut with empty string) !

Winni