Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed build and DevIL

  • Loading branch information...
commit 5730c157dc784c8b8f5eb811837716c54d705593 1 parent e925da1
@vshymanskyy authored
View
24 .cproject
@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?fileVersion 4.0.0?>
-
-<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.config.gnu.exe.debug.2036238980">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.debug.2036238980" moduleId="org.eclipse.cdt.core.settings" name="Debug">
@@ -23,8 +21,8 @@
<builder buildPath="${workspace_loc:/smort/Debug}" id="cdt.managedbuild.target.gnu.builder.exe.debug.706823281" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/>
<tool command="g++" id="cdt.managedbuild.tool.gnu.archiver.base.907975857" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.1235113975" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug">
- <option id="gnu.cpp.compiler.exe.debug.option.optimization.level.147779873" name="Optimization Level" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
- <option id="gnu.cpp.compiler.exe.debug.option.debugging.level.1305228454" name="Debug Level" superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.exe.debug.option.optimization.level.147779873" name="Optimization Level" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.optimize" valueType="enumerated"/>
+ <option id="gnu.cpp.compiler.exe.debug.option.debugging.level.1305228454" name="Debug Level" superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.default" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.include.paths.1615768033" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/smort/src/Core}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/smort/src/Shaders}&quot;"/>
@@ -40,8 +38,8 @@
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1757050824" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1721933442" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug">
- <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.exe.debug.option.optimization.level.968281783" name="Optimization Level" superClass="gnu.c.compiler.exe.debug.option.optimization.level" valueType="enumerated"/>
- <option id="gnu.c.compiler.exe.debug.option.debugging.level.2009475048" name="Debug Level" superClass="gnu.c.compiler.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
+ <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.exe.debug.option.optimization.level.968281783" name="Optimization Level" superClass="gnu.c.compiler.exe.debug.option.optimization.level" value="gnu.c.optimization.level.optimize" valueType="enumerated"/>
+ <option id="gnu.c.compiler.exe.debug.option.debugging.level.2009475048" name="Debug Level" superClass="gnu.c.compiler.exe.debug.option.debugging.level" value="gnu.c.debugging.level.default" valueType="enumerated"/>
<option id="gnu.c.compiler.option.debugging.other.301483135" name="Other debugging flags" superClass="gnu.c.compiler.option.debugging.other" value="-fno-builtin -fno-stack-protector" valueType="string"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.2140103282" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
@@ -49,6 +47,7 @@
<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.1473089755" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug">
<option id="gnu.cpp.link.option.libs.372862465" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
<listOptionValue builtIn="false" value="glut"/>
+ <listOptionValue builtIn="false" value="IL"/>
<listOptionValue builtIn="false" value="gomp"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1909734829" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
@@ -117,6 +116,7 @@
<tool command="g++" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.729198247" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug">
<option id="gnu.cpp.link.option.libs.369846416" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
<listOptionValue builtIn="false" value="glut"/>
+ <listOptionValue builtIn="false" value="IL"/>
<listOptionValue builtIn="false" value="gomp"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.2130254358" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
@@ -863,5 +863,13 @@
</profile>
</scannerConfigBuildInfo>
</storageModule>
- <storageModule moduleId="refreshScope"/>
+ <storageModule moduleId="refreshScope" versionNumber="2">
+ <configuration configurationName="Release">
+ <resource resourceType="PROJECT" workspacePath="/smort"/>
+ </configuration>
+ <configuration configurationName="Debug">
+ <resource resourceType="PROJECT" workspacePath="/smort"/>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
</cproject>
View
15 .settings/language.settings.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<project>
+ <configuration id="cdt.managedbuild.config.gnu.exe.debug.2036238980" name="Debug">
+ <extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
+ <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
+ <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
+ </extension>
+ </configuration>
+ <configuration id="cdt.managedbuild.config.gnu.exe.debug.2036238980.1837740925" name="Release">
+ <extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
+ <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
+ <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
+ </extension>
+ </configuration>
+</project>
View
16 camera.skel
@@ -1,14 +1,14 @@
SKEL
8 10
--10.00000 4.00000 4.00000
--8.42353 4.69067 2.86522
--8.04075 3.57524 4.48055
--9.19794 2.11763 3.74825
--9.58072 3.23306 2.13292
--9.57846 3.23590 2.13435
--9.57771 3.23372 2.13750
--9.57997 3.23088 2.13607
+38.52958 9.35158 49.84993
+36.92390 8.25607 49.66512
+36.66237 9.71011 49.40553
+38.07133 9.71011 47.98607
+38.33286 8.25607 48.24566
+38.33110 8.25607 48.24744
+38.33066 8.25850 48.24701
+38.33242 8.25850 48.24523
2 0 1 0.500 0.500 0.500 1.000
2 0 2 0.500 0.500 0.500 1.000
View
BIN  face.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2  src/Shaders/shPerlinImproved.cpp
@@ -1,7 +1,7 @@
#include "shPerlinImproved.h"
static float fade(float t) {
- return t * t * t * (t * (t * 6 - 15) + 10);
+ return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
}
static float lerp(float t, float a, float b) {
View
72 src/Shaders/shRaster.cpp
@@ -3,7 +3,8 @@
#include <cmath>
#include <cstring>
-rgba shRaster::GetPixel(int x,int y) const{
+rgba shRaster::GetPixel(int x,int y) const
+{
int index = bpp*(y*Width+x);
index = cMath::ClampRange(index,0,bpp*Width*Height-1);
switch (bpp) {
@@ -20,7 +21,9 @@ rgba shRaster::GetPixel(int x,int y) const{
return rgba();
}
-shRaster::shRaster(const char *fn,const FilteringMethod Filter) :filter(Filter) {
+shRaster::shRaster(const char *fn, const FilteringMethod Filter)
+ : filter(Filter)
+{
ILuint name;
static bool ilInitialized = false;
if (!ilInitialized) {
@@ -42,32 +45,28 @@ shRaster::shRaster(const char *fn,const FilteringMethod Filter) :filter(Filter)
data = new ILubyte[dataSize];
memcpy(data,ilGetData(),dataSize);
ilDeleteImages(1,&name);
-
+
}
-#define cubic(t) ((t)*(t)*(cMath::Three-cMath::Two*(t)))
+#define cubic(t) ((t)*(t)*(real(3.0)-real(2.0)*(t)))
-rgba shRaster::Shade(Ray &r) const{
+void shRaster::Shade (const Ray &r, rgba* result) const
+{
const real
- x = r.gState.UV.x.Abs()*real(Width),
- y = r.gState.UV.y.Abs()*real(Height);
+ x = r.gState.textureUV.x.Abs()*real(Width),
+ y = r.gState.textureUV.y.Abs()*real(Height);
switch(filter) {
case (FM_NONE):{
- return GetPixel((int)(x)%Width,(int)(y)%Height);
- }case (FM_NEAREST):{
-
- }case (FM_LINEAR):{
-
- }case (FM_BILINEAR):{
+ *result = GetPixel((int)(x)%Width,(int)(y)%Height);
+ } case (FM_BILINEAR):{
const real
- mx = floor(x),
- my = floor(y),
- x1 = fmod(mx, Width),
- y1 = fmod(my, Height);
+ mx = x.Floor(),
+ my = y.Floor(),
+ x1 = mx.Mod(Width),
+ y1 = my.Mod(Height);
real
- x2 = x1 + cMath::One,
- y2 = y1 + cMath::One;
-
+ x2 = x1 + real(1.0),
+ y2 = y1 + real(1.0);
{
real tmp(Width-1);
if (x2 > tmp)
@@ -80,22 +79,23 @@ rgba shRaster::Shade(Ray &r) const{
const real
fx = x-mx,
fy = y-my,
- ifx = cMath::One-fx,
- ify = cMath::One-fy;
- return
+ ifx = real(1.0)-fx,
+ ify = real(1.0)-fy;
+ *result =
GetPixel((int)(x1),(int)(y1))*(ifx*ify)+
GetPixel((int)(x2),(int)(y1))*(fx*ify)+
GetPixel((int)(x1),(int)(y2))*(ifx*fy)+
GetPixel((int)(x2),(int)(y2))*(fx*fy);
- }case (FM_BICUBIC):{
+ break;
+ } case (FM_BICUBIC):{
const real
- mx = floor(x),
- my = floor(y),
- x1 = fmod(mx, Width),
- y1 = fmod(my, Height);
+ mx = x.Floor(),
+ my = y.Floor(),
+ x1 = mx.Mod(Width),
+ y1 = my.Mod(Height);
real
- x2 = x1 + cMath::One,
- y2 = y1 + cMath::One;
+ x2 = x1 + real(1.0),
+ y2 = y1 + real(1.0);
{
real tmp(Width-1);
@@ -109,15 +109,17 @@ rgba shRaster::Shade(Ray &r) const{
const real
fx = cubic(x-mx),
fy = cubic(y-my),
- ifx = cMath::One-fx,
- ify = cMath::One-fy;
- return
+ ifx = real(1.0)-fx,
+ ify = real(1.0)-fy;
+ *result =
GetPixel((int)(x1),(int)(y1))*(ifx*ify)+
GetPixel((int)(x2),(int)(y1))*(fx*ify)+
GetPixel((int)(x1),(int)(y2))*(ifx*fy)+
GetPixel((int)(x2),(int)(y2))*(fx*fy);
- }default:{
- return GetPixel((int)(x)%Width,(int)(y)%Height);
+ break;
+ } default:{
+ *result = GetPixel((int)(x)%Width,(int)(y)%Height);
+ break;
}
}
}
View
4 src/Shaders/shRaster.h
@@ -1,6 +1,6 @@
#pragma once
#include "shBase.h"
-#include "..\..\Dependencies\DevIL\include\il.h"
+#include <IL/il.h>
class shRaster: public shBase{
private:
@@ -26,7 +26,7 @@ class shRaster: public shBase{
shRaster(const char *fn,const FilteringMethod Filter = FM_BICUBIC);
- rgba Shade(Ray &r) const;
+ void Shade (const Ray &r, rgba* result) const;
~shRaster();
};
View
18 src/Shaders/shReflect.h
@@ -1,14 +1,22 @@
#pragma once
#include "shBase.h"
-template <class Coef>
-class shReflect {
+class shReflect
+ : public shBase
+{
+
+private:
+ const shBase* mCoeficient;
public:
- shReflect();
- static void Shade(const Ray &r, rgba* result) {
+ shReflect(const shBase* coef)
+ : mCoeficient(coef)
+ {
+ }
+
+ void Shade(const Ray &r, rgba* result) const {
rgba Kr;
- Coef::Shade(r, &Kr);
+ mCoeficient->Shade(r, &Kr);
if (Kr.Luminance() > channel(0.0)) {
const vec3 reflDir = r.dir + r.gState.normal * r.gState.cosND * real(2.0);
Ray rayRefl(r.scene, r.gState.point, reflDir, r.cState.depth-1, r.parent);
View
185 src/Shaders/shWavelet.cpp
@@ -1,185 +0,0 @@
-#include "shWavelet.h"
-#include "cRandom.h"
-
-#define ARAD 16
-
-static int Mod(int x, int n) {
- int m=x%n;
- return (m<0) ? m+n : m;
-}
-
-static void Downsample (real *from, real *to, int n, int stride) {
- const real *a;
- static const real aCoeffs[2*ARAD] = {
- 0.000334,-0.001528, 0.000410, 0.003545,-0.000938,-0.008233, 0.002172, 0.019120,
- -0.005040,-0.044412, 0.011655, 0.103311,-0.025936,-0.243780, 0.033979, 0.655340,
- 0.655340, 0.033979,-0.243780,-0.025936, 0.103311, 0.011655,-0.044412,-0.005040,
- 0.019120, 0.002172,-0.008233,-0.000938, 0.003546, 0.000410,-0.001528, 0.000334
- };
- a = &aCoeffs[ARAD];
- for (int i=0; i<n/2; i++) {
- to[i*stride] = 0.0;
- for (int k=2*i-ARAD; k<=2*i+ARAD; k++)
- to[i*stride] += a[k-2*i] * from[Mod(k,n)*stride];
- }
-}
-
-static void Upsample(real *from, real *to, int n, int stride) {
- const real *p;
- static const real pCoeffs[4] = {
- 0.25, 0.75, 0.75, 0.25
- };
- p = &pCoeffs[2];
- for (int i=0; i<n; i++) {
- to[i*stride] = 0.0;
- for (int k=i/2; k<=i/2+1; k++)
- to[i*stride] += p[i-2*k] * from[Mod(k,n/2)*stride];
- }
-}
-
-shWavelet::shWavelet(int size, int seed)
- : ngBase(3)
-{
- if (size%2)
- size++; // tile size must be even
-
- mSize = size;
-
- cRandom::Seed(seed);
-
- int ix, iy, iz, i, sz=size*size*size;
-
- real *downsampled = new real[sz];
- real *upsampled = new real[sz];
- mNoise = new real[sz];
-
- // Step 1. Fill the tile with random numbers in the range -1 to 1.
- for (i=0; i<sz; i++) {
- mNoise[i] = cRandom::InRange(-real(1), real(1));
- }
-
- // Steps 2 and 3. Downsample and upsample the tile
- for (iy=0; iy<size; iy++) {
- for (iz=0; iz<size; iz++) { // each x row
- i = iy*size + iz*size*size;
- Downsample(&mNoise[i], &downsampled[i], size, 1);
- Upsample(&downsampled[i], &upsampled[i], size, 1);
- }
- }
- for (ix=0; ix<size; ix++) {
- for (iz=0; iz<size; iz++) { // each y row
- i = ix + iz*size*size;
- Downsample(&upsampled[i], &downsampled[i], size, size);
- Upsample(&downsampled[i], &upsampled[i], size, size);
- }
- }
- for (ix=0; ix<size; ix++) {
- for (iy=0; iy<size; iy++) { // each z row
- i = ix + iy*size;
- Downsample(&upsampled[i], &downsampled[i], size, size*size);
- Upsample(&downsampled[i], &upsampled[i], size, size*size);
- }
- }
- // Step 4. Subtract out the coarse-scale contribution
- for (i=0; i<sz; i++) {
- mNoise[i]-=upsampled[i];
- }
- // Avoid even/odd variance difference by adding odd-offset version of noise to itself.
- int offset=size/2;
- if (offset%2==0)
- offset++;
- for (i=0,ix=0; ix<size; ix++)
- for (iy=0; iy<size; iy++)
- for (iz=0; iz<size; iz++)
- downsampled[i++] = mNoise[ Mod(ix+offset,size) + Mod(iy+offset,size)*size + Mod(iz+offset,size)*size*size ];
- for (i=0; i<sz; i++) {
- mNoise[i]+=downsampled[i];
- }
-
- delete[] downsampled;
- delete[] upsampled;
-}
-
-shWavelet::~shWavelet() {
- delete[] mNoise;
-}
-
-real shWavelet::Noise3D(const vec3& vec) const{
- real items[3] = {vec.x, vec.y, vec.z};
- // Non-projected 3D noise
- int i, f[3], c[3], mid[3]; // f, c = filter, noise coeff indices
- real w[3][3], t, result =0.0;
- // Evaluate quadratic B-spline basis functions
- for (i=0; i<3; i++) {
- mid[i]=(items[i]-real(0.5)).Ceil();
- t=real(mid[i])-(items[i]-real(0.5));
- w[i][0]=t*t/real(2);
-
- w[i][1]=real(1)-w[i][0]-w[i][2];
-
- w[i][2]=(real(1)-t)*(real(1)-t)/real(2);
- }
- // Evaluate noise by weighting noise coefficients by basis function values
- for (f[2]=-1;f[2]<=1;f[2]++) {
- for (f[1]=-1;f[1]<=1;f[1]++) {
- for (f[0]=-1;f[0]<=1;f[0]++) {
- real weight=real(1);
- for (i=0; i<3; i++) {
- c[i]=Mod(mid[i]+f[i],mSize);
- weight*=w[i][f[i]+1];
- }
- result += weight * mNoise[c[2]*mSize*mSize+c[1]*mSize+c[0]];
- }
- }
- }
- return result;
-}
-
-//
-// real shWavelet::WMultibandNoise(const real p[3],real s,real *normal,int firstBand,int nbands,real *w) const
-// {
-// real q[3], result=0, variance=0;
-// int i, b;
-// for (b=0; b<nbands && s+firstBand+b<0; b++) {
-// for (i=0; i<=2; i++) {
-// q[i]=2*p[i]*pow(real(2),firstBand+b);
-// }
-// result += (normal) ? w[b] * WProjectedNoise(q,normal) : w[b] * Noise3D(q);
-// }
-// for (b=0; b<nbands; b++) {
-// variance+=w[b]*w[b];
-// }
-// // Adjust the noise so it has a variance of 1.
-// if (variance)
-// result /= cMath::Sqrt(variance * ((normal) ? 0.296 : 0.210));
-// return result;
-// }
-//
-// real shWavelet::WProjectedNoise(const real p[3], real normal[3]) const
-// {
-// // 3D noise projected onto 2D
-// int i, c[3], min[3], max[3], n=mSize; // c = noise coeff location
-// real support, result=0;
-// // Bound the support of the basis functions for this projection direction
-// for (i=0; i<3; i++) {
-// support = 3*.Abs(normal[i]) + 3*cMath::Sqrt((1-normal[i]*normal[i])/2);
-// min[i] = ceil(p[i] - (3*.Abs(normal[i]) + 3*cMath::Sqrt((1-normal[i]*normal[i])/2)));
-// max[i] = floor(p[i] + (3*.Abs(normal[i]) + 3*cMath::Sqrt((1-normal[i]*normal[i])/2))); }
-// // Loop over the noise coefficients within the bound.
-// for (c[2]=min[2];c[2]<=max[2];c[2]++) {
-// for (c[1]=min[1];c[1]<=max[1];c[1]++) {
-// for (c[0]=min[0];c[0]<=max[0];c[0]++) {
-// real t, t1, t2, t3, dot=0, weight=1;
-// // Dot the normal with the vector from c to p
-// for (i=0; i<3; i++) {dot+=normal[i]*(p[i]-c[i]);}
-// // Evaluate the basis function at c moved halfway to p along the normal.
-// for (i=0; i<3; i++) {
-// t = (c[i]+normal[i]*dot/2)-(p[i]-1.5); t1=t-1; t2=2-t; t3=3-t;
-// weight*=(t<=0||t>=3)? 0 : (t<1) ? t*t/2 : (t<2)? 1-(t1*t1+t2*t2)/2 : t3*t3/2;}
-// // Evaluate noise by weighting noise coefficients by basis function values.
-// result += weight * mNoise[Mod(c[2],n)*n*n+Mod(c[1],n)*n+Mod(c[0],n)];
-// }
-// }
-// }
-// return result;
-// }
View
18 src/Shaders/shWavelet.h
@@ -1,18 +0,0 @@
-#pragma once
-
-#include "ngBase.h"
-
-class shWavelet: public ngBase{
-private:
- int mSize;
- real *mNoise;
-
-// real WProjectedNoise(const real p[3], real normal[3]) const;
-// real WMultibandNoise(const real p[3], real s,real *normal,int firstBand,int nbands,real *w)const;
-
-public:
- shWavelet(int size = 64, int seed = 0);
- ~shWavelet(void);
-
- real Noise3D(const vec3& vec) const;
-};
View
6 src/Smort/Ray.h
@@ -37,6 +37,12 @@ struct Ray {
void UpdatePoint();
void UpdateNormal();
+
+ void Clear() {
+ dist = cMath::Huge;
+ cState.depth = NR_BOUNCES;
+ gState.object = NULL;
+ }
};
inline
View
6 src/Smort/fsBox.h
@@ -53,15 +53,17 @@ class fsBox
pixel = rgba(0.0);
channel weight(0.0);
+ Ray ray(geom);
+ rgba col;
+
for (real sx = -half_samples; sx < half_samples; sx += real(1)) {
for (real sy = -half_samples; sy < half_samples; sy += real(1)) {
const real sub_x = sample_step * real(sx) + cRandom::InRange(-half_sample_step, half_sample_step);
const real sub_y = sample_step * real(sy) + cRandom::InRange(-half_sample_step, half_sample_step);
//const channel curWeight = channel(flt.getWeight(vec2(sub_x, sub_y)));
- Ray ray(geom);
- rgba col;
cam->getRay(real(0.5 + x) + sub_x, real(0.5 + y) + sub_y, &ray);
+ ray.Clear();
geom->Trace(ray, &col);
samples++;
pixel += col;// * curWeight;
View
2  src/Smort/prSphere.cpp
@@ -6,7 +6,7 @@ prSphere::prSphere(const vec3 center, real radius, const shBase* MatFront, const
, mEquador (0.0, 0.0, 1.0)
, mRadius (radius)
, mMaterialFront(MatFront)
- , mMaterialBack (MatBack)
+ , mMaterialBack (MatBack?MatBack:MatFront)
, mNcrossE (mNorth.cross(mEquador))
, mSqrRadius (Square(mRadius))
{
View
241 src/Test/appGlut.h
@@ -16,6 +16,7 @@ class appGlut {
int mPixelation;
int mWidth, mHeight;
int mPosX, mPosY;
+ bool mNeedRender;
camThinLens* mCamera;
prBase* mGeometry;
@@ -24,9 +25,6 @@ class appGlut {
public:
- appGlut() {}
- ~appGlut() {}
-
static appGlut* GetInstance() {
static appGlut* inst = new appGlut();
return inst;
@@ -34,8 +32,8 @@ class appGlut {
void Run(int argc, char** argv, fsBase* sampler, camThinLens* cam, prBase* geom) {
mPixelation = 0;
- mWidth = 512;
- mHeight = 512;
+ mWidth = 800;
+ mHeight = 600;
mCamera = cam;
mGeometry = geom;
mSampler = sampler;
@@ -98,6 +96,9 @@ class appGlut {
void setFrameSize(int w, int h){
mFrame->setSize(w, h);
mCamera->setFrameSize(w, h);
+ mCamera->mViewSize.x = 1.0;
+ mCamera->mViewSize.y = real(h)/real(w);
+ mCamera->Precompute();
}
void Update(bool resize = true) {
@@ -114,14 +115,15 @@ class appGlut {
glDrawPixels(mFrame->Width(), mFrame->Height(), GL_RGBA, GL_FLOAT, mFrame->Buffer());
glutSwapBuffers();
printf("%d x %d, %d spp: %1.3f, %s RPS\n", mFrame->Width(), mFrame->Height(), mSampler->getSamples(), 1.0/atof(mFrame->getProperty("RenderTime")), mFrame->getProperty("RaysPerSec"));
+
}
static void Display() {
appGlut& app = *GetInstance();
- //glPixelZoom (1 << app.mPixelation, 1 << app.mPixelation);
- //glDrawPixels(app.mFrame->Width(), app.mFrame->Height(), GL_RGBA, GL_FLOAT, app.mFrame->Buffer());
- //glFlush();
- //glutSwapBuffers();
+ glPixelZoom (float(app.mWidth) / app.mFrame->Width(), float(app.mHeight) / app.mFrame->Height());
+ glDrawPixels(app.mFrame->Width(), app.mFrame->Height(), GL_RGBA, GL_FLOAT, app.mFrame->Buffer());
+ glFlush();
+ glutSwapBuffers();
}
static void Reshape(int width, int height) {
@@ -131,8 +133,11 @@ class appGlut {
app.mHeight = height;
char buff[32];
- sprintf(buff, "smort [%d x %d]\n", width, height);
+ sprintf(buff, "smort [%d x %d * %d]", width, height, app.mSampler->getSamples());
glutSetWindowTitle(buff);
+
+ Display();
+ app.mNeedRender = true;
}
}
@@ -217,170 +222,172 @@ class appGlut {
}
static void Idle() {
- appGlut& app = *GetInstance();
+ GetInstance()->OnIdle();
+ }
- bool changed = false;
- if (app.mKeyBuffer[0] || app.mKeyBuffer[1] || app.mKeyBuffer[2]) {
- changed = true;
- }
- if (app.mKeyBuffer['w']) {
- app.mCamera->mPosition += app.mCamera->mBase.w*real(0.5); changed = true;
+ void OnIdle()
+ {
+ if (mKeyBuffer[0] || mKeyBuffer[1] || mKeyBuffer[2]) {
+ mNeedRender = true;
+ //mPixelation = 2;
+ } /*else if (mPixelation == 2) {
+ mNeedRender = true;
+ mPixelation = 0;
+ }*/
+
+ if (mKeyBuffer['w']) {
+ mCamera->mPosition += mCamera->mBase.w*real(0.5); mNeedRender = true;
}
- if (app.mKeyBuffer['s']) {
- app.mCamera->mPosition -= app.mCamera->mBase.w*real(0.5); changed = true;
+ if (mKeyBuffer['s']) {
+ mCamera->mPosition -= mCamera->mBase.w*real(0.5); mNeedRender = true;
}
- if (app.mKeyBuffer['a']) {
- app.mCamera->mPosition -= app.mCamera->mBase.u*real(0.5); changed = true;
+ if (mKeyBuffer['a']) {
+ mCamera->mPosition -= mCamera->mBase.u*real(0.5); mNeedRender = true;
}
- if (app.mKeyBuffer['d']) {
- app.mCamera->mPosition += app.mCamera->mBase.u*real(0.5); changed = true;
+ if (mKeyBuffer['d']) {
+ mCamera->mPosition += mCamera->mBase.u*real(0.5); mNeedRender = true;
}
- if (app.mKeyBuffer['r']) {
- app.mCamera->mPosition += app.mCamera->mBase.v*real(0.5); changed = true;
+ if (mKeyBuffer['r']) {
+ mCamera->mPosition += mCamera->mBase.v*real(0.5); mNeedRender = true;
}
- if (app.mKeyBuffer['f']) {
- app.mCamera->mPosition -= app.mCamera->mBase.v*real(0.5); changed = true;
+ if (mKeyBuffer['f']) {
+ mCamera->mPosition -= mCamera->mBase.v*real(0.5); mNeedRender = true;
}
//speed
- if (app.mKeyBuffer['W']) {
- app.mCamera->mPosition += app.mCamera->mBase.w*real(5.0); changed = true;
+ if (mKeyBuffer['W']) {
+ mCamera->mPosition += mCamera->mBase.w*real(5.0); mNeedRender = true;
}
- if (app.mKeyBuffer['S']) {
- app.mCamera->mPosition -= app.mCamera->mBase.w*real(5.0); changed = true;
+ if (mKeyBuffer['S']) {
+ mCamera->mPosition -= mCamera->mBase.w*real(5.0); mNeedRender = true;
}
- if (app.mKeyBuffer['A']) {
- app.mCamera->mPosition -= app.mCamera->mBase.u*real(5.0); changed = true;
+ if (mKeyBuffer['A']) {
+ mCamera->mPosition -= mCamera->mBase.u*real(5.0); mNeedRender = true;
}
- if (app.mKeyBuffer['D']) {
- app.mCamera->mPosition += app.mCamera->mBase.u*real(5.0); changed = true;
+ if (mKeyBuffer['D']) {
+ mCamera->mPosition += mCamera->mBase.u*real(5.0); mNeedRender = true;
}
- if (app.mKeyBuffer['R']) {
- app.mCamera->mPosition += app.mCamera->mBase.v*real(5.0); changed = true;
+ if (mKeyBuffer['R']) {
+ mCamera->mPosition += mCamera->mBase.v*real(5.0); mNeedRender = true;
}
- if (app.mKeyBuffer['F']) {
- app.mCamera->mPosition -= app.mCamera->mBase.v*real(5.0); changed = true;
+ if (mKeyBuffer['F']) {
+ mCamera->mPosition -= mCamera->mBase.v*real(5.0); mNeedRender = true;
}
//projection
- if (app.mKeyBuffer['q']) {
- app.mCamera->mDistance -= 0.1;
- changed = true;
+ if (mKeyBuffer['q']) {
+ mCamera->mDistance -= 0.1;
+ mNeedRender = true;
}
- if (app.mKeyBuffer['e']) {
- app.mCamera->mDistance += 0.1;
- changed = true;
+ if (mKeyBuffer['e']) {
+ mCamera->mDistance += 0.1;
+ mNeedRender = true;
}
//super sampling
- if (app.mKeyBuffer['g']) {
- if (app.mSampler->getSamples() > 1) {
- app.mSampler->setSamples(app.mSampler->getSamples()-1);
- changed = true;
- app.mKeyBuffer['g'] = false;
+ if (mKeyBuffer['g']) {
+ if (mSampler->getSamples() > 1) {
+ mSampler->setSamples(mSampler->getSamples()-1);
+ mNeedRender = true;
+ mKeyBuffer['g'] = false;
}
}
- if (app.mKeyBuffer['h']) {
- if (app.mSampler->getSamples() < 5) {
- app.mSampler->setSamples(app.mSampler->getSamples()+1);
- changed = true;
- app.mKeyBuffer['h'] = false;
+ if (mKeyBuffer['h']) {
+ if (mSampler->getSamples() < 5) {
+ mSampler->setSamples(mSampler->getSamples()+1);
+ mNeedRender = true;
+ mKeyBuffer['h'] = false;
}
}
//DoF
- if (app.mKeyBuffer['p']) {
- app.mCamera->mUseDoF = !app.mCamera->mUseDoF;
- app.mKeyBuffer['p'] = false;
- changed = true;
- }
- if (app.mKeyBuffer['[']) {
- app.mCamera->mDofDistance -= 0.05;
- changed = true;
- }
- if (app.mKeyBuffer[']']) {
- app.mCamera->mDofDistance += 0.05;
- changed = true;
- }
- if (app.mKeyBuffer['-']) {
- if (app.mCamera->mDofAperture > real(0)) {
- app.mCamera->mDofAperture -= 0.01;
- changed = true;
+ if (mKeyBuffer['p']) {
+ mCamera->mUseDoF = !mCamera->mUseDoF;
+ mKeyBuffer['p'] = false;
+ mNeedRender = true;
+ }
+ if (mKeyBuffer['[']) {
+ mCamera->mDofDistance -= 0.05;
+ mNeedRender = true;
+ }
+ if (mKeyBuffer[']']) {
+ mCamera->mDofDistance += 0.05;
+ mNeedRender = true;
+ }
+ if (mKeyBuffer['-']) {
+ if (mCamera->mDofAperture > real(0)) {
+ mCamera->mDofAperture -= 0.01;
+ mNeedRender = true;
}
}
- if (app.mKeyBuffer['=']) {
- app.mCamera->mDofAperture += 0.01;
- changed = true;
+ if (mKeyBuffer['=']) {
+ mCamera->mDofAperture += 0.01;
+ mNeedRender = true;
usleep(50000);
}
- if (app.mKeyBuffer['b']) {
- app.mSampler->setPostProcess(!app.mSampler->getPostProcess());
- changed = true;
- app.mKeyBuffer['b'] = false;
+ if (mKeyBuffer['b']) {
+ mSampler->setPostProcess(!mSampler->getPostProcess());
+ mNeedRender = true;
+ mKeyBuffer['b'] = false;
}
- if (app.mKeyBuffer['n']) {
- if (app.mPixelation > 0) {
- app.mPixelation--;
- changed = true;
- app.mKeyBuffer['n'] = false;
+ if (mKeyBuffer['n']) {
+ if (mPixelation > 0) {
+ mPixelation--;
+ mNeedRender = true;
+ mKeyBuffer['n'] = false;
}
}
- if (app.mKeyBuffer['m']) {
- if (app.mPixelation < 4) {
- app.mPixelation++;
- changed = true;
- app.mKeyBuffer['m'] = false;
+ if (mKeyBuffer['m']) {
+ if (mPixelation < 4) {
+ mPixelation++;
+ mNeedRender = true;
+ mKeyBuffer['m'] = false;
}
}
- if (app.mKeyBuffer['t'] || app.mKeyBuffer['T']) {
+ if (mKeyBuffer['t'] || mKeyBuffer['T']) {
SKEL = new skel();
- const int factor = 1 << app.mPixelation;
- if (app.mKeyBuffer['t']) {
+ const int factor = 1 << mPixelation;
+ if (mKeyBuffer['t']) {
//for (int i = 0; i < 512; i++) {
- Ray ray(app.mGeometry);
+ Ray ray(mGeometry);
rgba col;
- app.mCamera->getRay(app.mPosX/factor, app.mPosY/factor, &ray);
- app.mGeometry->Trace(ray, &col);
+ mCamera->getRay(mPosX/factor, mPosY/factor, &ray);
+ mGeometry->Trace(ray, &col);
//}
- } else if (app.mKeyBuffer['T']) {
- app.Render();
+ } else if (mKeyBuffer['T']) {
+ Render();
}
SKEL->save("trace.skel");
printf("Trace saved (%d lines)\n", SKEL->getLineCount());
delete SKEL;
SKEL = NULL;
- app.mCamera->SaveSkel();
- app.mKeyBuffer['t'] = false;
- app.mKeyBuffer['T'] = false;
+ mCamera->SaveSkel();
+ mKeyBuffer['t'] = false;
+ mKeyBuffer['T'] = false;
}
- if (app.mKeyBuffer['.']) {
+ if (mKeyBuffer['.']) {
if (NR_BOUNCES<20) {
NR_BOUNCES ++;
- changed = true;
- app.mKeyBuffer['.'] = false;
+ mNeedRender = true;
+ mKeyBuffer['.'] = false;
}
}
- if (app.mKeyBuffer[',']) {
+ if (mKeyBuffer[',']) {
if (NR_BOUNCES>1) {
NR_BOUNCES --;
- changed = true;
- app.mKeyBuffer[','] = false;
+ mNeedRender = true;
+ mKeyBuffer[','] = false;
}
}
- if (app.mKeyBuffer['u']) {
- if(app.mSampler->getReportProgress()) {
- app.mSampler->setReportProgress(false);
- } else {
- app.mSampler->setReportProgress(true);
- }
-
- //changed = true;
- app.mKeyBuffer['u'] = false;
+ if (mKeyBuffer['u']) {
+ mSampler->setReportProgress(!mSampler->getReportProgress());
+ mKeyBuffer['u'] = false;
}
- if (changed) {
- app.Update();
+ if (mNeedRender) {
+ Update();
+ mNeedRender = false;
} else {
usleep(50000);
}
View
44 src/Test/main.cpp
@@ -36,7 +36,6 @@
#include "modAffineUV.h"
#include "shCheckered.h"
-#include "shWavelet.h"
#include "shPerlin.h"
#include "shPerlinImproved.h"
#include "shMarble.h"
@@ -44,6 +43,7 @@
#include "shHdrImage.h"
#include "shMirror.h"
#include "shGlass.h"
+#include "shRaster.h"
#include "shAbs.h"
#include "shAdd.h"
@@ -166,14 +166,17 @@ int main(int argc, char** args) {
signal(SIGTERM, onAbort);
signal(SIGINT, onAbort);
+ shRaster* face = new shRaster("face.png");
+
sceneBruteForce* a = new sceneBruteForce(
// new envConst(1.0)
- // new envCubic(new shConst(1.0, 0.0, 0.0), new shConst(0.0, 1.0, 0.0), new shConst(0.0, 0.0, 1.0), new shConst(1.0, 1.0, 0.0), new shConst(1.0, 0.0, 1.0), new shConst(0.0, 1.0, 1.0))
- new envSphericLanLon(new shHdrImage("/media/Transcend/Resources/environments/equirectangular/OpenfootageNET_Beach_CavalinoItalyHigh.hdr"))
+ // new envCubic( new shConst(1.0, 0.0, 0.0), new shConst(0.0, 1.0, 0.0), new shConst(0.0, 0.0, 1.0), new shConst(1.0, 1.0, 0.0), new shConst(1.0, 0.0, 1.0), new shConst(0.0, 1.0, 1.0))
+ new envCubic(face, face, face, face, face, face)
+ // new envSphericLanLon(new shHdrImage("/media/Transcend/Resources/environments/equirectangular/OpenfootageNET_Beach_CavalinoItalyHigh.hdr"))
);
- const float scale = 7.0;
+ const float scale = 14.0;
const float radius = 3.0;
const vec3 centers[27] = {
{0.0*scale, 0.0*scale, 0.0*scale},
@@ -207,7 +210,7 @@ int main(int argc, char** args) {
int pos = 0;
- /*a->Add(new prSphere(centers[pos++], radius, new shMirror(new shConst(0.8))));
+ a->Add(new prSphere(centers[pos++], radius, new shMirror(new shConst(0.8))));
a->Add(new prSphere(centers[pos++], radius, new shReflect(new shConst(0.8))));
a->Add(new prSphere(centers[pos++], radius, new shTrace(new shNormal())));
a->Add(new prSphere(centers[pos++], radius, new shCheckered(1.0, 0.05)));
@@ -218,22 +221,21 @@ int main(int argc, char** args) {
a->Add(new prSphere(centers[pos++], radius, new shRefract(new shConst(0.8), new shConst(1.33))));
a->Add(new prSphere(centers[pos++], radius, new shPerlinImproved()));
a->Add(new prSphere(centers[pos++], radius, new shPerlin()));
- //a->Add(new prSphere(centers[pos++], radius, new shWavelet()));
a->Add(new prSphere(centers[pos++], radius, new shAbs(new shNormal())));
a->Add(new prSphere(centers[pos++], radius, new shTurbulence(new shCheckered(0.1, 0.1), 10, 1, 0.5)));
a->Add(new prSphere(centers[pos++], radius, new shWood(new shPerlinImproved(), 0, 15, 2)));
a->Add(new prSphere(centers[pos++], radius, new shMarble(new shPerlinImproved(), 0, 4, 3)));
- //a->Add(new prSphere(centers[pos++], radius, new shBlend(new shConst(1.0), new shReflect(new shConst(0.8)), new shPerlinImproved())));
+ a->Add(new prSphere(centers[pos++], radius, new shBlend(new shConst(1.0), new shReflect(new shConst(0.8)), new shPerlinImproved())));
a->Add(new prSphere(centers[pos++], radius, new shGlass(new shConst(0.8), new shAdd(new shAbs(new shPerlin()), new shConst(1.0)))));
- //a->Add(new prSphere(centers[pos++], radius, new modGlossy(new shMirror(new shConst(0.8)), new shConst(0.05))));*/
- //a->Add(new prSphere(centers[pos++], radius, new shGlass(new shConst(0.8, 0.8, 0.8), new shBlend(new shConst(1.3), new shConst(1.7), new shAbs(new shPerlinImproved())))));
- //a->Add(new prSphere(centers[pos++], radius, new shGlass(new shConst(0.85, 0.85, 0.85), new shAdd(new shAbs(new shPerlin()), new shConst(1.0)))));
- //a->Add(new prSphere(centers[pos++], radius, new shMirror(new shBlend(new shConst(0.8), new shConst(0.4), new shCheckered(1.0, 1.0)))));
+ a->Add(new prSphere(centers[pos++], radius, new modGlossy(new shMirror(new shConst(0.8)), new shConst(0.05))));
+ a->Add(new prSphere(centers[pos++], radius, new shGlass(new shConst(0.8, 0.8, 0.8), new shBlend(new shConst(1.3), new shConst(1.7), new shAbs(new shPerlinImproved())))));
+ a->Add(new prSphere(centers[pos++], radius, new shGlass(new shConst(0.85, 0.85, 0.85), new shAdd(new shAbs(new shPerlin()), new shConst(1.0)))));
+ a->Add(new prSphere(centers[pos++], radius, new shMirror(new shBlend(new shConst(0.8), new shConst(0.4), new shCheckered(1.0, 1.0)))));
- shBase* glass = new shGlass(new shConst(1.0, 1.0, 1.0), new shConst(1.7));
+ //shBase* glass = new shGlass(new shConst(1.0, 1.0, 1.0), new shConst(1.7));
- for(int i=0; i<27; i++)
- a->Add(new prSphere(centers[pos++], radius, glass, glass));
+ //for(int i=0; i<27; i++)
+ // a->Add(new prSphere(centers[pos++], radius, glass, glass));
//a->Add(new prSphere(centers[pos++], radius, new shReflect(new shConst(0.05))));
@@ -247,19 +249,13 @@ int main(int argc, char** args) {
//addBox(a, vec3(-2.0, -2.0, -2.0), vec3(2.0, 2.0, 2.0), sh1, sh1);
//addBox(a, vec3(-1.8, -1.8, -1.8), vec3(1.8, 1.8, 1.8), sh2, sh2);
-
-
//shBase* shColorChecks = new shBlend(new shConst(0.8, 1.0, 0.0), new shConst(0.5, 0.0, 0.5), new shCheckered(1.0, 1.0));
- shBase* shColorChecks = new shCheckered(1.0, 1.0);
- shBase* shMirrorColorChecks = new shMirror(shColorChecks);
- shBase* shGlossyMirrorColorChecks = new modGlossy(shMirrorColorChecks, new shConst(0.1));
-
-
-
+ //shBase* shColorChecks = new shCheckered(1.0, 1.0);
+ //shBase* shMirrorColorChecks = new shMirror(shColorChecks);
+ //shBase* shGlossyMirrorColorChecks = new modGlossy(shMirrorColorChecks, new shConst(0.1));
- //tshConst2< tshConst<CONST_D, CONST_D, CONST_D> > shader_;
- //shBase* shFloor = new shGlass(new shConst(0.8), new shConst(1.33), new shConst(0.0), new shConst(100));
+ //shBase* shFloor = new shGlass(new shConst(1.0), new shConst(1.33), new shConst(0.0), new shConst(50));
//shBase* shFloor = new shAbs(new shNormal());
//shBase* shFloor = new shCheckered(.1, .1);
View
2  src/defines.h
@@ -50,7 +50,7 @@ extern class skel* SKEL;
typedef Fixed<int32_t, int64_t, 20> real;
#else
#include "floating.h"
- typedef Floating<double> real;
+ typedef Floating<float> real;
#endif
typedef float channel;
View
29 trace.skel
@@ -1,22 +1,13 @@
SKEL
-10 8
+5 4
-2.97687 -0.00564 -0.37178
-0.00000 0.00000 2.03917
-0.00000 -103948164297392128.00000 2.03917
-0.00000 103948164297392128.00000 2.03917
--1.75664 1.89374 1.52576
-3.07610 -0.00583 -0.38417
-2.87764 -0.00545 -0.35939
--10.00000 4.00000 4.00000
--1.69809 1.83062 1.47490
--1.81520 1.95687 1.57661
+25.76633 -0.22638 29.98983
+25.69900 -0.26572 29.92722
+38.52958 9.35158 49.84993
+25.84078 -0.21884 29.92350
+25.69187 -0.23393 30.05615
-2 0 1 0.022 0.042 0.080 0.300
-2 2 3 0.000 1039481591434313728.000 0.000 1.000
-2 4 0 0.022 0.042 0.080 0.300
-2 5 6 0.992 0.002 0.124 1.000
-2 4 0 0.006 0.005 0.003 0.300
-2 5 6 0.992 0.002 0.124 1.000
-2 7 4 0.017 0.033 0.062 0.300
-2 8 9 0.586 0.631 0.509 1.000
+2 0 1 1.000 1.000 0.000 0.300
+2 1 1 0.000 0.000 0.000 1.000
+2 2 0 0.908 0.908 0.000 0.300
+2 3 4 0.745 0.075 0.663 1.000
Please sign in to comment.
Something went wrong with that request. Please try again.