adapt convention
This commit is contained in:
parent
4c1f38a89e
commit
006fd85728
|
|
@ -563,7 +563,7 @@ SHADERS = \
|
||||||
shaders/shaders_multi_sample2d \
|
shaders/shaders_multi_sample2d \
|
||||||
shaders/shaders_write_depth \
|
shaders/shaders_write_depth \
|
||||||
shaders/shaders_hybrid_render \
|
shaders/shaders_hybrid_render \
|
||||||
shaders/shaders_deferred_shading
|
shaders/shaders_deferred_render
|
||||||
|
|
||||||
AUDIO = \
|
AUDIO = \
|
||||||
audio/audio_module_playing \
|
audio/audio_module_playing \
|
||||||
|
|
|
||||||
|
|
@ -469,7 +469,7 @@ SHADERS = \
|
||||||
shaders/shaders_multi_sample2d \
|
shaders/shaders_multi_sample2d \
|
||||||
shaders/shaders_write_depth \
|
shaders/shaders_write_depth \
|
||||||
shaders/shaders_hybrid_render \
|
shaders/shaders_hybrid_render \
|
||||||
shaders/shaders_deferred_shading
|
shaders/shaders_deferred_render
|
||||||
|
|
||||||
AUDIO = \
|
AUDIO = \
|
||||||
audio/audio_module_playing \
|
audio/audio_module_playing \
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,7 @@ Examples using raylib shaders functionality, including shaders loading, paramete
|
||||||
| 114 | [shaders_mesh_instancing](shaders/shaders_mesh_instancing.c) | <img src="shaders/shaders_mesh_instancing.png" alt="shaders_mesh_instancing" width="80"> | ⭐️⭐️⭐️⭐️ | 3.7 | **4.2** | [seanpringle](https://github.com/seanpringle) |
|
| 114 | [shaders_mesh_instancing](shaders/shaders_mesh_instancing.c) | <img src="shaders/shaders_mesh_instancing.png" alt="shaders_mesh_instancing" width="80"> | ⭐️⭐️⭐️⭐️ | 3.7 | **4.2** | [seanpringle](https://github.com/seanpringle) |
|
||||||
| 115 | [shaders_multi_sample2d](shaders/shaders_multi_sample2d.c) | <img src="shaders/shaders_multi_sample2d.png" alt="shaders_multi_sample2d" width="80"> | ⭐️⭐️☆☆ | 3.5 | 3.5 | [Ray](https://github.com/raysan5) |
|
| 115 | [shaders_multi_sample2d](shaders/shaders_multi_sample2d.c) | <img src="shaders/shaders_multi_sample2d.png" alt="shaders_multi_sample2d" width="80"> | ⭐️⭐️☆☆ | 3.5 | 3.5 | [Ray](https://github.com/raysan5) |
|
||||||
| 116 | [shaders_spotlight](shaders/shaders_spotlight.c) | <img src="shaders/shaders_spotlight.png" alt="shaders_spotlight" width="80"> | ⭐️⭐️☆☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/codifies) |
|
| 116 | [shaders_spotlight](shaders/shaders_spotlight.c) | <img src="shaders/shaders_spotlight.png" alt="shaders_spotlight" width="80"> | ⭐️⭐️☆☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/codifies) |
|
||||||
| 117 | [shaders_deferred_shading](shaders/shaders_deferred_shading.c) | <img src="shaders/shaders_deferred_shading.png" alt="shaders_deferred_shading" width="80"> | ⭐️⭐️⭐️⭐️ | 4.5 | 4.5 | [Justin Andreas Lacoste](https://github.com/27justin) |
|
| 117 | [shaders_deferred_render](shaders/shaders_deferred_render.c) | <img src="shaders/shaders_deferred_render.png" alt="shaders_deferred_render" width="80"> | ⭐️⭐️⭐️⭐️ | 4.5 | 4.5 | [Justin Andreas Lacoste](https://github.com/27justin) |
|
||||||
|
|
||||||
### category: audio
|
### category: audio
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,8 @@ void main() {
|
||||||
vec3 ambient = albedo * vec3(0.1f);
|
vec3 ambient = albedo * vec3(0.1f);
|
||||||
vec3 viewDirection = normalize(viewPosition - fragPosition);
|
vec3 viewDirection = normalize(viewPosition - fragPosition);
|
||||||
|
|
||||||
for(int i = 0; i < NR_LIGHTS; ++i) {
|
for(int i = 0; i < NR_LIGHTS; ++i)
|
||||||
|
{
|
||||||
if(lights[i].enabled == 0) continue;
|
if(lights[i].enabled == 0) continue;
|
||||||
vec3 lightDirection = lights[i].position - fragPosition;
|
vec3 lightDirection = lights[i].position - fragPosition;
|
||||||
vec3 diffuse = max(dot(normal, lightDirection), 0.0) * albedo * lights[i].color.xyz;
|
vec3 diffuse = max(dot(normal, lightDirection), 0.0) * albedo * lights[i].color.xyz;
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,7 @@ int main(void) {
|
||||||
const int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - deferred shading");
|
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - deferred render");
|
||||||
|
|
||||||
|
|
||||||
Camera camera = { 0 };
|
Camera camera = { 0 };
|
||||||
camera.position = (Vector3){ 5.0f, 4.0f, 5.0f }; // Camera position
|
camera.position = (Vector3){ 5.0f, 4.0f, 5.0f }; // Camera position
|
||||||
|
|
@ -70,12 +69,12 @@ int main(void) {
|
||||||
"resources/shaders/glsl330/deferred_shading.fs");
|
"resources/shaders/glsl330/deferred_shading.fs");
|
||||||
deferredShader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(deferredShader, "viewPosition");
|
deferredShader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(deferredShader, "viewPosition");
|
||||||
|
|
||||||
|
|
||||||
// Initialize the G-buffer
|
// Initialize the G-buffer
|
||||||
GBuffer gBuffer = { 0 };
|
GBuffer gBuffer = { 0 };
|
||||||
gBuffer.framebuffer = rlLoadFramebuffer(screenWidth, screenHeight);
|
gBuffer.framebuffer = rlLoadFramebuffer(screenWidth, screenHeight);
|
||||||
|
|
||||||
if(!gBuffer.framebuffer) {
|
if(!gBuffer.framebuffer)
|
||||||
|
{
|
||||||
TraceLog(LOG_WARNING, "Failed to create framebuffer");
|
TraceLog(LOG_WARNING, "Failed to create framebuffer");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
@ -93,13 +92,11 @@ int main(void) {
|
||||||
// Activate the draw buffers for our framebuffer
|
// Activate the draw buffers for our framebuffer
|
||||||
rlActiveDrawBuffers(3);
|
rlActiveDrawBuffers(3);
|
||||||
|
|
||||||
|
|
||||||
// Now we attach our textures to the framebuffer.
|
// Now we attach our textures to the framebuffer.
|
||||||
rlFramebufferAttach(gBuffer.framebuffer, gBuffer.positionTexture, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_TEXTURE2D, 0);
|
rlFramebufferAttach(gBuffer.framebuffer, gBuffer.positionTexture, RL_ATTACHMENT_COLOR_CHANNEL0, RL_ATTACHMENT_TEXTURE2D, 0);
|
||||||
rlFramebufferAttach(gBuffer.framebuffer, gBuffer.normalTexture, RL_ATTACHMENT_COLOR_CHANNEL1, RL_ATTACHMENT_TEXTURE2D, 0);
|
rlFramebufferAttach(gBuffer.framebuffer, gBuffer.normalTexture, RL_ATTACHMENT_COLOR_CHANNEL1, RL_ATTACHMENT_TEXTURE2D, 0);
|
||||||
rlFramebufferAttach(gBuffer.framebuffer, gBuffer.albedoSpecTexture, RL_ATTACHMENT_COLOR_CHANNEL2, RL_ATTACHMENT_TEXTURE2D, 0);
|
rlFramebufferAttach(gBuffer.framebuffer, gBuffer.albedoSpecTexture, RL_ATTACHMENT_COLOR_CHANNEL2, RL_ATTACHMENT_TEXTURE2D, 0);
|
||||||
|
|
||||||
|
|
||||||
// Finally we attach the depth buffer.
|
// Finally we attach the depth buffer.
|
||||||
gBuffer.depthRenderbuffer = rlLoadTextureDepth(screenWidth, screenHeight, true);
|
gBuffer.depthRenderbuffer = rlLoadTextureDepth(screenWidth, screenHeight, true);
|
||||||
rlFramebufferAttach(gBuffer.framebuffer, gBuffer.depthRenderbuffer, RL_ATTACHMENT_DEPTH, RL_ATTACHMENT_RENDERBUFFER, 0);
|
rlFramebufferAttach(gBuffer.framebuffer, gBuffer.depthRenderbuffer, RL_ATTACHMENT_DEPTH, RL_ATTACHMENT_RENDERBUFFER, 0);
|
||||||
|
|
@ -107,7 +104,8 @@ int main(void) {
|
||||||
// Make sure our framebuffer is complete.
|
// Make sure our framebuffer is complete.
|
||||||
// NOTE: rlFramebufferComplete() automatically unbinds the framebuffer, so we don't have
|
// NOTE: rlFramebufferComplete() automatically unbinds the framebuffer, so we don't have
|
||||||
// to rlDisableFramebuffer() here.
|
// to rlDisableFramebuffer() here.
|
||||||
if(rlFramebufferComplete(gBuffer.framebuffer) != true) {
|
if(rlFramebufferComplete(gBuffer.framebuffer) != true)
|
||||||
|
{
|
||||||
TraceLog(LOG_WARNING, "Framebuffer is not complete");
|
TraceLog(LOG_WARNING, "Framebuffer is not complete");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
@ -139,7 +137,8 @@ int main(void) {
|
||||||
const float CUBE_SCALE = 0.25;
|
const float CUBE_SCALE = 0.25;
|
||||||
Vector3 cubePositions[MAX_CUBES];
|
Vector3 cubePositions[MAX_CUBES];
|
||||||
float cubeRotations[MAX_CUBES];
|
float cubeRotations[MAX_CUBES];
|
||||||
for(int i = 0; i < MAX_CUBES; i++) {
|
for(int i = 0; i < MAX_CUBES; i++)
|
||||||
|
{
|
||||||
cubePositions[i] = (Vector3) {
|
cubePositions[i] = (Vector3) {
|
||||||
.x = (float)(rand() % 10) - 5,
|
.x = (float)(rand() % 10) - 5,
|
||||||
.y = (float)(rand() % 5),
|
.y = (float)(rand() % 5),
|
||||||
|
|
@ -161,7 +160,8 @@ int main(void) {
|
||||||
//---------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while (!WindowShouldClose()) {
|
while (!WindowShouldClose())
|
||||||
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
UpdateCamera(&camera, CAMERA_ORBITAL);
|
UpdateCamera(&camera, CAMERA_ORBITAL);
|
||||||
|
|
@ -205,7 +205,8 @@ int main(void) {
|
||||||
DrawModel(model, Vector3Zero(), 1.0f, WHITE);
|
DrawModel(model, Vector3Zero(), 1.0f, WHITE);
|
||||||
DrawModel(cube, (Vector3) { 0.0, 1.0f, 0.0 }, 1.0f, WHITE);
|
DrawModel(cube, (Vector3) { 0.0, 1.0f, 0.0 }, 1.0f, WHITE);
|
||||||
|
|
||||||
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 }, WHITE);
|
||||||
|
|
@ -219,7 +220,8 @@ int main(void) {
|
||||||
rlDisableFramebuffer();
|
rlDisableFramebuffer();
|
||||||
rlClearScreenBuffers(); // Clear color & depth buffer
|
rlClearScreenBuffers(); // Clear color & depth buffer
|
||||||
|
|
||||||
switch(activeTexture) {
|
switch(activeTexture)
|
||||||
|
{
|
||||||
case DEFERRED_SHADING:
|
case DEFERRED_SHADING:
|
||||||
BeginMode3D(camera);
|
BeginMode3D(camera);
|
||||||
rlDisableColorBlend();
|
rlDisableColorBlend();
|
||||||
|
|
@ -252,7 +254,8 @@ int main(void) {
|
||||||
// forward rendering
|
// forward rendering
|
||||||
BeginMode3D(camera);
|
BeginMode3D(camera);
|
||||||
rlEnableShader(rlGetShaderIdDefault());
|
rlEnableShader(rlGetShaderIdDefault());
|
||||||
for(int i = 0; i < MAX_LIGHTS; i++) {
|
for(int i = 0; i < MAX_LIGHTS; i++)
|
||||||
|
{
|
||||||
if(lights[i].enabled) DrawSphereEx(lights[i].position, 0.2f, 8, 8, lights[i].color);
|
if(lights[i].enabled) DrawSphereEx(lights[i].position, 0.2f, 8, 8, lights[i].color);
|
||||||
else DrawSphereWires(lights[i].position, 0.2f, 8, 8, ColorAlpha(lights[i].color, 0.3f));
|
else DrawSphereWires(lights[i].position, 0.2f, 8, 8, ColorAlpha(lights[i].color, 0.3f));
|
||||||
}
|
}
|
||||||
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 89 KiB |
Loading…
Reference in New Issue
Block a user