Compare commits

..

15 commits
dev ... master

Author SHA1 Message Date
8ab89daa5f rerun test
All checks were successful
Build Go (Linux + Windows) / build (push) Successful in 1m33s
2025-12-23 17:50:04 +01:00
657e091e7f new runner test. doutd
All checks were successful
Build Go (Linux + Windows) / build (push) Successful in 2m8s
2025-12-23 17:44:12 +01:00
b501847f57 green test
All checks were successful
Build Go (Linux + Windows) / build (push) Successful in 1m52s
2025-12-23 02:07:39 +01:00
83dada40b6 hope
All checks were successful
Build Go (Linux + Windows) / build (push) Successful in 1m47s
2025-12-22 23:02:59 +01:00
5cc9b3280a nah I need an LSP for this broo
Some checks failed
Build Go (Linux + Windows) / build (push) Failing after 1m33s
2025-12-22 22:57:46 +01:00
a8a67685ab it was not good, but maybe now...
Some checks failed
Build Go (Linux + Windows) / build (push) Failing after -1s
2025-12-22 22:52:31 +01:00
552d541ee9 I think it's good this time
Some checks failed
Build Go (Linux + Windows) / build (push) Failing after 1m33s
2025-12-22 22:36:40 +01:00
8369f40ee0 maybe...
All checks were successful
Build Go (Linux + Windows) / build (push) Successful in 1m41s
2025-12-22 22:29:32 +01:00
2b7bf6005e maybe now
Some checks failed
Build Go (Linux + Windows) / build (push) Failing after 47s
2025-12-22 22:10:42 +01:00
91d485e0cc added container field
Some checks failed
Build Go (Linux + Windows) / build (push) Failing after 39s
2025-12-21 22:53:27 +01:00
157c1bd8ba test CI/CD
Some checks are pending
Build Go (Linux + Windows) / build (push) Waiting to run
2025-12-21 22:47:17 +01:00
54082ee1bc Update README.md 2025-10-01 23:01:33 +02:00
62e28624eb Merge branch 'dev' 2025-09-28 18:47:37 +02:00
27c4cebb59 SmoothUnion pls 2025-09-28 18:46:24 +02:00
a1a6e0471c Merge pull request 'little scene change' (#1) from dev into master
Reviewed-on: Crizomb/RayMarchingGo#1
2025-09-28 18:43:03 +02:00
7 changed files with 45 additions and 19 deletions

View file

@ -0,0 +1,26 @@
name: Build Go (Linux + Windows)
on:
push:
workflow_dispatch:
jobs:
build:
runs-on: docker
container:
image: git.rufous-trench.ts.net/crizomb/forgejo-action-goraylib:deb13-node20-go1.24
steps:
- uses: actions/checkout@v4
- name: Build binaries
run: |
cd src
mkdir -p builds_artifact
GOOS=linux GOARCH=amd64 go build -o builds_artifact/raymarchgo-linux-amd64
GOOS=windows GOARCH=amd64 go build -o builds_artifact/raymarchgo-windows-amd64.exe
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: DebugBuilds
path: src/builds_artifact

View file

@ -1,2 +1,7 @@
Simple cpu ray-marching in go Simple cpu ray-marching in go
Focus on Lisiblity & Features Focus on Lisiblity & Features
<video src="https://git.rufous-trench.ts.net/Crizomb/Medias/raw/branch/main/rayMarchingGo.mp4" controls></video>
also used to test CI/CD things currently
inc=2

BIN
src/app-linux-amd64 Executable file

Binary file not shown.

View file

@ -1,4 +1,4 @@
module test_raylib module raymarching_go
go 1.24.7 go 1.24.7

View file

@ -15,7 +15,7 @@ import (
const WIDTH = 200 const WIDTH = 200
const HEIGHT = 200 const HEIGHT = 200
const TEXTURE_SCALE = 2 const TEXTURE_SCALE = 4
const MAX_DIST = 500.0 const MAX_DIST = 500.0
const MAX_STEP = 100 const MAX_STEP = 100
@ -23,9 +23,6 @@ const EPS = 0.1
const PI = math.Pi const PI = math.Pi
const SOFT_SHADOW_COEFF = 16 const SOFT_SHADOW_COEFF = 16
const LIGHT_POWER_EXP = 2.0
var LIGHT_POWER_FAC float64 = 2.0
var lightPos Vector3 var lightPos Vector3
var scene SDF var scene SDF
@ -36,8 +33,8 @@ var screenPhysicalSize float64
var cameraPos Vector3 var cameraPos Vector3
func init() { func init() {
lightPos = Vector3{0, -200, 100} lightPos = Vector3{100, -400, 400}
LIGHT_POWER_FAC = math.Pow(lightPos.Length(), LIGHT_POWER_EXP) * LIGHT_POWER_FAC
cameraPos = Vector3{0, -10, 25} cameraPos = Vector3{0, -10, 25}
screenSpherical = Vector3{10, PI/2 + 0.2, PI / 2} screenSpherical = Vector3{10, PI/2 + 0.2, PI / 2}
screenPhysicalSize = 5 screenPhysicalSize = 5
@ -46,9 +43,11 @@ func init() {
func update(t float64) { func update(t float64) {
sphereMat := RED_MAT sphereMat := RED_MAT
sphereMat2 := GREEN_MAT
sphereMat.specularFac = 0.5 sphereMat.specularFac = 0.5
sphereMat2.specularFac = 0.5
sphere := TranslatedSDF{Sphere{10, sphereMat}, Vector3{-15, 100, 10}} sphere := TranslatedSDF{Sphere{10, sphereMat}, Vector3{-15, 100, 10}}
sphere2 := TranslatedSDF{Sphere{10, sphereMat}, Vector3{15, 100, 10}} sphere2 := TranslatedSDF{Sphere{10, sphereMat2}, Vector3{15, 100, 10}}
// boxMat := BLUE_MAT // boxMat := BLUE_MAT
// box := TranslatedSDF{Box{Vector3{10, 2, 10}, boxMat}, Vector3{0, 100, 10}} // box := TranslatedSDF{Box{Vector3{10, 2, 10}, boxMat}, Vector3{0, 100, 10}}

View file

@ -9,30 +9,26 @@ import (
) )
func phongShading(point Vector3, normal Vector3, mat Material) Vector3 { func phongShading(point Vector3, normal Vector3, mat Material) Vector3 {
lightVecNormalized := (lightPos.Sub(point)).Normalized() lightVec := (lightPos.Sub(point)).Normalized()
reflectLight := Reflect(lightVec, normal)
reflectLight := Reflect(lightVecNormalized, normal)
eyeVec := (cameraPos.Sub(point)).Normalized() eyeVec := (cameraPos.Sub(point)).Normalized()
brutMat := mat.GetMaterialBrut() brutMat := mat.GetMaterialBrut()
ambiant := brutMat.ambiantColor.GetColor(point) ambiant := brutMat.ambiantColor.GetColor(point)
diffusePower := brutMat.diffuseFac * max(0, normal.Dot(lightVecNormalized)) diffusePower := brutMat.diffuseFac * max(0, normal.Dot(lightVec))
diffuse := brutMat.diffuseColor.GetColor(point).Scale(diffusePower) diffuse := brutMat.diffuseColor.GetColor(point).Scale(diffusePower)
specularPower := brutMat.specularFac * math.Pow(max(0, reflectLight.Dot(eyeVec)), brutMat.specularExp) specularPower := brutMat.specularFac * math.Pow(max(0, reflectLight.Dot(eyeVec)), brutMat.specularExp)
specular := brutMat.specularColor.GetColor(point).Scale(specularPower) specular := brutMat.specularColor.GetColor(point).Scale(specularPower)
return (ambiant.Add(diffuse).Add(specular)) return ambiant.Add(diffuse).Add(specular)
} }
func shadow(point Vector3) float64 { func shadow(point Vector3) float64 {
lightVec := (lightPos.Sub(point)) direction := (lightPos.Sub(point)).Normalized()
lightVecLength := lightVec.Length()
direction := lightVec.Scale(1 / lightVecLength)
p := point.Add(direction.Scale(5 * EPS)) p := point.Add(direction.Scale(5 * EPS))
res := 1.0 res := 1.0
dist_total := 0.0 dist_total := 0.0
lightPower := LIGHT_POWER_FAC / math.Pow(lightVecLength, LIGHT_POWER_EXP)
for range MAX_STEP { for range MAX_STEP {
dist := scene.Distance(p) dist := scene.Distance(p)
if dist < EPS { if dist < EPS {
@ -45,7 +41,7 @@ func shadow(point Vector3) float64 {
dist_total += dist dist_total += dist
p.Radd(direction.Scale(dist)) p.Radd(direction.Scale(dist))
} }
return res * lightPower return res
} }
func reflect(point Vector3, direction Vector3, normal Vector3, mat Material, reflectNumber int) Vector3 { func reflect(point Vector3, direction Vector3, normal Vector3, mat Material, reflectNumber int) Vector3 {
@ -71,7 +67,7 @@ func rayMarch(origin Vector3, direction Vector3, reflectNumber int) (bool, Vecto
mat := scene.GetMaterial(p) mat := scene.GetMaterial(p)
normal := Gradient(scene, p, EPS).Normalized() normal := Gradient(scene, p, EPS).Normalized()
phongShade := phongShading(p, normal, mat) phongShade := phongShading(p, normal, mat)
shadowCoeff := max(shadow(p), 0.1) shadowCoeff := max(shadow(p), 0.3)
reflectColor := reflect(p, direction, normal, mat, reflectNumber) reflectColor := reflect(p, direction, normal, mat, reflectNumber)
return true, phongShade.Add(reflectColor).Scale(shadowCoeff) return true, phongShade.Add(reflectColor).Scale(shadowCoeff)
// return true, phongShading(p, normal, *mat) // return true, phongShading(p, normal, *mat)

BIN
src/raymarching_go Executable file

Binary file not shown.