Git Product home page Git Product logo

simplescene's Introduction

SimpleScene

A Simple 3d OpenGL/OpenTK Scene manager in C#, which runs on Windows, Mac, and Linux.

(C) Copyright 2015-2017 by David W. Jeske, Sergey Butylkov

Released under the Apache 2.0 license.

Motivation

When I started to learn 3D, Axiom was just getting started, and as a port of ORGE, it was/is fairly complex to build and understand. Unity didn't exist. Instead I started with a simpler approachable library called Brume3D, and I learned quite a bit from it. However, it had two main problems. It was released under the LGPL, and it only ran on Windows (D3D). I found both of these points objectionable, so when I had learned enough, I created my own simple 3d library with OpenGL (OpenTK).

Features

  • 3d scene rendering with OpenTK, GL2.2 GLSL 120 for maximum compatibility
  • asset loading
    • wavefront OBJ
    • MD5MESH (with animations)
  • instanced rendering
  • shadow mapping
  • BVH space partitioning (with efficient dynamic updates)
  • A rudamentary 2D HUD framework based on Windows GDI

Documantation

simplescene's People

Contributors

honeyhazard avatar jeske avatar smoothdeveloper avatar tomnielsen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simplescene's Issues

Multi-pass lighting: More than 8 lights

It would be amazing if you used multi-pass lighting and etc. techniques I know very little about to allow more than 8 lights at one time.
The rough idea, as I've read it, is that you render the scene with the first 8 GL lights, then with the next set, then the next, and keep going until all lights are rendered.
... There's probably a better way to render large numbers of lights. Thus why I'm asking you, the much more skilled-with-OpenGL developer, to look into the possibilities.

[Feature] Camera Pan and smooth move in and out

Adding pan movement to the orbit camera would be nice addition. Panning would move the "look at" target and therefore rotations would still orbit around the new location. Smooth in and out movement using mouse click+drag in addition to wheel wheel steps would also be a nice addition. Perhaps right mouse which really isn't used for anything new here could be used to smoothly move in and out. Hold RMB+move mouse up moves in and down zooms out or something like that. You could also use the middle mouse button instead of the right mouse button for movement.

The in/out movement is separate from zooming which affects the FOV. I am not suggesting a zoom feature here.

arcball

Hi. I quite like this, having removed the ppsm shader call to get it to work on my laptop - would be nice if it dealt with this more gracefully..

Anyway, I noticed the camera mouse delta update code suffers from gimball lock (though it's all quaternion based.. I thought it would be ok).. so I've implemented an arcball-like solution on top of what's there. It's only a couple of methods on the camera class.. seems to work ok.. would you like it?

I've got it running inside a opentk GLControl, which was also a little fiddly. Might be nice to sort out that and include a demo..

Shader want compile with NVIDIA GPU

Have a laptop with Intel integrated HD GPU and NVIDIA GTX850M. When switching to NVIDIA GPU the application throws an GL Error: InvalidOperation.

GL Version = 4.4.0
GL Shader Version = 4.40 NVIDIA via Cg compiler
-- ss4_vertex.glsl --

-- ss4_fragment.glsl --

-- ss4_geometry.glsl --

Vertex info
-----------
0(38) : error C5025: lvalue in assignment too complex

Geometry info
-------------
0(102) : error C5025: lvalue in assignment too complex
0(102) : error C5025: lvalue in assignment too complex
0(102) : error C5025: lvalue in assignment too complex

ERROR: 0:16: 'dist' : geometry shader input varying variable must be declared as an array

Hello,

I compile and run time, the following error message appears, what is the problem?


-- bumpGeometry --
ERROR: 0:16: 'dist' : geometry shader input varying variable must be declared
as an array

noperspective varying vec3 dist;
ERROR: 0:19: '' : inconsistent qualifiers: storage
varying in vec3 VV[3];
ERROR: 0:20: '' : inconsistent qualifiers: storage
varying in vec3 vertexNormal[3];
ERROR: 0:21: '' : inconsistent qualifiers: storage
varying in vec3 lightPosition[3];
ERROR: 0:22: '' : inconsistent qualifiers: storage
varying in vec3 eyeVec[3];
ERROR: 0:23: '' : inconsistent qualifiers: storage
varying in vec3 vertexPosition_objectspace[3];
ERROR: 0:26: 'varying out' : supported in fragment shaders only
varying out vec3 f_VV;
ERROR: 0:27: 'varying out' : supported in fragment shaders only
varying out vec3 f_vertexNormal;
ERROR: 0:28: 'varying out' : supported in fragment shaders only
varying out vec3 f_lightPosition;
ERROR: 0:29: 'varying out' : supported in fragment shaders only
varying out vec3 f_eyeVec;
ERROR: 0:30: 'varying out' : supported in fragment shaders only
varying out vec3 f_vertexPosition_objectspace;
ERROR: 0:32: 'varying out' : supported in fragment shaders only
varying out vec3 surfaceLightVector;
ERROR: 0:33: 'varying out' : supported in fragment shaders only
varying out vec3 surfaceViewVector;
ERROR: 0:34: 'varying out' : supported in fragment shaders only
varying out vec3 surfaceNormalVector;
ERROR: 0:36: 'varying out' : supported in fragment shaders only
noperspective varying out vec3 f_dist;
ERROR: 0:83: 'surfaceLightVector' : undeclared identifier
surfaceLightVector = normalize(tangentSpaceMatrix * lightPosition[
i]);
ERROR: 0:83: 'assign' : cannot convert from '3-component vector of float' to 'f
loat'
surfaceLightVector = normalize(tangentSpaceMatrix * lightPosition[
i]);
ERROR: 0:84: 'surfaceViewVector' : undeclared identifier
surfaceViewVector = normalize(tangentSpaceMatrix * eyeVec[i]);
ERROR: 0:84: 'assign' : cannot convert from '3-component vector of float' to 'f
loat'
surfaceViewVector = normalize(tangentSpaceMatrix * eyeVec[i]);
ERROR: 0:85: 'surfaceNormalVector' : undeclared identifier
surfaceNormalVector = normalize(tangentSpaceMatrix * vertexNormal[i
]);
ERROR: 0:85: 'assign' : cannot convert from '3-component vector of float' to 'f
loat'
surfaceNormalVector = normalize(tangentSpaceMatrix * vertexNormal[i
]);
ERROR: 0:88: 'f_dist' : undeclared identifier
f_dist = vertexEdgeDistance[i];
ERROR: 0:88: 'assign' : cannot convert from '3-component vector of float' to 'f
loat'
f_dist = vertexEdgeDistance[i];
ERROR: 0:91: 'f_VV' : undeclared identifier
f_VV = VV[i];
ERROR: 0:91: 'assign' : cannot convert from '3-component vector of float' to 'f
loat'
f_VV = VV[i];
ERROR: 0:92: 'f_vertexNormal' : undeclared identifier
f_vertexNormal = vertexNormal[i];
ERROR: 0:92: 'assign' : cannot convert from '3-component vector of float' to 'f
loat'
f_vertexNormal = vertexNormal[i];
ERROR: 0:93: 'f_lightPosition' : undeclared identifier
f_lightPosition = lightPosition[i];
ERROR: 0:93: 'assign' : cannot convert from '3-component vector of float' to 'f
loat'
f_lightPosition = lightPosition[i];
ERROR: 0:94: 'f_eyeVec' : undeclared identifier
f_eyeVec = eyeVec[i];
ERROR: 0:94: 'assign' : cannot convert from '3-component vector of float' to 'f
loat'
f_eyeVec = eyeVec[i];
ERROR: 0:95: 'f_vertexPosition_objectspace' : undeclared identifier
f_vertexPosition_objectspace = vertexPosition_objectspace[i];
ERROR: 0:95: 'assign' : cannot convert from '3-component vector of float' to 'f
loat'
f_vertexPosition_objectspace = vertexPosition_objectspace[i];

** Shader Compile Failed **
The fragment shader uses varying surfaceLightVector, but previous shader does no
t write to it.
The fragment shader uses varying f_vertexNormal, but previous shader does not wr
ite to it.
The fragment shader uses varying f_lightPosition, but previous shader does not w
rite to it.
The fragment shader uses varying f_eyeVec, but previous shader does not write to
it.
The fragment shader uses varying f_dist, but previous shader does not write to i
t.

Unhandled Exception: System.Exception: GL Error: InvalidValue
at SimpleScene.SSShaderProgram_Main..ctor() in f:\Simple
Scene-master\SimpleScene\Core\SSShaderProgram_Main.cs:line 102
at WavefrontOBJViewer.WavefrontOBJViewer.Main() in f:\Si
mpleScene-master\WavefrontOBJViewer\Main.cs:line 110

Change texture on loaded meshs

How change texture on OBJ or md5 meshs?
Changing Mesh.textureMaterial or Object.textureMaterial does not work.
After loading and instancing mesh on scene *_.texture Material *_always NULL.

FBX Support?

Hello
Instead of use of the static OBJ, is support of the Autodesk FBX format planned?

Ability to change mesh's texture?

I was looking for a way to change an SSObjectMesh's texture while the program is running. My attempt at it was:

myObjectMesh.textureMaterial = new SSTextureMaterial (myNewTexture);

However, this doesn't seem to do anything -- I'm guessing I'm misunderstanding how SimpleScene handles this, looking for any suggestions! Thanks.

Compile fine but Not able to run demos

        SSAssetManager.AddAssetArchive(new SSAssetArchiveHandler_FileSystem("./Assets"));
            SSAssetManager.AddAssetArchive(new SSAssetArchiveHandler_FileSystem("../../Assets"));
            SSAssetManager.AddAssetArchive(new SSAssetArchiveHandler_FileSystem("../../../Assets"));
            SSAssetManager.AddAssetArchive(new SSAssetArchiveHandler_FileSystem("../../../../Assets"));
            SSAssetManager.AddAssetArchive(new SSAssetArchiveHandler_FileSystem("../../../DemosCommon/Assets"));

            mainShader = new SSMainShaderProgram(); // before mscene
            if (!mainShader.IsValid) {
                throw new Exception ("Failed to build the main shader");
            }

open in visual studio. Compile all. Fine.
GDiviaAGGTest works fine
But all TestBench fails at this stage
=> throw new Exception

Shadows too dark?

I do like the shadowmaps, models are bright on the lighted side, however the darker sides are pitch-black. Even if I set lighted to true on the object I don't see a difference. In older versions the shadowmap wasn't as advanced but models could be rendered with flat lighting and no shadows. I looked around the entire project but could not find a way to recreate this, disabling the shadow map simply renders the object black.

ssBVH code does not agree with comment

The first if statement in the following code snippet (in file ssBVH_Node.cs)

           // perform the best rotation...            
            if (bestRot.rot != Rot.NONE) {
                // if the best rotation is no-rotation... we check our parents anyhow..                
                if (parent != null) { 
                    // but only do it some random percentage of the time.
                    if ((DateTime.Now.Ticks % 100) < 2) {
                        bvh.refitNodes.Add(parent); 
                    }
                }                
            } else {
                // ...
            } 

should be replace by the following line of code???

if (bestRot.rot == Rot.NONE) {

build error

Hello,

I got theses errors.

Error 5 The type or namespace name 'SSLight' could not be found (are you missing a using directive or an assembly reference?) I:\test 1\SimpleScene-master\WavefrontOBJViewer\Main_setupScene.cs 34 20 WavefrontOBJViewer

Error 6 The name 'SSLight' does not exist in the current context I:\test 1\SimpleScene-master\WavefrontOBJViewer\Main_setupScene.cs 35 17 WavefrontOBJViewer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.