Update shaders_deferred_render.c for GLES3

This commit is contained in:
MikiZX1 2025-01-18 17:36:07 +01:00 committed by GitHub
parent 24d0313157
commit f6cc0e92c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -193,6 +193,15 @@ int main(void)
model.materials[0].shader = gbufferShader; model.materials[0].shader = gbufferShader;
cube.materials[0].shader = gbufferShader; cube.materials[0].shader = gbufferShader;
// add some specular noise to the material
Image tmp_img2=GenImagePerlinNoise(256,256,0,0,8.0);
Texture texture_specular=LoadTextureFromImage(tmp_img2);
UnloadImage(tmp_img2);
cube.materials[0].maps[MATERIAL_MAP_METALNESS].texture=texture_specular;
model.materials[0].maps[MATERIAL_MAP_METALNESS].texture=texture_specular;
// Create lights // Create lights
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
Light lights[MAX_LIGHTS] = { 0 }; Light lights[MAX_LIGHTS] = { 0 };
@ -204,6 +213,7 @@ int main(void)
const float CUBE_SCALE = 0.25; const float CUBE_SCALE = 0.25;
Vector3 cubePositions[MAX_CUBES] = { 0 }; Vector3 cubePositions[MAX_CUBES] = { 0 };
float cubeRotations[MAX_CUBES] = { 0 }; float cubeRotations[MAX_CUBES] = { 0 };
Color cubeColors[MAX_CUBES] = { 0 };
for (int i = 0; i < MAX_CUBES; i++) for (int i = 0; i < MAX_CUBES; i++)
{ {
@ -214,6 +224,9 @@ int main(void)
}; };
cubeRotations[i] = (float)(rand()%360); cubeRotations[i] = (float)(rand()%360);
cubeColors[i] = (Color){GetRandomValue(0,128),GetRandomValue(0,128),GetRandomValue(0,128),255};
} }
DeferredMode mode = DEFERRED_SHADING; DeferredMode mode = DEFERRED_SHADING;
@ -272,7 +285,7 @@ int main(void)
for (int i = 0; i < MAX_CUBES; i++) for (int i = 0; i < MAX_CUBES; i++)
{ {
Vector3 position = cubePositions[i]; Vector3 position = cubePositions[i];
DrawModelEx(cube, position, (Vector3) { 1, 1, 1 }, cubeRotations[i], (Vector3) { CUBE_SCALE, CUBE_SCALE, CUBE_SCALE }, WHITE); DrawModelEx(cube, position, (Vector3) { 1, 1, 1 }, cubeRotations[i], (Vector3) { CUBE_SCALE, CUBE_SCALE, CUBE_SCALE }, cubeColors[i]);
} }
rlDisableShader(); rlDisableShader();
@ -355,7 +368,7 @@ int main(void)
.height = screenHeight, .height = screenHeight,
}, (Rectangle) { 0, 0, (float)screenWidth, (float)-screenHeight }, Vector2Zero(), RAYWHITE); }, (Rectangle) { 0, 0, (float)screenWidth, (float)-screenHeight }, Vector2Zero(), RAYWHITE);
DrawText("ALBEDO TEXTURE", 10, screenHeight - 30, 20, DARKGREEN); DrawText("ALBEDO*SPECULAR TEXTURE", 10, screenHeight - 30, 20, DARKGREEN);
} break; } break;
default: break; default: break;
} }
@ -374,6 +387,8 @@ int main(void)
UnloadModel(model); // Unload the models UnloadModel(model); // Unload the models
UnloadModel(cube); UnloadModel(cube);
UnloadTexture(texture_specular);
UnloadShader(deferredShader); // Unload shaders UnloadShader(deferredShader); // Unload shaders
UnloadShader(gbufferShader); UnloadShader(gbufferShader);