bennyqbd / 3denginecpp Goto Github PK
View Code? Open in Web Editor NEWIt's like the 3D Game Engine, except in C++
License: Apache License 2.0
It's like the 3D Game Engine, except in C++
License: Apache License 2.0
It's seems to me that you have error when adding m_distance when determing if plane IntersectSphere.
With simple example plane1(Vector3f(0.0f, 1.0f, 0.0f), 3.0f); and sphere2(Vector3f(0.0f, 3.0f, 0.0f), 1.0f); you will get not intersecting and distance 5, but plane in the middle of sphere.(like in Image)
Maybe I don't understand, how you define plane, or dot product of vector3.
Can you help me with this?
your project is awsome,but what about any plan to add model animation feature on your engine? I think it would be very nice.
I've just noticed in the shadow mapping code, the shadow map coordinates are generated by multiplying the lightMatrix with the model-space position of the vertex.
Considering that the light matrix only contains the 'view' and 'projection' parts, don't we need to do lightMatrix * vec4(worldSpacePosition, 1.0)
rather than lightMatrix * vec4(modelSpacePosition, 1.0)
.
Or does your rendering engine include the model matrix in the lightMatrix
somewhere.
This is a weird issue because it seems fine with your game, but with my own game engine (with the shadow mapping code inspired by yours) I need to use the worldSpacePosition
for it to work correctly.
Some weird issue occurs when I run this. I have followed the build instructions and when I run, all I see is a black screen.
When I back up a little bit(S key) I see this
And when I back up even more, this shows up
I'm on Windows 7 (32 bit), using Visual Studio Express 2013
OpenGL version (according to graphics card) is 6.14.10.12874
Hello, I found out, that in Mavericks you should extend the window.cpp with these lines to around 26th line:
SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 3 );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 2 );
this should fix the problems maybe, for me, it was resolved after this, hence the stock SDL context created was for glsl 1.20...here is the error log if I remove those lines
Supported GLSL version is 1.20.
Error compiling shader type 2: 'ERROR: 0:1: '' : version '330' is not supported
ERROR: 0:2: 'layout' : syntax error syntax error
Program ended with exit code: 1
Creating a texture render target with a stencil attachment gives me GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT error. To create the texture target I use these parameters:
Any idea why?
Does anybody have fixed matrix inverse function?
Visual Studio is not capable of compiling your project anymore. This is, because you used GLenum drawBuffers[m_numTextures];
and Visual Studio doesn't want you to create dynamic arrays this way. The easy fix GLenum* drawBuffers = new GLenum[m_numTextures];
does not work either (but at least it compiles). It gives you this:
I was googling for something and found your repo. It looks interested for me, I downloaded it, but building gives errors !
I'm using vs2013 :
Error 4 error C1083: Cannot open source file: 'basicShader.cpp': No such file or directory
Error 1 error C1083: Cannot open source file: 'phongShader.cpp': No such file or directory
just letting you know :)
In case you committed the project correctly, I might consider make the mac build/xcodeProject for you as a support. may be some one out there need it !
cheers;
Fixes to prevent Policy warnings from syntax errors in CMake code files.
insert: SET(PROGRAMFILESX86 "PROGRAMFILES(X86)")
before: SET( GLEW_SEARCH_PATHS
and
change: "$ENV{PROGRAMFILES(X86)}/GLEW" # WINDOWS
to: "$ENV{${PROGRAMFILESX86}}/GLEW" # WINDOWS
insert: SET(PROGRAMFILESX86 "PROGRAMFILES(X86)")
before: SET( SDL2_SEARCH_PATHS
and
change: "$ENV{PROGRAMFILES(X86)}/SDL2" # WINDOWS
to: "$ENV{${PROGRAMFILESX86}}/SDL2" # WINDOWS
insert: SET(PROGRAMFILESX86 "PROGRAMFILES(X86)")
before: SET( ASSIMP_SEARCH_PATHS
and
change: "$ENV{PROGRAMFILES(X86)}/ASSIMP" # WINDOWS
to: "$ENV{${PROGRAMFILESX86}}/ASSIMP" # WINDOWS
Fixes to prevent program execution abort on free(): invalid pointer.
from: void operator=(Texture texture);
to: Texture& operator=(Texture other) noexcept;
File: ./src/rendering/texture.cpp, lines 207-213
replace:
void Texture::operator=(Texture texture)
{
char* temp[sizeof(Texture)/sizeof(char)];
memcpy(temp, this, sizeof(Texture));
memcpy(this, &texture, sizeof(Texture));
memcpy(&texture, temp, sizeof(Texture));
}
with:
Texture& Texture::operator=(Texture other) noexcept
{
//Implemented using move assignment.
//Guard self assignment
if (this == &other)
return *this;
if(m_textureData && m_textureData->RemoveReference())
{
if(m_fileName.length() > 0)
s_resourceMap.erase(m_fileName);
delete m_textureData;
}
m_fileName = other.m_fileName;
m_textureData = other.m_textureData;
m_textureData->AddReference();
return *this;
}
Originally posted by @gedeschaines in #45 (comment)
Hi, I'd like to ask how to implement vertex normals into this engine properly. No matter what I do, I either get broken or face normals as the result.
So I'd like to know if someone had a success implementing vertex normals in here.
The reason for smooth shading is my terrain generated from heightmap. My terrain feels blocky due to flat normals. See: http://prntscr.com/9xqiqb
Pointlight casting light on a spherical object, leaves a very sharp edge at the projection edge. Clearly I am throwing around words that I don't understand so here have a picture:
See the sharp edge from the orange light behind the object? Maybe one could solve this with something similar to what you did with the shadows.
And a very similar thing happens with the selfshadow(Don't know if this word exists in English but I mean the shadow produced on the own geometry)
Oh and please add this to freeMove.cpp:
if (input.GetKey(m_upKey))
Move(GetTransform()->GetRot()->GetUp(), movAmt);
if (input.GetKey(m_downKey))
Move(GetTransform()->GetRot()->GetDown(), movAmt);
it makes life easier xD
Hello,
From my point of view plane normalization contains a bug
Plane is defined with normal and distance.
That means, we should find some plane point just by multiplication:
P = N * D
if plane was defined like:
plane1(Vector3f(0.0f, 2.0f, 0.0f), 3.0f);
means, that P = (0, 6, 0)
after plane normalization with current implementation we will have:
plane1Norm (Vec3(0, 1, 0), 1.5);
as a result P1 = Vec3(0, 1, 0) * 1.5 = (0, 1.5, 0)
instead of (0, 6, 0)
I think in normalized method distance should be multiplied by magnitude instead of division.
Plane Plane::Normalized() const
{
float magnitude = m_normal.Length();
//Dividing the normal by it's length performs vector normalization.
//Distance however, must also be divided by the normal's length in
//order to create an equivalent plane.
- return Plane(m_normal/magnitude, m_distance/magnitude);
+ return Plane(m_normal/magnitude, m_distance*magnitude);
}
Are you going to add animation?
The current version of the engine gives the error message "Error linking shader program: Fragment shader writes to more than 1 type of output gl_FragData, gl_FragColor or user bound frag data.". The error occurs while compiling filter-fxaa.fs.
Hello, Benny.
I really liked your Intro to modern OpenGL tutorial and decided to try your Game Engine in C++. It compiled fine (I use Visual Studio 2012 and all dependences are resolved with versions of libraries from your repository). But during the runtime at some point assertion failes (see screenshot, I output names of the uniforms before the assertion check to see when it failes). Can it be that name of the uniform is too long or something else specific to my case? If I comment the assertion check it runs but without any lighting.
Thanks in advance.
Hi, today i encountered some glitches with the rendering of the Light in combination with the Paralax Mapping. Right now i am trying to find a commit where this is not occurring, i wonder if this is a new glitch or i simply did no recognized this. Maybe it hast something to do with a new graphics driver .. i really wonder why i did not recognized this in earlier commits ...
https://www.youtube.com/watch?v=jJeSTRz-mU8
archlinux 3.14.5-1
nvidia 337.25 xorg 1.15
GTX 750 Ti
Set your zFar plane from 1000.0 to 50.0 ... you can see that ambient gets culled off, but lights render remaining geometry as "transparent" --- it's same issue when you apply projection matrix which is not right-handed but left-handed...
Does anyone please know how to solve this issue?
I know you talked about that in your Video[*] and maybe you alredy fixed this but i just want to catch your attention in case you overlooked this.
as one can cleary see, the light is coming from the yellow direction. the shadowed part (green) should be lit by the light and the highlights (red) should be exactly on the other side of the brick.
Hi, it's me again with the same problem as on OSX. On M$ Windows 8.1 (MSVC 2013 Ultimate) I wasn't able to compile the program, just because those added lines, so I suggest to wrap it around like this
#ifdef __APPLE__ && ifdef __MACH__
SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 3 );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 2 );
#endif
in window.cpp around line 25 and it should work out of the box
Hello, I've recently tried to build the modified code you made when I proposed you to put preprocessor macro to the version setting in window.cpp...it works flawless with Windows 8.1 and MSVC 12 (2013) but it throws me error for OpenGL context as far as I don't remove or comment out those lines of setting up GL version via SDL...I'm truly sorry to bug you around with this crap, but on the other side, it should be cured in some way
I was recently looking at importing the sponza model into the engine but found it wouldnt load correctly due to the lack of support for multiple meshes in obj files.
The current version of the engine gives the error message
"Unhandled exception at 0x00099C63 in 3DEngineCpp.exe: 0xC0000005: Access violation reading location 0x0000000C.".
Its in mesh.cpp line 248 (const aiMesh* model = scene->mMeshes[0];)The error occurs while trying to load terrain2.obj (error appears only on windows) propably because outdated assimp :) (sorry for bad english im from Czech Republic )
//EDIT: closed, because i just removed by mistake my RES folder :D (stupid me)
Hi, just wanna ask if someone had difficulties running the engine.
It seems to crash on MappedValues::SetTexture method.
Engine crashes to terminal.
Hi Benny, I'm porting your 3DEngine to Java and accidentally bump into issue with texture creation.
In you Variance Shadow Mapping Implementation video you changed shadowMap internal format to GL_RG32F and since then is my rendering broken. The PCF shadow smoothing work just fine, but this is not.
The issue started here, after changing this line:
setTexture("shadowMap", new Texture(1024, 1024, null, GL_TEXTURE_2D, GL_NEAREST, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, true, GL_DEPTH_ATTACHMENT));
to line:
setTexture("shadowMap", new Texture(1024, 1024, null, GL_TEXTURE_2D, GL_LINEAR, GL_RG32F, GL_RGBA, true, GL_COLOR_ATTACHMENT0));
Here is my commit of changing code back to PCF shadows:
deamont66/3DEngine@82d9a5a
My code is complete mirror of this commit: https://github.com/BennyQBD/3DEngineCpp/tree/001bc572e85e090df77cd9de2f3cfa61ab3b563a
I don't really know what the issue can be. I have laptop with Intel Integrated Graphic (3.1.0 - Build 9.17.10.3347) and NVidia m555 (4.4.0) on both same result.
P.S.: My code include the fix for depth textures on Intel (glReadBuffer), but changing or removing it doesn't make any effect at all. And sorry for my bad English but it's not my native language.
I will be glad for any help, Thanks.
Hey Benny,
I got a issue with my window sync time. I profile SDLSwapBuffers which calls SDL_GL_SwapWindow(window) and it needs a lot of time. On our Forward-Renderer needs it nearly the same amount of time to sync as to render, at the moment about 32ms. On my Deferred-Renderer is the render time nearly 3ms but the sync time about 60 ms. Do you have any idea whats going on?
Thanks in advance and sorry for my bad english.
hi!
I've compiled the project in linux mint for codeblocks, but I get a pointer error. In "stb_image.c" the free() funcions is giving an error. what can i do?
thanks have a good day.
The vast majority of the code in this project is C, and it is confusing to anybody searching for C projects when they come across this with Cpp in the name. Just a recommendation.
Hi, Benny. I really like your series and I am really interested to see a 3D physics engine being implemented. However, the number of classes is getting too much for one folder. Maybe splitting it up into seperate folders for rendering, profiling, etc. (Sorry, I have only known C++ for a few weeks) This is just a suggestion.
The latest commit which implements variance shadow mapping appears to have broken the functionality as it existed pre-shadows.
The first soft shadowing code worked perfectly but the variance shadow mapping code appears to break all the lighting, normal mapping etc although there are basic textures rendered.
This was run using unmodified latest checking from the repository. Maybe another nVidia/Intel/ATI issue?
Shadow banding appears to be fixed but I still have this issue even with the most recent code. If you pan back while viewing the scene, the shadows begin to disappear. You can see the artifact line moving across where the shadows get removed although it is not visible in the images. I'm working on Windows, VS2013 and have a GTX770.
The current forward rendering technique is easy to learn and good to understand, but a deferred render pipeline would improve performance immense.
I'm working currently on a deferred renderer, but I got some troubles.
Benny, will you implement a deferred renderer sometimes?
Hi Benny,
Thank you for your great tutorials, but I am having a issue with Mesh load failed as shown below. Do you have any idea why its happen?
I am using mac OS(Yosemite), Xcode6.1.1 and have installed SDL2, glew, assimp with brew and cmaked as you described.
The models haven't been moved from the res folder.
Thank you in advance,
ochos
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.