-
Notifications
You must be signed in to change notification settings - Fork 118
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
Using other arrays in the generate
function
#317
Comments
Just guessing by what you wrote, your conclusion is probably correct. Maybe you could There is also a very simple ray tracer in |
The project is on GitHub here: https://github.com/LukaHorvat/RayTracer The relevant bits are I don't know if you can see anything immediately wrong here. In essence what is happening is the Inside of I'm guessing I have a fundamental misunderstanding of how things work. I assumed that if I I should note that I'm not a 100% sure that the error really is where I think it is, but since it's the error mentioned in the docs related to the Also, the reason for that |
Yes, I think specifically it is the use of The general approach to tackle this is to, instead of working on a single ray at a time, try to compute all rays at once, using multidimensional arrays to your advantage. For your program however this is a bit tricky since you use I think the most straightforward approach would be to compute the nearest intersection using |
If you want to instead do the all-rays-at-once approach, since you've defined a nice That is just for a single ray cast. Doing reflections is tricky: you can't do recursion in the Accelerate language, so you need to either find a way to express that in terms of iteration using |
Both approaches sound interesting. I have a few questions if you don't mind With the The other approach seems pretty nice but it means that I'll have a copy of As far as reflections go, currently I don't do them directly but instead On Tue, May 24, 2016 at 7:29 AM Trevor L. McDonell notifications@github.com
|
For the use of cast :: Acc Scene -> Exp Color -> Exp Ray -> Exp (Color, Optional Ray)
cast scene color ray = ...
where
intersect :: Exp (Optional Sphere)
intersect = sfoldl nearest none Z scene
nearest :: Exp (Optional Sphere) -> Exp Sphere -> Exp (Optional Sphere)
nearest old new = ... For the second approach, you would probably need to By the way, I created these after I wrote that toy ray tracer, but you may find these auxiliary packages of mine useful, particularly the first: https://github.com/tmcdonell/linear-accelerate |
I'll close this since it's not an issue. Also, I'm happy to report that I've managed to get it working with I don't want to open a separate issue for this but how come there are so many unimplemented class methods? Most of the errors I've encountered were because some part of my code decided to be polymorphic over standard numeric classes and instead of that being a type error it just crashed at runtime with things like 'no implmentation of toInteger' |
Arbitrary precision types like Some prelude functions such as I have recreated the relevant parts of the type class hierarchy in Accelerate, so use that instead and import only the parts of the Prelude that you require. |
I'm working on a ray tracer. I'm using the
generate
function to construct the array of pixels that will be displayed. Each pixel casts a ray. The casting is done by iterating through the scene of objects. I've put those objects into an accelerated array but my code fails with theinconsistent valuation @ shared 'Exp'
error. I suspect it's because I'm iterating through one array while generating another, but how do I get around this?The text was updated successfully, but these errors were encountered: