programing a raytracer
idea for normal smoothing algorithm:
(cant find any real internet sources on normal interpolation)
get the hit point
for each vertex on the triangle create a new ray through the hit point
get the length from the origin of that ray (vertex) to the line that it hits opposite of it using trig.
get the length from the origin to the hit point
for that vertex normalise the normal then scale it by (origin to hitpoint/origin to oposite edge).
add all the scalled vertex normals together then normalise that.
(cant find any real internet sources on normal interpolation)
get the hit point
for each vertex on the triangle create a new ray through the hit point
get the length from the origin of that ray (vertex) to the line that it hits opposite of it using trig.
get the length from the origin to the hit point
for that vertex normalise the normal then scale it by (origin to hitpoint/origin to oposite edge).
add all the scalled vertex normals together then normalise that.
a shiny monkey is a happy monkey
ok, i'm pretty sure that the turning black problem has nothing to do with normal smoothing, although i have no idea what it is because.
my problem:
triangles specified by 3 vertexes,0 1 3, turns black depending on how these verticies are configured
for example it turns black at two configureations: 3,0,1 and 1,0,3 but none of the other configurations
my problem:
triangles specified by 3 vertexes,0 1 3, turns black depending on how these verticies are configured
for example it turns black at two configureations: 3,0,1 and 1,0,3 but none of the other configurations
Code: Select all
Ray[] vert = {
new Ray(new Point(100, 0, -10), new Vector(0, .1, .1)),
new Ray(new Point(0, 100, -40), new Vector(0, .8, .8)),
new Ray(new Point( -100, 0, -10), new Vector(0, .1,.1)),
new Ray(new Point(0, -100, 80), new Vector(0, .8, .8)),
};
Objects[] objective = {
new Objects(new polygon(true, vert[3], vert[0], vert[1]), bdf),
}
a shiny monkey is a happy monkey
its not black lines that are the problem, i fixed that one already. its not a normal smoothing problem, i've been debbuging it for the last day and it doesnt realy seem to be an algorithmic error either.
also- i just learned about static constructors in java for edditing static classes... i changed my scene and camera stuff to work like this and now it renders about twice as fast (3-5 seconds for 400*400 2osi). i'm happy.
also- i just learned about static constructors in java for edditing static classes... i changed my scene and camera stuff to work like this and now it renders about twice as fast (3-5 seconds for 400*400 2osi). i'm happy.
a shiny monkey is a happy monkey
What about 0,3,1 (if that's possible) ? If 0,3,1 works ok I have no clue, sorry, if it doesn't maybe these triangles are created inverted, could it be ? In Maya (and some others apps I think) the direction of the normal of a created triangle depends on if you created the vertices clockwise or counter-clockwise (the later creating tris with normal facing toward the camera).for example it turns black at two configureations: 3,0,1 and 1,0,3 but none of the other configurations
obsolete asset
Who is online
Users browsing this forum: No registered users and 4 guests