Skip to content

Commit

Permalink
Implement phong shading (step 2)
Browse files Browse the repository at this point in the history
  • Loading branch information
caiiiycuk committed Feb 1, 2024
1 parent ac0ef7f commit 68056eb
Show file tree
Hide file tree
Showing 4 changed files with 765 additions and 558 deletions.
2 changes: 2 additions & 0 deletions Source/Render/sokol/SokolRender.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ class cSokolRender: public cInterfaceRenderDevice {
bool activeGlobalLight = false;
Vect3f activeLightDir;
sColor4f activeLightDiffuse;
sColor4f activeLightAmbient;
sColor4f activeLightSpecular;

//Commands handling
void ClearCommands();
Expand Down
6 changes: 5 additions & 1 deletion Source/Render/sokol/SokolRenderState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,9 @@ void cSokolRender::CreateCommand(VertexBuffer* vb, size_t vertices, IndexBuffer*
memcpy(fs_params->specular, &activeSpecular, sizeof(float) * 4);
memcpy(fs_params->emissive, &activeEmissive, sizeof(float) * 4);
fs_params->spec_power = activePower;
memcpy(fs_params->light_color, &activeLightDiffuse, sizeof(float) * 3);
memcpy(fs_params->light_ambient, &activeLightAmbient, sizeof(float) * 3);
memcpy(fs_params->light_diffuse, &activeLightDiffuse, sizeof(float) * 3);
memcpy(fs_params->light_specular, &activeLightSpecular, sizeof(float) * 3);
memcpy(fs_params->light_dir, &activeLightDir, sizeof(float) * 3);
break;
}
Expand Down Expand Up @@ -774,6 +776,8 @@ void cSokolRender::SetGlobalLight(Vect3f *vLight, sColor4f *Ambient, sColor4f *D
}
activeLightDir = *vLight;
activeLightDiffuse = *Diffuse;
activeLightAmbient = *Ambient;
activeLightSpecular = *Specular;
}
}

Expand Down
Loading

0 comments on commit 68056eb

Please sign in to comment.