Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDFShape support for ClearMaterial #21

Open
seanpringle opened this issue Oct 17, 2019 · 1 comment
Open

SDFShape support for ClearMaterial #21

seanpringle opened this issue Oct 17, 2019 · 1 comment

Comments

@seanpringle
Copy link

I tried to add a SphereSDF to the materials example, on the far right, using the same ClearMaterial as the regular Sphere next to it, but the result looks metallic.

Curious to know:

  • Is transparency expected to work with SDF shapes?
  • If so, any pointers on how I can go about fixing this? My first guess is something to do with Hitinfo at https://github.com/fogleman/pt/blob/master/pt/hit.go#L37, but it seems best to ask for ideas before going down the rabbit hole :-)

out100

package main

import . "github.com/fogleman/pt/pt"

func main() {
	scene := Scene{}
	r := 0.4
	var material Material

	material = DiffuseMaterial(HexColor(0x334D5C))
	scene.Add(NewSphere(V(-2, r, 0), r, material))

	material = SpecularMaterial(HexColor(0x334D5C), 2)
	scene.Add(NewSphere(V(-1, r, 0), r, material))

	material = GlossyMaterial(HexColor(0x334D5C), 2, Radians(50))
	scene.Add(NewSphere(V(0, r, 0), r, material))

	material = TransparentMaterial(HexColor(0x334D5C), 2, Radians(20), 1)
	scene.Add(NewSphere(V(1, r, 0), r, material))

	material = ClearMaterial(2, 0)
	scene.Add(NewSphere(V(2, r, 0), r, material))
	// Added SphereSDF
	scene.Add(NewSDFShape(NewTransformSDF(NewSphereSDF(r), Translate(V(3, r, 0))), material))

	material = MetallicMaterial(HexColor(0xFFFFFF), 0, 1)
	scene.Add(NewSphere(V(0, 1.5, -4), 1.5, material))

	scene.Add(NewCube(V(-1000, -1, -1000), V(1000, 0, 1000), GlossyMaterial(HexColor(0xFFFFFF), 1.4, Radians(20))))
	scene.Add(NewSphere(V(0, 5, 0), 1, LightMaterial(White, 25)))
	camera := LookAt(V(0, 3, 7), V(0, 1, 0), V(0, 1, 0), 30)
	sampler := NewSampler(16, 16)
	renderer := NewRenderer(&scene, &camera, sampler, 960, 540)
	renderer.IterativeRender("out%03d.png", 100)
}
@fogleman
Copy link
Owner

Yeah, try not doing that inside = false for your SDF shape. That looks like a hacky workaround I was doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants