REVIEWED: Ligthmap example
This commit is contained in:
parent
abcbd9817e
commit
5573f0f1c7
4 changed files with 81 additions and 72 deletions
|
@ -1,4 +1,5 @@
|
||||||
#version 330
|
#version 330
|
||||||
|
|
||||||
// Input vertex attributes (from vertex shader)
|
// Input vertex attributes (from vertex shader)
|
||||||
in vec2 fragTexCoord;
|
in vec2 fragTexCoord;
|
||||||
in vec2 fragTexCoord2;
|
in vec2 fragTexCoord2;
|
||||||
|
@ -12,9 +13,11 @@ uniform sampler2D texture1;
|
||||||
// Output fragment color
|
// Output fragment color
|
||||||
out vec4 finalColor;
|
out vec4 finalColor;
|
||||||
|
|
||||||
void main() {
|
void main()
|
||||||
|
{
|
||||||
// Texel color fetching from texture sampler
|
// Texel color fetching from texture sampler
|
||||||
vec4 texelColor = texture(texture0, fragTexCoord);
|
vec4 texelColor = texture(texture0, fragTexCoord);
|
||||||
vec4 texelColor2 = texture(texture1, fragTexCoord2);
|
vec4 texelColor2 = texture(texture1, fragTexCoord2);
|
||||||
|
|
||||||
finalColor = texelColor * texelColor2;
|
finalColor = texelColor * texelColor2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#version 330
|
#version 330
|
||||||
|
|
||||||
// Input vertex attributes
|
// Input vertex attributes
|
||||||
in vec3 vertexPosition;
|
in vec3 vertexPosition;
|
||||||
in vec2 vertexTexCoord;
|
in vec2 vertexTexCoord;
|
||||||
|
@ -15,7 +16,8 @@ out vec2 fragTexCoord;
|
||||||
out vec2 fragTexCoord2;
|
out vec2 fragTexCoord2;
|
||||||
out vec4 fragColor;
|
out vec4 fragColor;
|
||||||
|
|
||||||
void main() {
|
void main()
|
||||||
|
{
|
||||||
// Send vertex attributes to fragment shader
|
// Send vertex attributes to fragment shader
|
||||||
fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
|
fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
|
||||||
fragTexCoord = vertexTexCoord;
|
fragTexCoord = vertexTexCoord;
|
||||||
|
|
|
@ -46,8 +46,8 @@ int main(void)
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera = { 0 };
|
Camera camera = { 0 };
|
||||||
camera.position = (Vector3){ 2.0f, 4.0f, 6.0f }; // Camera position
|
camera.position = (Vector3){ 4.0f, 6.0f, 8.0f }; // Camera position
|
||||||
camera.target = (Vector3){ 0.0f, 0.5f, 0.0f }; // Camera looking at point
|
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||||
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
|
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
|
||||||
|
@ -66,6 +66,7 @@ int main(void)
|
||||||
// Load a new texcoords2 attributes buffer
|
// Load a new texcoords2 attributes buffer
|
||||||
mesh.vboId[SHADER_LOC_VERTEX_TEXCOORD02] = rlLoadVertexBuffer(mesh.texcoords2, mesh.vertexCount*2*sizeof(float), false);
|
mesh.vboId[SHADER_LOC_VERTEX_TEXCOORD02] = rlLoadVertexBuffer(mesh.texcoords2, mesh.vertexCount*2*sizeof(float), false);
|
||||||
rlEnableVertexArray(mesh.vaoId);
|
rlEnableVertexArray(mesh.vaoId);
|
||||||
|
|
||||||
// Index 5 is for texcoords2
|
// Index 5 is for texcoords2
|
||||||
rlSetVertexAttribute(5, 2, RL_FLOAT, 0, 0, 0);
|
rlSetVertexAttribute(5, 2, RL_FLOAT, 0, 0, 0);
|
||||||
rlEnableVertexAttribute(5);
|
rlEnableVertexAttribute(5);
|
||||||
|
@ -146,12 +147,15 @@ int main(void)
|
||||||
|
|
||||||
DrawTexturePro(
|
DrawTexturePro(
|
||||||
lightmap.texture,
|
lightmap.texture,
|
||||||
(Rectangle){ 0, 0, MAP_SIZE, MAP_SIZE },
|
(Rectangle){ 0, 0, -MAP_SIZE, -MAP_SIZE },
|
||||||
(Rectangle){ 0, 36, MAP_SIZE * 4, MAP_SIZE * 4 },
|
(Rectangle){ GetRenderWidth() - MAP_SIZE*8 - 10, 10, MAP_SIZE*8, MAP_SIZE*8 },
|
||||||
(Vector2){ 0.0, 0.0 },
|
(Vector2){ 0.0, 0.0 },
|
||||||
0.0,
|
0.0,
|
||||||
WHITE
|
WHITE);
|
||||||
);
|
|
||||||
|
DrawText("lightmap", GetRenderWidth() - 66, 16 + MAP_SIZE*8, 10, GRAY);
|
||||||
|
DrawText("10x10 pixels", GetRenderWidth() - 76, 30 + MAP_SIZE*8, 10, GRAY);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 224 KiB After Width: | Height: | Size: 205 KiB |
Loading…
Add table
Add a link
Reference in a new issue