Fix shaders
This commit is contained in:
parent
400097df9d
commit
620d205532
8 changed files with 22317 additions and 54982 deletions
22251
examples/shaders/custom_uniform/barracks.obj
Normal file
22251
examples/shaders/custom_uniform/barracks.obj
Normal file
File diff suppressed because it is too large
Load diff
BIN
examples/shaders/custom_uniform/barracks_diffuse.png
Normal file
BIN
examples/shaders/custom_uniform/barracks_diffuse.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 363 KiB |
File diff suppressed because it is too large
Load diff
Binary file not shown.
Before Width: | Height: | Size: 1.2 MiB |
|
@ -13,15 +13,16 @@ func main() {
|
|||
rl.InitWindow(screenWidth, screenHeight, "raylib [shaders] example - custom uniform variable")
|
||||
|
||||
camera := rl.Camera{}
|
||||
camera.Position = rl.NewVector3(3.0, 3.0, 3.0)
|
||||
camera.Position = rl.NewVector3(8.0, 8.0, 8.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
|
||||
camera.Projection = rl.CameraPerspective
|
||||
|
||||
dwarf := rl.LoadModel("dwarf.obj") // Load OBJ model
|
||||
texture := rl.LoadTexture("dwarf_diffuse.png") // Load model texture
|
||||
obj := rl.LoadModel("barracks.obj") // Load OBJ model
|
||||
texture := rl.LoadTexture("barracks_diffuse.png") // Load model texture
|
||||
|
||||
rl.SetMaterialTexture(dwarf.Materials, rl.MapDiffuse, texture) // Set dwarf model diffuse texture
|
||||
rl.SetMaterialTexture(obj.Materials, rl.MapDiffuse, texture) // Set obj model diffuse texture
|
||||
|
||||
position := rl.NewVector3(0.0, 0.0, 0.0) // Set model position
|
||||
|
||||
|
@ -52,7 +53,7 @@ func main() {
|
|||
swirlCenter[1] = float32(screenHeight) - mousePosition.Y
|
||||
|
||||
// Send new value to the shader to be used on drawing
|
||||
rl.SetShaderValue(shader, swirlCenterLoc, swirlCenter, 1)
|
||||
rl.SetShaderValue(shader, swirlCenterLoc, swirlCenter, rl.ShaderUniformVec2)
|
||||
|
||||
rl.UpdateCamera(&camera) // Update camera
|
||||
|
||||
|
@ -62,9 +63,11 @@ func main() {
|
|||
|
||||
rl.BeginTextureMode(target) // Enable drawing to texture
|
||||
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
rl.BeginMode3D(camera)
|
||||
|
||||
rl.DrawModel(dwarf, position, 2.0, rl.White) // Draw 3d model with texture
|
||||
rl.DrawModel(obj, position, 0.5, rl.White) // Draw 3d model with texture
|
||||
|
||||
rl.DrawGrid(10, 1.0) // Draw a grid
|
||||
|
||||
|
@ -81,7 +84,7 @@ func main() {
|
|||
|
||||
rl.EndShaderMode()
|
||||
|
||||
rl.DrawText("(c) Dwarf 3D model by David Moreno", screenWidth-200, screenHeight-20, 10, rl.Gray)
|
||||
rl.DrawText("(c) Barracks 3D model by Alberto Cano", screenWidth-200, screenHeight-20, 10, rl.Gray)
|
||||
|
||||
rl.DrawFPS(10, 10)
|
||||
|
||||
|
@ -90,7 +93,7 @@ func main() {
|
|||
|
||||
rl.UnloadShader(shader) // Unload shader
|
||||
rl.UnloadTexture(texture) // Unload texture
|
||||
rl.UnloadModel(dwarf) // Unload model
|
||||
rl.UnloadModel(obj) // Unload model
|
||||
rl.UnloadRenderTexture(target) // Unload render texture
|
||||
|
||||
rl.CloseWindow()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue