* Updated target to Raylib 6 + synced invoke called with the changes in C. [WARNING: Breaking changes!] * Added severial examples. Corrected towards the correct return type and add utilities to prevent working with pointers * Additional resources from the Raylib repo. * Fixed additional pinvokes to match with the new raylib bindings. [Warning breaking changes!] * Fixing the QOL utils * Fixing the Mesh struct * Applying changes after review. Merged resources.LICENSE + raylib-cs.Native.csproj only targets dotnet8 * Updated README to reflect .NET 10 and Raylib 6 compatibility changes. * Updated shader colors, adjusted car model scale, disabled HDR in SkyboxDemo, and fixed camera mode assignment. Removed unused `Capacity` field in FilePathList struct. * Improved XML comments for consistency, fixed spacing and formatting across examples, added new resources to `resources.LICENSE`. * Updated XML comment for `GetDirectoryFileCountEx` to clarify behavior and filtering options. * Updated and clarified XML comments for methods and parameters, improved naming consistency, and refined shader-related functions. Renamed enums in `Shader.cs` for so it is inline with the upstream. * Improved XML comments for clarity and consistency in `Model.cs` and `Mesh.cs`, updated method and variable names for better readability, and adjusted logic in span creation methods. * Corrected XML comment capitalization in `Model.cs`. --------- Co-authored-by: Meatcorps <info@meatcorps.nl>
56 lines
1.6 KiB
GLSL
56 lines
1.6 KiB
GLSL
#version 330 core
|
|
out vec4 finalColor;
|
|
|
|
in vec2 texCoord;
|
|
in vec2 texCoord2;
|
|
|
|
uniform sampler2D gPosition;
|
|
uniform sampler2D gNormal;
|
|
uniform sampler2D gAlbedoSpec;
|
|
|
|
struct Light {
|
|
int enabled;
|
|
int type; // Unused in this demo
|
|
vec3 position;
|
|
vec3 target; // Unused in this demo
|
|
vec4 color;
|
|
};
|
|
|
|
const int NR_LIGHTS = 4;
|
|
uniform Light lights[NR_LIGHTS];
|
|
uniform vec3 viewPosition;
|
|
|
|
const float QUADRATIC = 0.032;
|
|
const float LINEAR = 0.09;
|
|
|
|
void main()
|
|
{
|
|
vec3 fragPosition = texture(gPosition, texCoord).rgb;
|
|
vec3 normal = texture(gNormal, texCoord).rgb;
|
|
vec3 albedo = texture(gAlbedoSpec, texCoord).rgb;
|
|
float specular = texture(gAlbedoSpec, texCoord).a;
|
|
|
|
vec3 ambient = albedo*vec3(0.1f);
|
|
vec3 viewDirection = normalize(viewPosition - fragPosition);
|
|
|
|
for (int i = 0; i < NR_LIGHTS; i++)
|
|
{
|
|
if (lights[i].enabled == 0) continue;
|
|
vec3 lightDirection = lights[i].position - fragPosition;
|
|
vec3 diffuse = max(dot(normal, lightDirection), 0.0)*albedo*lights[i].color.xyz;
|
|
|
|
vec3 halfwayDirection = normalize(lightDirection + viewDirection);
|
|
float spec = pow(max(dot(normal, halfwayDirection), 0.0), 32.0);
|
|
vec3 specular = specular*spec*lights[i].color.xyz;
|
|
|
|
// Attenuation
|
|
float distance = length(lights[i].position - fragPosition);
|
|
float attenuation = 1.0/(1.0 + LINEAR*distance + QUADRATIC*distance*distance);
|
|
diffuse *= attenuation;
|
|
specular *= attenuation;
|
|
ambient += diffuse + specular;
|
|
}
|
|
|
|
finalColor = vec4(ambient, 1.0);
|
|
}
|
|
|