├── .gitignore
├── OppositeRenderer
├── Client
│ ├── Client.vcxproj
│ ├── Client.vcxproj.filters
│ ├── Client.vcxproj.user
│ ├── DistributedApplication.cpp
│ ├── DistributedApplication.hxx
│ ├── client.cpp
│ ├── client
│ │ ├── RenderResultPacketReceiver.cpp
│ │ ├── RenderResultPacketReceiver.hxx
│ │ ├── RenderServerConnection.cpp
│ │ ├── RenderServerConnection.hxx
│ │ ├── RenderServerConnections.cpp
│ │ ├── RenderServerConnections.hxx
│ │ ├── RenderServerState.cpp
│ │ ├── RenderServerState.h
│ │ └── commands
│ │ │ ├── GetServerDetailsCommand.cpp
│ │ │ ├── GetServerDetailsCommand.h
│ │ │ ├── ServerCommand.cpp
│ │ │ ├── ServerCommand.h
│ │ │ ├── ServerCommandResult.cpp
│ │ │ └── ServerCommandResult.h
│ ├── gui
│ │ ├── ClientMainWindow.cpp
│ │ ├── ClientMainWindow.hxx
│ │ ├── dialogs
│ │ │ ├── AddNewServerConnectionDialog.cpp
│ │ │ ├── AddNewServerConnectionDialog.hxx
│ │ │ └── ui
│ │ │ │ └── AddNewServerConnectionDialog.ui
│ │ └── docks
│ │ │ ├── ConnectedServersDock.cpp
│ │ │ ├── ConnectedServersDock.hxx
│ │ │ ├── RenderServersSummaryDock.cpp
│ │ │ ├── RenderServersSummaryDock.hxx
│ │ │ └── ui
│ │ │ ├── ConnectedServersDock.ui
│ │ │ └── RenderServersSummaryDock.ui
│ └── gui_models
│ │ ├── ConnectedServersTableModel.cpp
│ │ └── ConnectedServersTableModel.hxx
├── Gui
│ ├── Application.cpp
│ ├── Application.hxx
│ ├── Gui.vcxproj
│ ├── Gui.vcxproj.filters
│ ├── Gui.vcxproj.user
│ ├── LICENSE.txt
│ ├── RendererStatus.h
│ ├── RunningStatus.h
│ ├── gui
│ │ ├── AboutWindow.cpp
│ │ ├── AboutWindow.hxx
│ │ ├── ComputeDeviceInformationWidget.cpp
│ │ ├── ComputeDeviceInformationWidget.hxx
│ │ ├── ComputeDeviceInformationWidgetTabPage.cpp
│ │ ├── ComputeDeviceInformationWidgetTabPage.hxx
│ │ ├── MainWindowBase.cpp
│ │ ├── MainWindowBase.hxx
│ │ ├── RenderWidget.cpp
│ │ ├── RenderWidget.hxx
│ │ ├── docks
│ │ │ ├── CameraDock.cpp
│ │ │ ├── CameraDock.hxx
│ │ │ ├── OutputDock.cpp
│ │ │ ├── OutputDock.hxx
│ │ │ ├── PPMDock.cpp
│ │ │ ├── PPMDock.hxx
│ │ │ ├── RenderInformationDock.cpp
│ │ │ ├── RenderInformationDock.hxx
│ │ │ ├── SceneDock.cpp
│ │ │ ├── SceneDock.hxx
│ │ │ └── ui
│ │ │ │ ├── CameraDock.ui
│ │ │ │ ├── OutputDock.ui
│ │ │ │ ├── PPMDock.ui
│ │ │ │ ├── RenderInformationDock.ui
│ │ │ │ └── SceneDock.ui
│ │ ├── main.cpp
│ │ └── ui
│ │ │ ├── AboutWindow.ui
│ │ │ ├── ComputeDeviceInformationWidget.ui
│ │ │ ├── ComputeDeviceInformationWidgetTabPage.ui
│ │ │ ├── MainWindowBase.ui
│ │ │ └── RenderTypePPMInfo.ui
│ ├── gui_export_api.h
│ ├── main.cpp
│ ├── models
│ │ ├── OutputSettingsModel.cpp
│ │ ├── OutputSettingsModel.hxx
│ │ ├── PPMSettingsModel.cpp
│ │ ├── PPMSettingsModel.hxx
│ │ ├── RenderStatisticsModel.cpp
│ │ └── RenderStatisticsModel.hxx
│ └── scene
│ │ ├── SceneFactory.cpp
│ │ ├── SceneFactory.h
│ │ ├── SceneManager.cpp
│ │ └── SceneManager.hxx
├── LICENSE.txt
├── OppositeRenderer.sln
├── OppositeRenderer.suo
├── RenderEngine
│ ├── BuildRuleQt.targets
│ ├── ComputeDevice.cpp
│ ├── ComputeDevice.h
│ ├── ComputeDeviceRepository.cpp
│ ├── ComputeDeviceRepository.h
│ ├── RenderEngine.vcxproj
│ ├── RenderEngine.vcxproj.filters
│ ├── RenderEngine.vcxproj.user
│ ├── clientserver
│ │ ├── RenderResultPacket.cpp
│ │ ├── RenderResultPacket.h
│ │ ├── RenderServerRenderRequest.cpp
│ │ ├── RenderServerRenderRequest.h
│ │ ├── RenderServerRenderRequestDetails.cpp
│ │ └── RenderServerRenderRequestDetails.h
│ ├── config.h
│ ├── geometry_instance
│ │ ├── AAB.cu
│ │ ├── AABInstance.cpp
│ │ ├── AABInstance.h
│ │ ├── GeometryInstance.cpp
│ │ ├── GeometryInstance.h
│ │ ├── Sphere.cu
│ │ ├── SphereInstance.cpp
│ │ ├── SphereInstance.h
│ │ ├── Transform.cpp
│ │ ├── Transform.h
│ │ └── TriangleMesh.cu
│ ├── main.cpp
│ ├── material
│ │ ├── Diffuse.cpp
│ │ ├── Diffuse.cu
│ │ ├── Diffuse.h
│ │ ├── DiffuseEmitter.cpp
│ │ ├── DiffuseEmitter.cu
│ │ ├── DiffuseEmitter.h
│ │ ├── Glass.cpp
│ │ ├── Glass.cu
│ │ ├── Glass.h
│ │ ├── Material.cpp
│ │ ├── Material.h
│ │ ├── Mirror.cpp
│ │ ├── Mirror.cu
│ │ ├── Mirror.h
│ │ ├── ParticipatingMedium.cpp
│ │ ├── ParticipatingMedium.cu
│ │ ├── ParticipatingMedium.h
│ │ ├── Texture.cpp
│ │ ├── Texture.cu
│ │ └── Texture.h
│ ├── math
│ │ ├── AAB.cpp
│ │ ├── AAB.h
│ │ ├── Sphere.cpp
│ │ ├── Sphere.h
│ │ ├── Vector3.cpp
│ │ └── Vector3.h
│ ├── parallelogram.cu
│ ├── render_engine_export_api.h
│ ├── renderer
│ │ ├── Camera.cpp
│ │ ├── Camera.h
│ │ ├── Hitpoint.h
│ │ ├── Light.cpp
│ │ ├── Light.h
│ │ ├── OptixEntryPoint.h
│ │ ├── OptixRenderer.cpp
│ │ ├── OptixRenderer.h
│ │ ├── OptixRenderer_CPUKdTree.cpp
│ │ ├── OptixRenderer_SpatialHash.cu
│ │ ├── RadiancePRD.h
│ │ ├── RandomState.h
│ │ ├── RayType.h
│ │ ├── RenderMethod.h
│ │ ├── ShadowPRD.h
│ │ ├── TransmissionPRD.h
│ │ ├── helpers
│ │ │ ├── camera.h
│ │ │ ├── helpers.h
│ │ │ ├── light.h
│ │ │ ├── nsight.h
│ │ │ ├── optix.h
│ │ │ ├── random.h
│ │ │ ├── samplers.h
│ │ │ └── store_photon.h
│ │ ├── ppm
│ │ │ ├── DirectRadianceEstimation.cu
│ │ │ ├── IndirectRadianceEstimation.cu
│ │ │ ├── Output.cu
│ │ │ ├── Photon.h
│ │ │ ├── PhotonGenerator.cu
│ │ │ ├── PhotonGrid.h
│ │ │ ├── PhotonPRD.h
│ │ │ ├── RayGeneratorPPM.cu
│ │ │ ├── UniformGridPhotonInitialize.cu
│ │ │ ├── VolumetricPhotonInitialize.cu
│ │ │ ├── VolumetricPhotonSphere.cu
│ │ │ ├── VolumetricPhotonSphereRadiance.cu
│ │ │ └── VolumetricRadiancePRD.h
│ │ └── pt
│ │ │ └── RayGeneratorPT.cu
│ ├── scene
│ │ ├── Cornell.cpp
│ │ ├── Cornell.h
│ │ ├── IScene.cpp
│ │ ├── IScene.h
│ │ ├── Scene.cpp
│ │ └── Scene.h
│ ├── select.h
│ └── util
│ │ ├── BenchmarkTimer.cpp
│ │ ├── BenchmarkTimer.h
│ │ ├── Image.cpp
│ │ ├── Image.h
│ │ ├── Mouse.cpp
│ │ ├── Mouse.h
│ │ ├── imageformats
│ │ └── libtga
│ │ │ ├── AUTHORS
│ │ │ ├── COPYING
│ │ │ ├── INSTALL
│ │ │ ├── NEWS
│ │ │ ├── README
│ │ │ ├── tga.c
│ │ │ ├── tga.h
│ │ │ ├── tgaconfig.h
│ │ │ ├── tgaread.c
│ │ │ └── tgawrite.c
│ │ ├── sutil.c
│ │ └── sutil.h
├── Server
│ ├── Server.vcxproj
│ ├── Server.vcxproj.filters
│ ├── Server.vcxproj.user
│ ├── ServerState.cpp
│ ├── ServerState.h
│ ├── gui
│ │ ├── ReadyForRenderingWidget.cpp
│ │ ├── ReadyForRenderingWidget.hxx
│ │ ├── ServerWindow.cpp
│ │ ├── ServerWindow.hxx
│ │ ├── SetServerSettingsWidget.cpp
│ │ ├── SetServerSettingsWidget.hxx
│ │ ├── WaitingForConnectionWidget.cpp
│ │ ├── WaitingForConnectionWidget.hxx
│ │ └── ui
│ │ │ ├── ReadyForRenderingWidget.ui
│ │ │ ├── ServerWindow.ui
│ │ │ ├── SetServerSettingsWidget.ui
│ │ │ └── WaitingForConnectionWidget.ui
│ ├── main.cpp
│ └── server
│ │ ├── RenderServer.cpp
│ │ ├── RenderServer.hxx
│ │ ├── RenderServerRenderer.cpp
│ │ ├── RenderServerRenderer.hxx
│ │ ├── RenderServerState.cpp
│ │ └── RenderServerState.h
├── Standalone
│ ├── Standalone.vcxproj
│ ├── Standalone.vcxproj.filters
│ ├── Standalone.vcxproj.user
│ ├── StandaloneApplication.cpp
│ ├── StandaloneApplication.h
│ ├── StandaloneRenderManager.cpp
│ ├── StandaloneRenderManager.hxx
│ └── standalone.cpp
└── include
│ ├── GL
│ ├── freeglut.h
│ ├── freeglut_ext.h
│ ├── freeglut_std.h
│ ├── glew.h
│ ├── glext.h
│ ├── glut.h
│ ├── glxew.h
│ ├── glxext.h
│ ├── wglew.h
│ └── wglext.h
│ ├── assimp
│ ├── Compiler
│ │ ├── poppack1.h
│ │ └── pushpack1.h
│ ├── DefaultLogger.hpp
│ ├── Exporter.hpp
│ ├── IOStream.hpp
│ ├── IOSystem.hpp
│ ├── Importer.hpp
│ ├── LogStream.hpp
│ ├── Logger.hpp
│ ├── NullLogger.hpp
│ ├── ProgressHandler.hpp
│ ├── ai_assert.h
│ ├── anim.h
│ ├── camera.h
│ ├── cexport.h
│ ├── cfileio.h
│ ├── cimport.h
│ ├── color4.h
│ ├── color4.inl
│ ├── config.h
│ ├── defs.h
│ ├── importerdesc.h
│ ├── light.h
│ ├── material.h
│ ├── material.inl
│ ├── matrix3x3.h
│ ├── matrix3x3.inl
│ ├── matrix4x4.h
│ ├── matrix4x4.inl
│ ├── mesh.h
│ ├── postprocess.h
│ ├── quaternion.h
│ ├── quaternion.inl
│ ├── scene.h
│ ├── texture.h
│ ├── types.h
│ ├── vector2.h
│ ├── vector2.inl
│ ├── vector3.h
│ ├── vector3.inl
│ └── version.h
│ ├── vld.h
│ └── vld_def.h
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | # git ignore file
2 | *.lib
3 | *.cache
4 | *.tlog
5 | *.manifest
6 | *.lastbuildstate
7 | *.pdb
8 | *.deps
9 | *.exe
10 | *.ilk
11 | *.log
12 | *.sdf
13 | *.dll
14 | *.opensdf
15 | *.rc
16 | *.res
17 | *.ipch
18 | moc_*.cpp
19 | ui_*.h
20 | *.obj
21 | *.ptx
22 | *.mtl
23 | *.idb
--------------------------------------------------------------------------------
/OppositeRenderer/Client/Client.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(OutDir)
5 | WindowsLocalDebugger
6 | true
7 |
8 |
--------------------------------------------------------------------------------
/OppositeRenderer/Client/DistributedApplication.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 |
9 | #include "Application.hxx"
10 | #include
11 | #include
12 | #include "RunningStatus.h"
13 | #include "client/RenderServerConnections.hxx"
14 | #include "clientserver/RenderServerRenderRequest.h"
15 | #include "client/RenderResultPacketReceiver.hxx"
16 | #include
17 |
18 | class QApplication;
19 | class RenderServerConnections;
20 | class QTcpSocket;
21 |
22 | class DistributedApplication : public Application
23 | {
24 | Q_OBJECT;
25 | public:
26 | DistributedApplication(QApplication & qApplication);
27 | ~DistributedApplication(void);
28 | const RenderServerConnections & getServerConnections() const;
29 | void wait();
30 | RenderServerRenderRequest getNextRenderServerRenderRequest(unsigned int numIterations);
31 | bool canIssueNewRenderRequests();
32 | unsigned int getBackBufferNumIterations();
33 | unsigned int getTotalPacketsPending() const;
34 | unsigned int getBackBufferSizeBytes();
35 | unsigned int getPeakBackBufferSizeBytes() const;
36 |
37 | public slots:
38 | void onThreadStarted();
39 | void onAboutToQuit();
40 |
41 | private slots:
42 | void onNewServerConnectionSocket(QTcpSocket*);
43 | void onSequenceNumberIncremented();
44 | void onNewFrameReadyForDisplay(const float*, unsigned long long);
45 | void onPacketReceived(unsigned long long sequenceNumber, unsigned int numIterations);
46 | private:
47 | double m_PPMRadius;
48 | RenderServerConnections m_serverConnections;
49 | unsigned long long m_nextRenderServerRenderRequestIteration;
50 | unsigned long long m_lastSequenceNumber;
51 | unsigned long long m_numPreviewedIterations;
52 | unsigned long long m_totalPacketsPending;
53 | unsigned long long m_totalPacketsPendingLimit;
54 | RenderResultPacketReceiver m_renderResultPacketReceiver;
55 | QThread* m_renderResultPacketReceiverThread;
56 | QMutex m_mutex;
57 | };
--------------------------------------------------------------------------------
/OppositeRenderer/Client/client.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include
8 | #include
9 | #include
10 | #include "gui/MainWindowBase.hxx"
11 | #include "gui/ClientMainWindow.hxx"
12 | #include
13 | #include "client/RenderServerState.h"
14 | #include "DistributedApplication.hxx"
15 | //#include
16 |
17 | int main( int argc, char** argv )
18 | {
19 | qRegisterMetaType("RenderServerState::E");
20 | qRegisterMetaType("QAbstractSocket::SocketError");
21 | QApplication qApplication(argc, argv);
22 | qApplication.setOrganizationName("Opposite Renderer");
23 | qApplication.setApplicationName("Opposite Renderer");
24 |
25 | DistributedApplication application = DistributedApplication(qApplication);
26 | ClientMainWindow mainWindow(application);
27 |
28 | QThread* m_thread = new QThread(&qApplication);
29 | application.moveToThread(m_thread);
30 | m_thread->start();
31 |
32 | mainWindow.show();
33 | int returnCode = qApplication.exec();
34 |
35 | QMetaObject::invokeMethod(&application, "onAboutToQuit", Qt::QueuedConnection);
36 | application.wait();
37 |
38 | return returnCode;
39 | }
40 |
--------------------------------------------------------------------------------
/OppositeRenderer/Client/client/RenderResultPacketReceiver.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include
9 | #include
10 | #include
11 |
12 | /*
13 | This class will receive signals from RenderServerConnections each time the render server has produced a render (given as a
14 | RenderResultPacket.
15 | This class will do the necessary average/merging of the different subcomputations into the final render, and emits a signal
16 | each time a new frame is ready to be displayed.
17 | */
18 |
19 | class RenderResultPacket;
20 | class DistributedApplication;
21 |
22 | class RenderResultPacketReceiver : public QObject
23 | {
24 | Q_OBJECT;
25 | public:
26 | RenderResultPacketReceiver(const DistributedApplication & renderManager);
27 | ~RenderResultPacketReceiver(void);
28 | unsigned long long getIterationNumber() const;
29 | bool backBufferIsNotFilled();
30 | unsigned int getBackBufferNumIterations();
31 | unsigned int getBackBufferSizeBytes();
32 | unsigned int getPeakBackBufferSizeBytes() const;
33 |
34 | signals:
35 | void newFrameReadyForDisplay(const float*, unsigned long long);
36 | void packetReceived(unsigned long long sequenceNumber, unsigned int numIterations);
37 |
38 | public slots:
39 | void onThreadStarted();
40 | void onRenderResultPacketReceived(RenderResultPacket*);
41 |
42 | private:
43 | const DistributedApplication & m_application;
44 | unsigned long long m_iterationNumber;
45 | unsigned long long m_lastSequenceNumber;
46 | unsigned long long m_PPMNextExpectedIteration;
47 | unsigned int m_peakBackBufferSizeBytes;
48 | float* m_frontBuffer;
49 | void resetInternals();
50 | //float* m_backBuffer;
51 | //float* m_indirectPowerPerAreaBackBuffer;
52 | //QVector m_backBufferIterationNumbers;
53 | QMutex m_backBufferMutex;
54 | QVector m_backBuffer;
55 |
56 | void mergeRenderResultPathTracing(const RenderResultPacket* result );
57 | void mergeRenderResultPacketPhotonMapping(const RenderResultPacket* result );
58 | void mergeBufferRunningAverage( const float* inputBuffer, unsigned int inputBufferNumIterations, float* outputBuffer,
59 | unsigned int outputBufferNumIterations, unsigned int numPixels );
60 | bool iterationNumbersAreSequential(const QVector iterationsInPacketSorted);
61 | };
62 |
63 |
--------------------------------------------------------------------------------
/OppositeRenderer/Client/client/RenderServerConnections.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include
9 | #include
10 |
11 | class RenderServerConnection;
12 | class QThread;
13 |
14 | class RenderServerConnections : public QObject
15 | {
16 | Q_OBJECT;
17 | public:
18 | RenderServerConnections();
19 | ~RenderServerConnections();
20 | // Push back and pass ownership of the connection object
21 | void push_back(RenderServerConnection* connection);
22 | const RenderServerConnection & at(int index) const;
23 | RenderServerConnection & at(int index);
24 | int numServers() const;
25 | int numRenderingServers() const;
26 |
27 | signals:
28 | void serverConnectionAdded();
29 | void serversStateUpdated();
30 | private:
31 | std::vector m_serverConnections;
32 | std::vector m_serverConnectionThreads;
33 | RenderServerConnections(const RenderServerConnections &);
34 | RenderServerConnections & operator=(const RenderServerConnections &);
35 | };
36 |
--------------------------------------------------------------------------------
/OppositeRenderer/Client/client/RenderServerState.cpp:
--------------------------------------------------------------------------------
1 | #include "RenderServerState.h"
2 |
3 | const char* renderServerStateEnumToString(RenderServerState::E state)
4 | {
5 | switch(state)
6 | {
7 | case RenderServerState::NO_DEVICE_INFORMATION: return "No compute device information";
8 | case RenderServerState::WAITING_FOR_DEVICE_INFORMATION: return "Waiting for device information";
9 | case RenderServerState::RENDERING: return "OK/Ready";
10 | case RenderServerState::SENDING_RENDER_COMMAND: return "Sending render frame command to server";
11 | case RenderServerState::DISCONNECTED: return "Disconnected from server";
12 | case RenderServerState::ERROR_SOCKET: return "Error: Socket error";
13 | case RenderServerState::ERROR_UNKNOWN: return "Unknown error";
14 | case RenderServerState::ERROR_INVALID_CONFIRMATION: return "Error: Not valid confirmation from server on command";
15 | case RenderServerState::ERROR_COMMAND_TIMEOUT: return "Error: A command to server timed out / got no response";
16 | }
17 | return "(Unknown state)";
18 | }
19 |
--------------------------------------------------------------------------------
/OppositeRenderer/Client/client/RenderServerState.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 |
9 | /*
10 | Note that there are two RenderServerState enums, one for Server and one for Client
11 | */
12 |
13 | namespace RenderServerState
14 | {
15 | enum E
16 | {
17 | NO_DEVICE_INFORMATION,
18 | WAITING_FOR_DEVICE_INFORMATION,
19 | RENDERING,
20 | SENDING_RENDER_COMMAND,
21 | DISCONNECTED,
22 | ERROR_SOCKET,
23 | ERROR_INVALID_CONFIRMATION,
24 | ERROR_COMMAND_TIMEOUT,
25 | ERROR_UNKNOWN
26 | };
27 | }
28 |
29 | const char* renderServerStateEnumToString(RenderServerState::E state);
--------------------------------------------------------------------------------
/OppositeRenderer/Client/client/commands/GetServerDetailsCommand.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "GetServerDetailsCommand.h"
8 | #include "client/RenderServerConnection.hxx"
9 | #include
10 |
11 | GetServerDetailsCommand::GetServerDetailsCommand()
12 | {
13 |
14 | }
15 |
16 | GetServerDetailsCommand::~GetServerDetailsCommand(void)
17 | {
18 |
19 | }
20 |
21 | void GetServerDetailsCommand::executeCommand( QTcpSocket & socket )
22 | {
23 | char command[256];
24 | sprintf(command, "GET SERVER DETAILS\n");
25 | QByteArray a(command);
26 | socket.write(a);
27 | }
28 |
29 | ServerCommandResult GetServerDetailsCommand::onResponseReady(RenderServerConnection & connection, QTcpSocket & socket )
30 | {
31 | QDataStream stream(&socket);
32 | QString computeDeviceName;
33 | stream >> computeDeviceName;
34 |
35 | if(stream.status() != QDataStream::Ok)
36 | {
37 | printf("In GetServerDetailsCommand::onResponseReady, stream.status() != QDataStream::Ok\n");
38 | }
39 |
40 | if(computeDeviceName.length() < 4 || computeDeviceName.length() > 255)
41 | {
42 | return ServerCommandResult(false, RenderServerState::ERROR_INVALID_CONFIRMATION);
43 | }
44 |
45 | connection.setComputeDeviceName(computeDeviceName);
46 |
47 | return ServerCommandResult(true, RenderServerState::RENDERING);
48 | }
49 |
50 | RenderServerState::E GetServerDetailsCommand::getInitialRenderServerState() const
51 | {
52 | return RenderServerState::WAITING_FOR_DEVICE_INFORMATION;
53 | }
54 |
--------------------------------------------------------------------------------
/OppositeRenderer/Client/client/commands/GetServerDetailsCommand.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "ServerCommand.h"
9 |
10 | class GetServerDetailsCommand : public ServerCommand
11 | {
12 | public:
13 | GetServerDetailsCommand();
14 | virtual ~GetServerDetailsCommand(void);
15 | virtual void executeCommand( QTcpSocket & socket);
16 | virtual ServerCommandResult onResponseReady(RenderServerConnection & , QTcpSocket & socket);
17 | virtual RenderServerState::E getInitialRenderServerState() const;
18 | };
19 |
20 |
--------------------------------------------------------------------------------
/OppositeRenderer/Client/client/commands/ServerCommand.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "ServerCommand.h"
8 |
9 | ServerCommand::ServerCommand(void)
10 | {
11 | }
12 |
13 | ServerCommand::~ServerCommand(void)
14 | {
15 | }
--------------------------------------------------------------------------------
/OppositeRenderer/Client/client/commands/ServerCommand.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "ServerCommandResult.h"
9 | #include "client/RenderServerState.h"
10 |
11 | class QTcpSocket;
12 | class RenderServerConnection;
13 | class ServerCommand
14 | {
15 | public:
16 | ServerCommand(void);
17 | virtual ~ServerCommand(void) = 0;
18 | /*
19 | Execute a command and immediately return. Call onResponseReady() to wait for result.
20 | */
21 | virtual void executeCommand(QTcpSocket & m_socket) = 0;
22 | virtual ServerCommandResult onResponseReady(RenderServerConnection & connection, QTcpSocket & socket) = 0;
23 | virtual RenderServerState::E getInitialRenderServerState() const = 0;
24 | };
--------------------------------------------------------------------------------
/OppositeRenderer/Client/client/commands/ServerCommandResult.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "ServerCommandResult.h"
8 |
9 | ServerCommandResult::ServerCommandResult(void)
10 | : m_success(false),
11 | m_newRenderServerState(RenderServerState::ERROR_UNKNOWN)
12 | {
13 | }
14 |
15 | ServerCommandResult::ServerCommandResult(bool success, RenderServerState::E state)
16 | : m_success(success), m_newRenderServerState(state)
17 | {
18 |
19 | }
20 |
21 | ServerCommandResult::~ServerCommandResult(void)
22 | {
23 | }
24 |
25 | RenderServerState::E ServerCommandResult::getNewRenderServerState() const
26 | {
27 | return m_newRenderServerState;
28 | }
29 |
30 | void ServerCommandResult::setNewRenderServerState( RenderServerState::E val )
31 | {
32 | m_newRenderServerState = val;
33 | }
34 |
35 | bool ServerCommandResult::getSuccess() const
36 | {
37 | return m_success;
38 | }
39 |
40 | void ServerCommandResult::setSuccess( bool val )
41 | {
42 | m_success = val;
43 | }
44 |
--------------------------------------------------------------------------------
/OppositeRenderer/Client/client/commands/ServerCommandResult.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "client/RenderServerState.h"
9 |
10 | class ServerCommandResult
11 | {
12 | public:
13 | ServerCommandResult(void);
14 | ServerCommandResult(bool success, RenderServerState::E state = RenderServerState::ERROR_UNKNOWN);
15 | ~ServerCommandResult(void);
16 | RenderServerState::E getNewRenderServerState() const;
17 | void setNewRenderServerState(RenderServerState::E val);
18 | bool getSuccess() const;
19 | void setSuccess(bool val);
20 |
21 | private:
22 | bool m_success;
23 | RenderServerState::E m_newRenderServerState;
24 | };
25 |
26 |
--------------------------------------------------------------------------------
/OppositeRenderer/Client/gui/ClientMainWindow.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "ClientMainWindow.hxx"
8 | #include "DistributedApplication.hxx"
9 | #include
10 | #include "dialogs/AddNewServerConnectionDialog.hxx"
11 | #include "docks/ConnectedServersDock.hxx"
12 | #include "docks/RenderServersSummaryDock.hxx"
13 |
14 | ClientMainWindow::ClientMainWindow(DistributedApplication & application)
15 | : m_application(application),
16 | m_mainWindowBase(MainWindowBase(application))
17 | {
18 | QAction* aa = new QAction(this);
19 | aa->setObjectName(QString::fromUtf8("aa"));
20 | aa->setText("About Server Manager");
21 |
22 | // Add new render server action
23 |
24 | QAction* actionConnectToNewRenderServer = new QAction(this);
25 | actionConnectToNewRenderServer->setObjectName(QString::fromUtf8("aa"));
26 | actionConnectToNewRenderServer->setText("Add new render server");
27 | m_mainWindowBase.menuFile->insertAction(m_mainWindowBase.actionOpen_scene, actionConnectToNewRenderServer);
28 | m_mainWindowBase.setWindowTitle("Opposite Renderer");
29 | connect(actionConnectToNewRenderServer, SIGNAL(triggered()), this, SLOT(onActionConnectToNewRenderServer()));
30 |
31 | // Add connected servers dock
32 |
33 | ConnectedServersDock* dock = new ConnectedServersDock(&m_mainWindowBase, application.getServerConnections());
34 | m_mainWindowBase.addDockWidget(Qt::BottomDockWidgetArea, dock);
35 |
36 | // Add render server summary dock
37 |
38 | RenderServersSummaryDock* dock2 = new RenderServersSummaryDock(&m_mainWindowBase, application);
39 | m_mainWindowBase.addDockWidget(Qt::RightDockWidgetArea, dock2);
40 | connect(dock2, SIGNAL(actionConnectToNewRenderServer()), actionConnectToNewRenderServer, SIGNAL(triggered()));
41 |
42 | connect(this, SIGNAL(hasNewServerConnectionSocket(QTcpSocket*)),
43 | &m_application, SLOT(onNewServerConnectionSocket(QTcpSocket*)));
44 |
45 | onActionConnectToNewRenderServer();
46 | }
47 |
48 | void ClientMainWindow::show()
49 | {
50 | return m_mainWindowBase.showMaximized();
51 | }
52 |
53 | void ClientMainWindow::onActionConnectToNewRenderServer()
54 | {
55 | AddNewServerConnectionDialog* dialog = new AddNewServerConnectionDialog(&m_mainWindowBase, m_application.thread());
56 | connect(dialog, SIGNAL(hasNewServerConnectionSocket(QTcpSocket*)),
57 | this, SLOT(onNewServerConnectionSocket(QTcpSocket*)), Qt::DirectConnection);
58 | dialog->open();
59 | }
60 |
61 | void ClientMainWindow::onNewServerConnectionSocket(QTcpSocket* socket)
62 | {
63 | // Pass ownership of socket to the recipient
64 | socket->moveToThread(m_application.thread());
65 | emit hasNewServerConnectionSocket(socket);
66 | }
--------------------------------------------------------------------------------
/OppositeRenderer/Client/gui/ClientMainWindow.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "gui/MainWindowBase.hxx"
9 | #include
10 | #include "client/RenderServerConnection.hxx"
11 |
12 | class DistributedApplication;
13 |
14 | class ClientMainWindow : public QObject
15 | {
16 | Q_OBJECT;
17 |
18 | public:
19 | ClientMainWindow(DistributedApplication & application);
20 | void show();
21 |
22 | signals:
23 | void hasNewServerConnectionSocket(QTcpSocket*);
24 |
25 | private slots:
26 | void onActionConnectToNewRenderServer();
27 | void onNewServerConnectionSocket(QTcpSocket*);
28 |
29 | private:
30 | MainWindowBase m_mainWindowBase;
31 | DistributedApplication & m_application;
32 | };
--------------------------------------------------------------------------------
/OppositeRenderer/Client/gui/dialogs/AddNewServerConnectionDialog.hxx:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include "client/RenderServerConnection.hxx"
7 |
8 | namespace Ui
9 | {
10 | class AddNewServerConnectionDialog;
11 | }
12 |
13 | class QTimer;
14 |
15 | class AddNewServerConnectionDialog : public QDialog
16 | {
17 | Q_OBJECT
18 |
19 | public:
20 | explicit AddNewServerConnectionDialog(QWidget *parent, QThread* tcpSocketThread);
21 | ~AddNewServerConnectionDialog();
22 |
23 | signals:
24 | void hasNewServerConnectionSocket(QTcpSocket*);
25 |
26 | private slots:
27 | void onFormSubmit();
28 | void onHostConnectionError();
29 | void onConnectedToHost();
30 | void onHostDataAvailable();
31 | void onWaitForGreetingError();
32 |
33 | private:
34 | void showFormInitialState();
35 | void setError(const QString&);
36 | void socketDisconnectAndWait();
37 | Ui::AddNewServerConnectionDialog *ui;
38 | QTcpSocket* m_socket;
39 | QTimer* m_timerWaitForGreeting;
40 | };
--------------------------------------------------------------------------------
/OppositeRenderer/Client/gui/docks/ConnectedServersDock.cpp:
--------------------------------------------------------------------------------
1 | #include "ConnectedServersDock.hxx"
2 | #include "ui/ui_ConnectedServersDock.h"
3 |
4 | ConnectedServersDock::ConnectedServersDock(QWidget *parent, const RenderServerConnections & serverConnections) :
5 | QDockWidget(parent),
6 | m_model(ConnectedServersTableModel(this, serverConnections)),
7 | ui(new Ui::ConnectedServersDock)
8 | {
9 | ui->setupUi(this);
10 | this->setAllowedAreas(Qt::BottomDockWidgetArea);
11 | this->setMinimumSize(QSize(0,180));
12 | this->setFixedHeight(180);
13 | ui->tableView->setModel(&m_model);
14 |
15 | ui->tableView->horizontalHeader()->show();
16 | ui->tableView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
17 | ui->tableView->verticalHeader()->setDefaultSectionSize(100);
18 |
19 | ui->tableView->verticalHeader()->hide();
20 | ui->tableView->verticalHeader()->setStyleSheet("background:black;color:white;");
21 | ui->tableView->verticalHeader()->setDefaultSectionSize(20); // height of a row
22 | }
23 |
24 | ConnectedServersDock::~ConnectedServersDock()
25 | {
26 | delete ui;
27 | }
28 |
--------------------------------------------------------------------------------
/OppositeRenderer/Client/gui/docks/ConnectedServersDock.hxx:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include "gui_models/ConnectedServersTableModel.hxx"
4 |
5 | namespace Ui
6 | {
7 | class ConnectedServersDock;
8 | }
9 |
10 | class RenderServerConnections;
11 |
12 | class ConnectedServersDock : public QDockWidget
13 | {
14 | Q_OBJECT
15 |
16 | public:
17 | explicit ConnectedServersDock(QWidget *parent, const RenderServerConnections & serverConnections );
18 | ~ConnectedServersDock();
19 |
20 | private:
21 | Ui::ConnectedServersDock *ui;
22 | ConnectedServersTableModel m_model;
23 | };
--------------------------------------------------------------------------------
/OppositeRenderer/Client/gui/docks/RenderServersSummaryDock.cpp:
--------------------------------------------------------------------------------
1 | #include "RenderServersSummaryDock.hxx"
2 | #include "ui/ui_RenderServersSummaryDock.h"
3 | #include "client/RenderServerConnections.hxx"
4 | #include "DistributedApplication.hxx"
5 |
6 | RenderServersSummaryDock::RenderServersSummaryDock(QWidget *parent, DistributedApplication & application) :
7 | QDockWidget(parent),
8 | ui(new Ui::RenderServersSummaryDock),
9 | m_application(application)
10 | {
11 | ui->setupUi(this);
12 | connect(&m_application.getServerConnections(), SIGNAL(serversStateUpdated()), this, SLOT(onServersInfoUpdated()));
13 | connect(ui->pushButtonNewServerConnection, SIGNAL(clicked()), this, SIGNAL(actionConnectToNewRenderServer()));
14 | }
15 |
16 | RenderServersSummaryDock::~RenderServersSummaryDock()
17 | {
18 | delete ui;
19 | }
20 |
21 | void RenderServersSummaryDock::onServersInfoUpdated()
22 | {
23 | ui->previewedIterationsLabel->setText(QString::number(m_application.getRenderStatisticsModel().getNumPreviewedIterations()));
24 | ui->packetsPendingLabel->setText(QString::number(m_application.getTotalPacketsPending()));
25 | ui->numIterationsInBufferLabel->setText(QString::number(m_application.getBackBufferNumIterations()));
26 | ui->backBufferSizeLabel->setText(QString("%1 MB (peak %2 MB)")
27 | .arg(float(m_application.getBackBufferSizeBytes())/1024/1024, 0, 'f', 1)
28 | .arg(float(m_application.getPeakBackBufferSizeBytes())/1024/1024, 0, 'f', 1));
29 | }
30 |
--------------------------------------------------------------------------------
/OppositeRenderer/Client/gui/docks/RenderServersSummaryDock.hxx:
--------------------------------------------------------------------------------
1 | #ifndef RENDERSERVERSDOCK_H
2 | #define RENDERSERVERSDOCK_H
3 |
4 | #include
5 |
6 | namespace Ui {
7 | class RenderServersSummaryDock;
8 | }
9 |
10 | class DistributedApplication;
11 |
12 | class RenderServersSummaryDock : public QDockWidget
13 | {
14 | Q_OBJECT
15 |
16 | public:
17 | explicit RenderServersSummaryDock(QWidget *parent, DistributedApplication & application);
18 | ~RenderServersSummaryDock();
19 |
20 | public slots:
21 | void onServersInfoUpdated();
22 |
23 | signals:
24 | void actionConnectToNewRenderServer();
25 |
26 |
27 | private:
28 | Ui::RenderServersSummaryDock *ui;
29 | DistributedApplication & m_application;
30 | };
31 |
32 | #endif // RENDERSERVERSDOCK_H
33 |
--------------------------------------------------------------------------------
/OppositeRenderer/Client/gui/docks/ui/ConnectedServersDock.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | ConnectedServersDock
4 |
5 |
6 |
7 | 0
8 | 0
9 | 827
10 | 154
11 |
12 |
13 |
14 | QDockWidget::NoDockWidgetFeatures
15 |
16 |
17 | Qt::BottomDockWidgetArea
18 |
19 |
20 | Connected render servers
21 |
22 |
23 |
24 |
25 | 5
26 |
27 |
28 | 5
29 |
30 |
31 | 5
32 |
33 |
34 | 5
35 |
36 | -
37 |
38 |
39 | QAbstractItemView::NoEditTriggers
40 |
41 |
42 | false
43 |
44 |
45 | false
46 |
47 |
48 | true
49 |
50 |
51 | QAbstractItemView::NoSelection
52 |
53 |
54 | QAbstractItemView::SelectRows
55 |
56 |
57 | true
58 |
59 |
60 | false
61 |
62 |
63 | true
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/OppositeRenderer/Client/gui_models/ConnectedServersTableModel.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 |
9 | #include
10 | class RenderServerConnections;
11 |
12 | class ConnectedServersTableModel : public QAbstractTableModel
13 | {
14 | Q_OBJECT;
15 | public:
16 | ConnectedServersTableModel(QObject* parent, const RenderServerConnections & serverConnections );
17 | virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
18 | virtual int columnCount( const QModelIndex &parent = QModelIndex( ) ) const;
19 | virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
20 | virtual QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
21 | virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
22 |
23 | private slots:
24 | void onServersInfoUpdated();
25 |
26 | private:
27 | const RenderServerConnections & m_serverConnections;
28 | void abCde(int abc);
29 | };
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/Gui.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(OutDir)
5 | WindowsLocalDebugger
6 | Auto
7 | true
8 |
9 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 Stian Pedersen
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
4 | associated documentation files (the "Software"), to deal in the Software without restriction,
5 | including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
6 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
7 | subject to the following conditions:
8 |
9 | The above copyright notice and this permission notice shall be included in all copies or substantial
10 | portions of the Software.
11 |
12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
13 | LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
14 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
16 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/RendererStatus.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | namespace RendererStatus
9 | {
10 | enum E {NOT_INITIALIZED, INITIALIZING_ENGINE, INITIALIZING_SCENE, RENDERING};
11 | }
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/RunningStatus.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | namespace RunningStatus
9 | {
10 | enum E {STOPPED, RUNNING, PAUSE};
11 | }
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/gui/AboutWindow.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "AboutWindow.hxx"
8 | #include "ui/ui_AboutWindow.h"
9 | #include
10 |
11 | AboutWindow::AboutWindow(QWidget *parent) :
12 | QDialog(parent),
13 | ui(new Ui::AboutWindow)
14 | {
15 | ui->setupUi(this);
16 | }
17 |
18 | AboutWindow::~AboutWindow()
19 | {
20 | delete ui;
21 | }
22 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/gui/AboutWindow.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #ifndef ABOUTWINDOW_H
8 | #define ABOUTWINDOW_H
9 |
10 | #include
11 | #include "gui_export_api.h"
12 |
13 | namespace Ui {
14 | class AboutWindow;
15 | }
16 |
17 | class AboutWindow : public QDialog
18 | {
19 | Q_OBJECT
20 |
21 | public:
22 | explicit GUI_EXPORT_API AboutWindow(QWidget *parent = 0);
23 | GUI_EXPORT_API ~AboutWindow();
24 |
25 | private:
26 | Ui::AboutWindow *ui;
27 | };
28 |
29 | #endif // ABOUTWINDOW_H
30 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/gui/ComputeDeviceInformationWidget.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "ComputeDeviceInformationWidget.hxx"
8 | #include "ComputeDeviceInformationWidgetTabPage.hxx"
9 | #include "ComputeDevice.h"
10 | #include "ComputeDeviceRepository.h"
11 |
12 | ComputeDeviceInformationWidget::ComputeDeviceInformationWidget(QWidget* parent, ComputeDeviceRepository & computeDeviceRepo) :
13 | QWidget(parent)
14 | {
15 | setupUi(this);
16 | setupGpuDeviceTabPages(computeDeviceRepo);
17 | //connect(this, SIGNAL(hasChangedDeviceConfiguration()), parent, SLOT(onHasChangedDeviceConfiguration()));
18 | }
19 |
20 | void ComputeDeviceInformationWidget::setupGpuDeviceTabPages(ComputeDeviceRepository & computeDeviceRepo)
21 | {
22 | std::vector & computeDevices = computeDeviceRepo.getComputeDevices();
23 |
24 | this->setWindowTitle(QString("Configure Compute Devices (") + QString::number(computeDevices.size()) + QString(" devices found)"));
25 |
26 | for(int i = 0; i < computeDevices.size(); i++)
27 | {
28 | ComputeDeviceInformationWidgetTabPage* deviceTabPage = new ComputeDeviceInformationWidgetTabPage(this, computeDevices.at(i));
29 | QString computeDevName = computeDevices.at(i).getName();
30 | connect(deviceTabPage, SIGNAL(hasSelectedComputeDevice(ComputeDevice*)), this, SLOT(onHasSelectedComputeDevice(ComputeDevice*)));
31 | this->tabWidget->addTab(deviceTabPage, computeDevName);
32 | this->m_tabPages.push_back(deviceTabPage);
33 | }
34 | }
35 |
36 | void ComputeDeviceInformationWidget::onHasSelectedComputeDevice( ComputeDevice* device)
37 | {
38 | emit hasSelectedComputeDevice(device);
39 | }
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/gui/ComputeDeviceInformationWidget.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #ifndef GPU_DEVICE_INFORMATION_DIALOG_H
8 | #define GPU_DEVICE_INFORMATION_DIALOG_H
9 |
10 | #include
11 | #include "ui/ui_ComputeDeviceInformationWidget.h"
12 | #include
13 | #include "ComputeDeviceInformationWidgetTabPage.hxx"
14 | #include "gui_export_api.h"
15 |
16 | class ComputeDevice;
17 | class ComputeDeviceRepository;
18 |
19 | class ComputeDeviceInformationWidget : public QWidget, public Ui::ComputeDeviceInformationWidget
20 | {
21 | Q_OBJECT
22 |
23 | public:
24 | GUI_EXPORT_API ComputeDeviceInformationWidget(QWidget* parent, ComputeDeviceRepository & computeDeviceRepo);
25 |
26 | signals:
27 | GUI_EXPORT_API_QT void hasSelectedComputeDevice(ComputeDevice* selectedComputeDevice);
28 |
29 | private slots:
30 | void onHasSelectedComputeDevice(ComputeDevice*);
31 |
32 | private:
33 | void setupGpuDeviceTabPages(ComputeDeviceRepository & computeDeviceRepo);
34 | std::vector m_tabPages;
35 | };
36 |
37 | #endif
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/gui/ComputeDeviceInformationWidgetTabPage.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "ComputeDeviceInformationWidgetTabPage.hxx"
8 | #include
9 | #include "ComputeDevice.h"
10 |
11 | ComputeDeviceInformationWidgetTabPage::ComputeDeviceInformationWidgetTabPage(QWidget* parent, ComputeDevice & device)
12 | : m_device(device),
13 | QWidget(parent)
14 | {
15 | setupUi(this);
16 |
17 | GlobalMemory->setText(QString::number(device.getGlobalMemoryKB()/1024) + QString(" MB"));
18 | ConstantMemory->setText(QString::number(device.getConstantMemoryKB()) + QString(" KB"));
19 | L2CacheMemory->setText(QString::number(device.getL2CacheMemoryKB()) + QString(" KB"));
20 | SharedMemorySM->setText(QString::number(device.getSharedMemoryPerBlockKB()) + QString(" KB"));
21 | NumSM->setText(QString::number(device.getMultiProcessorCount()));
22 | ThreadsPerSM->setText(QString::number(device.getMaxThreadsPerMultiProcessor()));
23 | RegisterMemorySM->setText(QString::number(device.getRegisterMemoryPerBlockKB()) + QString(" KB"));
24 | RegistersSM->setText(QString::number(device.getRegistersPerBlock()));
25 | MemClockFq->setText(QString::number(device.getMemoryClockFrequencyKHz()/1024)+QString(" MhZ"));
26 | PrcClockFrq->setText(QString::number(device.getClockFrequencyKHz()/1024)+QString(" MhZ"));
27 | WarpSize->setText(QString::number(device.getWarpSize()));
28 | ComputeCapability->setText(QString(device.getComputeCapability()));
29 | MaxBlockDim->setText(QString::number(device.getMaxBlockDimensionX()) + QString(" x ") + QString::number(device.getMaxBlockDimensionY())
30 | + QString(" x ") + QString::number(device.getMaxBlockDimensionZ()));
31 | MaxGridDim->setText(QString::number(device.getMaxGridDimensionX()) + QString(" x ") + QString::number(device.getMaxGridDimensionY())
32 | + QString(" x ") + QString::number(device.getMaxGridDimensionZ()));
33 | MaxThreadsPerBlock->setText(QString::number(device.getMaxThreadsPerBlock()));
34 | DeviceId->setText(QString::number(device.getDeviceId()));
35 | PCIBusId->setText(QString::number(device.getPCIBusId()));
36 | MemoryBusWidth->setText(QString::number(device.getMemoryBusWidth())+QString(" bits"));
37 | UnifiedAddressing->setText(QString(device.getUnifiedAddressing() ? "Yes" : "No"));
38 | connect(this->buttonSelectDevice, SIGNAL(clicked()), this, SLOT(onButtonSelectComputeDevice()));
39 | }
40 |
41 | void ComputeDeviceInformationWidgetTabPage::onButtonSelectComputeDevice()
42 | {
43 | emit hasSelectedComputeDevice(&m_device);
44 | }
45 |
46 | ComputeDevice& ComputeDeviceInformationWidgetTabPage::getComputeDevice()
47 | {
48 | return this->m_device;
49 | }
50 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/gui/ComputeDeviceInformationWidgetTabPage.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #ifndef GPU_DEVICE_INFORMATION_DIALOG_TAB_PAGE_H
8 | #define GPU_DEVICE_INFORMATION_DIALOG_TAB_PAGE_H
9 |
10 | #include "ui/ui_ComputeDeviceInformationWidgetTabPage.h"
11 |
12 | class ComputeDevice;
13 |
14 | class ComputeDeviceInformationWidgetTabPage : public QWidget, private Ui::ComputeDeviceInformationWidgetTabPage
15 | {
16 | Q_OBJECT
17 |
18 | public:
19 | ComputeDeviceInformationWidgetTabPage(QWidget* parent, ComputeDevice & device);
20 | ComputeDevice& getComputeDevice();
21 |
22 | signals:
23 | void hasSelectedComputeDevice(ComputeDevice* device);
24 |
25 | private slots:
26 | void onButtonSelectComputeDevice();
27 |
28 | private:
29 | ComputeDevice& m_device;
30 | };
31 |
32 | #endif
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/gui/MainWindowBase.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include
9 | #include
10 | #include "ui/ui_MainWindowBase.h"
11 | #include "gui_export_api.h"
12 | #include
13 |
14 | class RenderWidget;
15 | class OptixRenderer;
16 | class Application;
17 | class Camera;
18 |
19 | class MainWindowBase : public QMainWindow, public Ui::MainWindowBase
20 | {
21 | Q_OBJECT
22 | public:
23 | GUI_EXPORT_API MainWindowBase(Application& application);
24 | GUI_EXPORT_API ~MainWindowBase();
25 | GUI_EXPORT_API virtual void closeEvent(QCloseEvent* event);
26 | static QString getApplicationStatusString(const Application & application, bool showSeconds = true);
27 |
28 | signals:
29 | void renderRestart();
30 | void renderStatusToggle();
31 | //void cameraUpdated();
32 |
33 | private slots:
34 | GUI_EXPORT_API_QT void onSetCameraToDefault();
35 | GUI_EXPORT_API_QT void onChangeRenderMethodPPM();
36 | GUI_EXPORT_API_QT void onChangeRenderMethodPT();
37 | GUI_EXPORT_API_QT void onConfigureGPUDevices();
38 | void onOpenSceneFile();
39 | void onReloadLastScene();
40 | //void onCameraUpdated();
41 | void onRunningStatusChanged();
42 |
43 | void onRenderMethodChanged();
44 | void onActionAbout();
45 | void onRenderStatusToggle();
46 | void onRenderRestart();
47 | void onUpdateRunningStatusLabelTimer();
48 | void onApplicationError(QString);
49 | void onActionOpenBuiltInScene();
50 | void onActionSaveImagePPM();
51 |
52 | private:
53 | void loadSceneByName( QString &fileName );
54 | RenderWidget* m_renderWidget;
55 | //void onChangeRenderMethod();
56 | Application & m_application;
57 | QLabel* m_statusbar_renderMethodLabel;
58 | QLabel* m_statusbar_runningStatusLabel;
59 | unsigned int m_renderWidth;
60 | unsigned int m_renderHeight;
61 | QFileInfo m_lastOpenedSceneFile;
62 | Camera & m_camera;
63 | };
64 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/gui/RenderWidget.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 |
9 | #include
10 | #include
11 | #include
12 | #include "util/Mouse.h"
13 | #include "renderer/Camera.h"
14 | #include
15 |
16 | class OptixRenderer;
17 | class RenderWindow;
18 | class QThread;
19 | class ComputeDevice;
20 | class OutputSettingsModel;
21 | class QLabel;
22 |
23 | /*
24 | * Handles displaying the Application output to the screen.
25 | */
26 |
27 | class RenderWidget : public QGLWidget
28 | {
29 | Q_OBJECT
30 |
31 | public:
32 | RenderWidget(QWidget *parent, Camera & camera, const OutputSettingsModel & model);
33 | ~RenderWidget();
34 | size_t getDisplayBufferSizeBytes();
35 |
36 | signals:
37 | void cameraUpdated();
38 |
39 | public slots:
40 | void onNewFrameReadyForDisplay(const float* cpuBuffer, unsigned long long iterationNumber);
41 |
42 | protected:
43 | virtual void initializeGL();
44 | virtual void resizeGL(int w, int h);
45 | virtual void paintGL();
46 | void displayFrame(const float* cpuBuffer, unsigned long long iterationNumber);
47 | QPair getDisplayBufferSize();
48 | virtual void mousePressEvent(QMouseEvent* event);
49 | virtual void mouseMoveEvent( QMouseEvent* event );
50 | virtual void resizeEvent(QResizeEvent* event);
51 |
52 | private:
53 | void initializeOpenGLShaders();
54 | Mouse m_mouse;
55 | float* m_displayBufferCpu;
56 | Camera & m_camera;
57 | const OutputSettingsModel & m_outputSettingsModel;
58 | bool m_hasLoadedGLShaders;
59 | GLuint m_GLProgram;
60 | GLuint m_GLTextureSampler;
61 | GLuint m_GLOutputBufferTexture;
62 | QLabel* m_iterationNumberLabel;
63 | };
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/gui/docks/CameraDock.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #ifndef CameraDock_H
8 | #define CameraDock_H
9 |
10 | #include
11 |
12 | namespace Ui {
13 | class CameraDock;
14 | }
15 |
16 | class Camera;
17 | class PPMSettingsModel;
18 | class OutputSettingsModel;
19 |
20 | class CameraDock : public QDockWidget
21 | {
22 | Q_OBJECT
23 |
24 | public:
25 | explicit CameraDock(QWidget *parent, Camera & camera, PPMSettingsModel & ppmModel, OutputSettingsModel & outputModel);
26 | ~CameraDock();
27 |
28 | public slots:
29 | void onCameraUpdated();
30 |
31 | signals:
32 | void cameraUpdated();
33 |
34 | private slots:
35 | void onUpdate();
36 | void onCornell();
37 | void onSponza();
38 | void onConference();
39 |
40 | private:
41 | Ui::CameraDock *ui;
42 | Camera & m_camera;
43 | PPMSettingsModel & m_PPMModel;
44 | OutputSettingsModel & m_outputModel;
45 | };
46 |
47 | #endif // CameraDock_H
48 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/gui/docks/OutputDock.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "OutputDock.hxx"
8 | #include "ui/ui_OutputDock.h"
9 | #include "models/OutputSettingsModel.hxx"
10 | #include
11 |
12 | OutputDock::OutputDock(QWidget *parent, OutputSettingsModel & model) :
13 | QDockWidget(parent),
14 | ui(new Ui::OutputDock),
15 | m_model(model)
16 | {
17 | ui->setupUi(this);
18 | this->setFeatures(QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable);
19 | this->setAllowedAreas(Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea);
20 | connect(ui->updateSettingsButton, SIGNAL(pressed()), this, SLOT(onFormSubmitted()));
21 | connect(&m_model, SIGNAL(resolutionUpdated()), this, SLOT(onOutputSettingsModelUpdated()));
22 | connect(&m_model, SIGNAL(gammaUpdated()), this, SLOT(onOutputSettingsModelUpdated()));
23 |
24 |
25 | onOutputSettingsModelUpdated();
26 | }
27 |
28 | OutputDock::~OutputDock()
29 | {
30 | delete ui;
31 | }
32 |
33 | void OutputDock::onFormSubmitted()
34 | {
35 | bool okWidth, okHeight;
36 | unsigned int width = ui->resolutionWidthEdit->text().toUInt(&okWidth);
37 | unsigned int height = ui->resolutionHeightEdit->text().toUInt(&okHeight);
38 | float gamma = (float)ui->gammaEdit->value();
39 |
40 | if(okWidth && okHeight && width < 10000 && height < 10000)
41 | {
42 | m_model.setWidth(width);
43 | m_model.setHeight(height);
44 | m_model.setGamma(gamma);
45 | }
46 | else
47 | {
48 | QMessageBox::information(this, "Invalid Render Output Settings", "Please make sure that the values you inserted are valid.");
49 | }
50 | }
51 |
52 | void OutputDock::onOutputSettingsModelUpdated()
53 | {
54 | ui->resolutionWidthEdit->setText(QString::number(m_model.getWidth()));
55 | ui->resolutionHeightEdit->setText(QString::number(m_model.getHeight()));
56 | ui->gammaEdit->setValue((double)m_model.getGamma());
57 | }
58 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/gui/docks/OutputDock.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #ifndef OutputDock_H
8 | #define OutputDock_H
9 |
10 | #include
11 |
12 | namespace Ui {
13 | class OutputDock;
14 | }
15 |
16 | class OutputSettingsModel;
17 |
18 | class OutputDock : public QDockWidget
19 | {
20 | Q_OBJECT
21 |
22 | public:
23 | explicit OutputDock(QWidget *parent, OutputSettingsModel & model);
24 | ~OutputDock();
25 |
26 | signals:
27 | void outputSettingsUpdated();
28 |
29 | private slots:
30 | void onFormSubmitted();
31 | void onOutputSettingsModelUpdated();
32 |
33 | private:
34 | Ui::OutputDock *ui;
35 | OutputSettingsModel & m_model;
36 | };
37 |
38 | #endif // OutputDock_H
39 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/gui/docks/PPMDock.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "PPMDock.hxx"
8 | #include "ui/ui_PPMDock.h"
9 | #include
10 | #include "Application.hxx"
11 | #include "models/PPMSettingsModel.hxx"
12 |
13 | PPMDock::PPMDock(QWidget *parent, const Application & application, PPMSettingsModel & PPMSettingsModel) :
14 | QDockWidget(parent),
15 | ui(new Ui::PPMDock),
16 | m_application(application),
17 | m_PPMSettingsModel(PPMSettingsModel)
18 | {
19 | ui->setupUi(this);
20 | this->setFeatures(QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable);
21 | this->setAllowedAreas(Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea);
22 | connect(ui->updateSettingsButton, SIGNAL(pressed()), this, SLOT(onFormSubmitted()));
23 | connect(&PPMSettingsModel, SIGNAL(updated()), this, SLOT(onModelUpdated()));
24 | connect(&m_application.getRenderStatisticsModel(), SIGNAL(updated()), this, SLOT(onRenderStatisticsUpdated()));
25 | onModelUpdated();
26 | }
27 |
28 | PPMDock::~PPMDock()
29 | {
30 | delete ui;
31 | }
32 |
33 | void PPMDock::onFormSubmitted()
34 | {
35 | m_PPMSettingsModel.setPPMInitialRadius(ui->ppmInitialRadiusEdit->value());
36 | }
37 |
38 | void PPMDock::onRenderStatisticsUpdated()
39 | {
40 | const RenderStatisticsModel & model = m_application.getRenderStatisticsModel();
41 | ui->emittedPhotons->setText(QString("%1 M").arg(model.getNumEmittedPhotons()/1E6, 0, 'f', 2));
42 | ui->ppmCurrentRadius->setText(QString("%1").arg(model.getCurrentPPMRadius(), 0, 'f', 3));
43 | ui->emittedPhotonsPerIteration->setText(QString("%1 M").arg(model.getNumEmittedPhotonsPerIteration()/1E6, 0, 'f', 2));
44 | if(m_application.getRenderTimeSeconds() > 0.5f)
45 | {
46 | ui->emittedPhotonsPerSecond->setText(QString("%1 M").arg(model.getNumEmittedPhotons()/m_application.getRenderTimeSeconds()/1E6, 0, 'f', 2));
47 | }
48 | else
49 | {
50 | ui->emittedPhotonsPerSecond->setText("");
51 | }
52 | }
53 |
54 | void PPMDock::onModelUpdated()
55 | {
56 | ui->ppmInitialRadiusEdit->setValue(m_PPMSettingsModel.getPPMInitialRadius());
57 | }
58 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/gui/docks/PPMDock.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #ifndef PPMDock_H
8 | #define PPMDock_H
9 |
10 | #include
11 |
12 | namespace Ui {
13 | class PPMDock;
14 | }
15 | class Application;
16 | class PPMSettingsModel;
17 |
18 | class PPMDock : public QDockWidget
19 | {
20 | Q_OBJECT
21 |
22 | public:
23 | explicit PPMDock(QWidget *parent, const Application & application, PPMSettingsModel & PPMSettings);
24 | ~PPMDock();
25 |
26 | public slots:
27 | void onRenderStatisticsUpdated();
28 |
29 | private slots:
30 | void onFormSubmitted();
31 | void onModelUpdated();
32 |
33 | private:
34 | Ui::PPMDock *ui;
35 | const Application & m_application;
36 | PPMSettingsModel & m_PPMSettingsModel;
37 | };
38 |
39 | #endif // PPMDock_H
40 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/gui/docks/RenderInformationDock.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #ifndef RENDERINFORMATIONDOCK_H
8 | #define RENDERINFORMATIONDOCK_H
9 |
10 | #include
11 | #include "RunningStatus.h"
12 |
13 | namespace Ui {
14 | class RenderInformationDock;
15 | }
16 |
17 | class Application;
18 | class RenderStatisticsModel;
19 |
20 | class RenderInformationDock : public QDockWidget
21 | {
22 | Q_OBJECT
23 |
24 | public:
25 | explicit RenderInformationDock(QWidget *parent, const RenderStatisticsModel & renderStatisticsModel, Application & application);
26 | ~RenderInformationDock();
27 |
28 | signals:
29 | void renderStatusToggle();
30 | void renderRestart();
31 |
32 | private slots:
33 | void onRunningStatusChanged();
34 | void onRenderStatisticsUpdated();
35 | void onUpdateRenderTime();
36 |
37 | private:
38 | Ui::RenderInformationDock *ui;
39 | Application & m_application;
40 | const RenderStatisticsModel & m_renderStatisticsModel;
41 | };
42 |
43 | #endif // RENDERINFORMATIONDOCK_H
44 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/gui/docks/SceneDock.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "SceneDock.hxx"
8 | #include "ui/ui_SceneDock.h"
9 | #include
10 | #include "scene/SceneManager.hxx"
11 |
12 | SceneDock::SceneDock(QWidget *parent, SceneManager & sceneManager) :
13 | QDockWidget(parent),
14 | m_sceneManager(sceneManager),
15 | ui(new Ui::SceneDock)
16 | {
17 | ui->setupUi(this);
18 | this->setFeatures(QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable);
19 | this->setAllowedAreas(Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea);
20 | connect(&sceneManager, SIGNAL(sceneUpdated()), this, SLOT(onSceneUpdated()));
21 | connect(&sceneManager, SIGNAL(sceneLoadingNew()), this, SLOT(onSceneLoadingNew()));
22 | connect(&sceneManager, SIGNAL(sceneLoadError(QString)), this, SLOT(onSceneUpdated()));
23 | onSceneUpdated();
24 | }
25 |
26 | SceneDock::~SceneDock()
27 | {
28 | delete ui;
29 | }
30 |
31 | void SceneDock::onSceneUpdated()
32 | {
33 | if(m_sceneManager.getScene() != NULL)
34 | {
35 | ui->sceneNameLabel->setText(QString(m_sceneManager.getScene()->getSceneName()));
36 | ui->numTrianglesLabel->setText(QString::number(m_sceneManager.getScene()->getNumTriangles()));
37 | }
38 | }
39 |
40 | void SceneDock::onSceneLoadingNew()
41 | {
42 | ui->sceneNameLabel->setText(QString("Loading new scene..."));
43 | ui->numTrianglesLabel->setText(QString(""));
44 | }
45 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/gui/docks/SceneDock.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #ifndef SceneDock_H
8 | #define SceneDock_H
9 |
10 | #include
11 |
12 | namespace Ui {
13 | class SceneDock;
14 | }
15 |
16 | class SceneManager;
17 |
18 | class SceneDock : public QDockWidget
19 | {
20 | Q_OBJECT
21 |
22 | public:
23 | explicit SceneDock(QWidget *parent, SceneManager & sceneManager);
24 | ~SceneDock();
25 |
26 | public slots:
27 | void onSceneUpdated();
28 | void onSceneLoadingNew();
29 |
30 | private:
31 | Ui::SceneDock *ui;
32 | SceneManager & m_sceneManager;
33 | };
34 |
35 | #endif // SceneDock_H
36 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/gui/main.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include
8 | #include
9 | #include
10 |
11 | BOOLEAN WINAPI DllMain( IN HINSTANCE hDllHandle,
12 | IN DWORD nReason,
13 | IN LPVOID Reserved )
14 | {
15 |
16 | }
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/gui/ui/AboutWindow.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | AboutWindow
4 |
5 |
6 | true
7 |
8 |
9 |
10 | 0
11 | 0
12 | 391
13 | 224
14 |
15 |
16 |
17 |
18 | 0
19 | 0
20 |
21 |
22 |
23 | About renderer
24 |
25 |
26 |
27 |
28 | 10
29 | 0
30 | 251
31 | 41
32 |
33 |
34 |
35 |
36 | 15
37 |
38 |
39 |
40 | About Opposite Renderer
41 |
42 |
43 |
44 |
45 |
46 | 10
47 | 40
48 | 371
49 | 171
50 |
51 |
52 |
53 |
54 | 0
55 | 0
56 |
57 |
58 |
59 | This renderer is a part of Stian Pedersens Master's thesis project at Norwegian University of Science and Technology. Project webpage: apartridge.github.io/OppositeRenderer/
60 |
61 |
62 | Qt::PlainText
63 |
64 |
65 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
66 |
67 |
68 | true
69 |
70 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/gui/ui/ComputeDeviceInformationWidget.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | ComputeDeviceInformationWidget
4 |
5 |
6 |
7 | 0
8 | 0
9 | 535
10 | 342
11 |
12 |
13 |
14 | GPU Device Information
15 |
16 |
17 |
18 |
19 | 5
20 | 5
21 | 526
22 | 331
23 |
24 |
25 |
26 | QTabWidget::North
27 |
28 |
29 | QTabWidget::Rounded
30 |
31 |
32 | -1
33 |
34 |
35 | false
36 |
37 |
38 | false
39 |
40 |
41 |
42 |
43 |
44 |
45 | onSaveDeviceConfiguration()
46 |
47 |
48 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/gui/ui/RenderTypePPMInfo.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | RenderTypePPMInfo
4 |
5 |
6 |
7 | 0
8 | 0
9 | 207
10 | 107
11 |
12 |
13 |
14 | Widget
15 |
16 |
17 | Progressive Photon Mapping
18 |
19 |
20 | true
21 |
22 |
23 | false
24 |
25 |
26 |
27 |
28 | 10
29 | 20
30 | 191
31 | 81
32 |
33 |
34 |
35 | -
36 |
37 |
38 | Radius
39 |
40 |
41 |
42 | -
43 |
44 |
45 | Photons
46 |
47 |
48 |
49 | -
50 |
51 |
52 | 0
53 |
54 |
55 |
56 | -
57 |
58 |
59 | 0
60 |
61 |
62 |
63 | -
64 |
65 |
66 | Photons/sec
67 |
68 |
69 |
70 | -
71 |
72 |
73 | 0
74 |
75 |
76 |
77 | -
78 |
79 |
80 | Emitted photons
81 |
82 |
83 |
84 | -
85 |
86 |
87 | 0
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/gui_export_api.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #ifndef GUI_EXPORT_API
9 | # ifdef RENDERER_GUI_DLL
10 | # define GUI_EXPORT_API __declspec(dllexport)
11 | # define GUI_EXPORT_API_QT Q_DECL_EXPORT
12 | # else
13 | # define GUI_EXPORT_API __declspec(dllimport)
14 | # define GUI_EXPORT_API_QT Q_DECL_IMPORT
15 | # endif
16 | #endif
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/main.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include
8 | #include
9 | //#include
10 |
11 | BOOLEAN WINAPI DllMain( IN HINSTANCE hDllHandle,
12 | IN DWORD nReason,
13 | IN LPVOID Reserved )
14 | {
15 | return TRUE;
16 | }
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/models/OutputSettingsModel.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "OutputSettingsModel.hxx"
8 |
9 | OutputSettingsModel::OutputSettingsModel(void)
10 | : m_width(0), m_height(0), m_gamma(2.2)
11 | {
12 |
13 | }
14 |
15 | OutputSettingsModel::~OutputSettingsModel(void)
16 | {
17 | }
18 |
19 | void OutputSettingsModel::setWidth( unsigned int width )
20 | {
21 | bool shouldEmit = (m_width != width);
22 | m_width = width;
23 | if(shouldEmit)
24 | {
25 | emit resolutionUpdated();
26 | }
27 | }
28 |
29 | void OutputSettingsModel::setHeight( unsigned int height )
30 | {
31 | bool shouldEmit = (m_height != height);
32 | m_height = height;
33 | if(shouldEmit)
34 | {
35 | emit resolutionUpdated();
36 | }
37 | }
38 |
39 | unsigned int OutputSettingsModel::getWidth() const
40 | {
41 | return m_width;
42 | }
43 |
44 | unsigned int OutputSettingsModel::getHeight() const
45 | {
46 | return m_height;
47 | }
48 |
49 | float OutputSettingsModel::getGamma() const
50 | {
51 | return m_gamma;
52 | }
53 |
54 | void OutputSettingsModel::setGamma( float gamma )
55 | {
56 | bool shouldEmit = (m_gamma != gamma);
57 | m_gamma = gamma;
58 | if(shouldEmit)
59 | {
60 | emit gammaUpdated();
61 | }
62 | }
63 |
64 | float OutputSettingsModel::getAspectRatio() const
65 | {
66 | return float(m_width)/float(m_height);
67 | }
68 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/models/OutputSettingsModel.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include
9 | #include "gui_export_api.h"
10 |
11 | class OutputSettingsModel : public QObject
12 | {
13 | Q_OBJECT;
14 |
15 | public:
16 | GUI_EXPORT_API OutputSettingsModel(void);
17 | GUI_EXPORT_API ~OutputSettingsModel(void);
18 | GUI_EXPORT_API void setWidth(unsigned int width);
19 | GUI_EXPORT_API void setHeight(unsigned int height);
20 | GUI_EXPORT_API unsigned int getWidth() const;
21 | GUI_EXPORT_API unsigned int getHeight() const;
22 | GUI_EXPORT_API float getGamma() const;
23 | GUI_EXPORT_API float getAspectRatio() const;
24 | GUI_EXPORT_API void setGamma(float gamma);
25 |
26 | signals:
27 | void resolutionUpdated();
28 | void gammaUpdated();
29 |
30 | private:
31 | unsigned int m_width;
32 | unsigned int m_height;
33 | float m_gamma;
34 | };
35 |
36 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/models/PPMSettingsModel.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "PPMSettingsModel.hxx"
8 |
9 | PPMSettingsModel::PPMSettingsModel(void)
10 | : m_PPMInitialRadius(0.0f)
11 | {
12 | }
13 |
14 | PPMSettingsModel::~PPMSettingsModel(void)
15 | {
16 | }
17 |
18 | double PPMSettingsModel::getPPMInitialRadius() const
19 | {
20 | return m_PPMInitialRadius;
21 | }
22 |
23 | void PPMSettingsModel::setPPMInitialRadius( double PPMInitialRadius )
24 | {
25 | m_PPMInitialRadius = PPMInitialRadius;
26 | emit updated();
27 | }
28 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/models/PPMSettingsModel.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include
9 | #include "gui_export_api.h"
10 | class PPMSettingsModel : public QObject
11 | {
12 | Q_OBJECT;
13 |
14 | public:
15 | GUI_EXPORT_API PPMSettingsModel(void);
16 | GUI_EXPORT_API ~PPMSettingsModel(void);
17 | GUI_EXPORT_API double getPPMInitialRadius() const;
18 | GUI_EXPORT_API void setPPMInitialRadius(double PPMInitialRadius);
19 |
20 | signals:
21 | void updated();
22 |
23 | private:
24 | double m_PPMInitialRadius;
25 | };
26 |
27 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/models/RenderStatisticsModel.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "RenderStatisticsModel.hxx"
8 |
9 | RenderStatisticsModel::RenderStatisticsModel(void)
10 | : m_currentPPMRadius(0.0f),
11 | m_numIterations(0),
12 | m_numPreviewedIterations(0),
13 | m_numEmittedPhotons(0),
14 | m_numEmittedPhotonsPerIteration(0)
15 | {
16 | }
17 |
18 | RenderStatisticsModel::~RenderStatisticsModel(void)
19 | {
20 | }
21 |
22 | unsigned long long RenderStatisticsModel::getNumIterations() const
23 | {
24 | return m_numIterations;
25 | }
26 |
27 | void RenderStatisticsModel::setNumIterations( unsigned long long numIterations )
28 | {
29 | m_numIterations = numIterations;
30 | emit updated();
31 | }
32 |
33 | unsigned long long RenderStatisticsModel::getNumPhotonsInEstimate() const
34 | {
35 | return m_numPhotonsInEstimate;
36 | }
37 |
38 | void RenderStatisticsModel::setNumPhotonsInEstimate( unsigned long long numberOfPhotonsInEstimate )
39 | {
40 | m_numPhotonsInEstimate = numberOfPhotonsInEstimate;
41 | }
42 |
43 | unsigned long long RenderStatisticsModel::getNumEmittedPhotons() const
44 | {
45 | return m_numEmittedPhotons;
46 | }
47 |
48 | void RenderStatisticsModel::setNumEmittedPhotons( unsigned long long numberOfEmittedPhotons )
49 | {
50 | m_numEmittedPhotons = numberOfEmittedPhotons;
51 | }
52 |
53 | unsigned long long RenderStatisticsModel::getNumEmittedPhotonsPerIteration() const
54 | {
55 | return m_numEmittedPhotonsPerIteration;
56 | }
57 |
58 | void RenderStatisticsModel::setNumEmittedPhotonsPerIteration( unsigned long long numberOfEmittedPhotonsPerIteration )
59 | {
60 | m_numEmittedPhotonsPerIteration = numberOfEmittedPhotonsPerIteration;
61 | }
62 |
63 | double RenderStatisticsModel::getCurrentPPMRadius() const
64 | {
65 | return m_currentPPMRadius;
66 | }
67 |
68 | void RenderStatisticsModel::setCurrentPPMRadius( double currentPPMRadius )
69 | {
70 | m_currentPPMRadius = currentPPMRadius;
71 | }
72 |
73 | unsigned long long RenderStatisticsModel::getNumPreviewedIterations() const
74 | {
75 | return m_numPreviewedIterations;
76 | }
77 |
78 | void RenderStatisticsModel::setNumPreviewedIterations( unsigned long long numPreviewedIterations )
79 | {
80 | m_numPreviewedIterations = numPreviewedIterations;
81 | }
82 |
83 | void RenderStatisticsModel::incrementNumPreviewedIterations()
84 | {
85 | m_numPreviewedIterations++;
86 | }
87 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/models/RenderStatisticsModel.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include
9 | #include
10 | #include "gui_export_api.h"
11 |
12 | class RenderStatisticsModel : public QObject
13 | {
14 | Q_OBJECT;
15 |
16 | public:
17 | GUI_EXPORT_API RenderStatisticsModel(void);
18 | GUI_EXPORT_API ~RenderStatisticsModel(void);
19 | GUI_EXPORT_API unsigned long long getNumIterations() const;
20 | GUI_EXPORT_API void setNumIterations(unsigned long long numIterations);
21 |
22 | GUI_EXPORT_API unsigned long long getNumPreviewedIterations() const;
23 | GUI_EXPORT_API void setNumPreviewedIterations(unsigned long long numPreviewedIterations);
24 |
25 | GUI_EXPORT_API unsigned long long getNumPhotonsInEstimate() const;
26 | GUI_EXPORT_API void setNumPhotonsInEstimate(unsigned long long numberOfPhotonsInEstimate);
27 | GUI_EXPORT_API unsigned long long getNumEmittedPhotons() const;
28 | GUI_EXPORT_API void setNumEmittedPhotons(unsigned long long numberOfEmittedPhotons);
29 | GUI_EXPORT_API unsigned long long getNumEmittedPhotonsPerIteration() const;
30 | GUI_EXPORT_API void setNumEmittedPhotonsPerIteration(unsigned long long numberOfEmittedPhotonsPerIteration);
31 | GUI_EXPORT_API double getCurrentPPMRadius() const;
32 | GUI_EXPORT_API void setCurrentPPMRadius(double currentPPMRadius);
33 | GUI_EXPORT_API void incrementNumPreviewedIterations();
34 |
35 | signals:
36 | void updated();
37 |
38 | private:
39 | unsigned long long m_numEmittedPhotons;
40 | unsigned long long m_numEmittedPhotonsPerIteration;
41 | double m_currentPPMRadius;
42 | unsigned long long m_numPhotonsInEstimate;
43 | unsigned long long m_numIterations;
44 | unsigned long long m_numPreviewedIterations;
45 | };
46 |
47 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/scene/SceneFactory.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "SceneFactory.h"
8 | #include "scene/IScene.h"
9 | #include "scene/Cornell.h"
10 |
11 | SceneFactory::SceneFactory(void)
12 | {
13 | }
14 |
15 |
16 | SceneFactory::~SceneFactory(void)
17 | {
18 | }
19 |
20 | IScene* SceneFactory::getSceneByName( const char* name )
21 | {
22 | if(strcmp(name, "Cornell") == 0)
23 | {
24 | return new Cornell();
25 | }
26 | else
27 | {
28 | return Scene::createFromFile(name);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/scene/SceneFactory.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "gui_export_api.h"
9 | class IScene;
10 | class SceneFactory
11 | {
12 | public:
13 | GUI_EXPORT_API SceneFactory(void);
14 | GUI_EXPORT_API ~SceneFactory(void);
15 | GUI_EXPORT_API IScene* getSceneByName(const char* name);
16 | };
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/scene/SceneManager.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "SceneManager.hxx"
8 | #include
9 | #include
10 |
11 | SceneManager::SceneManager(void)
12 | : m_scene(NULL),
13 | m_status(SceneManagerStatus::NO_SCENE)
14 | {
15 |
16 | }
17 |
18 | SceneManager::~SceneManager(void)
19 | {
20 | delete m_scene;
21 | }
22 |
23 | IScene* SceneManager::getScene() const
24 | {
25 | return m_scene;
26 | }
27 |
28 | // Asynchronously load the new scene given by sceneName
29 | void SceneManager::setScene( const char* sceneName )
30 | {
31 | QMetaObject::invokeMethod(this, "onLoadNewScene", Qt::QueuedConnection, Q_ARG(QString, QString(sceneName)));
32 | }
33 |
34 | void SceneManager::onLoadNewScene( QString sceneName )
35 | {
36 | emit sceneLoadingNew();
37 | SceneManagerStatus::E oldStatus = m_status;
38 | m_status = SceneManagerStatus::IMPORTING;
39 | try
40 | {
41 | IScene* oldScene = m_scene;
42 | m_scene = m_factory.getSceneByName(sceneName.toAscii().constData());
43 | emit sceneUpdated();
44 | delete oldScene;
45 | m_status = SceneManagerStatus::HAS_SCENE;
46 | }
47 | catch(const std::exception & E)
48 | {
49 | emit sceneLoadError(QString(E.what()));
50 | m_status = oldStatus;
51 | }
52 | }
53 |
54 | SceneManagerStatus::E SceneManager::getStatus() const
55 | {
56 | return m_status;
57 | }
58 |
--------------------------------------------------------------------------------
/OppositeRenderer/Gui/scene/SceneManager.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 |
9 | #include "scene/IScene.h"
10 | #include "SceneFactory.h"
11 | #include
12 | #include "gui_export_api.h"
13 |
14 | namespace SceneManagerStatus
15 | {
16 | enum E {NO_SCENE, IMPORTING, HAS_SCENE};
17 |
18 | }
19 |
20 | class SceneManager : public QObject
21 | {
22 | Q_OBJECT;
23 | public:
24 | SceneManager(void);
25 | ~SceneManager(void);
26 | GUI_EXPORT_API_QT IScene* getScene() const;
27 | GUI_EXPORT_API_QT void setScene(const char* sceneName);
28 | SceneManagerStatus::E getStatus() const;
29 | signals:
30 | void sceneLoadingNew();
31 | void sceneUpdated();
32 | void sceneLoadError(QString error);
33 | private slots:
34 | void onLoadNewScene(QString sceneName);
35 | private:
36 | SceneFactory m_factory;
37 | SceneManagerStatus::E m_status;
38 | IScene* m_scene;
39 | };
--------------------------------------------------------------------------------
/OppositeRenderer/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 Opposite Renderer, Stian Pedersen
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
4 | associated documentation files (the "Software"), to deal in the Software without restriction,
5 | including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
6 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
7 | subject to the following conditions:
8 |
9 | The above copyright notice and this permission notice shall be included in all copies or substantial
10 | portions of the Software.
11 |
12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
13 | LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
14 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
16 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/OppositeRenderer/OppositeRenderer.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apartridge/OppositeRenderer/d3b51aac5a86d57a21d5428aad3ffe873a5f0b60/OppositeRenderer/OppositeRenderer.suo
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/BuildRuleQt.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/ComputeDeviceRepository.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "ComputeDeviceRepository.h"
8 | #include
9 | #include
10 |
11 | ComputeDeviceRepository::ComputeDeviceRepository(void)
12 | {
13 | int numDevs;
14 | cudaGetDeviceCount(&numDevs);
15 |
16 | for(int i = 0; i < numDevs; i++)
17 | {
18 | cudaDeviceProp devProp;
19 | cudaGetDeviceProperties(&devProp, i);
20 | ComputeDevice device = ComputeDevice::fromCudaDeviceProperties(devProp, i);
21 | this->m_computeDevices.push_back(device);
22 | }
23 | }
24 |
25 | ComputeDeviceRepository::~ComputeDeviceRepository(void)
26 | {
27 |
28 | }
29 |
30 | std::vector & ComputeDeviceRepository::getComputeDevices()
31 | {
32 | return m_computeDevices;
33 | }
34 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/ComputeDeviceRepository.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include
9 | #include "ComputeDevice.h"
10 | #include "render_engine_export_api.h"
11 |
12 | class ComputeDeviceRepository
13 | {
14 | public:
15 | RENDER_ENGINE_EXPORT_API ComputeDeviceRepository(void);
16 | RENDER_ENGINE_EXPORT_API ~ComputeDeviceRepository(void);
17 | RENDER_ENGINE_EXPORT_API static ComputeDeviceRepository& get();
18 | RENDER_ENGINE_EXPORT_API std::vector & getComputeDevices();
19 |
20 | private:
21 | std::vector m_computeDevices;
22 | };
23 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/RenderEngine.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(OutDir)
5 | WindowsLocalDebugger
6 | Auto
7 | true
8 |
9 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/clientserver/RenderResultPacket.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "render_engine_export_api.h"
9 | #include
10 | #include
11 |
12 | /*
13 | A RenderResultPacket is what we send from server to client with the rendered image.
14 | A packet can consist of several iterations of the algorithm combined in a single image/frame to save space.
15 | There is a vector of iteration numbers in each packet which says what this packet contains.
16 | */
17 |
18 | class RenderResultPacket
19 | {
20 | public:
21 | RENDER_ENGINE_EXPORT_API RenderResultPacket();
22 | RENDER_ENGINE_EXPORT_API RenderResultPacket(unsigned long long sequenceNumber, QVector iterationNumbersInPacket,
23 | QByteArray output);
24 |
25 | RENDER_ENGINE_EXPORT_API ~RenderResultPacket(void);
26 | RENDER_ENGINE_EXPORT_API unsigned long long getSequenceNumber() const;
27 | RENDER_ENGINE_EXPORT_API const QVector & getIterationNumbersInPacket() const;
28 | RENDER_ENGINE_EXPORT_API int getNumIterationsInPacket() const;
29 | RENDER_ENGINE_EXPORT_API float getRenderTimeSeconds() const;
30 | RENDER_ENGINE_EXPORT_API float getTotalTimeSeconds() const;
31 | RENDER_ENGINE_EXPORT_API void setRenderTimeSeconds(float renderTime);
32 | RENDER_ENGINE_EXPORT_API void setTotalTimeSeconds(float renderTime);
33 | RENDER_ENGINE_EXPORT_API unsigned long long getFirstIterationNumber() const;
34 | RENDER_ENGINE_EXPORT_API unsigned long long getLastIterationNumber() const;
35 | RENDER_ENGINE_EXPORT_API const QByteArray & getOutput() const;
36 | RENDER_ENGINE_EXPORT_API void merge(const RenderResultPacket & other);
37 | RENDER_ENGINE_EXPORT_API bool operator < (const RenderResultPacket & other) const;
38 |
39 | private:
40 | unsigned long long m_sequenceNumber;
41 | QVector m_iterationNumbersInPacket;
42 | QByteArray m_output;
43 | float m_renderTimeSeconds;
44 | float m_totalTimeSeconds;
45 | };
46 |
47 | class QDataStream;
48 | RENDER_ENGINE_EXPORT_API QDataStream & operator << (QDataStream & out, const RenderResultPacket & renderRequest);
49 | RENDER_ENGINE_EXPORT_API QDataStream & operator >> (QDataStream & in, RenderResultPacket & renderFrameCommand);
50 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/clientserver/RenderServerRenderRequest.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "render_engine_export_api.h"
9 | #include
10 | #include "RenderServerRenderRequestDetails.h"
11 |
12 | class RenderServerRenderRequest
13 | {
14 | public:
15 | RENDER_ENGINE_EXPORT_API RenderServerRenderRequest();
16 | RENDER_ENGINE_EXPORT_API RenderServerRenderRequest(unsigned long long sequenceNumber, const QVector & iterationNumbers,
17 | const QVector & ppmRadii, const RenderServerRenderRequestDetails & details);
18 |
19 | RENDER_ENGINE_EXPORT_API ~RenderServerRenderRequest(void);
20 | RENDER_ENGINE_EXPORT_API const QVector & getPPMRadii() const;
21 | RENDER_ENGINE_EXPORT_API const QVector & getIterationNumbers() const;
22 | RENDER_ENGINE_EXPORT_API unsigned long long getSequenceNumber() const;
23 | RENDER_ENGINE_EXPORT_API unsigned long long getFirstIterationNumber() const;
24 | RENDER_ENGINE_EXPORT_API unsigned int getNumIterations() const;
25 | RENDER_ENGINE_EXPORT_API const RenderServerRenderRequestDetails & getDetails() const;
26 |
27 | private:
28 | unsigned long long m_sequenceNumber;
29 | QVector m_iterationNumbers;
30 | QVector m_ppmRadii;
31 | RenderServerRenderRequestDetails m_details;
32 | };
33 |
34 | class QDataStream;
35 | RENDER_ENGINE_EXPORT_API QDataStream & operator << (QDataStream & out, const RenderServerRenderRequest & renderRequest);
36 | RENDER_ENGINE_EXPORT_API QDataStream & operator >> (QDataStream & in, RenderServerRenderRequest & renderRequest);
37 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/clientserver/RenderServerRenderRequestDetails.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 |
9 | #include "render_engine_export_api.h"
10 | #include "renderer/Camera.h"
11 | #include "renderer/RenderMethod.h"
12 | #include
13 | #include
14 |
15 | class RenderServerRenderRequestDetails
16 | {
17 | public:
18 | RENDER_ENGINE_EXPORT_API RenderServerRenderRequestDetails();
19 | RENDER_ENGINE_EXPORT_API RenderServerRenderRequestDetails(const Camera & camera, QByteArray sceneName, RenderMethod::E renderMethod, unsigned int width, unsigned int height, double ppmAlpha);
20 | RENDER_ENGINE_EXPORT_API unsigned int getWidth() const;
21 | RENDER_ENGINE_EXPORT_API unsigned int getHeight() const;
22 | RENDER_ENGINE_EXPORT_API double getPPMAlpha() const;
23 | RENDER_ENGINE_EXPORT_API const Camera & getCamera() const;
24 | RENDER_ENGINE_EXPORT_API const QByteArray & getSceneName() const;
25 | RENDER_ENGINE_EXPORT_API const RenderMethod::E getRenderMethod() const;
26 | private:
27 | Camera m_camera;
28 | RenderMethod::E m_renderMethod;
29 | unsigned int m_width;
30 | unsigned int m_height;
31 | double m_ppmAlpha;
32 | QByteArray m_sceneName;
33 | };
34 |
35 | class QDataStream;
36 | RENDER_ENGINE_EXPORT_API QDataStream & operator << (QDataStream & out, const RenderServerRenderRequestDetails & details);
37 | RENDER_ENGINE_EXPORT_API QDataStream & operator >> (QDataStream & in, RenderServerRenderRequestDetails & details);
38 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/config.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 |
9 | #define PPM_X ( 1 << 0 )
10 | #define PPM_Y ( 1 << 1 )
11 | #define PPM_Z ( 1 << 2 )
12 | #define PPM_LEAF ( 1 << 3 )
13 | #define PPM_NULL ( 1 << 4 )
14 |
15 | #define ACCELERATION_STRUCTURE_UNIFORM_GRID 0
16 | #define ACCELERATION_STRUCTURE_KD_TREE_CPU 1
17 | #define ACCELERATION_STRUCTURE_STOCHASTIC_HASH 2
18 | #define ACCELERATION_STRUCTURE (ACCELERATION_STRUCTURE_UNIFORM_GRID)
19 |
20 | #if ACCELERATION_STRUCTURE == ACCELERATION_STRUCTURE_STOCHASTIC_HASH
21 | #define MAX_PHOTONS_DEPOSITS_PER_EMITTED 1
22 | #else
23 | #define MAX_PHOTONS_DEPOSITS_PER_EMITTED 4
24 | #endif
25 |
26 | #define ENABLE_RENDER_DEBUG_OUTPUT 0
27 | #define ENABLE_PARTICIPATING_MEDIA 0
28 |
29 | #define MAX_PHOTON_TRACE_DEPTH (ENABLE_PARTICIPATING_MEDIA?15:7)
30 | #define MAX_RADIANCE_TRACE_DEPTH 9
31 | #define NUM_VOLUMETRIC_PHOTONS 200000
32 | #define PHOTON_TRACING_RR_START_DEPTH 3
33 | #define PATH_TRACING_RR_START_DEPTH 3
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/geometry_instance/AABInstance.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "AABInstance.h"
8 |
9 | bool AABInstance::m_hasLoadedOptixPrograms = false;
10 | optix::Program AABInstance::m_programBoundingBox;
11 | optix::Program AABInstance::m_programIntersection;
12 |
13 | AABInstance::AABInstance(Material & _material, const AAB & aab)
14 | : GeometryInstance(_material),
15 | m_aab(aab)
16 | {
17 |
18 | }
19 |
20 | optix::Geometry AABInstance::getOptixGeometry( optix::Context & context)
21 | {
22 | if(m_hasLoadedOptixPrograms == false)
23 | {
24 | m_programBoundingBox = context->createProgramFromPTXFile("AAB.cu.ptx", "boundingBox");
25 | m_programIntersection = context->createProgramFromPTXFile("AAB.cu.ptx", "intersect");
26 | m_hasLoadedOptixPrograms = true;
27 | }
28 |
29 | optix::Geometry geometry = context->createGeometry();
30 | geometry->setPrimitiveCount(1u);
31 | geometry->setBoundingBoxProgram(m_programBoundingBox);
32 | geometry->setIntersectionProgram(m_programIntersection);
33 |
34 | geometry["cuboidMin"]->setFloat( this->m_aab.min );
35 | geometry["cuboidMax"]->setFloat( this->m_aab.max );
36 |
37 | return geometry;
38 | }
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/geometry_instance/AABInstance.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 |
9 | #include
10 | #include "GeometryInstance.h"
11 | #include "material/Material.h"
12 | #include "math/AAB.h"
13 |
14 | class AABInstance : public GeometryInstance
15 | {
16 | public:
17 | AABInstance(Material& material, const AAB & aab);
18 | private:
19 | AAB m_aab;
20 | virtual optix::Geometry getOptixGeometry(optix::Context & context);
21 |
22 | static optix::Program m_programBoundingBox;
23 | static optix::Program m_programIntersection;
24 | static bool m_hasLoadedOptixPrograms;
25 |
26 | };
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/geometry_instance/GeometryInstance.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "GeometryInstance.h"
8 | #include "material/Material.h"
9 | optix::GeometryInstance GeometryInstance::getOptixGeometryInstance( optix::Context & context )
10 | {
11 | optix::Geometry sphereGeometry = this->getOptixGeometry(context);
12 | optix::Material omaterial = this->m_material.getOptixMaterial(context);
13 | optix::GeometryInstance gi = context->createGeometryInstance( sphereGeometry, &omaterial, &omaterial+1 );
14 | this->m_material.registerGeometryInstanceValues(gi);
15 | return gi;
16 | }
17 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/geometry_instance/GeometryInstance.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include
9 |
10 | class Material;
11 | class GeometryInstance
12 | {
13 | protected:
14 | Material & m_material;
15 | GeometryInstance(Material & _material) : m_material(_material) {};
16 | protected:
17 | virtual optix::Geometry getOptixGeometry( optix::Context & context) = 0;
18 | public:
19 | optix::GeometryInstance getOptixGeometryInstance(optix::Context & context);
20 | };
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/geometry_instance/SphereInstance.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "SphereInstance.h"
8 | #include "math/Sphere.h"
9 |
10 | bool SphereInstance::m_hasLoadedOptixPrograms = false;
11 | optix::Program SphereInstance::m_programBoundingBox;
12 | optix::Program SphereInstance::m_programIntersection;
13 |
14 | SphereInstance::SphereInstance(Material & _material, const Sphere & sphere)
15 | : GeometryInstance(_material),
16 | m_sphere(sphere)
17 | {
18 |
19 | }
20 |
21 | optix::Geometry SphereInstance::getOptixGeometry( optix::Context & context)
22 | {
23 | if(m_hasLoadedOptixPrograms == false)
24 | {
25 | m_programBoundingBox = context->createProgramFromPTXFile("Sphere.cu.ptx", "boundingBox");
26 | m_programIntersection = context->createProgramFromPTXFile("Sphere.cu.ptx", "intersect");
27 | m_hasLoadedOptixPrograms = true;
28 | }
29 |
30 | optix::Geometry sphere = context->createGeometry();
31 | sphere->setPrimitiveCount(1);
32 | sphere->setIntersectionProgram( m_programIntersection );
33 | sphere->setBoundingBoxProgram( m_programBoundingBox );
34 |
35 | sphere["radius"]->setFloat( this->m_sphere.radius );
36 | sphere["center"]->setFloat( this->m_sphere.center );
37 |
38 | return sphere;
39 | }
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/geometry_instance/SphereInstance.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 |
9 | #include "GeometryInstance.h"
10 | #include "material/Material.h"
11 | #include "math/Sphere.h"
12 |
13 | class Sphere;
14 | class SphereInstance : public GeometryInstance
15 | {
16 | private:
17 | Sphere m_sphere;
18 | static optix::Program m_programBoundingBox;
19 | static optix::Program m_programIntersection;
20 | static bool m_hasLoadedOptixPrograms;
21 | public:
22 | SphereInstance(Material& material, const Sphere & sphere);
23 | virtual optix::Geometry getOptixGeometry(optix::Context & context);
24 | };
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/geometry_instance/Transform.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "Transform.h"
8 |
9 | Transform::Transform()
10 | {
11 | this->arr[0] = 1;
12 | this->arr[1] = 0;
13 | this->arr[2] = 0;
14 | this->arr[3] = 0;
15 | this->arr[4] = 0;
16 | this->arr[5] = 1;
17 | this->arr[6] = 0;
18 | this->arr[7] = 0;
19 | this->arr[8] = 0;
20 | this->arr[9] = 0;
21 | this->arr[10] = 1;
22 | this->arr[11] = 0;
23 | this->arr[12] = 0;
24 | this->arr[13] = 0;
25 | this->arr[14] = 0;
26 | this->arr[15] = 1;
27 | }
28 |
29 | optix::Transform Transform::getOptixTransform( optix::Context& context )
30 | {
31 | optix::Transform t = context->createTransform();
32 | t->setMatrix(false, this->arr, NULL);
33 | return t;
34 | }
35 |
36 | void Transform::translate( float x, float y, float z )
37 | {
38 | this->arr[3] += x;
39 | this->arr[7] += y;
40 | this->arr[11] += z;
41 | }
42 |
43 | void Transform::scale( float scale )
44 | {
45 | this->arr[0] *= scale;
46 | this->arr[5] *= scale;
47 | this->arr[10] *= scale;
48 | }
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/geometry_instance/Transform.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include
9 |
10 | class Transform
11 | {
12 | private:
13 | float arr[16];
14 | public:
15 | Transform();
16 | optix::Transform getOptixTransform(optix::Context& context);
17 | void translate( float x, float y, float z );
18 | void scale( float scale );
19 | };
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/main.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include
8 | #include
9 | //#include
10 |
11 | BOOLEAN WINAPI DllMain( IN HINSTANCE hDllHandle,
12 | IN DWORD nReason,
13 | IN LPVOID Reserved )
14 | {
15 | return TRUE;
16 | }
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/material/Diffuse.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "Diffuse.h"
8 | #include "renderer/RayType.h"
9 |
10 | bool Diffuse::m_optixMaterialIsCreated = false;
11 | optix::Material Diffuse::m_optixMaterial;
12 |
13 | Diffuse::Diffuse(const Vector3 & Kd)
14 | {
15 | this->Kd = Kd;
16 | }
17 |
18 | optix::Material Diffuse::getOptixMaterial(optix::Context & context)
19 | {
20 | if(!m_optixMaterialIsCreated)
21 | {
22 | m_optixMaterial = context->createMaterial();
23 | optix::Program radianceProgram = context->createProgramFromPTXFile( "Diffuse.cu.ptx", "closestHitRadiance");
24 | optix::Program photonProgram = context->createProgramFromPTXFile( "Diffuse.cu.ptx", "closestHitPhoton");
25 | m_optixMaterial->setClosestHitProgram(RayType::RADIANCE, radianceProgram);
26 | m_optixMaterial->setClosestHitProgram(RayType::RADIANCE_IN_PARTICIPATING_MEDIUM, radianceProgram);
27 | m_optixMaterial->setClosestHitProgram(RayType::PHOTON, photonProgram);
28 | m_optixMaterial->setClosestHitProgram(RayType::PHOTON_IN_PARTICIPATING_MEDIUM, photonProgram);
29 | m_optixMaterial->validate();
30 |
31 | this->registerMaterialWithShadowProgram(context, m_optixMaterial);
32 | m_optixMaterialIsCreated = true;
33 | }
34 | return m_optixMaterial;
35 | }
36 |
37 | /*
38 | // Register any material-dependent values to be available in the optix program.
39 | */
40 |
41 | void Diffuse::registerGeometryInstanceValues(optix::GeometryInstance & instance )
42 | {
43 | instance["Kd"]->setFloat(this->Kd);
44 | }
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/material/Diffuse.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "Material.h"
9 | #include "math/Vector3.h"
10 |
11 | class Diffuse : public Material
12 | {
13 | private:
14 | Vector3 Kd;
15 | static bool m_optixMaterialIsCreated;
16 | static optix::Material m_optixMaterial;
17 | public:
18 | Diffuse(const Vector3 & Kd);
19 | virtual optix::Material getOptixMaterial(optix::Context & context);
20 | virtual void registerGeometryInstanceValues(optix::GeometryInstance & instance);
21 | };
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/material/DiffuseEmitter.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "DiffuseEmitter.h"
8 | #include "renderer/RayType.h"
9 |
10 | bool DiffuseEmitter::m_optixMaterialIsCreated = false;
11 | optix::Material DiffuseEmitter::m_optixMaterial;
12 |
13 | DiffuseEmitter::DiffuseEmitter(const Vector3 & power, const Vector3 & Kd)
14 | : m_power(power), m_Kd(Kd), m_inverseArea(0)
15 | {
16 | m_power.x *= Kd.x;
17 | m_power.y *= Kd.y;
18 | m_power.z *= Kd.z;
19 | }
20 |
21 | optix::Material DiffuseEmitter::getOptixMaterial(optix::Context & context)
22 | {
23 | if(!m_optixMaterialIsCreated)
24 | {
25 | optix::Program radianceProgram = context->createProgramFromPTXFile( "DiffuseEmitter.cu.ptx", "closestHitRadiance");
26 | m_optixMaterial = context->createMaterial();
27 | m_optixMaterial->setClosestHitProgram(RayType::RADIANCE, radianceProgram);
28 | m_optixMaterial->setClosestHitProgram(RayType::RADIANCE_IN_PARTICIPATING_MEDIUM, radianceProgram);
29 | m_optixMaterial->setClosestHitProgram(RayType::PHOTON, context->createProgramFromPTXFile( "DiffuseEmitter.cu.ptx", "closestHitPhoton") );
30 | m_optixMaterial->setAnyHitProgram(RayType::SHADOW, context->createProgramFromPTXFile( "DiffuseEmitter.cu.ptx", "gatherAnyHitOnEmitter"));
31 | this->registerMaterialWithShadowProgram(context, m_optixMaterial);
32 | m_optixMaterialIsCreated = true;
33 | }
34 | return m_optixMaterial;
35 | }
36 |
37 | /*
38 | // Register any material-dependent values to be available in the optix program.
39 | */
40 |
41 | void DiffuseEmitter::registerGeometryInstanceValues(optix::GeometryInstance & instance )
42 | {
43 | instance["Kd"]->setFloat(m_Kd);
44 | instance["Ks"]->setFloat(0.0f, 0.0f, 0.0f);
45 | optix::float3 powerPerArea = m_power;
46 |
47 | powerPerArea.x *= m_inverseArea;
48 | powerPerArea.y *= m_inverseArea;
49 | powerPerArea.z *= m_inverseArea;
50 |
51 | instance["powerPerArea"]->setFloat(powerPerArea);
52 | instance["power"]->setFloat(m_power);
53 | }
54 |
55 | Vector3 DiffuseEmitter::getPower() const
56 | {
57 | return m_power;
58 | }
59 |
60 | void DiffuseEmitter::setInverseArea( float inverseArea )
61 | {
62 | m_inverseArea = inverseArea;
63 | }
64 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/material/DiffuseEmitter.cu:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include
8 | #include
9 | #include "renderer/RadiancePRD.h"
10 | #include "renderer/ShadowPRD.h"
11 | #include "renderer/ppm/PhotonPRD.h"
12 |
13 | using namespace optix;
14 |
15 | rtDeclareVariable(float3, shadingNormal, attribute shadingNormal, );
16 | rtDeclareVariable(optix::Ray, ray, rtCurrentRay, );
17 | rtDeclareVariable(float, tHit, rtIntersectionDistance, );
18 | rtDeclareVariable(RadiancePRD, radiancePrd, rtPayload, );
19 | rtDeclareVariable(float3, powerPerArea, , );
20 | rtDeclareVariable(float3, Kd, , );
21 | rtDeclareVariable(ShadowPRD, shadowPrd, rtPayload, );
22 | rtDeclareVariable(PhotonPRD, photonPrd, rtPayload, );
23 |
24 | /*
25 | // Radiance Program
26 | */
27 |
28 | RT_PROGRAM void closestHitRadiance()
29 | {
30 | float3 worldShadingNormal = normalize( rtTransformNormal( RT_OBJECT_TO_WORLD, shadingNormal ) );
31 | float3 Le = powerPerArea/M_PIf;
32 | radiancePrd.radiance += radiancePrd.attenuation*Le;
33 | radiancePrd.flags |= PRD_HIT_EMITTER;
34 | radiancePrd.lastTHit = tHit;
35 | }
36 |
37 | /*
38 | // Photon Program
39 | */
40 |
41 | RT_PROGRAM void closestHitPhoton()
42 | {
43 | photonPrd.depth++;
44 | }
45 |
46 | RT_PROGRAM void gatherAnyHitOnEmitter()
47 | {
48 | shadowPrd.attenuation = 1.0f;
49 | rtTerminateRay();
50 | }
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/material/DiffuseEmitter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "Material.h"
9 | #include "math/Vector3.h"
10 |
11 | class DiffuseEmitter : public Material
12 | {
13 | private:
14 | Vector3 m_power;
15 | Vector3 m_Kd;
16 | static bool m_optixMaterialIsCreated;
17 | static optix::Material m_optixMaterial;
18 | float m_inverseArea;
19 | public:
20 | DiffuseEmitter(const Vector3 & power, const Vector3 & Kd);
21 | virtual optix::Material getOptixMaterial(optix::Context & context);
22 | virtual void registerGeometryInstanceValues(optix::GeometryInstance & instance);
23 | Vector3 getPower() const;
24 | void setInverseArea(float inverseArea);
25 | };
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/material/Glass.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "Glass.h"
8 | #include "renderer/RayType.h"
9 |
10 | bool Glass::m_optixMaterialIsCreated = false;
11 | optix::Material Glass::m_optixMaterial;
12 |
13 | Glass::Glass( float indexOfRefraction, const Vector3 & Ks )
14 | {
15 | this->indexOfRefraction = indexOfRefraction;
16 | this->Ks = Ks;
17 | }
18 |
19 | optix::Material Glass::getOptixMaterial(optix::Context & context)
20 | {
21 | if(!m_optixMaterialIsCreated)
22 | {
23 | m_optixMaterial = context->createMaterial();
24 | optix::Program radianceClosestProgram = context->createProgramFromPTXFile( "Glass.cu.ptx", "closestHitRadiance");
25 | optix::Program radianceAnyHitProgram = context->createProgramFromPTXFile( "Glass.cu.ptx", "anyHitRadiance");
26 | optix::Program photonClosestProgram = context->createProgramFromPTXFile( "Glass.cu.ptx", "closestHitPhoton");
27 | optix::Program photonAnyHitProgram = context->createProgramFromPTXFile( "Glass.cu.ptx", "anyHitPhoton");
28 |
29 | m_optixMaterial->setClosestHitProgram(RayType::RADIANCE, radianceClosestProgram);
30 | //m_optixMaterial->setAnyHitProgram(RayType::RADIANCE, radianceAnyHitProgram );
31 | m_optixMaterial->setClosestHitProgram(RayType::RADIANCE_IN_PARTICIPATING_MEDIUM, radianceClosestProgram);
32 | //m_optixMaterial->setAnyHitProgram(RayType::RADIANCE_IN_PARTICIPATING_MEDIUM, radianceAnyHitProgram);
33 |
34 | m_optixMaterial->setClosestHitProgram(RayType::PHOTON, photonClosestProgram);
35 | //m_optixMaterial->setAnyHitProgram(RayType::PHOTON, photonAnyHitProgram);
36 | m_optixMaterial->setClosestHitProgram(RayType::PHOTON_IN_PARTICIPATING_MEDIUM, photonClosestProgram);
37 | // m_optixMaterial->setAnyHitProgram(RayType::PHOTON_IN_PARTICIPATING_MEDIUM, photonAnyHitProgram);
38 |
39 | this->registerMaterialWithShadowProgram(context, m_optixMaterial);
40 | m_optixMaterialIsCreated = true;
41 | }
42 |
43 | return m_optixMaterial;
44 | }
45 |
46 | /*
47 | // Register any material-dependent values to be available in the optix program.
48 | */
49 | void Glass::registerGeometryInstanceValues(optix::GeometryInstance & instance )
50 | {
51 | instance["indexOfRefraction"]->setFloat(this->indexOfRefraction);
52 | instance["Kd"]->setFloat( 0, 0 , 0 );
53 | instance["Ks"]->setFloat(this->Ks);
54 | }
55 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/material/Glass.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "Material.h"
9 | #include "math/Vector3.h"
10 |
11 | class Glass : public Material
12 | {
13 | private:
14 | float indexOfRefraction;
15 | Vector3 Ks;
16 | static bool m_optixMaterialIsCreated;
17 | static optix::Material m_optixMaterial;
18 | public:
19 | Glass(float indexOfRefraction, const Vector3 & Ks);
20 | virtual optix::Material getOptixMaterial(optix::Context & context);
21 | virtual void registerGeometryInstanceValues(optix::GeometryInstance & instance);
22 | };
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/material/Material.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "Material.h"
8 | #include "renderer/RayType.h"
9 |
10 | bool Material::m_hasLoadedOptixAnyHitProgram = false;
11 | optix::Program Material::m_optixAnyHitProgram;
12 |
13 | Material::~Material()
14 | {
15 |
16 | }
17 |
18 | void Material::registerMaterialWithShadowProgram( optix::Context & context, optix::Material & material )
19 | {
20 | if(!m_hasLoadedOptixAnyHitProgram)
21 | {
22 | m_optixAnyHitProgram = context->createProgramFromPTXFile( "DirectRadianceEstimation.cu.ptx", "gatherAnyHitOnNonEmitter");
23 | m_hasLoadedOptixAnyHitProgram = true;
24 | }
25 | material->setAnyHitProgram(RayType::SHADOW, m_optixAnyHitProgram);
26 | }
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/material/Material.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include
9 | class Material
10 | {
11 | public:
12 | Material(){}
13 | virtual ~Material();
14 | virtual optix::Material getOptixMaterial(optix::Context & context) = 0;
15 | virtual void registerGeometryInstanceValues( optix::GeometryInstance & instance ) = 0;
16 | protected:
17 | static void registerMaterialWithShadowProgram(optix::Context & context, optix::Material & material);
18 | private:
19 | static bool m_hasLoadedOptixAnyHitProgram;
20 | static optix::Program m_optixAnyHitProgram;
21 | };
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/material/Mirror.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "Mirror.h"
8 | #include "renderer/RayType.h"
9 |
10 | bool Mirror::m_optixMaterialIsCreated = false;
11 | optix::Material Mirror::m_optixMaterial;
12 |
13 | Mirror::Mirror(const Vector3 & Kr)
14 | {
15 | this->Kr = Kr;
16 | }
17 |
18 | optix::Material Mirror::getOptixMaterial(optix::Context & context)
19 | {
20 | if(!m_optixMaterialIsCreated)
21 | {
22 | optix::Program photonProgram = context->createProgramFromPTXFile( "Mirror.cu.ptx", "closestHitPhoton");
23 | optix::Program radianceProgram = context->createProgramFromPTXFile( "Mirror.cu.ptx", "closestHitRadiance");
24 | m_optixMaterial = context->createMaterial();
25 | m_optixMaterial->setClosestHitProgram(RayType::RADIANCE, radianceProgram);
26 | m_optixMaterial->setClosestHitProgram(RayType::RADIANCE_IN_PARTICIPATING_MEDIUM, radianceProgram);
27 | m_optixMaterial->setClosestHitProgram(RayType::PHOTON, photonProgram);
28 | m_optixMaterial->setClosestHitProgram(RayType::PHOTON_IN_PARTICIPATING_MEDIUM, photonProgram);
29 | this->registerMaterialWithShadowProgram(context, m_optixMaterial);
30 | m_optixMaterialIsCreated = true;
31 | }
32 | return m_optixMaterial;
33 | }
34 |
35 | void Mirror::registerGeometryInstanceValues(optix::GeometryInstance & instance )
36 | {
37 | instance["Kr"]->setFloat(this->Kr);
38 | }
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/material/Mirror.cu:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include
8 | #include
9 | #include "config.h"
10 | #include "renderer/RayType.h"
11 | #include "renderer/RadiancePRD.h"
12 | #include "renderer/ppm/PhotonPRD.h"
13 | #include "renderer/ppm/Photon.h"
14 |
15 | using namespace optix;
16 |
17 | rtDeclareVariable(uint2, launchIndex, rtLaunchIndex, );
18 | rtDeclareVariable(PhotonPRD, photonPrd, rtPayload, );
19 | rtDeclareVariable(RadiancePRD, radiancePrd, rtPayload, );
20 | rtDeclareVariable(optix::Ray, ray, rtCurrentRay, );
21 | rtDeclareVariable(float, tHit, rtIntersectionDistance, );
22 |
23 | rtDeclareVariable(float3, geometricNormal, attribute geometricNormal, );
24 | rtDeclareVariable(float3, shadingNormal, attribute shadingNormal, );
25 |
26 | rtDeclareVariable(rtObject, sceneRootObject, , );
27 | rtDeclareVariable(float3, Kr, , );
28 |
29 |
30 | RT_PROGRAM void closestHitRadiance()
31 | {
32 | float3 worldShadingNormal = normalize( rtTransformNormal( RT_OBJECT_TO_WORLD, shadingNormal ) );
33 | float3 hitPoint = ray.origin + tHit*ray.direction;
34 | radiancePrd.depth++;
35 | if(radiancePrd.depth <= MAX_RADIANCE_TRACE_DEPTH)
36 | {
37 | radiancePrd.attenuation *= Kr;
38 | float3 newRayDirection = reflect(ray.direction, worldShadingNormal);
39 | Ray newRay ( hitPoint, newRayDirection, RayType::RADIANCE, 0.0001, RT_DEFAULT_MAX );
40 | rtTrace( sceneRootObject, newRay, radiancePrd );
41 | }
42 | radiancePrd.lastTHit = tHit;
43 | }
44 |
45 | RT_PROGRAM void closestHitPhoton()
46 | {
47 | float3 worldShadingNormal = normalize( rtTransformNormal( RT_OBJECT_TO_WORLD, shadingNormal ) );
48 | float3 hitPoint = ray.origin + tHit*ray.direction;
49 | photonPrd.depth++;
50 | if (photonPrd.depth <= MAX_PHOTON_TRACE_DEPTH)
51 | {
52 | photonPrd.power *= Kr;
53 | float3 newPhotonDirection = reflect(ray.direction, worldShadingNormal);
54 | Ray newPhoton (hitPoint, newPhotonDirection, RayType::PHOTON, 0.0001 );
55 | rtTrace(sceneRootObject, newPhoton, photonPrd);
56 | }
57 | }
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/material/Mirror.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "Material.h"
9 | #include "math/Vector3.h"
10 |
11 | class Mirror : public Material
12 | {
13 | public:
14 | Mirror(const Vector3 & Kr);
15 | virtual optix::Material getOptixMaterial(optix::Context & context);
16 | virtual void registerGeometryInstanceValues(optix::GeometryInstance & instance);
17 | private:
18 | Vector3 Kr;
19 | static bool m_optixMaterialIsCreated;
20 | static optix::Material m_optixMaterial;
21 | };
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/material/ParticipatingMedium.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "ParticipatingMedium.h"
8 | #include "renderer/RayType.h"
9 |
10 | bool ParticipatingMedium::m_optixMaterialIsCreated = false;
11 | optix::Material ParticipatingMedium::m_optixMaterial;
12 |
13 | ParticipatingMedium::ParticipatingMedium(float sigma_s, float sigma_a)
14 | : m_sigma_a(sigma_a), m_sigma_s(sigma_s)
15 | {
16 | }
17 |
18 | optix::Material ParticipatingMedium::getOptixMaterial(optix::Context & context)
19 | {
20 | if(!m_optixMaterialIsCreated)
21 | {
22 | optix::Program radianceProgram = context->createProgramFromPTXFile( "ParticipatingMedium.cu.ptx", "closestHitRadiance");
23 | optix::Program photonProgram = context->createProgramFromPTXFile( "ParticipatingMedium.cu.ptx", "closestHitPhoton");
24 | //optix::Program transmissionProgram = context->createProgramFromPTXFile( "ParticipatingMedium.cu.ptx", "radianceTransmission");
25 |
26 | m_optixMaterial = context->createMaterial();
27 | m_optixMaterial->setClosestHitProgram(RayType::RADIANCE, radianceProgram);
28 | m_optixMaterial->setClosestHitProgram(RayType::RADIANCE_IN_PARTICIPATING_MEDIUM, radianceProgram);
29 | m_optixMaterial->setClosestHitProgram(RayType::PHOTON, photonProgram);
30 | m_optixMaterial->setClosestHitProgram(RayType::PHOTON_IN_PARTICIPATING_MEDIUM, photonProgram);
31 |
32 | this->registerMaterialWithShadowProgram(context, m_optixMaterial);
33 |
34 | m_optixMaterialIsCreated = true;
35 | }
36 |
37 | return m_optixMaterial;
38 | }
39 |
40 | /*
41 | // Register any material-dependent values to be available in the optix program.
42 | */
43 |
44 | void ParticipatingMedium::registerGeometryInstanceValues(optix::GeometryInstance & instance )
45 | {
46 | instance["participatingMedium"]->setUint(1);
47 | instance["sigma_a"]->setFloat(m_sigma_a);
48 | instance["sigma_s"]->setFloat(m_sigma_s);
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/material/ParticipatingMedium.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "Material.h"
9 |
10 | class ParticipatingMedium : public Material
11 | {
12 | public:
13 | ParticipatingMedium(float sigma_s, float sigma_a);
14 | virtual optix::Material getOptixMaterial(optix::Context & context);
15 | virtual void registerGeometryInstanceValues(optix::GeometryInstance & instance);
16 | private:
17 | //float indexOfRefraction;
18 | static bool m_optixMaterialIsCreated;
19 | static optix::Material m_optixMaterial;
20 | float m_sigma_s;
21 | float m_sigma_a;
22 | };
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/material/Texture.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "Material.h"
9 | class QString;
10 | class Image;
11 | class Texture : public Material
12 | {
13 | public:
14 | Texture(const QString & textureAbsoluteFilePath);
15 | Texture(const QString & textureAbsoluteFilePath, const QString & normalMapAbsoluteFilePath);
16 | virtual ~Texture();
17 | virtual optix::Material getOptixMaterial(optix::Context & context);
18 | virtual void registerGeometryInstanceValues(optix::GeometryInstance & instance);
19 |
20 | private:
21 | void loadDiffuseImage( const QString & textureAbsoluteFilePath );
22 | void loadNormalMapImage( const QString & normalsAbsoluteFilePath );
23 | optix::TextureSampler createTextureSamplerFromBuffer(optix::Context & context, optix::Buffer buffer);
24 | optix::Buffer createBufferFromImage(optix::Context & context, const Image & image);
25 |
26 | static bool m_optixMaterialIsCreated;
27 | static optix::Material m_optixMaterial;
28 | optix::TextureSampler m_diffuseSampler;
29 | optix::TextureSampler m_normalMapSampler;
30 | Image* m_diffuseImage;
31 | Image* m_normalMapImage;
32 | };
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/math/AAB.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "AAB.h"
8 |
9 | AAB::AAB(const Vector3 & min, const Vector3 & max)
10 | {
11 | this->min = min;
12 | this->max = max;
13 | }
14 |
15 | AAB::AAB()
16 | : min(Vector3()), max(Vector3())
17 | {
18 |
19 | }
20 |
21 | Vector3 AAB::getExtent() const
22 | {
23 | return this->max - this->min;
24 | }
25 |
26 | Vector3 AAB::getCenter() const
27 | {
28 | return (min+max)*0.5f;
29 | }
30 |
31 | Sphere AAB::getBoundingSphere() const
32 | {
33 | Vector3 center = getCenter();
34 | Vector3 extent = getExtent();
35 | float radius = (max - center).length();
36 | Sphere sphere(center, radius);
37 | return sphere;
38 | }
39 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/math/AAB.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "Vector3.h"
9 | #include "math/Sphere.h"
10 |
11 | class AAB
12 | {
13 | public:
14 | Vector3 min;
15 | Vector3 max;
16 | AAB(const Vector3 &, const Vector3 &);
17 | AAB();
18 | Vector3 getExtent() const;
19 | Vector3 getCenter() const;
20 | Sphere getBoundingSphere() const;
21 | void addPadding(float a)
22 | {
23 | min -= a;
24 | max += a;
25 | }
26 | };
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/math/Sphere.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "Sphere.h"
8 |
9 | Sphere::Sphere(const Vector3 & center, float radius)
10 | {
11 | this->center = center;
12 | this->radius = radius;
13 | }
14 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/math/Sphere.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "math/Vector3.h"
9 |
10 | class Sphere
11 | {
12 | public:
13 | Vector3 center;
14 | float radius;
15 | #ifdef __CUDACC__
16 | __device__
17 | #endif
18 | Sphere()
19 | {
20 |
21 | }
22 | Sphere(const Vector3 & center, float radius);
23 | };
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/math/Vector3.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "Vector3.h"
8 | #include
9 |
10 | Vector3 Vector3::operator+( const Vector3 & other ) const
11 | {
12 | return Vector3(this->x + other.x, this->y + other.y, this->z + other.z);
13 | }
14 |
15 | Vector3 Vector3::operator-( const Vector3 & other ) const
16 | {
17 | return Vector3(this->x - other.x, this->y - other.y, this->z - other.z);
18 | }
19 |
20 | Vector3 Vector3::operator*( float scale ) const
21 | {
22 | return Vector3(this->x*scale, this->y*scale, this->z*scale);
23 | }
24 |
25 | float Vector3::length2()
26 | {
27 | return dot(*this, *this);
28 | }
29 |
30 | float Vector3::dot( const Vector3 & a, const Vector3 & b )
31 | {
32 | return a.x*b.x + a.y*b.y + a.z*b.x;
33 | }
34 |
35 | float Vector3::length()
36 | {
37 | return sqrtf(length2());
38 | }
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/math/Vector3.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include
9 |
10 | #ifdef __CUDACC__
11 | #define _VECTOR3_DEVICE_CODE_ __device__ __host__
12 | #else
13 | #define _VECTOR3_DEVICE_CODE_
14 | #endif
15 |
16 | class Vector3
17 | {
18 | public:
19 | _VECTOR3_DEVICE_CODE_ Vector3()
20 | {
21 |
22 | }
23 | _VECTOR3_DEVICE_CODE_ Vector3(const optix::float3 & f3)
24 | {
25 | __of3 = f3;
26 | }
27 | _VECTOR3_DEVICE_CODE_ Vector3(float a)
28 | {
29 | this->x = a;
30 | this->y = a;
31 | this->z = a;
32 | }
33 | _VECTOR3_DEVICE_CODE_ Vector3(float x, float y, float z)
34 | {
35 | this->x = x;
36 | this->y = y;
37 | this->z = z;
38 | }
39 |
40 | _VECTOR3_DEVICE_CODE_ operator optix::float3 () const
41 | {
42 | return __of3;
43 | }
44 |
45 | #ifndef __CUDACC__
46 | Vector3 operator + (const Vector3 & other) const;
47 | Vector3 operator - (const Vector3 & other) const;
48 | Vector3 operator * (float) const;
49 | float length();
50 | float length2();
51 | #endif
52 |
53 | union
54 | {
55 | struct {float x, y, z;};
56 | optix::float3 __of3;
57 | };
58 | static float dot(const Vector3 & a, const Vector3 & b);
59 | };
60 |
61 | __inline__ Vector3 operator += (Vector3 & a, float b)
62 | {
63 | a.x += b;
64 | a.y += b;
65 | a.z += b;
66 | return a;
67 | }
68 |
69 | __inline__ Vector3 operator -= (Vector3 & a, float b)
70 | {
71 | a += -b;
72 | return a;
73 | }
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/render_engine_export_api.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #ifndef RENDER_ENGINE_EXPORT_API
9 | # ifdef RENDER_ENGINE_DLL
10 | # define RENDER_ENGINE_EXPORT_API __declspec(dllexport)
11 | # define RENDER_ENGINE_EXPORT_API_QT Q_DECL_EXPORT
12 | # else
13 | # define RENDER_ENGINE_EXPORT_API __declspec(dllimport)
14 | # define RENDER_ENGINE_EXPORT_API_QT Q_DECL_IMPORT
15 | # endif
16 | #endif
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/Camera.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "render_engine_export_api.h"
4 | #include
5 | #include
6 | #include "math/Vector3.h"
7 |
8 | class Camera
9 | {
10 | //typedef optix::float3 float3;
11 |
12 | public:
13 | enum AspectRatioMode
14 | {
15 | KeepVertical,
16 | KeepHorizontal,
17 | KeepNone
18 | };
19 |
20 | #ifdef __CUDACC__
21 | Camera()
22 | {
23 |
24 | }
25 | ~Camera()
26 | {
27 |
28 | }
29 | #else
30 |
31 | RENDER_ENGINE_EXPORT_API Camera()
32 | {
33 | eye = Vector3(1,1,1);
34 | lookat = Vector3(0,0,0);
35 | up = Vector3(0,1,0);
36 | hfov = 60.0;
37 | vfov = 60.0;
38 | aperture = 0;
39 | aspectRatioMode = KeepVertical;
40 | setup();
41 | }
42 |
43 | RENDER_ENGINE_EXPORT_API Camera(Vector3 _eye, Vector3 _lookat)
44 | : eye(_eye), lookat(_lookat)
45 | {
46 | up = Vector3(0,1,0);
47 | hfov = 60.0;
48 | vfov = 60.0;
49 | aperture = 0;
50 | aspectRatioMode = KeepVertical;
51 | setup();
52 | }
53 |
54 | RENDER_ENGINE_EXPORT_API Camera(Vector3 eye, Vector3 lookat, Vector3 up, float hfov=60, float vfov=60, float aperture=0,
55 | AspectRatioMode arm = KeepVertical);
56 |
57 | RENDER_ENGINE_EXPORT_API void setup();
58 | RENDER_ENGINE_EXPORT_API void scaleFOV(float);
59 | RENDER_ENGINE_EXPORT_API void translate(float, float);
60 | RENDER_ENGINE_EXPORT_API void dolly(float);
61 | RENDER_ENGINE_EXPORT_API void transform( const optix::Matrix4x4& trans );
62 | RENDER_ENGINE_EXPORT_API void setAspectRatio(float ratio);
63 | RENDER_ENGINE_EXPORT_API void setParameters(Vector3 eye_in, Vector3 lookat_in, Vector3 up_in, float hfov_in, float vfov_in, Camera::AspectRatioMode aspectRatioMode_in);
64 |
65 | #endif
66 |
67 | optix::float3 eye, lookat, up;
68 | float hfov, vfov;
69 | float aperture;
70 | optix::float3 lookdir, camera_u, camera_v;
71 | AspectRatioMode aspectRatioMode;
72 | };
73 |
74 | class QDataStream;
75 | RENDER_ENGINE_EXPORT_API QDataStream & operator << (QDataStream & out, const Camera & camera);
76 | RENDER_ENGINE_EXPORT_API QDataStream & operator >> (QDataStream & in, Camera & camera);
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/Hitpoint.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "config.h"
9 | #include "renderer/RadiancePRD.h"
10 | struct Hitpoint
11 | {
12 | optix::float3 position;
13 | optix::float3 normal;
14 | optix::float3 attenuation;
15 | optix::float3 radiance;
16 | optix::uint flags;
17 | optix::float3 volumetricRadiance;
18 | };
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/Light.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "Light.h"
8 | #include
9 | #include "render_engine_export_api.h"
10 |
11 | Light::Light( Vector3 power, Vector3 position, Vector3 v1, Vector3 v2 )
12 | : power(power),
13 | position(position),
14 | v1(v1),
15 | v2(v2),
16 | lightType(LightType::AREA)
17 | {
18 | optix::float3 crossProduct = optix::cross(v1, v2);
19 | normal = Vector3(optix::normalize(crossProduct));
20 | area = length(crossProduct);
21 | inverseArea = 1.0f/area;
22 | }
23 |
24 | Light::Light(Vector3 power, Vector3 position)
25 | : power(power),
26 | position(position),
27 | lightType(LightType::POINT)
28 | {
29 |
30 | }
31 |
32 | Light::Light( Vector3 power, Vector3 position, Vector3 direction, float angle )
33 | : power(power), position(position), direction(direction), angle(angle), lightType(LightType::SPOT)
34 | {
35 | direction = optix::normalize(direction);
36 | }
37 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/Light.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "math/Vector3.h"
9 | #include "render_engine_export_api.h"
10 |
11 | class Light
12 | {
13 | public:
14 | enum LightType {AREA, POINT, SPOT};
15 |
16 | #ifndef __CUDACC__
17 | RENDER_ENGINE_EXPORT_API Light(){};
18 | RENDER_ENGINE_EXPORT_API Light(Vector3 power, Vector3 position, Vector3 v1, Vector3 v2);
19 | RENDER_ENGINE_EXPORT_API Light(Vector3 power, Vector3 position);
20 | RENDER_ENGINE_EXPORT_API Light(Vector3 power, Vector3 position, Vector3 direction, float angle);
21 |
22 | #endif
23 |
24 | optix::float3 power;
25 | optix::float3 position;
26 | optix::float3 v1;
27 | optix::float3 v2;
28 |
29 | float inverseArea;
30 | union
31 | {
32 | float area; // area
33 | float angle; // spot
34 | };
35 |
36 | union
37 | {
38 | optix::float3 normal; // area
39 | optix::float3 direction; // spot
40 | };
41 |
42 | LightType lightType;
43 | };
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/OptixEntryPoint.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 |
9 | namespace OptixEntryPoint
10 | {
11 | enum {
12 | PPM_RAYTRACE_PASS,
13 | PPM_PHOTON_PASS,
14 | PPM_INDIRECT_RADIANCE_ESTIMATION_PASS,
15 | PPM_DIRECT_RADIANCE_ESTIMATION_PASS,
16 | PPM_OUTPUT_PASS,
17 | PT_RAYTRACE_PASS,
18 | #if ENABLE_PARTICIPATING_MEDIA
19 | PPM_CLEAR_VOLUMETRIC_PHOTONS_PASS,
20 | #endif
21 | #if ACCELERATION_STRUCTURE == ACCELERATION_STRUCTURE_STOCHASTIC_HASH
22 | PPM_CLEAR_PHOTONS_UNIFORM_GRID_PASS,
23 | #endif
24 | NUM_PASSES
25 | };
26 | }
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/RadiancePRD.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "RandomState.h"
9 |
10 | struct RadiancePRD
11 | {
12 | optix::float3 attenuation;
13 | optix::float3 radiance;
14 | optix::uint depth;
15 | optix::float3 position;
16 | optix::float3 normal;
17 | optix::uint flags;
18 | union
19 | {
20 | optix::float3 randomNewDirection;
21 | optix::float3 Le;
22 | };
23 | RandomState randomState;
24 | #if ENABLE_PARTICIPATING_MEDIA
25 | optix::float3 volumetricRadiance;
26 | #endif
27 | float lastTHit;
28 | };
29 |
30 | #define PRD_HIT_EMITTER (1<<31u)
31 | #define PRD_ERROR (1<<30u)
32 | #define PRD_MISS (1<<29u)
33 | #define PRD_HIT_SPECULAR (1<<28u)
34 | #define PRD_HIT_NON_SPECULAR (1<<27u)
35 | #define PRD_PATH_TRACING (1<<26u)
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/RandomState.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 |
9 | //#define USE_CHEAP_RANDOM
10 |
11 | #ifdef USE_CHEAP_RANDOM
12 | #include
13 | typedef uint32_t RandomState;
14 | #else
15 | #include
16 | typedef curandState RandomState;
17 | #endif
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/RayType.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | namespace RayType
9 | {
10 | enum E
11 | {
12 | RADIANCE,
13 | PHOTON,
14 | RADIANCE_IN_PARTICIPATING_MEDIUM,
15 | PHOTON_IN_PARTICIPATING_MEDIUM,
16 | VOLUMETRIC_RADIANCE,
17 | SHADOW,
18 | PARTICIPATING_MEDIUM_TRANSMISSION,
19 | NUM_RAY_TYPES
20 | };
21 | }
22 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/RenderMethod.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | namespace RenderMethod
9 | {
10 | enum E
11 | {
12 | PATH_TRACING,
13 | PROGRESSIVE_PHOTON_MAPPING,
14 | NONE
15 | };
16 | }
17 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/ShadowPRD.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | struct ShadowPRD
9 | {
10 | float attenuation;
11 | };
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/TransmissionPRD.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | struct TransmissionPRD
9 | {
10 | float attenuation;
11 | float enterMediumT;
12 | };
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/helpers/camera.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "samplers.h"
9 |
10 | // If the camera has a aperture > 0, we model it using a thin lens model. Camera.lookdir length is the focal length of the camera.
11 | __inline__ __device__ void modifyRayForDepthOfField(const Camera & camera, optix::float3 & rayOrigin, optix::float3& rayDirection, RandomState& randomState )
12 | {
13 | if(camera.aperture > 0)
14 | {
15 | optix::float3 focalPlaneCenterPoint = camera.eye + camera.lookdir;
16 | optix::float3 camLookDir = optix::normalize(camera.lookdir);
17 |
18 | float focalPlaneT = (optix::dot(camLookDir, focalPlaneCenterPoint) - optix::dot(camLookDir, camera.eye))/optix::dot(camLookDir, rayDirection);
19 | optix::float3 lookAt = rayOrigin + focalPlaneT*rayDirection;
20 |
21 | optix::float2 dofSample = getRandomUniformFloat2(&randomState);
22 | float2 disc = sampleUnitDisc(dofSample);
23 |
24 | rayOrigin += disc.x*camera.camera_u*camera.aperture + disc.y*camera.camera_v*camera.aperture;
25 | rayDirection = optix::normalize(lookAt - rayOrigin);
26 | }
27 | }
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/helpers/helpers.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 |
9 | #if 0
10 | #define OPTIX_DEBUG_PRINT(depth, str, ...) \
11 | if(launchIndex.x == 328 && launchIndex.y == 139){ printf("%d %d: ", launchIndex.x, launchIndex.y); \
12 | for(int i = 0; i < depth; i++){printf(" ");} \
13 | printf(str, __VA_ARGS__); \
14 | }
15 | #else
16 | #define OPTIX_DEBUG_PRINT(depth, str, ...) // nothing
17 | #endif
18 |
19 | // Create ONB from normalized normal (code: Physically Based Rendering, Pharr & Humphreys pg. 63)
20 |
21 | static __device__ __inline__ void createCoordinateSystem( const optix::float3& N, optix::float3& U, optix::float3& V/*, optix::float3& W*/ )
22 | {
23 | using namespace optix;
24 |
25 | if(fabs(N.x) > fabs(N.y))
26 | {
27 | float invLength = 1.f/sqrtf(N.x*N.x + N.z*N.z);
28 | U = make_float3(-N.z*invLength, 0.f, N.x*invLength);
29 | }
30 | else
31 | {
32 | float invLength = 1.f/sqrtf(N.y*N.y + N.z*N.z);
33 | U = make_float3(0.f, N.z*invLength, -N.y*invLength);
34 | }
35 | V = cross(N, U);
36 | }
37 |
38 | static __device__ __host__ __inline__ float maxf(float a, float b)
39 | {
40 | return a > b ? a : b;
41 | }
42 |
43 | // Returns true if ray direction points in the opposite direction
44 | // as the normal, where the normal points outwards from the face
45 | static __device__ __host__ __inline__ bool hitFromOutside(const optix::float3 & rayDirection, const optix::float3 & normal)
46 | {
47 | return (optix::dot(normal, rayDirection) < 0);
48 | }
49 |
50 | static __device__ __inline__ int intmin(int a, int b)
51 | {
52 | return a < b ? a : b;
53 | }
54 |
55 | static __device__ __inline__ float favgf(const optix::float3 & v )
56 | {
57 | return (v.x+v.y+v.z)*0.3333333333f;
58 | }
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/helpers/light.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 |
9 | #include "renderer/Light.h"
10 | #include "random.h"
11 | #include "helpers.h"
12 | #include "renderer/ShadowPRD.h"
13 | #include "renderer/TransmissionPRD.h"
14 |
15 | optix::float3 __inline __device__ getLightContribution(const Light & light, const optix::float3 & rec_position,
16 | const optix::float3 & rec_normal, const rtObject & rootObject, RandomState & randomState)
17 | {
18 | float lightFactor = 1;
19 |
20 | float lightDistance = 0;
21 | float3 pointOnLight;
22 |
23 | if(light.lightType == Light::AREA)
24 | {
25 | float2 sample = getRandomUniformFloat2(&randomState);
26 | pointOnLight = light.position + sample.x*light.v1 + sample.y*light.v2;
27 | }
28 | else if(light.lightType == Light::POINT)
29 | {
30 | pointOnLight = light.position;
31 | lightFactor *= 1.f/4.f;
32 | }
33 | else if(light.lightType == Light::SPOT)
34 | {
35 | // Todo find correct direct light for spot light
36 | lightFactor = 0;
37 | }
38 |
39 | float3 towardsLight = pointOnLight - rec_position;
40 | lightDistance = optix::length(towardsLight);
41 | towardsLight = towardsLight / lightDistance;
42 | float n_dot_l = maxf(0, optix::dot(rec_normal, towardsLight));
43 | lightFactor *= n_dot_l / (M_PIf*lightDistance*lightDistance);
44 |
45 | if(light.lightType == Light::AREA)
46 | {
47 | lightFactor *= maxf(0, optix::dot(-towardsLight, light.normal));
48 | }
49 |
50 | if (lightFactor > 0.0f)
51 | {
52 | ShadowPRD shadowPrd;
53 | shadowPrd.attenuation = 1.0f;
54 | optix::Ray shadow_ray (rec_position, towardsLight, RayType::SHADOW, 0.0001, lightDistance-0.0001);
55 | rtTrace(rootObject, shadow_ray, shadowPrd);
56 | lightFactor *= shadowPrd.attenuation;
57 |
58 |
59 | // Check for participating media transmission
60 | /*#if ENABLE_PARTICIPATING_MEDIA
61 | TransmissionPRD transmissionPrd;
62 | transmissionPrd.attenuation = 1.0f;
63 | optix::Ray transmissionRay (rec_position, towardsLight, RayType::PARTICIPATING_MEDIUM_TRANSMISSION, 0.001, lightDistance-0.01);
64 | rtTrace(rootObject, transmissionRay, transmissionPrd);
65 | lightFactor *= transmissionPrd.attenuation;
66 | #endif
67 | */
68 | //printf("Point on light:%.2f %.2f %.2f shadowPrd.attenuation %.2f\n", pointOnLight.x, pointOnLight.y, pointOnLight.z, shadowPrd.attenuation);
69 | return light.power*lightFactor;
70 | }
71 |
72 | return optix::make_float3(0);
73 | };
74 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/helpers/optix.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 |
9 | template
10 | static T* getDevicePtr(optix::Buffer & buffer, int deviceNumber)
11 | {
12 | CUdeviceptr d;
13 | buffer->getDevicePointer(deviceNumber, &d);
14 | return (T*)d;
15 | }
16 |
17 | template
18 | static thrust::device_ptr getThrustDevicePtr(optix::Buffer & buffer, int deviceNumber)
19 | {
20 | return thrust::device_pointer_cast(getDevicePtr(buffer, deviceNumber));
21 | }
22 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/helpers/random.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 |
9 | #include "renderer/RandomState.h"
10 | #include
11 |
12 | #ifdef USE_CHEAP_RANDOM
13 |
14 | /*
15 | The fast/cheap random generation scheme courtesy of
16 | http://www.reedbeta.com/blog/2013/01/12/quick-and-easy-gpu-random-numbers-in-d3d11/
17 | */
18 |
19 | static uint32_t __host__ __device__ rand_xorshift(uint32_t& state)
20 | {
21 | state ^= (state << 13);
22 | state ^= (state >> 17);
23 | state ^= (state << 5);
24 | return state;
25 | }
26 |
27 | static uint32_t __host__ __device__ wang_hash(uint32_t seed)
28 | {
29 | seed = (seed ^ 61) ^ (seed >> 16);
30 | seed *= 9;
31 | seed = seed ^ (seed >> 4);
32 | seed *= 0x27d4eb2d;
33 | seed = seed ^ (seed >> 15);
34 | return seed;
35 | }
36 |
37 | static void __host__ __device__ initializeRandomState(RandomState* state, uint32_t seed, uint32_t index)
38 | {
39 | state[0] = wang_hash(seed+index);
40 | }
41 |
42 | // Return a float from [0,1)
43 | static __device__ __inline__ float getRandomUniformFloat( RandomState* state )
44 | {
45 | float scale = float(0xFFFFFFFF);
46 | // Clear the last bit to be strictly less than 1
47 | return float(rand_xorshift(*state) & ~1)/scale;
48 | }
49 |
50 | #else
51 |
52 | static void __device__ initializeRandomState(RandomState* state, unsigned int seed, unsigned int index)
53 | {
54 | curand_init(seed+index, 0, 0, state);
55 | }
56 |
57 | // Return a float from 0,1
58 | static __device__ __inline__ float getRandomUniformFloat( RandomState* state )
59 | {
60 | return curand_uniform(state);
61 | }
62 |
63 | #endif
64 |
65 | static __device__ __inline__ optix::float2 getRandomUniformFloat2( RandomState* state )
66 | {
67 | optix::float2 sample;
68 | sample.x = getRandomUniformFloat(state);
69 | sample.y = getRandomUniformFloat(state);
70 | return sample;
71 | }
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/helpers/samplers.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "helpers.h"
9 |
10 | // Get a random direction from the hemisphere of direction around normalized normal,
11 | // sampled with the cosine distribution p(theta, phi) = cos(theta)/PI
12 |
13 | static __device__ __inline__ optix::float3 sampleUnitHemisphereCos(const optix::float3 & normal, const optix::float2& sample)
14 | {
15 | using namespace optix;
16 |
17 | float theta = acosf(sqrtf(sample.x));
18 | float phi = 2.0f * M_PIf *sample.y;
19 | float xs = sinf(theta) * cosf(phi);
20 | float ys = cosf(theta);
21 | float zs = sinf(theta) * sinf(phi);
22 |
23 | float3 U, V;
24 | createCoordinateSystem(normal, U, V);
25 |
26 | return optix::normalize(xs*U + ys*normal + zs*V);
27 | }
28 |
29 | // Sample unit hemisphere around (normalized) normal
30 |
31 | static __device__ __inline__ optix::float3 sampleUnitHemisphere(const optix::float3 & normal, const optix::float2& sample)
32 | {
33 | optix::float3 U, V;
34 | createCoordinateSystem( normal, U, V);
35 | float phi = 2.0f * M_PIf*sample.x;
36 | float r = sqrtf( sample.y );
37 | float x = r * cosf(phi);
38 | float y = r * sinf(phi);
39 | float z = 1.0f - x*x -y*y;
40 | z = z > 0.0f ? sqrtf(z) : 0.0f;
41 | return optix::normalize(U*x + V*y + normal*z);
42 | }
43 |
44 | static __device__ __inline__ optix::float3 sampleUnitSphere(const optix::float2& sample)
45 | {
46 | optix::float3 v;
47 | v.z = sample.x;
48 | float t = 2*M_PIf*sample.y;
49 | float r = sqrtf(1.f-v.z*v.z);
50 | v.x = r*cosf(t);
51 | v.y = r*sinf(t);
52 | return v;
53 | }
54 |
55 | static __device__ __inline__ optix::float2 sampleUnitDisc(const optix::float2& sample)
56 | {
57 | float r = sqrtf(sample.x);
58 | float theta = 2.f*M_PIf*sample.y;
59 | float x = r*cosf(theta);
60 | float y = r*sinf(theta);
61 | return make_float2(x, y);
62 | }
63 |
64 | // Sample disc (normal must be normalized)
65 |
66 | static __device__ float3 sampleDisc(const float2 & sample, const float3 & center, const float radius, const float3 & normal)
67 | {
68 | float3 U, V;
69 | createCoordinateSystem( normal, U, V);
70 | float2 unitDisc = sampleUnitDisc(sample);
71 | return center + radius * ( U*unitDisc.x + V*unitDisc.y );
72 | }
73 |
74 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/helpers/store_photon.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "renderer/ppm/PhotonGrid.h"
9 |
10 | // Unfortunately, we need a macro for photon storing code
11 |
12 | #if ACCELERATION_STRUCTURE == ACCELERATION_STRUCTURE_UNIFORM_GRID || ACCELERATION_STRUCTURE == ACCELERATION_STRUCTURE_KD_TREE_CPU
13 | #define STORE_PHOTON(photon) \
14 | photons[photonPrd.pm_index + photonPrd.numStoredPhotons] = photon; \
15 | photonPrd.numStoredPhotons++;
16 | #else
17 | #define STORE_PHOTON(photon) \
18 | { \
19 | uint3 gridLoc = getPhotonGridIndex(photon.position, photonsWorldOrigo, photonsGridCellSize); \
20 | uint hash = getHashValue(gridLoc, photonsGridSize, photonsSize); \
21 | photons[hash] = photon; \
22 | atomicAdd(&photonsHashTableCount[hash], 1); \
23 | }
24 | #endif
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/ppm/DirectRadianceEstimation.cu:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include "config.h"
11 | #include "renderer/helpers/random.h"
12 | #include "renderer/Light.h"
13 | #include "renderer/RayType.h"
14 | #include "renderer/Hitpoint.h"
15 | #include "renderer/ShadowPRD.h"
16 | #include "renderer/helpers/light.h"
17 |
18 | using namespace optix;
19 |
20 | rtDeclareVariable(rtObject, sceneRootObject, , );
21 | rtBuffer raytracePassOutputBuffer;
22 | rtBuffer directRadianceBuffer;
23 | rtBuffer randomStates;
24 | rtBuffer lights;
25 | rtDeclareVariable(uint2, launchIndex, rtLaunchIndex, );
26 | rtDeclareVariable(ShadowPRD, shadowPrd, rtPayload, );
27 |
28 | RT_PROGRAM void kernel()
29 | {
30 | Hitpoint rec = raytracePassOutputBuffer[launchIndex];
31 |
32 | // Use radiance value if we do not hit a non-specular surface
33 | if(!(rec.flags & PRD_HIT_NON_SPECULAR))
34 | {
35 | if((rec.flags & PRD_HIT_EMITTER) && !(rec.flags & PRD_HIT_SPECULAR))
36 | {
37 | directRadianceBuffer[launchIndex] = fminf(rec.radiance, make_float3(1));
38 | }
39 | else
40 | {
41 | directRadianceBuffer[launchIndex] = rec.radiance;
42 | }
43 |
44 | return;
45 | }
46 |
47 | /*
48 | // Compute direct radiance
49 | */
50 |
51 | int numLights = lights.size();
52 | const int numShadowSamples = ENABLE_PARTICIPATING_MEDIA ? 0 : 4;
53 | float3 directRadiance = make_float3(0);
54 | if(numShadowSamples > 0)
55 | {
56 | float3 avgLightRadiance = make_float3(0.f);
57 |
58 | for(int shadowSample = 0; shadowSample < numShadowSamples; shadowSample++)
59 | {
60 | float sample = getRandomUniformFloat(&randomStates[launchIndex]);
61 | int randomLightIndex = intmin(int(sample*numLights), lights.size()-1);
62 | Light & light = lights[randomLightIndex];
63 | float scale = numLights;
64 | float3 lightContrib = getLightContribution(light, rec.position, rec.normal, sceneRootObject, randomStates[launchIndex]);
65 | avgLightRadiance += scale * lightContrib;
66 | }
67 |
68 | directRadiance = rec.attenuation*avgLightRadiance/numShadowSamples;
69 | }
70 |
71 | directRadianceBuffer[launchIndex] = directRadiance;
72 |
73 | }
74 |
75 | RT_PROGRAM void gatherAnyHitOnNonEmitter()
76 | {
77 | shadowPrd.attenuation = 0.0f;
78 | rtTerminateRay();
79 | }
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/ppm/Output.cu:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include
8 | #include
9 |
10 | using namespace optix;
11 |
12 | rtBuffer outputBuffer;
13 | rtBuffer indirectRadianceBuffer;
14 | rtBuffer directRadianceBuffer;
15 | rtDeclareVariable(uint2, launchIndex, rtLaunchIndex, );
16 | rtDeclareVariable(uint, localIterationNumber, , );
17 |
18 | static __device__ __inline float3 averageInNewRadiance(const float3 newRadiance, const float3 oldRadiance, const unsigned int iterationNumber)
19 | {
20 | // If iterationNumber = 0, we do not average but take new
21 | if(iterationNumber > 0)
22 | {
23 | return oldRadiance + (newRadiance-oldRadiance)/float(iterationNumber+1);
24 | }
25 | else
26 | {
27 | return newRadiance;
28 | }
29 | }
30 |
31 | RT_PROGRAM void kernel()
32 | {
33 | float3 finalRadiance = directRadianceBuffer[launchIndex] + indirectRadianceBuffer[launchIndex];
34 | outputBuffer[launchIndex] = averageInNewRadiance(finalRadiance, outputBuffer[launchIndex], localIterationNumber);
35 | }
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/ppm/Photon.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "config.h"
9 |
10 | struct Photon
11 | {
12 | #ifdef __CUDACC__
13 | __device__ __inline Photon(const optix::float3 & power, const optix::float3 & position, const optix::float3 & rayDirection, const optix::float3 & normal)
14 | : power(power), position(position), rayDirection(rayDirection)
15 | {
16 |
17 | }
18 |
19 | __device__ __inline Photon(void)
20 | {
21 |
22 | }
23 | #endif
24 | optix::float3 power;
25 | optix::float3 position;
26 | optix::float3 rayDirection;
27 | #if ACCELERATION_STRUCTURE == ACCELERATION_STRUCTURE_KD_TREE_CPU
28 | optix::uint axis;
29 | #endif
30 | #if ENABLE_PARTICIPATING_MEDIA
31 | optix::uint numDeposits;
32 | #endif
33 | };
34 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/ppm/PhotonGrid.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "config.h"
9 |
10 | static __host__ __device__ __inline optix::uint3 floor3f(const optix::float3 & f)
11 | {
12 | optix::uint3 result;
13 | result.x = (unsigned int)floor(f.x);
14 | result.y = (unsigned int)floor(f.y);
15 | result.z = (unsigned int)floor(f.z);
16 | return result;
17 | }
18 |
19 | __host__ __device__ __inline optix::uint3 getPhotonGridIndex(const optix::float3 & position, const optix::float3 & sceneWorldOrigo, const float & cellSize)
20 | {
21 | float3 positivePosition = position-sceneWorldOrigo;
22 | return floor3f(positivePosition*(1.f/cellSize));
23 | }
24 |
25 | __host__ __device__ __inline unsigned int getPhotonGridIndex1D(const optix::uint3 & gridPosition, const optix::uint3& gridSize )
26 | {
27 | return gridPosition.x + gridPosition.y*gridSize.x + gridPosition.z*gridSize.x*gridSize.y;
28 | }
29 |
30 | __host__ __device__ __inline unsigned int getHashValue(const optix::uint3 & gridPosition, const optix::uint3& gridSize, const unsigned int max)
31 | {
32 | return getPhotonGridIndex1D(gridPosition, gridSize) & (max-1);
33 | }
34 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/ppm/PhotonPRD.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "renderer/RandomState.h"
9 | struct PhotonPRD
10 | {
11 | optix::float3 power;
12 | float weight;
13 | optix::uint pm_index;
14 | optix::uint numStoredPhotons;
15 | optix::uint depth;
16 | RandomState randomState;
17 | };
18 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/ppm/UniformGridPhotonInitialize.cu:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 | #include "config.h"
7 |
8 | #if ACCELERATION_STRUCTURE == ACCELERATION_STRUCTURE_STOCHASTIC_HASH
9 | #include
10 | #include
11 | #include "Photon.h"
12 |
13 | using namespace optix;
14 |
15 | rtBuffer photonsHashTableCount;
16 | //rtBuffer photons;
17 | rtDeclareVariable(uint1, launchIndex, rtLaunchIndex, );
18 |
19 | RT_PROGRAM void kernel()
20 | {
21 | photonsHashTableCount[launchIndex.x] = 0.0f;
22 | }
23 | #endif
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/ppm/VolumetricPhotonInitialize.cu:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include
8 | #include
9 | #include "Photon.h"
10 |
11 | #if ENABLE_PARTICIPATING_MEDIA
12 |
13 | using namespace optix;
14 |
15 | rtBuffer volumetricPhotons;
16 | rtDeclareVariable(uint1, launchIndex, rtLaunchIndex, );
17 |
18 | RT_PROGRAM void kernel()
19 | {
20 | Photon photon = Photon(make_float3(0), make_float3(0), make_float3(0), make_float3(0));
21 | photon.numDeposits = 0;
22 | volumetricPhotons[launchIndex.x] = photon;
23 | }
24 |
25 | #endif
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/ppm/VolumetricPhotonSphere.cu:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include
8 | #include "Photon.h"
9 |
10 | #if ENABLE_PARTICIPATING_MEDIA
11 |
12 | using namespace optix;
13 |
14 | rtDeclareVariable(float3, photonPosition, attribute photonPosition,);
15 | rtDeclareVariable(float3, photonPower, attribute photonPower,);
16 | rtDeclareVariable(uint, photonId, attribute photonId,);
17 | rtDeclareVariable(float, volumetricRadius, ,);
18 | rtDeclareVariable(optix::Ray, ray, rtCurrentRay,);
19 | rtBuffer photonsBuffer;
20 |
21 | // Intersection code in part from NVIDIA's Optix SDK
22 |
23 | RT_PROGRAM void intersect(int primIdx)
24 | {
25 | Photon & photon = photonsBuffer[primIdx];
26 |
27 | float3 O = ray.origin - photon.position;
28 | float b = dot(O, ray.direction );
29 | float c = dot(O, O) - volumetricRadius*volumetricRadius;
30 | float disc = b*b - c;
31 | if( disc > 0.0f )
32 | {
33 | float sdisc = sqrtf( disc );
34 | float root1 = (-b - sdisc);
35 | bool check_second = true;
36 |
37 | if( rtPotentialIntersection(root1))
38 | {
39 | photonId = primIdx;
40 | photonPosition = photon.position;
41 | photonPower = photon.power*photon.numDeposits;
42 | if( rtReportIntersection( 0 ) )
43 | check_second = false;
44 | }
45 |
46 | if( check_second )
47 | {
48 | float root2 = (-b + sdisc);
49 | if( rtPotentialIntersection(root2))
50 | {
51 | photonId = primIdx;
52 | photonPosition = photon.position;
53 | photonPower = photon.power*photon.numDeposits;
54 | rtReportIntersection( 0 );
55 | }
56 | }
57 | }
58 | }
59 |
60 | RT_PROGRAM void boundingBox(int primIdx, float result[6])
61 | {
62 | Photon & photon = photonsBuffer[primIdx];
63 | if(fmaxf(photon.power) > 0)
64 | {
65 | const float3 radius3 = make_float3(volumetricRadius);
66 | float3 min_ = photon.position - radius3;
67 | float3 max_ = photon.position + radius3;
68 | result[0] = min_.x;
69 | result[1] = min_.y;
70 | result[2] = min_.z;
71 | result[3] = max_.x;
72 | result[4] = max_.y;
73 | result[5] = max_.z;
74 | }
75 | else
76 | {
77 | result[0] = 0.0f;
78 | result[1] = 0.0f;
79 | result[2] = 0.0f;
80 | result[3] = 0.0f;
81 | result[4] = 0.0f;
82 | result[5] = 0.0f;
83 | }
84 | }
85 |
86 | #endif
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/ppm/VolumetricPhotonSphereRadiance.cu:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include
8 | #include
9 | #include "renderer/ppm/VolumetricRadiancePRD.h"
10 |
11 | using namespace optix;
12 |
13 | rtDeclareVariable(VolumetricRadiancePRD, volRadiancePrd, rtPayload, );
14 | rtDeclareVariable(optix::Ray, ray, rtCurrentRay, );
15 | rtDeclareVariable(float, tHit, rtIntersectionDistance, );
16 |
17 | rtDeclareVariable(float3, photonPosition, attribute photonPosition, );
18 | rtDeclareVariable(float3, photonPower, attribute photonPower, );
19 | rtDeclareVariable(uint, photonId, attribute photonId, );
20 |
21 | rtDeclareVariable(float, volumetricRadius, ,);
22 |
23 | RT_PROGRAM void anyHitRadiance()
24 | {
25 | float t = dot(photonPosition-ray.origin, ray.direction);
26 |
27 | if(t < ray.tmax && t > ray.tmin)
28 | {
29 | volRadiancePrd.radiance += (1/(M_PIf*volumetricRadius*volumetricRadius)) * photonPower * exp(-volRadiancePrd.sigma_t*t) * (1.f/(4.f*M_PIf));
30 | volRadiancePrd.numHits++;
31 | }
32 | rtIgnoreIntersection();
33 | }
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/renderer/ppm/VolumetricRadiancePRD.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | struct VolumetricRadiancePRD
9 | {
10 | float sigma_t;
11 | float sigma_s;
12 | optix::float3 radiance;
13 | unsigned int numHits;
14 | };
15 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/scene/Cornell.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #ifndef CORNELL_H
8 | #define CORNELL_H
9 |
10 | #include "Scene.h"
11 | #include "renderer/Light.h"
12 | #include "renderer/Camera.h"
13 | #include "render_engine_export_api.h"
14 |
15 |
16 | class Material;
17 |
18 | class Cornell : public IScene
19 | {
20 | public:
21 | RENDER_ENGINE_EXPORT_API Cornell(void);
22 | RENDER_ENGINE_EXPORT_API virtual ~Cornell(void){}
23 | RENDER_ENGINE_EXPORT_API virtual optix::Group getSceneRootGroup(optix::Context & context);
24 | RENDER_ENGINE_EXPORT_API virtual const QVector & getSceneLights() const;
25 | RENDER_ENGINE_EXPORT_API virtual Camera getDefaultCamera(void) const;
26 | RENDER_ENGINE_EXPORT_API virtual const char* getSceneName() const;
27 | RENDER_ENGINE_EXPORT_API static const char* getCornellSceneName();
28 | RENDER_ENGINE_EXPORT_API virtual unsigned int getNumTriangles() const;
29 | RENDER_ENGINE_EXPORT_API virtual AAB getSceneAABB() const;
30 |
31 | private:
32 | optix::Material m_material;
33 | optix::Material m_glassMaterial;
34 | optix::Program m_pgram_bounding_box;
35 | optix::Program m_pgram_intersection;
36 | QVector m_sceneLights;
37 | AAB m_sceneAABB;
38 | optix::GeometryInstance createParallelogram(optix::Context & context, const optix::float3& anchor, const optix::float3& offset1, const optix::float3& offset2, Material & material);
39 |
40 | };
41 | #endif
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/scene/IScene.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "Scene.h"
8 | #include
9 | #include
10 |
11 | IScene::IScene()
12 | {
13 |
14 | }
15 |
16 | IScene::~IScene()
17 | {
18 |
19 | }
20 |
21 | // This base implementation finds a initial PPM radius by looking at the scene extent
22 |
23 | float IScene::getSceneInitialPPMRadiusEstimate() const
24 | {
25 | Vector3 sceneExtent = getSceneAABB().getExtent();
26 | float volume = sceneExtent.x*sceneExtent.y*sceneExtent.z;
27 | float cubelength = pow(volume, 1.f/3.f);
28 | float A = 6*cubelength*cubelength;
29 | float radius = A*3.94e-6;
30 | return radius;
31 | }
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/scene/IScene.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 |
9 | #include
10 | #include
11 | #include "renderer/Camera.h"
12 | #include "renderer/Light.h"
13 | #include "render_engine_export_api.h"
14 | #include "math/AAB.h"
15 |
16 | class IScene
17 | {
18 | public:
19 | RENDER_ENGINE_EXPORT_API IScene();
20 | RENDER_ENGINE_EXPORT_API virtual ~IScene();
21 | RENDER_ENGINE_EXPORT_API virtual optix::Group getSceneRootGroup(optix::Context & context) = 0;
22 | RENDER_ENGINE_EXPORT_API virtual const QVector & getSceneLights() const = 0;
23 | RENDER_ENGINE_EXPORT_API virtual Camera getDefaultCamera() const = 0;
24 | RENDER_ENGINE_EXPORT_API virtual const char* getSceneName() const = 0;
25 | RENDER_ENGINE_EXPORT_API virtual AAB getSceneAABB() const = 0;
26 | RENDER_ENGINE_EXPORT_API virtual float getSceneInitialPPMRadiusEstimate() const;
27 | RENDER_ENGINE_EXPORT_API virtual unsigned int getNumTriangles() const = 0;
28 | };
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/scene/Scene.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 |
9 | #include "IScene.h"
10 | #include "renderer/Light.h"
11 | #include "render_engine_export_api.h"
12 | #include
13 | #include
14 | #include "math/AAB.h"
15 |
16 | struct aiScene;
17 | struct aiMesh;
18 | class Material;
19 | struct aiNode;
20 | class DiffuseEmitter;
21 | struct aiColor3D;
22 | class QFileInfo;
23 |
24 | namespace Assimp
25 | {
26 | class Importer;
27 | }
28 |
29 | class Scene : public IScene
30 | {
31 | public:
32 | Scene(void);
33 | RENDER_ENGINE_EXPORT_API virtual ~Scene(void);
34 | RENDER_ENGINE_EXPORT_API static IScene* createFromFile(const char* file);
35 | virtual optix::Group getSceneRootGroup(optix::Context & context);
36 | void loadDefaultSceneCamera();
37 | virtual const QVector & getSceneLights() const;
38 | virtual Camera getDefaultCamera() const;
39 | virtual const char* getSceneName() const;
40 | virtual AAB getSceneAABB() const ;
41 | RENDER_ENGINE_EXPORT_API virtual unsigned int getNumTriangles() const;
42 |
43 | private:
44 | optix::Geometry Scene::createGeometryFromMesh(aiMesh* mesh, optix::Context & context);
45 | void loadMeshLightSource( aiMesh* mesh, DiffuseEmitter* diffuseEmitter );
46 | optix::Group getGroupFromNode(optix::Context & context, aiNode* node, QVector & geometries, QVector & materials);
47 | optix::GeometryInstance getGeometryInstance( optix::Context & context, optix::Geometry & geometry, Material* material );
48 | bool colorHasAnyComponent(const aiColor3D & color);
49 | void loadSceneMaterials();
50 | void loadLightSources();
51 | QVector m_materials;
52 | QVector m_lights;
53 | QByteArray m_sceneName;
54 | QFileInfo* m_sceneFile;
55 | Assimp::Importer* m_importer;
56 | const aiScene* m_scene;
57 | optix::Program m_intersectionProgram;
58 | optix::Program m_boundingBoxProgram;
59 | Camera m_defaultCamera;
60 | AAB m_sceneAABB;
61 | unsigned int m_numTriangles;
62 |
63 | };
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/util/BenchmarkTimer.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "BenchmarkTimer.h"
8 |
9 | BenchmarkTimer::BenchmarkTimer(void)
10 | : m_state(NOT_RUNNING),
11 | m_accumSeconds(0.0f)
12 | {
13 |
14 | }
15 |
16 | BenchmarkTimer::~BenchmarkTimer( void )
17 | {
18 |
19 | }
20 |
21 | void BenchmarkTimer::start()
22 | {
23 | m_time.start();
24 | m_accumSeconds = 0;
25 | m_state = RUNNING;
26 | }
27 |
28 | void BenchmarkTimer::restart()
29 | {
30 | m_time.restart();
31 | m_accumSeconds = 0.0f;
32 | m_state = RUNNING;
33 | }
34 |
35 | void BenchmarkTimer::pause()
36 | {
37 | if(m_state == RUNNING)
38 | {
39 | m_accumSeconds += m_time.elapsed()/1000.0f;
40 | }
41 | m_state = NOT_RUNNING;
42 | }
43 |
44 | void BenchmarkTimer::resume()
45 | {
46 | if(m_state == NOT_RUNNING)
47 | {
48 | m_time.restart();
49 | m_state = RUNNING;
50 | }
51 | }
52 |
53 | double BenchmarkTimer::elapsedSeconds()
54 | {
55 | BenchmarkTimerState state = m_state;
56 |
57 | if(state == RUNNING)
58 | {
59 | pause();
60 | }
61 |
62 | double secs = m_accumSeconds;
63 |
64 | if(state == RUNNING)
65 | {
66 | resume();
67 | }
68 |
69 | return secs;
70 | }
71 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/util/BenchmarkTimer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include
9 | #include "render_engine_export_api.h"
10 |
11 | class BenchmarkTimer
12 | {
13 | public:
14 | RENDER_ENGINE_EXPORT_API BenchmarkTimer(void);
15 | RENDER_ENGINE_EXPORT_API ~BenchmarkTimer(void);
16 | RENDER_ENGINE_EXPORT_API void start();
17 | RENDER_ENGINE_EXPORT_API void restart();
18 | RENDER_ENGINE_EXPORT_API void pause();
19 | RENDER_ENGINE_EXPORT_API void resume();
20 | RENDER_ENGINE_EXPORT_API double elapsedSeconds();
21 | private:
22 | enum BenchmarkTimerState
23 | {
24 | RUNNING, NOT_RUNNING
25 | };
26 | QTime m_time;
27 | double m_accumSeconds;
28 | BenchmarkTimerState m_state;
29 | };
30 |
31 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/util/Image.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 |
8 | #pragma once
9 | class QString;
10 | class QFile;
11 | class Image
12 | {
13 | public:
14 | Image(const QString & imageCompletePath);
15 | ~Image(void);
16 | unsigned int getWidth() const;
17 | unsigned int getHeight() const;
18 | const unsigned char* constData() const;
19 |
20 | private:
21 | void loadImageFromTga( const QFile & image );
22 | unsigned int m_width;
23 | unsigned int m_height;
24 | unsigned int m_depth;
25 | unsigned char* m_imageData;
26 | };
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/util/imageformats/libtga/AUTHORS:
--------------------------------------------------------------------------------
1 | Matthias Brueckner Maintainer
2 |
3 |
4 | Special thanks to:
5 | Raphael FRANCOIS and Gordon Matzigkeit
6 | I took parts of the code from their TGA filter for The Gimp
7 |
8 | Paul Cohen
9 | for his ideas and suggestions
10 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/util/imageformats/libtga/NEWS:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apartridge/OppositeRenderer/d3b51aac5a86d57a21d5428aad3ffe873a5f0b60/OppositeRenderer/RenderEngine/util/imageformats/libtga/NEWS
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/util/imageformats/libtga/README:
--------------------------------------------------------------------------------
1 | RELEASE NOTES Libtga 1.0.1 Nov 28 2002
2 |
3 |
4 | These are the release notes for the Libtga package. The TGA library
5 | is a library to read and write TGA images.
6 |
7 |
8 | COPYING:
9 |
10 | Libtga is released under the GNU Lesser General Public License. The
11 | example programs are released under the GNU General Public License.
12 | The documentation is released under the GNU Free Documentation
13 | License. For more information on the licenses see the the files
14 | COPYING, COPYING.LIB and COPYING.DOC in the project's root directory
15 | and the corresponding sub directories.
16 |
17 |
18 | INSTALLING:
19 |
20 | Instructions on how to install and compile the package can be found
21 | in the file INSTALL.
22 |
23 |
24 | REPORTING BUGS:
25 |
26 | If you want to report a bug or have any problems with this package
27 | or want to see a feature in a future release either mail the
28 | maintainer or submit a bug report at http://sf.net/projects/tgalib
29 |
30 |
31 | SITES:
32 |
33 | Download
34 | http://sf.net/projects/tgalib
35 |
36 | Homepage
37 | http://tgalib.sf.net
38 |
39 | Anonymous CVS
40 | export CVSROOT=:pserver:anonymous@cvs.tgalib.sf.net:/cvsroot/tgalib
41 | cvs login
42 | cvs -z3 co libtga
43 |
44 |
45 |
46 | AUTHORS:
47 |
48 | See the AUTHORS file.
49 |
50 |
51 |
52 | Matthias Brueckner Nov 28 2002
53 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/util/imageformats/libtga/tga.c:
--------------------------------------------------------------------------------
1 | /*
2 | * tga.c
3 | *
4 | * Copyright (C) 2001-2002 Matthias Brueckner
5 | * This file is part of the TGA library (libtga).
6 | *
7 | * This program is free software; you can redistribute it and/or modify
8 | * it under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation; either version 2 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU Library General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 | */
21 |
22 | #include
23 | #include
24 | #include "tga.h"
25 |
26 |
27 | TGA*
28 | TGAOpen(char *file,
29 | char *mode)
30 | {
31 | TGA *tga;
32 | FILE *fd;
33 |
34 | tga = (TGA*)malloc(sizeof(TGA));
35 | if (!tga) {
36 | TGA_ERROR(tga, TGA_OOM);
37 | return NULL;
38 | }
39 |
40 | tga->off = 0;
41 |
42 | fd = fopen(file, mode);
43 | if (!fd) {
44 | TGA_ERROR(tga, TGA_OPEN_FAIL);
45 | free(tga);
46 | return NULL;
47 | }
48 | tga->fd = fd;
49 | tga->last = TGA_OK;
50 | return tga;
51 | }
52 |
53 |
54 | TGA*
55 | TGAOpenFd(FILE *fd)
56 | {
57 | TGA *tga;
58 |
59 | tga = (TGA*)malloc(sizeof(TGA));
60 | if (!tga) {
61 | TGA_ERROR(tga, TGA_OOM);
62 | return NULL;
63 | }
64 |
65 | if (!fd) {
66 | TGA_ERROR(tga, TGA_OPEN_FAIL);
67 | free(tga);
68 | return NULL;
69 | }
70 |
71 | tga->off = ftell(fd);
72 | if(tga->off == -1) {
73 | TGA_ERROR(tga, TGA_OPEN_FAIL);
74 | free(tga);
75 | return NULL;
76 | }
77 |
78 | tga->fd = fd;
79 | tga->last = TGA_OK;
80 | return tga;
81 | }
82 |
83 |
84 | void
85 | TGAClose(TGA *tga)
86 | {
87 | if (tga) {
88 | fclose(tga->fd);
89 | free(tga);
90 | }
91 | }
92 |
93 |
94 | char*
95 | TGAStrError(tuint8 code)
96 | {
97 | if (code >= TGA_ERRORS) code = TGA_ERROR;
98 | return tga_error_strings[code];
99 | }
100 |
101 |
102 | tlong
103 | __TGASeek(TGA *tga,
104 | tlong off,
105 | int whence)
106 | {
107 | fseek(tga->fd, off, whence);
108 | tga->off = ftell(tga->fd);
109 | return tga->off;
110 | }
111 |
112 |
113 | void
114 | __TGAbgr2rgb(tbyte *data,
115 | size_t size,
116 | size_t bytes)
117 | {
118 | size_t i;
119 | tbyte tmp;
120 |
121 | for (i = 0; i < size; i += bytes) {
122 | tmp = data[i];
123 | data[i] = data[i + 2];
124 | data[i + 2] = tmp;
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/OppositeRenderer/RenderEngine/util/imageformats/libtga/tgaconfig.h:
--------------------------------------------------------------------------------
1 | /* src/tgaconfig.h. Generated by configure. */
2 | /* src/tgaconfig.h.in. Generated from configure.in by autoheader. */
3 |
4 | /* Define to 1 if you have the header file. */
5 | #define HAVE_DLFCN_H 1
6 |
7 | /* Define to 1 if you have the header file. */
8 | #define HAVE_INTTYPES_H 1
9 |
10 | /* Define to 1 if you have the header file. */
11 | #define HAVE_MEMORY_H 1
12 |
13 | /* Define to 1 if you have the header file. */
14 | #define HAVE_STDINT_H 1
15 |
16 | /* Define to 1 if you have the header file. */
17 | #define HAVE_STDLIB_H 1
18 |
19 | /* Define to 1 if you have the header file. */
20 | #define HAVE_STRINGS_H 1
21 |
22 | /* Define to 1 if you have the header file. */
23 | #define HAVE_STRING_H 1
24 |
25 | /* Define to 1 if you have the header file. */
26 | #define HAVE_SYS_STAT_H 1
27 |
28 | /* Define to 1 if you have the header file. */
29 | #define HAVE_SYS_TYPES_H 1
30 |
31 | /* Define to 1 if you have the header file. */
32 | #define HAVE_UNISTD_H 1
33 |
34 | /* Name of package */
35 | #define PACKAGE "libtga"
36 |
37 | /* Define to the address where bug reports for this package should be sent. */
38 | #define PACKAGE_BUGREPORT ""
39 |
40 | /* Define to the full name of this package. */
41 | #define PACKAGE_NAME ""
42 |
43 | /* Define to the full name and version of this package. */
44 | #define PACKAGE_STRING ""
45 |
46 | /* Define to the one symbol short name of this package. */
47 | #define PACKAGE_TARNAME ""
48 |
49 | /* Define to the version of this package. */
50 | #define PACKAGE_VERSION ""
51 |
52 | /* The size of a `unsigned int', as computed by sizeof. */
53 | #define SIZEOF_UNSIGNED_INT 4
54 |
55 | /* Define to 1 if you have the ANSI C header files. */
56 | #define STDC_HEADERS 1
57 |
58 | /* Version number of package */
59 | #define VERSION "1.0.1"
60 |
61 | /* Define to empty if `const' does not conform to ANSI C. */
62 | /* #undef const */
63 |
64 | /* Define to `unsigned' if does not define. */
65 | /* #undef size_t */
66 |
--------------------------------------------------------------------------------
/OppositeRenderer/Server/Server.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/OppositeRenderer/Server/Server.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 | $(OutDir)
6 | WindowsLocalDebugger
7 |
8 |
--------------------------------------------------------------------------------
/OppositeRenderer/Server/ServerState.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "ServerState.h"
8 | const char* serverStateEnumToString(ServerState::E state)
9 | {
10 | switch(state)
11 | {
12 | case ServerState::WAIT_FOR_CLIENT_CONNECTION: return "Awaiting connection from client.";
13 | case ServerState::SET_COMPUTE_DEVICE: return "Select compute device to use.";
14 | case ServerState::SET_SERVER_SETTINGS: return "Configure server settings.";
15 | case ServerState::READY_FOR_RENDERING: return "Ready for rendering.";
16 | }
17 | return "(Unknown state.)";
18 | }
--------------------------------------------------------------------------------
/OppositeRenderer/Server/ServerState.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | namespace ServerState
9 | {
10 | enum E {SET_COMPUTE_DEVICE,
11 | SET_SERVER_SETTINGS,
12 | WAIT_FOR_CLIENT_CONNECTION,
13 | READY_FOR_RENDERING};
14 | }
15 | const char* serverStateEnumToString(ServerState::E state);
--------------------------------------------------------------------------------
/OppositeRenderer/Server/gui/ReadyForRenderingWidget.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "ReadyForRenderingWidget.hxx"
8 | #include "ui/ui_ReadyForRenderingWidget.h"
9 | #include "ComputeDevice.h"
10 |
11 | ReadyForRenderingWidget::ReadyForRenderingWidget(QWidget *parent) :
12 | QWidget(parent),
13 | ui(new Ui::ReadyForRenderingWidget)
14 | {
15 | ui->setupUi(this);
16 | }
17 |
18 | ReadyForRenderingWidget::~ReadyForRenderingWidget()
19 | {
20 | delete ui;
21 | }
22 |
23 | void ReadyForRenderingWidget::appendToLog(const QString& log)
24 | {
25 | ui->serverLog->appendPlainText(log);
26 | }
27 |
28 | void ReadyForRenderingWidget::clearLog()
29 | {
30 | ui->serverLog->clear();
31 | }
32 |
33 | void ReadyForRenderingWidget::setClientName(const QString& name)
34 | {
35 | ui->clientLabel->setText(name);
36 | }
37 |
38 | void ReadyForRenderingWidget::setComputeDevice(const ComputeDevice & device )
39 | {
40 | ui->computeDeviceNameLabel->setText(QString("%1 (id %2)").arg(device.getName()).arg(device.getDeviceId()));
41 | }
42 |
43 | void ReadyForRenderingWidget::setServerName( const QString & name )
44 | {
45 | ui->serverLabel->setText(name);
46 | }
47 |
48 | void ReadyForRenderingWidget::setRenderTime( float renderTime, float totalTime )
49 | {
50 | ui->totalTimeLabel->setText(QString("%1 seconds").arg(totalTime, 0, 'f', 1));
51 | ui->timeSpentRenderingLabel->setText(QString("%1 seconds (%2 %)").arg(renderTime).arg((renderTime/totalTime)*100, 0, 'f', 1));
52 | }
53 |
54 | void ReadyForRenderingWidget::setPendingRenderCommandsAndIterations( unsigned int pendingRenderIterations, unsigned int pendingRenderCommands )
55 | {
56 | ui->pendingRenderIterationsCommandsLabel->setText(QString("%1/%2").arg(pendingRenderIterations).arg(pendingRenderCommands));
57 | }
--------------------------------------------------------------------------------
/OppositeRenderer/Server/gui/ReadyForRenderingWidget.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #ifndef READYFORRENDERINGWIDGET_H
8 | #define READYFORRENDERINGWIDGET_H
9 |
10 | #include
11 |
12 | class QString;
13 | class ComputeDevice;
14 |
15 | namespace Ui {
16 | class ReadyForRenderingWidget;
17 | }
18 |
19 | class ReadyForRenderingWidget : public QWidget
20 | {
21 | Q_OBJECT
22 |
23 | public:
24 | explicit ReadyForRenderingWidget(QWidget *parent = 0);
25 | ~ReadyForRenderingWidget();
26 | void appendToLog( const QString & );
27 | void clearLog();
28 | void setComputeDevice(const ComputeDevice & );
29 | void setClientName(const QString &);
30 | void setServerName(const QString &);
31 | void setRenderTime(float renderTime, float totalTime);
32 | void setPendingRenderCommandsAndIterations(unsigned int pendingRenderCommands, unsigned int pendingRenderIterations);
33 | private:
34 | Ui::ReadyForRenderingWidget *ui;
35 | };
36 |
37 | #endif // READYFORRENDERINGWIDGET_H
38 |
--------------------------------------------------------------------------------
/OppositeRenderer/Server/gui/ServerWindow.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #ifndef MAINWINDOW_H
8 | #define MAINWINDOW_H
9 |
10 | #include
11 | #include "ServerState.h"
12 | #include "server/RenderServerState.h"
13 | #include "ComputeDeviceRepository.h"
14 |
15 | class QTcpSocket;
16 | class QTcpServer;
17 | class QLabel;
18 | class ComputeDevice;
19 | class ComputeDeviceInformationWidget;
20 | class SetServerSettingsWidget;
21 | class WaitingForConnectionWidget;
22 | class ReadyForRenderingWidget;
23 | class RenderServer;
24 |
25 | namespace Ui
26 | {
27 | class ServerWindow;
28 | }
29 |
30 | class ServerWindow : public QMainWindow
31 | {
32 | Q_OBJECT
33 |
34 | public:
35 | explicit ServerWindow(QWidget *parent, RenderServer & serverApplication);
36 | ~ServerWindow();
37 |
38 | public slots:
39 | void onNewConnection();
40 | void onActionSetComputeDevice();
41 | void onNewServerState(ServerState::E);
42 | void onNewServerApplicationLogString(QString);
43 |
44 | signals:
45 | void newServerState(ServerState::E);
46 |
47 |
48 | private slots:
49 | void onClientConnectionDisconnected();
50 | void onStartServerFormSubmitted();
51 | void onHasSelectedComputeDevice(ComputeDevice*);
52 | void onActionAbout();
53 | void onNewRenderState(RenderServerState::E);
54 | void onTimeout();
55 |
56 | private:
57 | // UI
58 | Ui::ServerWindow *ui;
59 | QLabel* m_serverStateLabel;
60 | QLabel* m_renderStateLabel;
61 | const char* fromServerStateEnumToString(ServerState::E);
62 | ComputeDeviceInformationWidget* m_setComputeDeviceWidget;
63 | SetServerSettingsWidget* m_serverSettingsWidget;
64 | WaitingForConnectionWidget* m_waitingForConnectionWidget;
65 | ReadyForRenderingWidget* m_readyForRenderingWidget;
66 |
67 | // SERVER
68 | ServerState::E m_serverState;
69 | RenderServerState::E m_renderState;
70 | QTcpSocket *m_clientSocket;
71 | QTcpServer *m_server;
72 | void setServerState(ServerState::E state);
73 | ushort m_serverPort;
74 | ComputeDevice* m_computeDevice;
75 | RenderServer& m_renderServer;
76 | ComputeDeviceRepository m_computeDeviceRepository;
77 |
78 | void onStateSetComputeDeviceEnter();
79 | void onStateSetComputeDeviceExit();
80 | void onStateSetServerSettingsEnter();
81 | void onStateSetServerSettingsExit();
82 | void onStateWaitForConnectionEnter();
83 | void onStateWaitForConnectionExit();
84 | void onStateReadyForRenderingEnter();
85 | void onStateReadyForRenderingExit();
86 | void resetProcess();
87 |
88 | };
89 |
90 | #endif // MAINWINDOW_H
91 |
--------------------------------------------------------------------------------
/OppositeRenderer/Server/gui/SetServerSettingsWidget.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "SetServerSettingsWidget.hxx"
8 | #include "ui/ui_SetServerSettingsWidget.h"
9 | #include
10 |
11 | SetServerSettingsWidget::SetServerSettingsWidget(QWidget *parent) :
12 | QWidget(parent),
13 | ui(new Ui::SetServerSettingsWidget)
14 | {
15 | ui->setupUi(this);
16 | connect(ui->startServerButton, SIGNAL(clicked()), this, SLOT(onStartServerButtonClicked()));
17 | connect(ui->portNumber, SIGNAL(returnPressed()), ui->startServerButton, SIGNAL(clicked()));
18 |
19 | }
20 |
21 | SetServerSettingsWidget::~SetServerSettingsWidget()
22 | {
23 | delete ui;
24 | }
25 |
26 | void SetServerSettingsWidget::onStartServerButtonClicked()
27 | {
28 | bool ok;
29 | m_portNumber = ui->portNumber->text().toUShort(&ok);
30 | if(m_portNumber > 0 && ok)
31 | {
32 | emit startServerFormSubmitted();
33 | }
34 | else
35 | {
36 | QMessageBox::information(this, "Port number is not valid",
37 | "Please select a port number between 1 and 65535. Please make sure it's not in use on your system.");
38 | }
39 | }
40 |
41 | ushort SetServerSettingsWidget::getPortNumber() const
42 | {
43 | return m_portNumber;
44 | }
--------------------------------------------------------------------------------
/OppositeRenderer/Server/gui/SetServerSettingsWidget.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #ifndef SETSERVERSETTINGSWIDGET_H
8 | #define SETSERVERSETTINGSWIDGET_H
9 |
10 | #include
11 |
12 | namespace Ui {
13 | class SetServerSettingsWidget;
14 | }
15 |
16 | class SetServerSettingsWidget : public QWidget
17 | {
18 | Q_OBJECT
19 |
20 | public:
21 | explicit SetServerSettingsWidget(QWidget *parent = 0);
22 | ~SetServerSettingsWidget();
23 | ushort getPortNumber() const;
24 |
25 | signals:
26 | void startServerFormSubmitted();
27 |
28 | private slots:
29 | void onStartServerButtonClicked();
30 |
31 | private:
32 | Ui::SetServerSettingsWidget *ui;
33 | ushort m_portNumber;
34 | };
35 |
36 | #endif // SETSERVERSETTINGSWIDGET_H
37 |
--------------------------------------------------------------------------------
/OppositeRenderer/Server/gui/WaitingForConnectionWidget.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "WaitingForConnectionWidget.hxx"
8 | #include "ui/ui_WaitingForConnectionWidget.h"
9 |
10 | WaitingForConnectionWidget::WaitingForConnectionWidget(QWidget *parent) :
11 | QWidget(parent),
12 | ui(new Ui::WaitingForConnectionWidget)
13 | {
14 | ui->setupUi(this);
15 | }
16 |
17 | WaitingForConnectionWidget::~WaitingForConnectionWidget()
18 | {
19 | delete ui;
20 | }
21 |
22 | void WaitingForConnectionWidget::setPortNumber( QString& string )
23 | {
24 | ui->portNumberLabel->setText(string);
25 | }
--------------------------------------------------------------------------------
/OppositeRenderer/Server/gui/WaitingForConnectionWidget.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #ifndef WAITINGFORCONNECTIONWIDGET_H
8 | #define WAITINGFORCONNECTIONWIDGET_H
9 |
10 | #include
11 |
12 | namespace Ui {
13 | class WaitingForConnectionWidget;
14 | }
15 |
16 | class WaitingForConnectionWidget : public QWidget
17 | {
18 | Q_OBJECT
19 |
20 | public:
21 | explicit WaitingForConnectionWidget(QWidget *parent = 0);
22 | ~WaitingForConnectionWidget();
23 | void setPortNumber(QString& string);
24 |
25 | private:
26 | Ui::WaitingForConnectionWidget *ui;
27 | };
28 |
29 | #endif // WAITINGFORCONNECTIONWIDGET_H
30 |
--------------------------------------------------------------------------------
/OppositeRenderer/Server/gui/ui/SetServerSettingsWidget.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | SetServerSettingsWidget
4 |
5 |
6 |
7 | 0
8 | 0
9 | 537
10 | 105
11 |
12 |
13 |
14 | Form
15 |
16 |
17 |
18 |
19 | 105
20 | 15
21 | 341
22 | 22
23 |
24 |
25 |
26 |
27 | QFormLayout::AllNonFixedFieldsGrow
28 |
29 |
30 | 20
31 |
32 | -
33 |
34 |
35 | Listen on port:
36 |
37 |
38 |
39 | -
40 |
41 |
42 | 5050
43 |
44 |
45 | 5
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | 215
58 | 50
59 | 129
60 | 23
61 |
62 |
63 |
64 | Start server
65 |
66 |
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/OppositeRenderer/Server/gui/ui/WaitingForConnectionWidget.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | WaitingForConnectionWidget
4 |
5 |
6 |
7 | 0
8 | 0
9 | 537
10 | 93
11 |
12 |
13 |
14 | Form
15 |
16 |
17 |
18 |
19 | 10
20 | 15
21 | 521
22 | 26
23 |
24 |
25 |
26 |
27 | 9
28 | 75
29 | true
30 |
31 |
32 |
33 | Waiting for connection on port
34 |
35 |
36 | Qt::AlignCenter
37 |
38 |
39 |
40 |
41 |
42 | 10
43 | 45
44 | 521
45 | 26
46 |
47 |
48 |
49 |
50 | 15
51 | 50
52 | false
53 |
54 |
55 |
56 | 000
57 |
58 |
59 | Qt::AlignCenter
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/OppositeRenderer/Server/main.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | /*
8 | * This is the render server main entry. The render server accepts connections from clients
9 | * and will perform rendering per request
10 | */
11 |
12 | #include
13 | #include
14 | #include
15 | #include "gui/ServerWindow.hxx"
16 | #include
17 | #include "server/RenderServer.hxx"
18 | //#include
19 |
20 | int main( int argc, char** argv )
21 | {
22 | QApplication app(argc, argv);
23 | app.setOrganizationName("Opposite Renderer");
24 | app.setApplicationName("Opposite Renderer");
25 |
26 | RenderServer renderServer;
27 | ServerWindow serverWindow(NULL, renderServer);
28 | serverWindow.show();
29 | int appCode = app.exec();
30 | renderServer.wait();
31 | return appCode;
32 | }
33 |
--------------------------------------------------------------------------------
/OppositeRenderer/Server/server/RenderServer.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | /*
8 | The renderserver responds to RenderServerRenderRequest from the client, and performs them.
9 | The RenderServerRenderer is actually responsible for the rendering, and lives in its own thread
10 | This class deals with network communication between client and server.
11 | */
12 |
13 | #pragma once
14 | #include
15 | #include
16 | #include "RenderServerState.h"
17 | #include "clientserver/RenderResultPacket.h"
18 | #include "clientserver/RenderServerRenderRequest.h"
19 | #include "RenderServerRenderer.hxx"
20 | #include
21 | #include
22 |
23 | class ComputeDevice;
24 | class QByteArray;
25 | class IScene;
26 | class QTcpSocket;
27 |
28 | class RenderServer : public QObject
29 | {
30 | Q_OBJECT;
31 | public:
32 | RenderServer(void);
33 | ~RenderServer(void);
34 | void initializeDevice(const ComputeDevice & computeDevice);
35 | void initializeClient(QTcpSocket & clientSocket);
36 | unsigned int getNumPendingRenderIterations();
37 | double getRenderTimeSeconds();
38 | double getTotalTimeSeconds();
39 | unsigned int getNumPendingRenderCommands();
40 | void wait();
41 |
42 | public slots:
43 | void onDataFromClient();
44 | void sendConfirmationToClient();
45 | void appendToLog(QString);
46 | void onNewRenderResultPacket(RenderResultPacket);
47 |
48 | signals:
49 | void renderStateUpdated(RenderServerState::E);
50 | void logStringAppended(QString);
51 | void renderTimeUpdated();
52 |
53 | private:
54 | RenderResultPacket getRenderFrameResult(const RenderServerRenderRequest & renderRequest);
55 | void setRenderState(RenderServerState::E renderState);
56 | RenderServerRenderRequest getRenderServerRenderRequestFromClient();
57 | RenderServerState::E m_renderState;
58 |
59 | QTcpSocket* m_clientSocket;
60 | QDataStream* m_clientSocketDataStream;
61 | int m_clientExpectingBytes;
62 |
63 | RenderServerRenderer m_renderServerRenderer;
64 | QThread* m_renderServerRendererThread;
65 | unsigned long long m_iterationsRendered;
66 | };
--------------------------------------------------------------------------------
/OppositeRenderer/Server/server/RenderServerRenderer.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 | #include "renderer/OptixRenderer.h"
9 | #include "clientserver/RenderResultPacket.h"
10 | #include "clientserver/RenderServerRenderRequest.h"
11 | #include "scene/SceneFactory.h"
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include "util/BenchmarkTimer.h"
18 |
19 | class ComputeDevice;
20 | class RenderServer;
21 |
22 | class RenderServerRenderer : public QObject
23 | {
24 | Q_OBJECT;
25 | public:
26 | RenderServerRenderer(const RenderServer & renderServer);
27 | ~RenderServerRenderer(void);
28 | void initialize(const ComputeDevice* computeDevice);
29 | void initializeNewClient();
30 | const ComputeDevice & getComputeDevice() const;
31 | void pushCommandToQueue( RenderServerRenderRequest renderRequest );
32 | unsigned int getNumPendingRenderCommands();
33 | unsigned long long getCurrentSequenceNumber() const;
34 | double getRenderTimeSeconds();
35 | double getTotalTimeSeconds();
36 | void wait();
37 | unsigned int getNumPendingRenderIterations();
38 |
39 | public slots:
40 | void onThreadStarted();
41 | void onAboutToQuit();
42 | void onClientDisconnected();
43 |
44 | signals:
45 | void newLogString(QString);
46 | void newRenderResultPacket(RenderResultPacket);
47 |
48 | private slots:
49 | void onNewRenderCommandInQueue();
50 |
51 | private:
52 | void renderFrame(unsigned long long iterationNumber, unsigned long long localIterationNumber, float PPMRadius, bool createOutputBuffer, const RenderServerRenderRequestDetails & details);
53 | RenderResultPacket createRenderResultPacket(const RenderServerRenderRequest & request);
54 | void loadNewScene(const QByteArray & sceneName );
55 | const RenderServer & m_renderServer;
56 | OptixRenderer m_renderer;
57 | const ComputeDevice* m_computeDevice;
58 | QString m_sceneName;
59 | IScene* m_scene;
60 |
61 | BenchmarkTimer m_totalTime;
62 | BenchmarkTimer m_renderTime;
63 |
64 | unsigned long long m_currentSequenceNumber;
65 |
66 | QMutex m_queueMutex;
67 | QQueue m_queue;
68 | QWaitCondition m_waitCondition;
69 | QMutex m_waitConditionMutex;
70 | bool m_quit;
71 | };
72 |
73 |
--------------------------------------------------------------------------------
/OppositeRenderer/Server/server/RenderServerState.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "RenderServerState.h"
8 | const char* renderStateEnumToText(RenderServerState::E state)
9 | {
10 | switch(state)
11 | {
12 | case RenderServerState::READY: return "Ready";
13 | case RenderServerState::RENDERING: return "Rendering";
14 | case RenderServerState::ERROR_UNKNOWN: return "Unknown error";
15 | case RenderServerState::WAITING_FOR_INTRODUCTION_REQUEST: return "Wait for introduction request.";
16 | }
17 | return "(Unknown state.)";
18 | }
--------------------------------------------------------------------------------
/OppositeRenderer/Server/server/RenderServerState.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | /*
8 | Note that there are two RenderServerState enums, one for Server and one for Client
9 | */
10 | #pragma once
11 | namespace RenderServerState
12 | {
13 | enum E {NOT_VALID_RENDER_STATE,
14 | WAITING_FOR_INTRODUCTION_REQUEST,
15 | READY,
16 | RENDERING,
17 | ERROR_UNKNOWN};
18 | }
19 | const char* renderStateEnumToText(RenderServerState::E state);
--------------------------------------------------------------------------------
/OppositeRenderer/Standalone/Standalone.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {5cb8a90e-9084-42d3-8c21-4b79415d3ce1}
6 |
7 |
8 | {d91c7da3-42eb-4ae4-ab3c-a07fd492b96f}
9 |
10 |
11 | {64844c91-a6ae-4e56-b7b1-d86eb092e11c}
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/OppositeRenderer/Standalone/Standalone.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 | $(OutDir)
6 | WindowsLocalDebugger
7 |
8 |
--------------------------------------------------------------------------------
/OppositeRenderer/Standalone/StandaloneApplication.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include "StandaloneApplication.h"
8 | #include "ComputeDevice.h"
9 | #include
10 | #include
11 |
12 | StandaloneApplication::StandaloneApplication(QApplication & qApplication, const ComputeDevice & device)
13 | : Application(qApplication),
14 | m_renderManager(StandaloneRenderManager(qApplication, *this, device))
15 | {
16 | connect(&m_renderManager, SIGNAL(newFrameReadyForDisplay(const float*, unsigned long long)),
17 | this, SIGNAL(newFrameReadyForDisplay(const float*, unsigned long long)));
18 |
19 | // Run render manager in thread
20 |
21 | m_thread = new QThread(&qApplication);
22 | m_renderManager.moveToThread(m_thread);
23 | QObject::connect(m_thread, SIGNAL(started()), &m_renderManager, SLOT(start()));
24 | m_thread->start();
25 |
26 | // Pass on render manager errors as application errors
27 | connect(&m_renderManager, SIGNAL(renderManagerError(QString)),
28 | this, SIGNAL(applicationError(QString)),
29 | Qt::QueuedConnection);
30 |
31 | }
32 |
33 | StandaloneApplication::~StandaloneApplication(void)
34 | {
35 |
36 | }
37 |
38 | void StandaloneApplication::wait()
39 | {
40 | waitOnApplicationFinished();
41 | m_thread->quit();
42 | m_thread->wait();
43 | }
44 |
--------------------------------------------------------------------------------
/OppositeRenderer/Standalone/StandaloneApplication.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #pragma once
8 |
9 | #include "Application.hxx"
10 | #include "StandaloneRenderManager.hxx"
11 |
12 | class QApplication;
13 | class ComputeDevice;
14 | class QThread;
15 | class StandaloneApplication : public Application
16 | {
17 | public:
18 | StandaloneApplication(QApplication & qApplication, const ComputeDevice & device);
19 | ~StandaloneApplication(void);
20 | void wait();
21 | private:
22 | StandaloneRenderManager m_renderManager;
23 | QThread* m_thread;
24 | };
--------------------------------------------------------------------------------
/OppositeRenderer/Standalone/StandaloneRenderManager.hxx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include
8 | #include
9 | #include
10 | #include "RunningStatus.h"
11 | #include
12 | #include "renderer/OptixRenderer.h"
13 | #include "renderer/Camera.h"
14 |
15 | class IScene;
16 | class Application;
17 | class QApplication;
18 | class ComputeDevice;
19 |
20 | class StandaloneRenderManager : public QObject
21 | {
22 | Q_OBJECT;
23 | public:
24 | StandaloneRenderManager(QApplication & qApplication, Application & application, const ComputeDevice& device);
25 | virtual ~StandaloneRenderManager();
26 | void renderNextIteration();
27 | void wait();
28 |
29 | public slots:
30 | void start();
31 |
32 | signals:
33 | void newFrameReadyForDisplay(const float* cpuBuffer, unsigned long long iterationNumber);
34 | void continueRayTracing();
35 | void renderManagerError(QString);
36 |
37 | private slots:
38 | void onSceneLoadingNew();
39 | void onSceneUpdated();
40 | void onContinueRayTracing();
41 | void onSequenceNumberIncremented();
42 | void onRunningStatusChanged();
43 |
44 | private:
45 | void fillRenderStatistics();
46 | void continueRayTracingIfRunningAsync();
47 |
48 | Application & m_application;
49 | unsigned long long m_nextIterationNumber;
50 |
51 | OptixRenderer m_renderer;
52 | Camera m_camera;
53 | QTime renderTime;
54 | float* m_outputBuffer;
55 | IScene* m_currentScene;
56 | const ComputeDevice & m_device;
57 | double m_PPMRadius;
58 | bool m_compileScene;
59 | bool m_noEmittedSignals;
60 | };
61 |
--------------------------------------------------------------------------------
/OppositeRenderer/Standalone/standalone.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Opposite Renderer
3 | * For the full copyright and license information, please view the LICENSE.txt
4 | * file that was distributed with this source code.
5 | */
6 |
7 | #include
8 | #include
9 | #include
10 | #include "gui/MainWindowBase.hxx"
11 | #include "StandaloneApplication.h"
12 | #include "ComputeDeviceRepository.h"
13 | #include
14 | #include
15 |
16 | //#include
17 |
18 | int main( int argc, char** argv )
19 | {
20 | QApplication qApplication(argc, argv);
21 | qApplication.setOrganizationName("Opposite Renderer");
22 | qApplication.setApplicationName("Opposite Renderer");
23 |
24 | QTextStream out(stdout);
25 | QTextStream in(stdin);
26 |
27 | try
28 | {
29 | ComputeDeviceRepository repository;
30 |
31 | const std::vector & repo = repository.getComputeDevices();
32 |
33 | out << "Available compute devices:" << endl;
34 |
35 | for(int i = 0; i < repo.size(); i++)
36 | {
37 | const ComputeDevice & device = repo.at(i);
38 | out << " " << i << ": " << device.getName() << " (CC " << device.getComputeCapability() << " PCI Bus "<< device.getPCIBusId() <<")" << endl;
39 | }
40 |
41 | int deviceNumber = repo.size() == 1 ? 0 : -1;
42 |
43 | while (deviceNumber >= repo.size() || deviceNumber < 0)
44 | {
45 | out << "Select 0-" << repo.size()-1 << ":" << endl;
46 | in >> deviceNumber;
47 | }
48 |
49 | out << deviceNumber << endl;
50 |
51 | ComputeDevice device = repo.at(deviceNumber);
52 |
53 | StandaloneApplication application = StandaloneApplication(qApplication, device);
54 |
55 | // Run application
56 | QThread* applicationThread = new QThread(&qApplication);
57 | application.moveToThread(applicationThread);
58 | applicationThread->start();
59 |
60 | MainWindowBase mainWindow(application);
61 | mainWindow.showMaximized();
62 | int returnCode = qApplication.exec();
63 | application.wait();
64 |
65 | applicationThread->quit();
66 | applicationThread->wait();
67 |
68 | return returnCode;
69 | }
70 | catch(const std::exception & E)
71 | {
72 | QMessageBox::warning(NULL, "Exception Thrown During Launch of Standalone", E.what());
73 | return -1;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/OppositeRenderer/include/GL/freeglut.h:
--------------------------------------------------------------------------------
1 | #ifndef __FREEGLUT_H__
2 | #define __FREEGLUT_H__
3 |
4 | /*
5 | * freeglut.h
6 | *
7 | * The freeglut library include file
8 | *
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
10 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
12 | * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
13 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15 | */
16 |
17 | #include "freeglut_std.h"
18 | #include "freeglut_ext.h"
19 |
20 | /*** END OF FILE ***/
21 |
22 | #endif /* __FREEGLUT_H__ */
23 |
--------------------------------------------------------------------------------
/OppositeRenderer/include/GL/glut.h:
--------------------------------------------------------------------------------
1 | #ifndef __GLUT_H__
2 | #define __GLUT_H__
3 |
4 | /*
5 | * glut.h
6 | *
7 | * The freeglut library include file
8 | *
9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
10 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
12 | * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
13 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15 | */
16 |
17 | #include "freeglut_std.h"
18 |
19 | /*** END OF FILE ***/
20 |
21 | #endif /* __GLUT_H__ */
22 |
--------------------------------------------------------------------------------
/OppositeRenderer/include/assimp/Compiler/poppack1.h:
--------------------------------------------------------------------------------
1 |
2 | // ===============================================================================
3 | // May be included multiple times - resets structure packing to the defaults
4 | // for all supported compilers. Reverts the changes made by #include
5 | //
6 | // Currently this works on the following compilers:
7 | // MSVC 7,8,9
8 | // GCC
9 | // BORLAND (complains about 'pack state changed but not reverted', but works)
10 | // ===============================================================================
11 |
12 | #ifndef AI_PUSHPACK_IS_DEFINED
13 | # error pushpack1.h must be included after poppack1.h
14 | #endif
15 |
16 | // reset packing to the original value
17 | #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
18 | # pragma pack( pop )
19 | #endif
20 | #undef PACK_STRUCT
21 |
22 | #undef AI_PUSHPACK_IS_DEFINED
23 |
--------------------------------------------------------------------------------
/OppositeRenderer/include/assimp/Compiler/pushpack1.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | // ===============================================================================
4 | // May be included multiple times - sets structure packing to 1
5 | // for all supported compilers. #include reverts the changes.
6 | //
7 | // Currently this works on the following compilers:
8 | // MSVC 7,8,9
9 | // GCC
10 | // BORLAND (complains about 'pack state changed but not reverted', but works)
11 | //
12 | //
13 | // USAGE:
14 | //
15 | // struct StructToBePacked {
16 | // } PACK_STRUCT;
17 | //
18 | // ===============================================================================
19 |
20 | #ifdef AI_PUSHPACK_IS_DEFINED
21 | # error poppack1.h must be included after pushpack1.h
22 | #endif
23 |
24 | #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
25 | # pragma pack(push,1)
26 | # define PACK_STRUCT
27 | #elif defined( __GNUC__ )
28 | # define PACK_STRUCT __attribute__((packed))
29 | #else
30 | # error Compiler not supported
31 | #endif
32 |
33 | #if defined(_MSC_VER)
34 |
35 | // C4103: Packing was changed after the inclusion of the header, propably missing #pragma pop
36 | # pragma warning (disable : 4103)
37 | #endif
38 |
39 | #define AI_PUSHPACK_IS_DEFINED
40 |
41 |
42 |
--------------------------------------------------------------------------------
/OppositeRenderer/include/assimp/ai_assert.h:
--------------------------------------------------------------------------------
1 | /** @file assert.h
2 | */
3 | #ifndef AI_DEBUG_H_INC
4 | #define AI_DEBUG_H_INC
5 |
6 | #ifdef _DEBUG
7 | # include
8 | # define ai_assert(expression) assert(expression)
9 | #else
10 | # define ai_assert(expression)
11 | #endif
12 |
13 |
14 | #endif
15 |
--------------------------------------------------------------------------------
/OppositeRenderer/include/assimp/defs.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apartridge/OppositeRenderer/d3b51aac5a86d57a21d5428aad3ffe873a5f0b60/OppositeRenderer/include/assimp/defs.h
--------------------------------------------------------------------------------
/OppositeRenderer/include/assimp/matrix3x3.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apartridge/OppositeRenderer/d3b51aac5a86d57a21d5428aad3ffe873a5f0b60/OppositeRenderer/include/assimp/matrix3x3.h
--------------------------------------------------------------------------------
/OppositeRenderer/include/assimp/matrix3x3.inl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apartridge/OppositeRenderer/d3b51aac5a86d57a21d5428aad3ffe873a5f0b60/OppositeRenderer/include/assimp/matrix3x3.inl
--------------------------------------------------------------------------------
/OppositeRenderer/include/assimp/matrix4x4.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apartridge/OppositeRenderer/d3b51aac5a86d57a21d5428aad3ffe873a5f0b60/OppositeRenderer/include/assimp/matrix4x4.h
--------------------------------------------------------------------------------
/OppositeRenderer/include/assimp/matrix4x4.inl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apartridge/OppositeRenderer/d3b51aac5a86d57a21d5428aad3ffe873a5f0b60/OppositeRenderer/include/assimp/matrix4x4.inl
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | OppositeRenderer
2 | ================
3 |
4 | GPU Photon Mapper
5 |
6 | Please read more about this project at URL:
7 | http://apartridge.github.io/OppositeRenderer/
8 |
9 | The forked project by igui contains some useful notes about building the project:
10 | https://github.com/igui/OppositeRenderer
11 |
--------------------------------------------------------------------------------