aboutsummaryrefslogtreecommitdiff
path: root/deps/raylib/examples/models/resources/shaders/glsl330
diff options
context:
space:
mode:
authorbonmas14 <bonmas14@gmail.com>2025-09-20 22:28:15 +0300
committerbonmas14 <bonmas14@gmail.com>2025-09-20 22:28:15 +0300
commitcdda4c4182c9ee068567529715e4a5c68a8efb58 (patch)
tree38a63f62a64018a2d35fc33354f8589fd33b7514 /deps/raylib/examples/models/resources/shaders/glsl330
downloadc_wizard-cdda4c4182c9ee068567529715e4a5c68a8efb58.tar.gz
c_wizard-cdda4c4182c9ee068567529715e4a5c68a8efb58.zip
Init commit v1.0
Diffstat (limited to 'deps/raylib/examples/models/resources/shaders/glsl330')
-rw-r--r--deps/raylib/examples/models/resources/shaders/glsl330/cubemap.fs30
-rw-r--r--deps/raylib/examples/models/resources/shaders/glsl330/cubemap.vs20
-rw-r--r--deps/raylib/examples/models/resources/shaders/glsl330/skinning.fs17
-rw-r--r--deps/raylib/examples/models/resources/shaders/glsl330/skinning.vs37
-rw-r--r--deps/raylib/examples/models/resources/shaders/glsl330/skybox.fs30
-rw-r--r--deps/raylib/examples/models/resources/shaders/glsl330/skybox.vs24
-rw-r--r--deps/raylib/examples/models/resources/shaders/glsl330/voxel_lighting.fs76
-rw-r--r--deps/raylib/examples/models/resources/shaders/glsl330/voxel_lighting.vs32
8 files changed, 266 insertions, 0 deletions
diff --git a/deps/raylib/examples/models/resources/shaders/glsl330/cubemap.fs b/deps/raylib/examples/models/resources/shaders/glsl330/cubemap.fs
new file mode 100644
index 0000000..f59003f
--- /dev/null
+++ b/deps/raylib/examples/models/resources/shaders/glsl330/cubemap.fs
@@ -0,0 +1,30 @@
+#version 330
+
+// Input vertex attributes (from vertex shader)
+in vec3 fragPosition;
+
+// Input uniform values
+uniform sampler2D equirectangularMap;
+
+// Output fragment color
+out vec4 finalColor;
+
+vec2 SampleSphericalMap(vec3 v)
+{
+ vec2 uv = vec2(atan(v.z, v.x), asin(v.y));
+ uv *= vec2(0.1591, 0.3183);
+ uv += 0.5;
+ return uv;
+}
+
+void main()
+{
+ // Normalize local position
+ vec2 uv = SampleSphericalMap(normalize(fragPosition));
+
+ // Fetch color from texture map
+ vec3 color = texture(equirectangularMap, uv).rgb;
+
+ // Calculate final fragment color
+ finalColor = vec4(color, 1.0);
+}
diff --git a/deps/raylib/examples/models/resources/shaders/glsl330/cubemap.vs b/deps/raylib/examples/models/resources/shaders/glsl330/cubemap.vs
new file mode 100644
index 0000000..d71f808
--- /dev/null
+++ b/deps/raylib/examples/models/resources/shaders/glsl330/cubemap.vs
@@ -0,0 +1,20 @@
+#version 330
+
+// Input vertex attributes
+in vec3 vertexPosition;
+
+// Input uniform values
+uniform mat4 matProjection;
+uniform mat4 matView;
+
+// Output vertex attributes (to fragment shader)
+out vec3 fragPosition;
+
+void main()
+{
+ // Calculate fragment position based on model transformations
+ fragPosition = vertexPosition;
+
+ // Calculate final vertex position
+ gl_Position = matProjection*matView*vec4(vertexPosition, 1.0);
+}
diff --git a/deps/raylib/examples/models/resources/shaders/glsl330/skinning.fs b/deps/raylib/examples/models/resources/shaders/glsl330/skinning.fs
new file mode 100644
index 0000000..d2d1868
--- /dev/null
+++ b/deps/raylib/examples/models/resources/shaders/glsl330/skinning.fs
@@ -0,0 +1,17 @@
+#version 330
+
+// Input vertex attributes (from vertex shader)
+in vec2 fragTexCoord;
+in vec4 fragColor;
+
+// Output fragment color
+out vec4 finalColor;
+
+uniform sampler2D texture0;
+uniform vec4 colDiffuse;
+
+void main()
+{
+ vec4 texelColor = texture(texture0, fragTexCoord);
+ finalColor = texelColor*colDiffuse*fragColor;
+}
diff --git a/deps/raylib/examples/models/resources/shaders/glsl330/skinning.vs b/deps/raylib/examples/models/resources/shaders/glsl330/skinning.vs
new file mode 100644
index 0000000..7513611
--- /dev/null
+++ b/deps/raylib/examples/models/resources/shaders/glsl330/skinning.vs
@@ -0,0 +1,37 @@
+#version 330
+
+#define MAX_BONE_NUM 128
+
+// Input vertex attributes
+in vec3 vertexPosition;
+in vec2 vertexTexCoord;
+in vec4 vertexColor;
+in vec4 vertexBoneIds;
+in vec4 vertexBoneWeights;
+
+// Input uniform values
+uniform mat4 mvp;
+uniform mat4 boneMatrices[MAX_BONE_NUM];
+
+// Output vertex attributes (to fragment shader)
+out vec2 fragTexCoord;
+out vec4 fragColor;
+
+void main()
+{
+ int boneIndex0 = int(vertexBoneIds.x);
+ int boneIndex1 = int(vertexBoneIds.y);
+ int boneIndex2 = int(vertexBoneIds.z);
+ int boneIndex3 = int(vertexBoneIds.w);
+
+ vec4 skinnedPosition =
+ vertexBoneWeights.x*(boneMatrices[boneIndex0]*vec4(vertexPosition, 1.0)) +
+ vertexBoneWeights.y*(boneMatrices[boneIndex1]*vec4(vertexPosition, 1.0)) +
+ vertexBoneWeights.z*(boneMatrices[boneIndex2]*vec4(vertexPosition, 1.0)) +
+ vertexBoneWeights.w*(boneMatrices[boneIndex3]*vec4(vertexPosition, 1.0));
+
+ fragTexCoord = vertexTexCoord;
+ fragColor = vertexColor;
+
+ gl_Position = mvp*skinnedPosition;
+} \ No newline at end of file
diff --git a/deps/raylib/examples/models/resources/shaders/glsl330/skybox.fs b/deps/raylib/examples/models/resources/shaders/glsl330/skybox.fs
new file mode 100644
index 0000000..d71fef0
--- /dev/null
+++ b/deps/raylib/examples/models/resources/shaders/glsl330/skybox.fs
@@ -0,0 +1,30 @@
+#version 330
+
+// Input vertex attributes (from vertex shader)
+in vec3 fragPosition;
+
+// Input uniform values
+uniform samplerCube environmentMap;
+uniform bool vflipped;
+uniform bool doGamma;
+
+// Output fragment color
+out vec4 finalColor;
+
+void main()
+{
+ // Fetch color from texture map
+ vec3 color = vec3(0.0);
+
+ if (vflipped) color = texture(environmentMap, vec3(fragPosition.x, -fragPosition.y, fragPosition.z)).rgb;
+ else color = texture(environmentMap, fragPosition).rgb;
+
+ if (doGamma)// Apply gamma correction
+ {
+ color = color/(color + vec3(1.0));
+ color = pow(color, vec3(1.0/2.2));
+ }
+
+ // Calculate final fragment color
+ finalColor = vec4(color, 1.0);
+}
diff --git a/deps/raylib/examples/models/resources/shaders/glsl330/skybox.vs b/deps/raylib/examples/models/resources/shaders/glsl330/skybox.vs
new file mode 100644
index 0000000..f41d469
--- /dev/null
+++ b/deps/raylib/examples/models/resources/shaders/glsl330/skybox.vs
@@ -0,0 +1,24 @@
+#version 330
+
+// Input vertex attributes
+in vec3 vertexPosition;
+
+// Input uniform values
+uniform mat4 matProjection;
+uniform mat4 matView;
+
+// Output vertex attributes (to fragment shader)
+out vec3 fragPosition;
+
+void main()
+{
+ // Calculate fragment position based on model transformations
+ fragPosition = vertexPosition;
+
+ // Remove translation from the view matrix
+ mat4 rotView = mat4(mat3(matView));
+ vec4 clipPos = matProjection*rotView*vec4(vertexPosition, 1.0);
+
+ // Calculate final vertex position
+ gl_Position = clipPos;
+}
diff --git a/deps/raylib/examples/models/resources/shaders/glsl330/voxel_lighting.fs b/deps/raylib/examples/models/resources/shaders/glsl330/voxel_lighting.fs
new file mode 100644
index 0000000..1b6c5cf
--- /dev/null
+++ b/deps/raylib/examples/models/resources/shaders/glsl330/voxel_lighting.fs
@@ -0,0 +1,76 @@
+#version 330
+
+// Input vertex attributes (from vertex shader)
+in vec3 fragPosition;
+//in vec2 fragTexCoord;
+in vec4 fragColor;
+in vec3 fragNormal;
+
+// Input uniform values
+//uniform sampler2D texture0;
+uniform vec4 colDiffuse;
+
+// Output fragment color
+out vec4 finalColor;
+
+// NOTE: Add here your custom variables
+
+#define MAX_LIGHTS 4
+#define LIGHT_DIRECTIONAL 0
+#define LIGHT_POINT 1
+
+struct Light {
+ int enabled;
+ int type;
+ vec3 position;
+ vec3 target;
+ vec4 color;
+};
+
+// Input lighting values
+uniform Light lights[MAX_LIGHTS];
+uniform vec4 ambient;
+uniform vec3 viewPos;
+
+void main()
+{
+ // Texel color fetching from texture sampler
+ //vec4 texelColor = texture(texture0, fragTexCoord);
+ vec3 lightDot = vec3(0.0);
+ vec3 normal = normalize(fragNormal);
+ vec3 viewD = normalize(viewPos - fragPosition);
+ vec3 specular = vec3(0.0);
+
+ // NOTE: Implement here your fragment shader code
+
+ for (int i = 0; i < MAX_LIGHTS; i++)
+ {
+ if (lights[i].enabled == 1)
+ {
+ vec3 light = vec3(0.0);
+
+ if (lights[i].type == LIGHT_DIRECTIONAL)
+ {
+ light = -normalize(lights[i].target - lights[i].position);
+ }
+
+ if (lights[i].type == LIGHT_POINT)
+ {
+ light = normalize(lights[i].position - fragPosition);
+ }
+
+ float NdotL = max(dot(normal, light), 0.0);
+ lightDot += lights[i].color.rgb*NdotL;
+
+ float specCo = 0.0;
+ if (NdotL > 0.0) specCo = pow(max(0.0, dot(viewD, reflect(-(light), normal))), 16.0); // 16 refers to shine
+ specular += specCo;
+ }
+ }
+
+ finalColor = (fragColor*((colDiffuse + vec4(specular, 1.0))*vec4(lightDot, 1.0)));
+ finalColor += fragColor*(ambient/10.0)*colDiffuse;
+
+ // Gamma correction
+ finalColor = pow(finalColor, vec4(1.0/2.2));
+}
diff --git a/deps/raylib/examples/models/resources/shaders/glsl330/voxel_lighting.vs b/deps/raylib/examples/models/resources/shaders/glsl330/voxel_lighting.vs
new file mode 100644
index 0000000..f60bfd2
--- /dev/null
+++ b/deps/raylib/examples/models/resources/shaders/glsl330/voxel_lighting.vs
@@ -0,0 +1,32 @@
+#version 330
+
+// Input vertex attributes
+in vec3 vertexPosition;
+//in vec2 vertexTexCoord;
+in vec3 vertexNormal;
+in vec4 vertexColor;
+
+// Input uniform values
+uniform mat4 mvp;
+uniform mat4 matModel;
+uniform mat4 matNormal;
+
+// Output vertex attributes (to fragment shader)
+out vec3 fragPosition;
+//out vec2 fragTexCoord;
+out vec4 fragColor;
+out vec3 fragNormal;
+
+// NOTE: Add here your custom variables
+
+void main()
+{
+ // Send vertex attributes to fragment shader
+ fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
+ //fragTexCoord = vertexTexCoord;
+ fragColor = vertexColor;
+ fragNormal = normalize(vec3(matNormal*vec4(vertexNormal, 1.0)));
+
+ // Calculate final vertex position
+ gl_Position = mvp*vec4(vertexPosition, 1.0);
+}