TheCherno / Sparky

Cross-Platform High Performance 2D/3D game engine for people like me who like to write code.
Apache License 2.0
1.09k stars 222 forks source link

OpenGL shader #70

Closed Ilohama closed 8 years ago

Ilohama commented 8 years ago

Hey! First of all, I'm running the sandbox on a Intel HD Graphics 4000 just to advice.

Second is that the renderer isn't working with OpenGL (I tried with D3, and it works totally fine). The scene is created, i have all of 3D stuff but the 2D stuff isn't working at all (I put errors at the end).

So i can understand that my OpenGL version won't support the version 330 core but why all the 3D stuff is working?

Here is the Sparky console errors :

SPARKY:    ----------------------------------
SPARKY:     OpenGL:
SPARKY:        4.0.0 - Build 10.18.10.4358
SPARKY:        Intel`
SPARKY:        Intel(R) HD Graphics 4000
SPARKY:    ----------------------------------

--------------------------- Test3D Part ---------------------------

SPARKY:    Failed to compile fragment shader!
ERROR: 0:12: '' : array size too big
ERROR: 0:20: 'textures' : undeclared identifier
ERROR: 0:20: 'textures' :  left of '[' is not of type array, matrix, or vector
ERROR: 0:20: 'texture' : no matching overloaded function found (using implicit conversion)
ERROR: 0:25: 'textures' : undeclared identifier
ERROR: 0:25: 'textures' :  left of '[' is not of type array, matrix, or vector
ERROR: 0:25: 'texture' : no matching overloaded function found (using implicit conversion)
ERROR: 0:25: 'assign' :  cannot convert from 'const float' to '4-component vector of float'

SPARKY:    BatchRenderer: could not find uniform sys_ProjectionMatrix in shader!
SPARKY:    BatchRenderer: could not find uniform sys_ViewMatrix in shader!
SPARKY:    BatchRenderer: could not find uniform sys_ModelMatrix in shader!
SPARKY:    BatchRenderer: could not find uniform sys_MaskMatrix in shader!
SPARKY:    BatchRenderer: could not find uniform textures in shader!
SPARKY:    BatchRenderer: could not find uniform textures in shader!
SPARKY:    Failed to compile fragment shader!
ERROR: 0:12: '' : array size too big
ERROR: 0:20: 'textures' : undeclared identifier
ERROR: 0:20: 'textures' :  left of '[' is not of type array, matrix, or vector
ERROR: 0:20: 'texture' : no matching overloaded function found (using implicit conversion)
ERROR: 0:25: 'textures' : undeclared identifier
ERROR: 0:25: 'textures' :  left of '[' is not of type array, matrix, or vector
ERROR: 0:25: 'texture' : no matching overloaded function found (using implicit conversion)
ERROR: 0:25: 'assign' :  cannot convert from 'const float' to '4-component vector of float'

SPARKY:    BatchRenderer: could not find uniform sys_ProjectionMatrix in shader!
SPARKY:    BatchRenderer: could not find uniform sys_ViewMatrix in shader!
SPARKY:    BatchRenderer: could not find uniform sys_ModelMatrix in shader!
SPARKY:    BatchRenderer: could not find uniform sys_MaskMatrix in shader!
SPARKY:    BatchRenderer: could not find uniform textures in shader!
SPARKY:    BatchRenderer: could not find uniform textures in shader!

SPARKY:    Skybox: could not find uniform sys_ProjectionMatrix in shader!
SPARKY:    Skybox: could not find uniform sys_ViewMatrix in shader!
SPARKY:    Skybox: could not find uniform sys_ModelMatrix in shader!
SPARKY:    Skybox: could not find uniform sys_CameraPosition in shader!
SPARKY:    AdvancedLighting: could not find uniform u_NormalColor in shader!

--------------------------- Test2D Part ---------------------------

SPARKY:    Failed to compile fragment shader!
ERROR: 0:12: '' : array size too big
ERROR: 0:20: 'textures' : undeclared identifier
ERROR: 0:20: 'textures' :  left of '[' is not of type array, matrix, or vector
ERROR: 0:20: 'texture' : no matching overloaded function found (using implicit conversion)
ERROR: 0:25: 'textures' : undeclared identifier
ERROR: 0:25: 'textures' :  left of '[' is not of type array, matrix, or vector
ERROR: 0:25: 'texture' : no matching overloaded function found (using implicit conversion)
ERROR: 0:25: 'assign' :  cannot convert from 'const float' to '4-component vector of float'

SPARKY:    BatchRenderer: could not find uniform sys_ProjectionMatrix in shader!
SPARKY:    BatchRenderer: could not find uniform sys_ViewMatrix in shader!
SPARKY:    BatchRenderer: could not find uniform sys_ModelMatrix in shader!
SPARKY:    BatchRenderer: could not find uniform sys_MaskMatrix in shader!
SPARKY:    BatchRenderer: could not find uniform textures in shader!
SPARKY:    BatchRenderer: could not find uniform textures in shader!
TheCherno commented 8 years ago

Your OpenGL version is 4.0, so everything in Sparky should work. Just to be clear, Test2D isn't working in OpenGL, but Test3D does work? If so, do you see the FPS counter and other debug text when running Test3D? Does Ctrl-Tab bring up the debug menu?

Ilohama commented 8 years ago

Test3D is working only for 3D, all the debug text, FPS counter, Debug menu (I assume that's all the 2D parts) isn't working at all.

PS : sorry for time to respond, i was watching the release vid.

TheCherno commented 8 years ago

Could you try reducing the sampler array size in BatchRenderer.shader from 32 to 8? See if that works. (https://github.com/TheCherno/Sparky/blob/master/Sparky-core/src/sp/platform/opengl/shaders/BatchRenderer.shader#L54)

Ilohama commented 8 years ago

Well, 2D part is working now but some errors still remains. After a test, these debug var on the debug menu doesn't work :

Remaining Test3D errors :

SPARKY:    BatchRenderer: could not find uniform sys_ViewMatrix in shader!
SPARKY:    BatchRenderer: could not find uniform sys_ModelMatrix in shader!
SPARKY:    BatchRenderer: could not find uniform sys_MaskMatrix in shader!
SPARKY:    BatchRenderer: could not find uniform sys_ViewMatrix in shader!
SPARKY:    BatchRenderer: could not find uniform sys_ModelMatrix in shader!
SPARKY:    BatchRenderer: could not find uniform sys_MaskMatrix in shader!

SPARKY:    Skybox: could not find uniform sys_ProjectionMatrix in shader!
SPARKY:    Skybox: could not find uniform sys_ViewMatrix in shader!
SPARKY:    Skybox: could not find uniform sys_ModelMatrix in shader!
SPARKY:    Skybox: could not find uniform sys_CameraPosition in shader!
SPARKY:    AdvancedLighting: could not find uniform u_NormalColor in shader!
TheCherno commented 8 years ago

Padding works after restarting the debug menu (close and re-open). The rest of those debug menu items just aren't hooked up anymore (take a look at Test3D and what those items do). Light direction and intensity should still work though, are you sure that it doesn't? Does it work in DirectX/OpenGL?

As for those logging errors, those are more or less warnings. I'm curious to see where they're coming from, but they're not vital. Everything in the viewport should be working. Also, do those warnings appear in OpenGL only?

Ilohama commented 8 years ago

(bunch of test later) So, Light pos/intensity isn't working only with OpenGL, but totally works with DX. Reported logging error appear red, so even if it's more or less warnings, it's only appear on OpenGL. DX bring me some warnings but no errors (nothing red in console, and it's write 'warning' and practicaly truncation warnings) and these are not comming from sparky.

TheCherno commented 8 years ago

Original issue resolved.