text helper

  • kingeric1992
  • Topic Author
More
6 years 9 months ago - 6 years 9 months ago #1 by kingeric1992 text helper was created by kingeric1992
a header file for drawing text
demo usage:
Warning: Spoiler!

Result:

[hr]

github link
[img
Last edit: 6 years 9 months ago by kingeric1992.
The following user(s) said Thank You: WLHM15

Please Log in or Create an account to join the conversation.

  • BlueSkyKnight
More
6 years 9 months ago - 6 years 9 months ago #2 by BlueSkyKnight Replied by BlueSkyKnight on topic text helper
Neat... Looks like I did it the hard/tedious way. since I didn't want to use any external texture.



github.com/BlueSkyDefender/Depth3D/blob/...t_Sharp.fx#L316-L452

Your solution is better and easier. Since it allows for much more freedom.
Last edit: 6 years 9 months ago by BlueSkyKnight.

Please Log in or Create an account to join the conversation.

  • kingeric1992
  • Topic Author
More
6 years 9 months ago - 6 years 9 months ago #3 by kingeric1992 Replied by kingeric1992 on topic text helper
yeah, I don't think ppl would ever use this, but it is kind of handy as a utility header.

another approach would be the 3x5 char like in the ascii sahder.
//3x5 num/char text
int getTextBit( int id ) {  
    int cText[10] = { 
        31599,  9362, 29671, 29647, 23497,//0,1,2,3,4
        31183, 31215, 31305, 31727, 31689 //5,6,7,8,9
        //expand char here
    };

    return cText[max(id, 9)];
}

float text(float2 uv, int n){
    uv = 1.0 - uv;

    float bit = pow(2.0, floor(uv.x*3.0) + 3.0*floor(uv.y*5.0));
    uv = abs(uv - 0.5);
   
    return step( 0.5, floor(float(getTextBit(n))/bit) % 2.0)*
           step(uv.x, 0.499)*step(uv.y, 0.499);
}
and it is possible to add a AA func to upscale the text to x2 scale or x3 scale.
Last edit: 6 years 9 months ago by kingeric1992.

Please Log in or Create an account to join the conversation.

  • Marty McFly
More
6 years 9 months ago #4 by Marty McFly Replied by Marty McFly on topic text helper
This might come in handy :)

btw: pow(2,x) -> exp2(x)

Please Log in or Create an account to join the conversation.

  • kingeric1992
  • Topic Author
More
6 years 9 months ago #5 by kingeric1992 Replied by kingeric1992 on topic text helper
should be fine as long as gl/hlsl compilers are doing constant folding.
pow(2, x) --> exp2( x * log2(2) ) ---> exp2(x)

though, not the same for the case of pow(x, 2)
where hlsl would resolve to x*x and gl might not.

Please Log in or Create an account to join the conversation.

  • hunt1hunt
More
6 years 3 weeks ago #6 by hunt1hunt Replied by hunt1hunt on topic text helper
@kingeric1992:text helper.fx(44, 1): error X3000: syntax error: unexpected 'identifier'

Please Log in or Create an account to join the conversation.

  • hunt1hunt
More
6 years 1 week ago #7 by hunt1hunt Replied by hunt1hunt on topic text helper
thanks,!Why i use the shader can't this show text?

Please Log in or Create an account to join the conversation.

  • hunt1hunt
More
6 years 1 week ago - 6 years 1 week ago #8 by hunt1hunt Replied by hunt1hunt on topic text helper
kingeric1992,hi,Why i use the shader can't this show text? i use reshade322,yes can show text now :P

Warning: Spoiler!

Last edit: 6 years 1 week ago by hunt1hunt.

Please Log in or Create an account to join the conversation.