Merge branch 'master' of https://github.com/raysan5/raylib
This commit is contained in:
commit
bbf884d7b3
40 changed files with 132 additions and 130 deletions
|
|
@ -7,6 +7,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers
|
||||||
| Name | raylib Version | Language | License |
|
| Name | raylib Version | Language | License |
|
||||||
| :--------------------------------------------------------------------------------------- | :--------------: | :------------------------------------------------------------------: | :------------------: |
|
| :--------------------------------------------------------------------------------------- | :--------------: | :------------------------------------------------------------------: | :------------------: |
|
||||||
| [raylib](https://github.com/raysan5/raylib) | **5.5** | [C/C++](https://en.wikipedia.org/wiki/C_(programming_language)) | Zlib |
|
| [raylib](https://github.com/raysan5/raylib) | **5.5** | [C/C++](https://en.wikipedia.org/wiki/C_(programming_language)) | Zlib |
|
||||||
|
| [raylib-ada](https://github.com/Fabien-Chouteau/raylib-ada) | **5.5** | [Ada](https://en.wikipedia.org/wiki/Ada_(programming_language)) | MIT |
|
||||||
| [raylib-beef](https://github.com/Starpelly/raylib-beef) | **5.5** | [Beef](https://www.beeflang.org) | MIT |
|
| [raylib-beef](https://github.com/Starpelly/raylib-beef) | **5.5** | [Beef](https://www.beeflang.org) | MIT |
|
||||||
| [raybit](https://github.com/Alex-Velez/raybit) | **5.0** | [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck) | MIT |
|
| [raybit](https://github.com/Alex-Velez/raybit) | **5.0** | [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck) | MIT |
|
||||||
| [raylib-c3](https://github.com/c3lang/vendor/tree/main/libraries/raylib55.c3l) | **5.5** | [C3](https://c3-lang.org) | MIT |
|
| [raylib-c3](https://github.com/c3lang/vendor/tree/main/libraries/raylib55.c3l) | **5.5** | [C3](https://c3-lang.org) | MIT |
|
||||||
|
|
|
||||||
|
|
@ -30,13 +30,13 @@ void ProcessAudio(void *buffer, unsigned int frames)
|
||||||
|
|
||||||
for (unsigned int frame = 0; frame < frames; frame++)
|
for (unsigned int frame = 0; frame < frames; frame++)
|
||||||
{
|
{
|
||||||
float *left = &samples[frame * 2 + 0], *right = &samples[frame * 2 + 1];
|
float *left = &samples[frame*2 + 0], *right = &samples[frame*2 + 1];
|
||||||
|
|
||||||
*left = powf(fabsf(*left), exponent) * ( (*left < 0.0f)? -1.0f : 1.0f );
|
*left = powf(fabsf(*left), exponent)*( (*left < 0.0f)? -1.0f : 1.0f );
|
||||||
*right = powf(fabsf(*right), exponent) * ( (*right < 0.0f)? -1.0f : 1.0f );
|
*right = powf(fabsf(*right), exponent)*( (*right < 0.0f)? -1.0f : 1.0f );
|
||||||
|
|
||||||
average += fabsf(*left) / frames; // accumulating average volume
|
average += fabsf(*left)/frames; // accumulating average volume
|
||||||
average += fabsf(*right) / frames;
|
average += fabsf(*right)/frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Moving history to the left
|
// Moving history to the left
|
||||||
|
|
@ -99,7 +99,7 @@ int main(void)
|
||||||
DrawRectangle(199, 199, 402, 34, LIGHTGRAY);
|
DrawRectangle(199, 199, 402, 34, LIGHTGRAY);
|
||||||
for (int i = 0; i < 400; i++)
|
for (int i = 0; i < 400; i++)
|
||||||
{
|
{
|
||||||
DrawLine(201 + i, 232 - (int)(averageVolume[i] * 32), 201 + i, 232, MAROON);
|
DrawLine(201 + i, 232 - (int)(averageVolume[i]*32), 201 + i, 232, MAROON);
|
||||||
}
|
}
|
||||||
DrawRectangleLines(199, 199, 402, 34, GRAY);
|
DrawRectangleLines(199, 199, 402, 34, GRAY);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ int main(void)
|
||||||
float fp = (float)(mousePosition.y);
|
float fp = (float)(mousePosition.y);
|
||||||
frequency = 40.0f + (float)(fp);
|
frequency = 40.0f + (float)(fp);
|
||||||
|
|
||||||
float pan = (float)(mousePosition.x) / (float)screenWidth;
|
float pan = (float)(mousePosition.x)/(float)screenWidth;
|
||||||
SetAudioStreamPan(stream, pan);
|
SetAudioStreamPan(stream, pan);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -141,7 +141,7 @@ int main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scale read cursor's position to minimize transition artifacts
|
// Scale read cursor's position to minimize transition artifacts
|
||||||
//readCursor = (int)(readCursor * ((float)waveLength / (float)oldWavelength));
|
//readCursor = (int)(readCursor*((float)waveLength/(float)oldWavelength));
|
||||||
oldFrequency = frequency;
|
oldFrequency = frequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -148,8 +148,8 @@ int main(void)
|
||||||
static void AudioProcessEffectLPF(void *buffer, unsigned int frames)
|
static void AudioProcessEffectLPF(void *buffer, unsigned int frames)
|
||||||
{
|
{
|
||||||
static float low[2] = { 0.0f, 0.0f };
|
static float low[2] = { 0.0f, 0.0f };
|
||||||
static const float cutoff = 70.0f / 44100.0f; // 70 Hz lowpass filter
|
static const float cutoff = 70.0f/44100.0f; // 70 Hz lowpass filter
|
||||||
const float k = cutoff / (cutoff + 0.1591549431f); // RC filter formula
|
const float k = cutoff/(cutoff + 0.1591549431f); // RC filter formula
|
||||||
|
|
||||||
// Converts the buffer data before using it
|
// Converts the buffer data before using it
|
||||||
float *bufferData = (float *)buffer;
|
float *bufferData = (float *)buffer;
|
||||||
|
|
@ -158,8 +158,8 @@ static void AudioProcessEffectLPF(void *buffer, unsigned int frames)
|
||||||
const float l = bufferData[i];
|
const float l = bufferData[i];
|
||||||
const float r = bufferData[i + 1];
|
const float r = bufferData[i + 1];
|
||||||
|
|
||||||
low[0] += k * (l - low[0]);
|
low[0] += k*(l - low[0]);
|
||||||
low[1] += k * (r - low[1]);
|
low[1] += k*(r - low[1]);
|
||||||
bufferData[i] = low[0];
|
bufferData[i] = low[0];
|
||||||
bufferData[i + 1] = low[1];
|
bufferData[i + 1] = low[1];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -294,7 +294,7 @@ void UpdateCameraPlayerBoundsPush(Camera2D *camera, Player *player, EnvItem *env
|
||||||
|
|
||||||
Vector2 bboxWorldMin = GetScreenToWorld2D((Vector2){ (1 - bbox.x)*0.5f*width, (1 - bbox.y)*0.5f*height }, *camera);
|
Vector2 bboxWorldMin = GetScreenToWorld2D((Vector2){ (1 - bbox.x)*0.5f*width, (1 - bbox.y)*0.5f*height }, *camera);
|
||||||
Vector2 bboxWorldMax = GetScreenToWorld2D((Vector2){ (1 + bbox.x)*0.5f*width, (1 + bbox.y)*0.5f*height }, *camera);
|
Vector2 bboxWorldMax = GetScreenToWorld2D((Vector2){ (1 + bbox.x)*0.5f*width, (1 + bbox.y)*0.5f*height }, *camera);
|
||||||
camera->offset = (Vector2){ (1 - bbox.x)*0.5f * width, (1 - bbox.y)*0.5f*height };
|
camera->offset = (Vector2){ (1 - bbox.x)*0.5f*width, (1 - bbox.y)*0.5f*height };
|
||||||
|
|
||||||
if (player->position.x < bboxWorldMin.x) camera->target.x = player->position.x;
|
if (player->position.x < bboxWorldMin.x) camera->target.x = player->position.x;
|
||||||
if (player->position.y < bboxWorldMin.y) camera->target.y = player->position.y;
|
if (player->position.y < bboxWorldMin.y) camera->target.y = player->position.y;
|
||||||
|
|
|
||||||
|
|
@ -100,8 +100,8 @@ int main(void)
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
||||||
camera.projection = CAMERA_ORTHOGRAPHIC;
|
camera.projection = CAMERA_ORTHOGRAPHIC;
|
||||||
camera.fovy = 20.0f; // near plane width in CAMERA_ORTHOGRAPHIC
|
camera.fovy = 20.0f; // near plane width in CAMERA_ORTHOGRAPHIC
|
||||||
CameraYaw(&camera, -135 * DEG2RAD, true);
|
CameraYaw(&camera, -135*DEG2RAD, true);
|
||||||
CameraPitch(&camera, -45 * DEG2RAD, true, true, false);
|
CameraPitch(&camera, -45*DEG2RAD, true, true, false);
|
||||||
}
|
}
|
||||||
else if (camera.projection == CAMERA_ORTHOGRAPHIC)
|
else if (camera.projection == CAMERA_ORTHOGRAPHIC)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,7 @@ static void UpdateCameraAngle(Camera *camera)
|
||||||
// Rotate view vector around right axis
|
// Rotate view vector around right axis
|
||||||
float pitchAngle = -lookRotation.y -
|
float pitchAngle = -lookRotation.y -
|
||||||
lean.y;
|
lean.y;
|
||||||
pitchAngle = Clamp(pitchAngle, -PI / 2 + 0.0001f, PI / 2 - 0.0001f); // Clamp angle so it doesn't go past straight up or straight down
|
pitchAngle = Clamp(pitchAngle, -PI/2 + 0.0001f, PI/2 - 0.0001f); // Clamp angle so it doesn't go past straight up or straight down
|
||||||
Vector3 pitch = Vector3RotateByAxisAngle(yaw, right, pitchAngle);
|
Vector3 pitch = Vector3RotateByAxisAngle(yaw, right, pitchAngle);
|
||||||
|
|
||||||
// Head animation
|
// Head animation
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ int main(void)
|
||||||
cameraPlayer2.position.x = -3.0f;
|
cameraPlayer2.position.x = -3.0f;
|
||||||
cameraPlayer2.position.y = 3.0f;
|
cameraPlayer2.position.y = 3.0f;
|
||||||
|
|
||||||
RenderTexture screenPlayer2 = LoadRenderTexture(screenWidth / 2, screenHeight);
|
RenderTexture screenPlayer2 = LoadRenderTexture(screenWidth/2, screenHeight);
|
||||||
|
|
||||||
// Build a flipped rectangle the size of the split view to use for drawing later
|
// Build a flipped rectangle the size of the split view to use for drawing later
|
||||||
Rectangle splitScreenRect = { 0.0f, 0.0f, (float)screenPlayer1.texture.width, (float)-screenPlayer1.texture.height };
|
Rectangle splitScreenRect = { 0.0f, 0.0f, (float)screenPlayer1.texture.width, (float)-screenPlayer1.texture.height };
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ int main(void)
|
||||||
|
|
||||||
DrawText("Try clicking on the box with your mouse!", 240, 10, 20, DARKGRAY);
|
DrawText("Try clicking on the box with your mouse!", 240, 10, 20, DARKGRAY);
|
||||||
|
|
||||||
if (collision.hit) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, (int)(screenHeight * 0.1f), 30, GREEN);
|
if (collision.hit) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30))/2, (int)(screenHeight*0.1f), 30, GREEN);
|
||||||
|
|
||||||
DrawText("Right click mouse to toggle camera controls", 10, 430, 10, GRAY);
|
DrawText("Right click mouse to toggle camera controls", 10, 430, 10, GRAY);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ int main(void)
|
||||||
int x = (int)(((float)i)/dpiScale.x);
|
int x = (int)(((float)i)/dpiScale.x);
|
||||||
if (odd) DrawRectangle(x, pixelGridTop, (int)cellSizePx, pixelGridBottom - pixelGridTop, CLITERAL(Color){ 0, 121, 241, 100 });
|
if (odd) DrawRectangle(x, pixelGridTop, (int)cellSizePx, pixelGridBottom - pixelGridTop, CLITERAL(Color){ 0, 121, 241, 100 });
|
||||||
|
|
||||||
DrawLine(x, pixelGridTop, (int)(((float)i) / dpiScale.x), pixelGridLabelY - 10, GRAY);
|
DrawLine(x, pixelGridTop, (int)(((float)i)/dpiScale.x), pixelGridLabelY - 10, GRAY);
|
||||||
|
|
||||||
if ((x - lastTextX) >= minTextSpace)
|
if ((x - lastTextX) >= minTextSpace)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,6 @@ static void DrawTextCenterKeyHelp(const char *key, const char *text, int posX, i
|
||||||
int spaceSize = MeasureText(" ", fontSize);
|
int spaceSize = MeasureText(" ", fontSize);
|
||||||
int pressSize = MeasureText("Press", fontSize);
|
int pressSize = MeasureText("Press", fontSize);
|
||||||
int keySize = MeasureText(key, fontSize);
|
int keySize = MeasureText(key, fontSize);
|
||||||
int textSize = MeasureText(text, fontSize);
|
|
||||||
int textSizeCurrent = 0;
|
int textSizeCurrent = 0;
|
||||||
|
|
||||||
DrawText("Press", posX, posY, fontSize, color);
|
DrawText("Press", posX, posY, fontSize, color);
|
||||||
|
|
@ -184,4 +183,4 @@ static void DrawTextCenterKeyHelp(const char *key, const char *text, int posX, i
|
||||||
DrawRectangle(posX + textSizeCurrent, posY + fontSize, keySize, 3, RED);
|
DrawRectangle(posX + textSizeCurrent, posY + fontSize, keySize, 3, RED);
|
||||||
textSizeCurrent += keySize + 2*spaceSize;
|
textSizeCurrent += keySize + 2*spaceSize;
|
||||||
DrawText(text, posX + textSizeCurrent, posY, fontSize, color);
|
DrawText(text, posX + textSizeCurrent, posY, fontSize, color);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ int main(void)
|
||||||
//SetConfigFlags(FLAG_VSYNC_HINT | FLAG_MSAA_4X_HINT | FLAG_WINDOW_HIGHDPI);
|
//SetConfigFlags(FLAG_VSYNC_HINT | FLAG_MSAA_4X_HINT | FLAG_WINDOW_HIGHDPI);
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - window flags");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - window flags");
|
||||||
|
|
||||||
Vector2 ballPosition = { GetScreenWidth() / 2.0f, GetScreenHeight() / 2.0f };
|
Vector2 ballPosition = { GetScreenWidth()/2.0f, GetScreenHeight()/2.0f };
|
||||||
Vector2 ballSpeed = { 5.0f, 4.0f };
|
Vector2 ballSpeed = { 5.0f, 4.0f };
|
||||||
float ballRadius = 20;
|
float ballRadius = 20;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ int main(void)
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawText("Enemy: 100 / 100", (int)cubeScreenPosition.x - MeasureText("Enemy: 100/100", 20)/2, (int)cubeScreenPosition.y, 20, BLACK);
|
DrawText("Enemy: 100/100", (int)cubeScreenPosition.x - MeasureText("Enemy: 100/100", 20)/2, (int)cubeScreenPosition.y, 20, BLACK);
|
||||||
|
|
||||||
DrawText(TextFormat("Cube position in screen space coordinates: [%i, %i]", (int)cubeScreenPosition.x, (int)cubeScreenPosition.y), 10, 10, 20, LIME);
|
DrawText(TextFormat("Cube position in screen space coordinates: [%i, %i]", (int)cubeScreenPosition.x, (int)cubeScreenPosition.y), 10, 10, 20, LIME);
|
||||||
DrawText("Text 2d should be always on top of the cube", 10, 40, 20, GRAY);
|
DrawText("Text 2d should be always on top of the cube", 10, 40, 20, GRAY);
|
||||||
|
|
@ -84,4 +84,4 @@ int main(void)
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -127,8 +127,8 @@ int main(void)
|
||||||
if (IsMouseButtonDown(MOUSE_BUTTON_MIDDLE))
|
if (IsMouseButtonDown(MOUSE_BUTTON_MIDDLE))
|
||||||
{
|
{
|
||||||
const Vector2 mouseDelta = GetMouseDelta();
|
const Vector2 mouseDelta = GetMouseDelta();
|
||||||
camerarot.x = mouseDelta.x * 0.05f;
|
camerarot.x = mouseDelta.x*0.05f;
|
||||||
camerarot.y = mouseDelta.y * 0.05f;
|
camerarot.y = mouseDelta.y*0.05f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -138,14 +138,14 @@ int main(void)
|
||||||
|
|
||||||
UpdateCameraPro(&camera,
|
UpdateCameraPro(&camera,
|
||||||
(Vector3) {
|
(Vector3) {
|
||||||
(IsKeyDown(KEY_W) || IsKeyDown(KEY_UP)) * 0.1f - // Move forward-backward
|
(IsKeyDown(KEY_W) || IsKeyDown(KEY_UP))*0.1f - // Move forward-backward
|
||||||
(IsKeyDown(KEY_S) || IsKeyDown(KEY_DOWN)) * 0.1f,
|
(IsKeyDown(KEY_S) || IsKeyDown(KEY_DOWN))*0.1f,
|
||||||
(IsKeyDown(KEY_D) || IsKeyDown(KEY_RIGHT)) * 0.1f - // Move right-left
|
(IsKeyDown(KEY_D) || IsKeyDown(KEY_RIGHT))*0.1f - // Move right-left
|
||||||
(IsKeyDown(KEY_A) || IsKeyDown(KEY_LEFT)) * 0.1f,
|
(IsKeyDown(KEY_A) || IsKeyDown(KEY_LEFT))*0.1f,
|
||||||
0.0f // Move up-down
|
0.0f // Move up-down
|
||||||
},
|
},
|
||||||
camerarot,
|
camerarot,
|
||||||
GetMouseWheelMove() * -2.0f); // Move to target (zoom)
|
GetMouseWheelMove()*-2.0f); // Move to target (zoom)
|
||||||
|
|
||||||
// Cycle between models on mouse click
|
// Cycle between models on mouse click
|
||||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) currentModel = (currentModel + 1) % MAX_VOX_FILES;
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) currentModel = (currentModel + 1) % MAX_VOX_FILES;
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
#include "raymath.h"
|
#include "raymath.h"
|
||||||
|
|
||||||
|
#undef FLT_MAX
|
||||||
#define FLT_MAX 340282346638528859811704183484516925440.0f // Maximum value of a float, from bit pattern 01111111011111111111111111111111
|
#define FLT_MAX 340282346638528859811704183484516925440.0f // Maximum value of a float, from bit pattern 01111111011111111111111111111111
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
|
|
@ -245,4 +246,4 @@ int main(void)
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -161,9 +161,9 @@ static Mesh GenMeshPoints(int numPoints)
|
||||||
// https://en.wikipedia.org/wiki/Spherical_coordinate_system
|
// https://en.wikipedia.org/wiki/Spherical_coordinate_system
|
||||||
for (int i = 0; i < numPoints; i++)
|
for (int i = 0; i < numPoints; i++)
|
||||||
{
|
{
|
||||||
float theta = ((float)PI*rand())/RAND_MAX;
|
float theta = ((float)PI*rand())/((float)RAND_MAX);
|
||||||
float phi = (2.0f*PI*rand())/RAND_MAX;
|
float phi = (2.0f*PI*rand())/((float)RAND_MAX);
|
||||||
float r = (10.0f*rand())/RAND_MAX;
|
float r = (10.0f*rand())/((float)RAND_MAX);
|
||||||
|
|
||||||
mesh.vertices[i*3 + 0] = r*sinf(theta)*cosf(phi);
|
mesh.vertices[i*3 + 0] = r*sinf(theta)*cosf(phi);
|
||||||
mesh.vertices[i*3 + 1] = r*sinf(theta)*sinf(phi);
|
mesh.vertices[i*3 + 1] = r*sinf(theta)*sinf(phi);
|
||||||
|
|
|
||||||
|
|
@ -79,9 +79,9 @@ int main(void)
|
||||||
// Projection from XYZW to XYZ from perspective point (0, 0, 0, 3)
|
// Projection from XYZW to XYZ from perspective point (0, 0, 0, 3)
|
||||||
// NOTE: Trace a ray from (0, 0, 0, 3) > p and continue until W = 0
|
// NOTE: Trace a ray from (0, 0, 0, 3) > p and continue until W = 0
|
||||||
float c = 3.0f/(3.0f - p.w);
|
float c = 3.0f/(3.0f - p.w);
|
||||||
p.x = c * p.x;
|
p.x = c*p.x;
|
||||||
p.y = c * p.y;
|
p.y = c*p.y;
|
||||||
p.z = c * p.z;
|
p.z = c*p.z;
|
||||||
|
|
||||||
// Split XYZ coordinate and W values later for drawing
|
// Split XYZ coordinate and W values later for drawing
|
||||||
transformed[i] = (Vector3){ p.x, p.y, p.z };
|
transformed[i] = (Vector3){ p.x, p.y, p.z };
|
||||||
|
|
@ -125,4 +125,4 @@ int main(void)
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ void main()
|
||||||
light = normalize(lights[i].position - fragPosition);
|
light = normalize(lights[i].position - fragPosition);
|
||||||
|
|
||||||
float NdotL = max(dot(normal, light), 0.0);
|
float NdotL = max(dot(normal, light), 0.0);
|
||||||
lightDot += lights[i].color.rgb * NdotL;
|
lightDot += lights[i].color.rgb*NdotL;
|
||||||
|
|
||||||
if (NdotL > 0.0)
|
if (NdotL > 0.0)
|
||||||
{
|
{
|
||||||
|
|
@ -56,8 +56,8 @@ void main()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 finalColor = (fragColor * ((colDiffuse + vec4(specular, 1.0)) * vec4(lightDot, 1.0)));
|
vec4 finalColor = (fragColor*((colDiffuse + vec4(specular, 1.0))*vec4(lightDot, 1.0)));
|
||||||
finalColor += fragColor * (ambient / 10.0) * colDiffuse;
|
finalColor += fragColor*(ambient/10.0)*colDiffuse;
|
||||||
|
|
||||||
finalColor = pow(finalColor, vec4(1.0/2.2)); // gamma correction
|
finalColor = pow(finalColor, vec4(1.0/2.2)); // gamma correction
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,9 @@ varying vec3 fragNormal;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
fragPosition = vec3(matModel * vec4(vertexPosition, 1.0));
|
fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
|
||||||
fragColor = vertexColor;
|
fragColor = vertexColor;
|
||||||
fragNormal = normalize(vec3(matNormal * vec4(vertexNormal, 1.0)));
|
fragNormal = normalize(vec3(matNormal*vec4(vertexNormal, 1.0)));
|
||||||
|
|
||||||
gl_Position = mvp * vec4(vertexPosition, 1.0);
|
gl_Position = mvp*vec4(vertexPosition, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ void main()
|
||||||
light = normalize(lights[i].position - fragPosition);
|
light = normalize(lights[i].position - fragPosition);
|
||||||
|
|
||||||
float NdotL = max(dot(normal, light), 0.0);
|
float NdotL = max(dot(normal, light), 0.0);
|
||||||
lightDot += lights[i].color.rgb * NdotL;
|
lightDot += lights[i].color.rgb*NdotL;
|
||||||
|
|
||||||
if (NdotL > 0.0)
|
if (NdotL > 0.0)
|
||||||
{
|
{
|
||||||
|
|
@ -53,8 +53,8 @@ void main()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 finalColor = (fragColor * ((colDiffuse + vec4(specular, 1.0)) * vec4(lightDot, 1.0)));
|
vec4 finalColor = (fragColor*((colDiffuse + vec4(specular, 1.0))*vec4(lightDot, 1.0)));
|
||||||
finalColor += fragColor * (ambient / 10.0) * colDiffuse;
|
finalColor += fragColor*(ambient/10.0)*colDiffuse;
|
||||||
|
|
||||||
finalColor = pow(finalColor, vec4(1.0/2.2)); // gamma correction
|
finalColor = pow(finalColor, vec4(1.0/2.2)); // gamma correction
|
||||||
|
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue