random hemisphere (tlrcam related
ok, new copy of TLRcam, this time the file format is a bit different, and the phong works. its also got some minor speed increases in stuff like normalization. oh, and the camera model used is a thin lense camera which can simulate spherical distortion (it was actualy a complete accident).
- Attachments
-
- tlrcam.zip
- TLRcam
- (95.68 KiB) Downloaded 192 times
a shiny monkey is a happy monkey

new Version: this one has an accelerator tree and has memory issues solved. i've created images as large as 2000*2000 (didnt try any larger). the new camera types can be auto (in which case the second double is replaced by a point, manual, in which there is a second double, and simple, which has no dof, even though the first double is still there.
- Attachments
-
- tlrcam.zip
- (411.82 KiB) Downloaded 427 times
a shiny monkey is a happy monkey
the new one has a scene file in it called monkey.tlr and scene.tlr (monkey is the newest picture and scene is the cornel box) . it also has a .bat that you should edit manualy if you want to load monkey or render a large image. to edit the .bat open it up in notepad and change the first line's jdk to the location of your newest downloaded jdk
Code: Select all
@set javadir="C:\Program Files\Java\jdk1.5.0_09"
@set mem=1G
@%javadir%\bin\java -Xmx%mem% -Xss200k -server -jar TLRcam.jar %*
@if %errorlevel% neq 0 pausea shiny monkey is a happy monkey
interpolating across a tri. the only problem with that is that because in a diffuse mat, the rays are getting shot at completely random angles, sometimes they go under the actual normal and within the mesh so that i have to check them with the actual normal and reshoot them if they are wrong. this doesnt seem to create the smooth look that normal smoothing is supposed to accomplish
a shiny monkey is a happy monkey
Consider me confused then.
Ray:
Camera -> into some tri -> if normal smoothing on, ray is bounced in a direction that is weighted by the surrounding normals
Even though diffuse mats bounce in random directions anyway, it's important that they bounce in the correct *spot*, and not necessarily the correct "direction" - with smoothing on, rays will end up bouncing slightly in front of or slightly behind of the defined mesh.
Ray:
Camera -> into some tri -> if normal smoothing on, ray is bounced in a direction that is weighted by the surrounding normals
Even though diffuse mats bounce in random directions anyway, it's important that they bounce in the correct *spot*, and not necessarily the correct "direction" - with smoothing on, rays will end up bouncing slightly in front of or slightly behind of the defined mesh.
i got tlrcam to compile to a .exe and it might be a bit faster depending on your computer. i think it still might depend a little on some java stuff, but it seems to be mostly binary and stuff.
this version has a new path tracing algorithm that i am eventually going to add MLT. the new algorithm mutates a little slower but converges faster so the speed differences you notice between the older versions and this versions you can not measure in seconds/mutation
because of the issue of having time to write a scene api type thing i am going to include the scene loader source. its sorta legible if you know java.
note: i realy realy want to avoid legal issues (my parents are lawyers) so please dont use this code for anything until i open source the program. you should be able to wait a couple more months.
this version has a new path tracing algorithm that i am eventually going to add MLT. the new algorithm mutates a little slower but converges faster so the speed differences you notice between the older versions and this versions you can not measure in seconds/mutation
because of the issue of having time to write a scene api type thing i am going to include the scene loader source. its sorta legible if you know java.
note: i realy realy want to avoid legal issues (my parents are lawyers) so please dont use this code for anything until i open source the program. you should be able to wait a couple more months.
Code: Select all
package ThinLenseReflex;
import java.util.Vector;
/**
* Thin Lense Reflex
*
* Description: java unbiased renderer
*
* Copyright: Copyright (c) 2007
*
* author Matthew Mirman version 0.1b
*/
public class Loader {
public static Tracer Loader(int X, int Y, String path, String imagePath, int osi) {
Camera bounce = new SimpleCamera();
Vector<TreeRoot> jam = new Vector<TreeRoot> (0, 1);
MaterialVector mats = new MaterialVector();
try {
Parser scene = new Parser(path);
while (true) {
String a = scene.getNextToken();
if (a.equals("o")) {
String b = scene.getNextToken();
if (b.equals("sphere")) {
String name = scene.getNextToken();
jam.add(new PrimitiveObject(new SpherePrim(scene.getNextDouble(), new Point3(scene)),
mats.findMat(name)));
}
if (b.equals("mesh")) {
Vector<Double> verts = new Vector<Double> (0, 3);
Vector<Double> norms = new Vector<Double> (0, 3);
Vector<Integer> tris = new Vector<Integer> (0, 7);
Vector<Material> innermats = new Vector<Material> (0, 1);
int currentMat = -1;
String c = scene.getNextToken();
try {
while (!c.equals("}")) {
if (c.equals("v")) {
verts.add(new Double(scene.getNextDouble()));
verts.add(new Double(scene.getNextDouble()));
verts.add(new Double(scene.getNextDouble()));
}
else if (c.equals("vn")) {
norms.add(new Double(scene.getNextDouble()));
norms.add(new Double(scene.getNextDouble()));
norms.add(new Double(scene.getNextDouble()));
}
else if (c.equals("mat")) {
String name = scene.getNextToken();
currentMat++;
innermats.add(mats.findMat(name));
System.out.println(mats.m.get(mats.get(name)).name);
}
else if (c.equals("f")) {
tris.add(new Integer(scene.getNextInt() - 1));
tris.add(new Integer(scene.getNextInt() - 1));
tris.add(new Integer(scene.getNextInt() - 1));
tris.add(new Integer(scene.getNextInt() - 1));
tris.add(new Integer(scene.getNextInt() - 1));
tris.add(new Integer(scene.getNextInt() - 1));
tris.add(new Integer(currentMat));
}
c = scene.getNextToken();
}
Mesh prick = new Mesh(verts, norms, tris, innermats);
//Octree tar=new Octree(new Vector<TreeRoot>( prick.meshBreak()), prick.getBounds());
// jam.add(tar);
jam.addAll(prick.meshBreak());
}
catch (Exception e) {
}
}
}
else if (a.equals("m")) {
mats.read(scene);
}
else if (a.equals("camera")) {
System.out.println("cam");
String b = scene.getNextToken();
if (b.equals("auto")){
Point3 origin = new Point3(scene);
Point3 destination = new Point3(scene);
Vector3 dir= new Ray(origin, destination).Direction.normalized();
Vector3 up=new Vector3(scene).normalized();
bounce = new ThinLenseCam(origin,
dir,
up,
scene.getNextDouble(),
new Vector3(origin, new Point3(scene)).norm(),
X, Y,
scene.getNextDouble());
}else if(b.equals("simple")){
Point3 origin = new Point3(scene);
Point3 destination = new Point3(scene);
bounce = new SimpleCamera(origin,
new Ray(origin, destination).Direction.normalized(),
new Vector3(scene).normalized(),
scene.getNextDouble(),
scene.getNextDouble(), X*osi, Y*osi,
scene.getNextDouble());
}else{
Point3 origin = new Point3(scene);
Point3 destination = new Point3(scene);
bounce = new ThinLenseCam(origin,
new Ray(origin, destination).Direction.normalized(),
new Vector3(scene).normalized(),
scene.getNextDouble(),
scene.getNextDouble(), X*osi, Y*osi,
scene.getNextDouble());
}
}
}
}
catch (Exception e) {
}
return new SimpleTracer(RenderBegginer.X,RenderBegginer.Y, jam, bounce, osi);
}
}
class MaterialName {
public Material m;
public String name;
MaterialName() {
}
}
class MaterialVector {
Vector<MaterialName> m = new Vector<MaterialName> (1, 1);
public void add(MaterialName p) {
m.add(p);
}
public void read(Parser scene) throws Exception{
System.out.println("mat");
MaterialName mat = new MaterialName();
mat.name = scene.getNextToken();
String type = scene.getNextToken();
if (type.equals("emit")) {
Texture diffuse = new TexSolid(Colour.black);
Texture reflect = new TexSolid(Colour.black);
Texture refract = new TexSolid(Colour.black);
double gloss = 0;
Colour m2=new Colour(scene);
Texture emit = new TexSolid(m2);
mat.m = new Material(diffuse, reflect, refract, emit,
gloss, true);
scene.getNextToken();
System.out.println("completed mat "+m2.toString()+" "+mat.name);
add(mat);
}else{
Texture diffuse = new TexSolid(Colour.black);
Texture reflect = new TexSolid(Colour.black);
Texture refract = new TexSolid(Colour.black);
Texture emit = new TexSolid(Colour.black);
double gloss = 0;
while (!type.equals("}")) {
if (type.equals("d")) {
diffuse = new TexSolid(new Colour(scene));
}
if (type.equals("rl")) {
reflect = new TexSolid(new Colour(scene));
}
if (type.equals("rf")) {
refract = new TexSolid(new Colour(scene));
}
if (type.equals("em")) {
emit = new TexSolid(new Colour(scene));
}
if (type.equals("g")) {
gloss = scene.getNextDouble();
}
type = scene.getNextToken();
}
mat.m = new Material( diffuse, reflect, refract, emit,
gloss, false);
System.out.println("");
System.out.println("completed mat " + " " +
mat.name);
add(mat);
}
/*
if (type.equals("diff")) {
mat.m =new DefaultMat(new BSDF(scene));
Colour m2=new Colour(scene);
System.out.println("completed mat "+m2.toString()+" "+mat.name);
add(mat, m2);
}
else if (type.equals("emit")) {
mat.m = new Emmiter();
Colour m2=new Colour(scene);
System.out.println("completed mat "+m2.toString()+" "+mat.name);
add(mat, m2);
}
else if (type.equals("phong")) {
mat.m =new DefaultMat(new BSRDF(scene));
Colour m2=new Colour(scene);
System.out.println("completed mat "+m2.toString()+" "+mat.name);
add(mat, m2);
}*/
}
public Material get(int index) {
return m.get(index).m;
}
public Material findMat(String s) {
for (int i = 0; i < m.size(); i++) {
if (m.get(i).name.equals(s)) {
return m.get(i).m;
}
}
return null;
}
public int get(String s) {
for (int i = 0; i < m.size(); i++) {
if (m.get(i).name.equals(s)) {
return i;
}
}
return -1;
}
public Material[] getArray() {
Material[] list = new Material[m.size()];
for (int i = 0; i < m.size(); i++) {
list[i] = m.get(i).m;
}
return list;
}
}
- Attachments
-
- tlrcam.zip
- not the exe version - that was too big, i'll post that somewhere else
- (505.32 KiB) Downloaded 173 times
a shiny monkey is a happy monkey
interpolating across a tri. the only problem with that is that because in a diffuse mat, the rays are getting shot at completely random angles, sometimes they go under the actual normal and within the mesh so that i have to check them with the actual normal and reshoot them if they are wrong. this doesnt seem to create the smooth look that normal smoothing is supposed to accomplish
Sorry, I meant to reply to this one...
What I do is just reject the path if it goes underneath the geometry. Maybe not the best way but no problems with smoothing artifacts (well, smoothing artifacts that aren't caused by too rough a mesh anyway)
Ian.
Sorry, I meant to reply to this one...
What I do is just reject the path if it goes underneath the geometry. Maybe not the best way but no problems with smoothing artifacts (well, smoothing artifacts that aren't caused by too rough a mesh anyway)
Ian.
i do that too, except rather than rejecting the path, i reshoot it about 50 times till it works (gets slow and bugy in theory with smoothed ultra reflective surfaces). i might have solved my problem, but i dont think it's solved fully, i realy dont know. its alot harder to tell at this point.
a shiny monkey is a happy monkey
Who is online
Users browsing this forum: Bing [Bot] and 70 guests