change shader version to 100 for android support
This commit is contained in:
parent
bd31e1058d
commit
f58fabcea9
36
shaders/sun_100.fs
Normal file
36
shaders/sun_100.fs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#version 100
|
||||||
|
|
||||||
|
precision mediump float;
|
||||||
|
|
||||||
|
varying vec2 fragTexCoord;
|
||||||
|
varying vec4 fragColor;
|
||||||
|
|
||||||
|
|
||||||
|
uniform vec3 color;
|
||||||
|
uniform float sun_radius;
|
||||||
|
uniform float start_transperency;
|
||||||
|
|
||||||
|
vec2 offset = vec2(1.0, 1.0);
|
||||||
|
float sun_end = 1.0;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
offset.x -= fragTexCoord.x * 2.0;
|
||||||
|
offset.y -= fragTexCoord.y * 2.0;
|
||||||
|
float radius = length(offset);
|
||||||
|
|
||||||
|
if(radius < sun_radius){
|
||||||
|
|
||||||
|
gl_FragColor = vec4(color, 1.0);
|
||||||
|
|
||||||
|
}else if(radius < sun_end){
|
||||||
|
|
||||||
|
float gradient = radius;
|
||||||
|
gradient -= sun_radius;
|
||||||
|
gradient = gradient / (sun_end - sun_radius) * start_transperency;
|
||||||
|
gl_FragColor = vec4(color, start_transperency - gradient);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
gl_FragColor = vec4(color, 0.0);
|
||||||
|
}
|
||||||
|
}
|
@ -5,37 +5,37 @@
|
|||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
#include <rlgl.h>
|
#include <rlgl.h>
|
||||||
|
|
||||||
const char* sun_shader = "#version 330\n\
|
const char* sun_shader_100 = "#version 100\n\
|
||||||
in vec2 fragTexCoord;\
|
precision mediump float;\
|
||||||
in vec4 fragColor;\
|
varying vec2 fragTexCoord;\
|
||||||
out vec4 finalColor;\
|
varying vec4 fragColor;\
|
||||||
uniform vec3 color;\
|
uniform vec3 color;\
|
||||||
uniform float sun_radius;\
|
uniform float sun_radius;\
|
||||||
uniform float start_transperency;\
|
uniform float start_transperency;\
|
||||||
vec2 offset = vec2(1.0f, 1.0f);\
|
vec2 offset = vec2(1.0, 1.0);\
|
||||||
float sun_end = 1.0f;\
|
float sun_end = 1.0;\
|
||||||
void main()\
|
void main()\
|
||||||
{\
|
{\
|
||||||
offset.x -= fragTexCoord.x * 2;\
|
offset.x -= fragTexCoord.x * 2.0;\
|
||||||
offset.y -= fragTexCoord.y * 2;\
|
offset.y -= fragTexCoord.y * 2.0;\
|
||||||
float radius = length(offset);\
|
float radius = length(offset);\
|
||||||
if (radius < sun_radius) {\
|
if (radius < sun_radius) {\
|
||||||
finalColor = vec4(color, 1.0f);\
|
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 / (sun_end - sun_radius) * start_transperency;\
|
||||||
finalColor = vec4(color, start_transperency - gradient);\
|
gl_FragColor = vec4(color, start_transperency - gradient);\
|
||||||
}\
|
}\
|
||||||
else {\
|
else {\
|
||||||
finalColor = vec4(color, 0.0f);\
|
gl_FragColor = vec4(color, 0.0);\
|
||||||
}\
|
}\
|
||||||
}";
|
}";
|
||||||
|
|
||||||
void Sun::init()
|
void Sun::init()
|
||||||
{
|
{
|
||||||
shader = LoadShaderFromMemory(0, sun_shader);
|
shader = LoadShaderFromMemory(0, sun_shader_100);
|
||||||
target = LoadRenderTexture(sizeTexute, sizeTexute);
|
target = LoadRenderTexture(sizeTexute, sizeTexute);
|
||||||
|
|
||||||
sun_radius_loc = GetShaderLocation(shader, "sun_radius");
|
sun_radius_loc = GetShaderLocation(shader, "sun_radius");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user