Update shader for android

This commit is contained in:
Nikola Petrov 2025-02-15 22:34:24 +01:00
parent e020784f4f
commit 1994e7ccb1
8 changed files with 143 additions and 153 deletions

View File

@ -1,10 +1,3 @@
# how to build
```
g++ build.cpp -o build
./build
or
./build run
```
# Code style # Code style
@ -35,6 +28,6 @@ or
## Generate shader .h files ## Generate shader .h files
``` ```
xxd -i shaders/sun_100.fs > inc/sunShader.hpp xxd -i shaders/sun_100.fs > shared/inc/canvas/sunShader.hpp
xxd -i shaders/sun_330.fs >> inc/sunShader.hpp xxd -i shaders/sun_330.fs >> shared/inc/canvas/sunShader.hpp
``` ```

View File

@ -1,17 +1,17 @@
#version 100 #version 300 es
precision mediump float; precision mediump float;
varying vec2 fragTexCoord; in vec2 fragTexCoord;
varying vec4 fragColor; in vec4 fragColor;
out vec4 finalColor;
uniform vec3 color; uniform vec3 color;
uniform float sun_radius;
uniform float start_transperency;
vec2 offset = vec2(1.0, 1.0); vec2 offset = vec2(1.0, 1.0);
float sun_end = 1.0;
float start_transparency = 0.40f;
float sun_radius = 0.6f;
float sun_end = 1.0f;
void main() void main()
{ {
@ -20,17 +20,13 @@ void main()
float radius = length(offset); float radius = length(offset);
if(radius < sun_radius){ if(radius < sun_radius){
finalColor = vec4(color, 1.0);
gl_FragColor = vec4(color, 1.0);
}else if(radius < sun_end){ }else if(radius < sun_end){
float gradient = radius; float gradient = radius;
gradient -= sun_radius; gradient -= sun_radius;
gradient = gradient / (sun_end - sun_radius) * start_transperency; gradient = gradient / 0.4f * start_transparency;
gl_FragColor = vec4(color, start_transperency - gradient); finalColor = vec4(color, start_transparency - gradient);
}else{ }else{
gl_FragColor = vec4(color, 0.0); finalColor = vec4(color, 0.0);
} }
} }

View File

@ -5,9 +5,10 @@ in vec4 fragColor;
out vec4 finalColor; out vec4 finalColor;
uniform vec3 color; uniform vec3 color;
uniform float sun_radius; vec2 offset = vec2(1.0, 1.0);
uniform float start_transperency;
vec2 offset = vec2(1.0f, 1.0f); float start_transparency = 0.40f;
float sun_radius = 0.6f;
float sun_end = 1.0f; float sun_end = 1.0f;
void main() void main()
@ -20,8 +21,8 @@ void main()
}else if(radius < sun_end){ }else if(radius < sun_end){
float gradient = radius; float gradient = radius;
gradient -= sun_radius; gradient -= sun_radius;
gradient = gradient / (sun_end - sun_radius) * start_transperency; gradient = gradient / 0.4f * start_transparency;
finalColor = vec4(color, start_transperency - gradient); finalColor = vec4(color, start_transparency - gradient);
}else{ }else{
finalColor = vec4(color, 0.0f); finalColor = vec4(color, 0.0f);
} }

View File

@ -6,7 +6,6 @@ public:
static void init(); static void init();
static void deinit(); static void deinit();
static void setColor(Color color); static void setColor(Color color);
static void setSoftEdge(bool soft);
static void draw(float x, float y, float size); static void draw(float x, float y, float size);
Circle() = delete; Circle() = delete;
@ -16,11 +15,6 @@ private:
static RenderTexture2D target; static RenderTexture2D target;
static Shader shader; static Shader shader;
static float radius;
static float start_transperency;
static float c[3]; static float c[3];
static int radius_loc;
static int start_transperency_loc;
static int colorLoc; static int colorLoc;
}; };

View File

@ -1,88 +1,123 @@
const char *sun_shader_100 = "#version 100\n\ unsigned char shaders_sun_100_fs[] = {
precision mediump float;\ 0x23, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x33, 0x30, 0x30,
varying vec2 fragTexCoord;\ 0x20, 0x65, 0x73, 0x0a, 0x0a, 0x70, 0x72, 0x65, 0x63, 0x69, 0x73, 0x69,
varying vec4 fragColor;\ 0x6f, 0x6e, 0x20, 0x6d, 0x65, 0x64, 0x69, 0x75, 0x6d, 0x70, 0x20, 0x66,
uniform vec3 color;\ 0x6c, 0x6f, 0x61, 0x74, 0x3b, 0x0a, 0x0a, 0x69, 0x6e, 0x20, 0x76, 0x65,
uniform float sun_radius;\ 0x63, 0x32, 0x20, 0x66, 0x72, 0x61, 0x67, 0x54, 0x65, 0x78, 0x43, 0x6f,
uniform float start_transperency;\ 0x6f, 0x72, 0x64, 0x3b, 0x0a, 0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x34,
vec2 offset = vec2(1.0, 1.0);\ 0x20, 0x66, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a,
float sun_end = 1.0;\ 0x6f, 0x75, 0x74, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x66, 0x69, 0x6e,
void main()\ 0x61, 0x6c, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x0a, 0x75, 0x6e,
{\ 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x63,
offset.x -= fragTexCoord.x * 2.0;\ 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x76, 0x65, 0x63, 0x32, 0x20, 0x6f,
offset.y -= fragTexCoord.y * 2.0;\ 0x66, 0x66, 0x73, 0x65, 0x74, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x32,
float radius = length(offset);\ 0x28, 0x31, 0x2e, 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x0a,
if (radius < sun_radius) {\ 0x0a, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74,
gl_FragColor = vec4(color, 1.0);\ 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x63,
}\ 0x79, 0x20, 0x3d, 0x20, 0x30, 0x2e, 0x34, 0x30, 0x66, 0x3b, 0x0a, 0x66,
else if (radius < sun_end) {\ 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x72, 0x61, 0x64,
float gradient = radius;\ 0x69, 0x75, 0x73, 0x20, 0x3d, 0x20, 0x30, 0x2e, 0x36, 0x66, 0x3b, 0x0a,
gradient -= sun_radius;\ 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x65, 0x6e,
gradient = gradient / (sun_end - sun_radius) * start_transperency;\ 0x64, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x66, 0x3b, 0x0a, 0x0a, 0x76,
gl_FragColor = vec4(color, start_transperency - gradient);\ 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x29, 0x0a, 0x7b,
}\ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x2e,
else {\ 0x78, 0x20, 0x2d, 0x3d, 0x20, 0x66, 0x72, 0x61, 0x67, 0x54, 0x65, 0x78,
gl_FragColor = vec4(color, 0.0);\ 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x2e, 0x78, 0x20, 0x2a, 0x20, 0x32, 0x2e,
}\ 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x66, 0x66, 0x73, 0x65,
}"; 0x74, 0x2e, 0x79, 0x20, 0x2d, 0x3d, 0x20, 0x66, 0x72, 0x61, 0x67, 0x54,
0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x2e, 0x79, 0x20, 0x2a, 0x20,
0x32, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f,
0x61, 0x74, 0x20, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x20, 0x3d, 0x20,
0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x28, 0x6f, 0x66, 0x66, 0x73, 0x65,
0x74, 0x29, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x28,
0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x20, 0x3c, 0x20, 0x73, 0x75, 0x6e,
0x5f, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x29, 0x7b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x43,
0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x28,
0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x69,
0x66, 0x28, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x20, 0x3c, 0x20, 0x73,
0x75, 0x6e, 0x5f, 0x65, 0x6e, 0x64, 0x29, 0x7b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x67,
0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x3d, 0x20, 0x72, 0x61,
0x64, 0x69, 0x75, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x2d,
0x3d, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x67, 0x72,
0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x3d, 0x20, 0x67, 0x72, 0x61,
0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x2f, 0x20, 0x30, 0x2e, 0x34, 0x66,
0x20, 0x2a, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x72, 0x61,
0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x6e, 0x61, 0x6c,
0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34,
0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x73, 0x74, 0x61, 0x72,
0x74, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e,
0x63, 0x79, 0x20, 0x2d, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e,
0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x65, 0x6c, 0x73,
0x65, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66,
0x69, 0x6e, 0x61, 0x6c, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20,
0x76, 0x65, 0x63, 0x34, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20,
0x30, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a,
0x7d, 0x0a
};
unsigned int shaders_sun_100_fs_len = 710;
unsigned char shaders_sun_330_fs[] = { unsigned char shaders_sun_330_fs[] = {
0x23, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x33, 0x33, 0x30, 0x23, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x33, 0x33, 0x30,
0x0a, 0x0a, 0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x66, 0x72, 0x0a, 0x0a, 0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x66, 0x72,
0x61, 0x67, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x3b, 0x0a, 0x61, 0x67, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x3b, 0x0a,
0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x66, 0x72, 0x61, 0x67, 0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x66, 0x72, 0x61, 0x67,
0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x6f, 0x75, 0x74, 0x20, 0x76, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x6f, 0x75, 0x74, 0x20, 0x76,
0x65, 0x63, 0x34, 0x20, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x43, 0x6f, 0x6c, 0x65, 0x63, 0x34, 0x20, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x43, 0x6f, 0x6c,
0x6f, 0x72, 0x3b, 0x0a, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x6f, 0x72, 0x3b, 0x0a, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d,
0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3b,
0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x66, 0x6c, 0x6f, 0x0a, 0x76, 0x65, 0x63, 0x32, 0x20, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74,
0x61, 0x74, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x72, 0x61, 0x64, 0x69, 0x75, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x31, 0x2e, 0x30, 0x2c,
0x73, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x66, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x0a, 0x66, 0x6c, 0x6f, 0x61,
0x6c, 0x6f, 0x61, 0x74, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x74, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x72, 0x61, 0x6e,
0x72, 0x61, 0x6e, 0x73, 0x70, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x3b, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x20, 0x3d, 0x20, 0x30,
0x0a, 0x76, 0x65, 0x63, 0x32, 0x20, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x2e, 0x34, 0x30, 0x66, 0x3b, 0x0a, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20,
0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x31, 0x2e, 0x30, 0x66, 0x73, 0x75, 0x6e, 0x5f, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x20, 0x3d,
0x2c, 0x20, 0x31, 0x2e, 0x30, 0x66, 0x29, 0x3b, 0x0a, 0x66, 0x6c, 0x6f, 0x20, 0x30, 0x2e, 0x36, 0x66, 0x3b, 0x0a, 0x66, 0x6c, 0x6f, 0x61, 0x74,
0x61, 0x74, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x65, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x65, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x31,
0x20, 0x31, 0x2e, 0x30, 0x66, 0x3b, 0x0a, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x2e, 0x30, 0x66, 0x3b, 0x0a, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d,
0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x61, 0x69, 0x6e, 0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x2e, 0x78, 0x20, 0x2d, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x2e, 0x78, 0x20, 0x2d, 0x3d, 0x20,
0x3d, 0x20, 0x66, 0x72, 0x61, 0x67, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x66, 0x72, 0x61, 0x67, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64,
0x72, 0x64, 0x2e, 0x78, 0x20, 0x2a, 0x20, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x2e, 0x78, 0x20, 0x2a, 0x20, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x2e, 0x79, 0x20, 0x2d, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x2e, 0x79, 0x20, 0x2d, 0x3d, 0x20,
0x3d, 0x20, 0x66, 0x72, 0x61, 0x67, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x66, 0x72, 0x61, 0x67, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64,
0x72, 0x64, 0x2e, 0x79, 0x20, 0x2a, 0x20, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x2e, 0x79, 0x20, 0x2a, 0x20, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x72, 0x61, 0x64, 0x69, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73,
0x75, 0x73, 0x20, 0x3d, 0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x28, 0x20, 0x3d, 0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x28, 0x6f, 0x66,
0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x66, 0x73, 0x65, 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69,
0x20, 0x69, 0x66, 0x28, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x20, 0x3c, 0x66, 0x28, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x20, 0x3c, 0x20, 0x73,
0x20, 0x73, 0x75, 0x6e, 0x5f, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x29, 0x75, 0x6e, 0x5f, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x29, 0x7b, 0x0a,
0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x6e, 0x61,
0x6e, 0x61, 0x6c, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76, 0x6c, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63,
0x65, 0x63, 0x34, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x31, 0x34, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x31, 0x2e, 0x30,
0x2e, 0x30, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x65, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x65, 0x6c, 0x73,
0x6c, 0x73, 0x65, 0x20, 0x69, 0x66, 0x28, 0x72, 0x61, 0x64, 0x69, 0x75, 0x65, 0x20, 0x69, 0x66, 0x28, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x20,
0x73, 0x20, 0x3c, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x65, 0x6e, 0x64, 0x29, 0x3c, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x65, 0x6e, 0x64, 0x29, 0x7b, 0x0a,
0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61,
0x6f, 0x61, 0x74, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x74, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x3d,
0x20, 0x3d, 0x20, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x20, 0x20, 0x20, 0x20, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e,
0x65, 0x6e, 0x74, 0x20, 0x2d, 0x3d, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x72, 0x74, 0x20, 0x2d, 0x3d, 0x20, 0x73, 0x75, 0x6e, 0x5f, 0x72, 0x61, 0x64,
0x61, 0x64, 0x69, 0x75, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x75, 0x73, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x3d, 0x20,
0x3d, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x2f, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x2f, 0x20, 0x30,
0x20, 0x28, 0x73, 0x75, 0x6e, 0x5f, 0x65, 0x6e, 0x64, 0x20, 0x2d, 0x20, 0x2e, 0x34, 0x66, 0x20, 0x2a, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f,
0x73, 0x75, 0x6e, 0x5f, 0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x29, 0x20, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x63, 0x79,
0x2a, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69,
0x73, 0x70, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x6e, 0x61, 0x6c, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x43, 0x65, 0x63, 0x34, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x73,
0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x28, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61,
0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x20, 0x2d, 0x20, 0x67, 0x72, 0x61, 0x64,
0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x69, 0x65, 0x6e, 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d,
0x79, 0x20, 0x2d, 0x20, 0x67, 0x72, 0x61, 0x64, 0x69, 0x65, 0x6e, 0x74, 0x65, 0x6c, 0x73, 0x65, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x20, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x43, 0x6f, 0x6c, 0x6f, 0x72,
0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x28, 0x63, 0x6f, 0x6c, 0x6f,
0x6e, 0x61, 0x6c, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76, 0x72, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20,
0x65, 0x63, 0x34, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x30, 0x20, 0x20, 0x7d, 0x0a, 0x7d, 0x0a
0x2e, 0x30, 0x66, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, };
0x7d, 0x0a}; unsigned int shaders_sun_330_fs_len = 678;

View File

@ -52,7 +52,6 @@ void BackGround::deinit()
void BackGround::draw(Dna *dna) void BackGround::draw(Dna *dna)
{ {
Circle::setSoftEdge(true);
m_dna = dna; m_dna = dna;
mountenSeed = dna->mountenSeed; mountenSeed = dna->mountenSeed;
starSeed = dna->starSeed; starSeed = dna->starSeed;

View File

@ -6,11 +6,7 @@
RenderTexture2D Circle::target; RenderTexture2D Circle::target;
Shader Circle::shader; Shader Circle::shader;
float Circle::radius;
float Circle::start_transperency;
float Circle::c[3]; float Circle::c[3];
int Circle::radius_loc;
int Circle::start_transperency_loc;
int Circle::colorLoc; int Circle::colorLoc;
void Circle::init() void Circle::init()
@ -22,14 +18,6 @@ void Circle::init()
#endif #endif
target = LoadRenderTexture(sizeTexute, sizeTexute); target = LoadRenderTexture(sizeTexute, sizeTexute);
radius = 0.6f;
radius_loc = GetShaderLocation(shader, "sun_radius");
SetShaderValue(shader, radius_loc, &radius, SHADER_UNIFORM_FLOAT);
start_transperency = 0.40f;
start_transperency_loc = GetShaderLocation(shader, "start_transperency");
SetShaderValue(shader, start_transperency_loc, &start_transperency, SHADER_UNIFORM_FLOAT);
c[0] = 1.0f; c[0] = 1.0f;
c[1] = 1.0f; c[1] = 1.0f;
c[2] = 1.0f; c[2] = 1.0f;
@ -55,19 +43,6 @@ void Circle::setColor(Color color)
SetShaderValue(shader, colorLoc, c, SHADER_UNIFORM_VEC3); SetShaderValue(shader, colorLoc, c, SHADER_UNIFORM_VEC3);
} }
void Circle::setSoftEdge(bool soft)
{
if (soft)
{
radius = 0.6f;
}
else
{
radius = 1.0f;
}
SetShaderValue(shader, radius_loc, &radius, SHADER_UNIFORM_FLOAT);
}
void Circle::draw(float x, float y, float size) void Circle::draw(float x, float y, float size)
{ {
Rectangle dest = {x - size, y - size, size * 2, size * 2}; Rectangle dest = {x - size, y - size, size * 2, size * 2};

View File

@ -1,7 +1,6 @@
#include <cmath> #include <cmath>
#include "canvas/Tree.hpp" #include "canvas/Tree.hpp"
#include "canvas/Circle.hpp"
#include <raylib.h> #include <raylib.h>
#include <raymath.h> #include <raymath.h>
@ -45,8 +44,6 @@ void Tree::init(int size)
void Tree::draw(Dna *dna) void Tree::draw(Dna *dna)
{ {
Circle::setSoftEdge(false);
m_dna = dna; m_dna = dna;
branchSeed = dna->branchSeed; branchSeed = dna->branchSeed;
drawCalls.push_back({start, 180.0f, 0}); drawCalls.push_back({start, 180.0f, 0});