1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- [gd_scene load_steps=6 format=2]
- [ext_resource path="res://font.png" type="Texture" id=1]
- [ext_resource path="res://round.png" type="Texture" id=2]
- [ext_resource path="res://CPU_object.gd" type="Script" id=3]
- [sub_resource type="Shader" id=1]
- code = "shader_type canvas_item;
- render_mode blend_add;
- uniform vec4 color:hint_color;
- uniform vec4 text_col:hint_color;
- uniform int value;
- uniform int len;
- uniform sampler2D iChannel3;
- uniform float zoom_val; //only for outside zoom
- //https://www.shadertoy.com/view/tsdGzN
- // include global zoom
- void C(inout vec2 U, inout vec4 T, in int c, float z_v){
- U.x+=.5;
- if(U.x<.0||U.x>1.||U.y<0.||U.y>1. ){
- T+= vec4(0);
- }
- else{
- vec2 tu=U/16. + fract( vec2(float(c), float(15-c/16)) / 16.);
- tu.y=1.-tu.y;
- T+= textureGrad( iChannel3,tu, dFdx(tu/(16.*max(z_v,0.001))),dFdy(tu/(16.*max(z_v,0.001))));
- }
- }
- // X dig max
- float print_int(vec2 U, int val, float z_v) {
- vec4 T = vec4(0);
- int cval=val;
- int X=7;
- for(int i=0;i<X;i++){
- if(cval>0){
- int tv=cval%10;
- C(U,T,48+tv,z_v);
- cval=cval/10;
- }
- else{
- if(length(T.yz)==0.)
- return -1.;
- else return T.x;
- }
- }
- if(length(T.yz)==0.)
- return -1.;
- else return T.x;
- }
- vec4 add_text(in vec2 p, float z_v) {
- vec2 res=vec2(1.,.5);
- vec2 uv=(p-0.25)*2.;
- uv.y=1.-uv.y;
- int a=0;
- vec2 epos=vec2(-0.12*(float(len+a)-0.5),0.25);
- float c=print_int((uv*res-res/2.+epos)*2.,value,z_v);
- c=clamp(c,0.,1.);
- return vec4(c)*text_col*step(0.02,z_v);
- }
- void mainImage( out vec4 fragColor, in vec2 fragCoord, in vec2 iResolution , sampler2D iChannel0, float z_v)
- {
- vec2 uv=fragCoord/iResolution;
- vec4 tx=texture(iChannel0,uv);
- tx.rgb=tx.rgb+color.rgb*(1.-(tx.rgb));
- vec4 tf=add_text(uv,z_v);
- tx.rgb=mix(0.8*tx.rgb,tf.rgb*3.,tf.a);
- fragColor=tx;
- }
- void fragment(){
- vec2 iResolution=1./TEXTURE_PIXEL_SIZE;
- float z_v=zoom_val*iResolution.y/(1./SCREEN_PIXEL_SIZE).y;
- mainImage(COLOR,UV*iResolution,iResolution,TEXTURE,z_v);
- }"
- [sub_resource type="ShaderMaterial" id=2]
- shader = SubResource( 1 )
- shader_param/color = Color( 0.74902, 0.180392, 0.180392, 1 )
- shader_param/text_col = Color( 0.992157, 1, 0.207843, 1 )
- shader_param/value = 1234567
- shader_param/len = 7
- shader_param/zoom_val = 1.0
- shader_param/iChannel3 = ExtResource( 1 )
- [node name="CPU_object" type="Sprite"]
- material = SubResource( 2 )
- position = Vector2( 515.562, 327.28 )
- texture = ExtResource( 2 )
- script = ExtResource( 3 )
|