This commit is contained in:
Konstantin8105 2022-11-22 18:39:52 +03:00
parent 05e7c1f5e7
commit 2f5d911417
193 changed files with 5 additions and 104847 deletions

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

View file

@ -1,26 +0,0 @@
#version 330
// Input vertex attributes
in vec3 vertexPosition;
in vec2 vertexTexCoord;
in vec3 vertexNormal;
in vec4 vertexColor;
// Input uniform values
uniform mat4 mvp;
// Output vertex attributes (to fragment shader)
out vec2 fragTexCoord;
out vec4 fragColor;
// NOTE: Add here your custom variables
void main()
{
// Send vertex attributes to fragment shader
fragTexCoord = vertexTexCoord;
fragColor = vertexColor;
// Calculate final vertex position
gl_Position = mvp*vec4(vertexPosition, 1.0);
}

View file

@ -1,26 +0,0 @@
#version 330
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord;
in vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// Output fragment color
out vec4 finalColor;
// NOTE: Add here your custom variables
void main()
{
// Texel color fetching from texture sampler
vec4 texelColor = texture(texture0, fragTexCoord)*colDiffuse*fragColor;
// Convert texel color to grayscale using NTSC conversion weights
float gray = dot(texelColor.rgb, vec3(0.299, 0.587, 0.114));
// Calculate final fragment color
finalColor = vec4(gray, gray, gray, texelColor.a);
}

View file

@ -1,66 +0,0 @@
package main
import (
"fmt"
"github.com/gen2brain/raylib-go/raylib"
)
func main() {
screenWidth := int32(800)
screenHeight := int32(450)
rl.SetConfigFlags(rl.FlagMsaa4xHint) // Enable Multi Sampling Anti Aliasing 4x (if available)
rl.InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader")
camera := rl.Camera{}
camera.Position = rl.NewVector3(3.0, 3.0, 3.0)
camera.Target = rl.NewVector3(0.0, 1.5, 0.0)
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
camera.Fovy = 45.0
dwarf := rl.LoadModel("dwarf.obj") // Load OBJ model
texture := rl.LoadTexture("dwarf_diffuse.png") // Load model texture
shader := rl.LoadShader("glsl330/base.vs", "glsl330/grayscale.fs") // Load model shader
rl.SetMaterialTexture(dwarf.Materials, rl.MapDiffuse, texture)
dwarf.Materials.Shader = shader // Set shader effect to 3d model
position := rl.NewVector3(0.0, 0.0, 0.0) // Set model position
rl.SetCameraMode(camera, rl.CameraFree) // Set free camera mode
rl.SetTargetFPS(60)
for !rl.WindowShouldClose() {
rl.UpdateCamera(&camera) // Update camera
rl.BeginDrawing()
rl.ClearBackground(rl.RayWhite)
rl.BeginMode3D(camera)
rl.DrawModel(dwarf, position, 2.0, rl.White) // Draw 3d model with texture
rl.DrawGrid(10, 1.0) // Draw a grid
rl.EndMode3D()
rl.DrawText("(c) Dwarf 3D model by David Moreno", screenWidth-200, screenHeight-20, 10, rl.Gray)
rl.DrawText(fmt.Sprintf("Camera position: (%.2f, %.2f, %.2f)", camera.Position.X, camera.Position.Y, camera.Position.Z), 600, 20, 10, rl.Black)
rl.DrawText(fmt.Sprintf("Camera target: (%.2f, %.2f, %.2f)", camera.Target.X, camera.Target.Y, camera.Target.Z), 600, 40, 10, rl.Gray)
rl.DrawFPS(10, 10)
rl.EndDrawing()
}
rl.UnloadShader(shader) // Unload shader
rl.UnloadTexture(texture) // Unload texture
rl.UnloadModel(dwarf) // Unload model
rl.CloseWindow()
}