-
Posts
2,346 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Posts posted by SpiderPig
-
-
And the answer is :
#include "../../../../../../../../UltraEngine/Templates/Common/Shaders\Base\Materials.glsl"
Relatively speaking.
-
I wanted to try and compile some shaders in a location away from the validator and the .glsl files. It compiles fine so long as I don't try to include anything in the shader.
The BAT file;
C:\UltraEngine\Tools\glslangValidator.exe "C:\_output\Test.frag" -V -o "C:\_output\Test.frag.spv"
The Shader;
#version 450 #extension GL_GOOGLE_include_directive : enable #extension GL_ARB_separate_shader_objects : enable #extension GL_EXT_multiview : enable //Compiles if this line is commented out #include "C:\UltraEngine\Templates\Common\Shaders\Base\Materials.glsl" layout(location = 0) out vec4 outColor; void main() { outColor = vec4(0.0f, 1.0f, 1.0f, 1.0f); }
Does the validator only use relative paths somhow?
-
I have found it.
"OPAQUE": { "default": { "base": { "geometry": "Materials/Point.geom.spv", "fragment": "Materials/Point.frag.spv" }, "depthPass": { "geometry": "Materials/Point.geom.spv" } } }
-
Ah yes that is the problem. Where does that go in the shader family JSON?
{ "shaderFamily": { "root": "Shaders/PBR.json", "static": { "float": { "OPAQUE": { "default": { "base": { "geometry": "Materials/Point.geom.spv", "fragment": "Materials/Point.frag.spv" } } }, "MASK": { "default": { "base": { } } } }, "double": { "OPAQUE": { "default": { "base": { } } }, "MASK": { "default": { "base": { } } } } } } }
-
I've had no luck with this. When I add a geometry stage to the material family, it's fragment shader no longer works. The points seem to be showing the background color. I've got a simplified example here, it should move the verts a bit and they should be green.
#include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 1440, 900, displays[0]); auto framebuffer = CreateFramebuffer(window); auto world = CreateWorld(); auto camera = CreateCamera(world); camera->Move(0, 2, 0); camera->SetClearColor(1, 0, 0); auto light = CreateDirectionalLight(world); light->SetColor(5.0f); light->SetRotation(35, 35, 35); auto floor = CreateBox(world, 100.0f, 0.5f, 100.0f); auto model = CreateModel(world); auto mesh = model->AddMesh(MESH_POINTS); for (int z = 0; z < 100; z++) { for (int x = 0; x < 100; x++) { mesh->AddVertex((float)x / 10.0f - 5.0f, 1.0f, (float)z / 10.0f); } } model->UpdateBounds(); model->SetMaterial(LoadMaterial("Materials\\Point.mat")); while (window->KeyHit(KEY_ESCAPE) == false && window->Closed() == false) { world->Update(); world->Render(framebuffer); } return 0; }
-
Ooo nice. I'd like to read that!
- 2
-
I deleted a few faces and remade them but still the same result. There are no double vertices and they appear to be correctly connected.
-
This is just perplexing. The one on the left was made in blender, the right was exported from marching cubes. Both have flat shading. The left has a few more faces and vertices on the bevel, but, why the odd shading around the triangles on the right?
-
I noticed this a while ago just briefly. Text area works but text field is not visible. The project is up to date.
#include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 1440, 900, displays[0]); auto framebuffer = CreateFramebuffer(window); auto world = CreateWorld(); auto camera = CreateCamera(world); camera->Move(0, 2, -3); camera->SetClearColor(1, 0, 0); auto light = CreateDirectionalLight(world); light->SetRotation(35, 35, 35); auto floor = CreateBox(world, 100.0f, 0.5f, 100.0f); auto default_font = LoadFont("Fonts\\arial.ttf"); auto ui = CreateInterface(world, default_font, framebuffer->size); ui->SetRenderLayers(2); ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f); auto ui_camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); ui_camera->SetPosition((float)framebuffer->size.x * 0.5f, (float)framebuffer->size.y * 0.5f, 0); ui_camera->SetRenderLayers(2); ui_camera->SetClearMode(CLEAR_DEPTH); //auto text = CreateTextArea(0, 0, 512, 30, ui->root); auto text = CreateTextField(0, 0, 512, 30, ui->root); text->SetText("Hello Ultra"); while (window->KeyHit(KEY_ESCAPE) == false && window->Closed() == false) { while (PeekEvent()) { ui->ProcessEvent(WaitEvent()); } world->Update(); world->Render(framebuffer); } return 0; }
-
Yeah that's a good idea. I briefly looked at getting normals from an SDF in a shader. I think it's just a few extra samples in some known directions... I will try this.
-
I saw here I might need to do a better job at averaging the normals of shared vertices. It says to use the angle to determine the weight that each face's normal will effect the vertex. I tried with the dot product and seemed to get slightly better results but I'm unsure on exactly what the value of "Angle" in this answers code should be. Degrees maybe? or just 0 to 1?
Is there a "proper" method of average normals for shared vertices? Usually I just add all the faces normals up that share the vertex and divided by total number of faces that share it. Might be half my problem.
-
Thanks I had no idea it could be done that easily in GIMP.
- 2
-
Thanks I'll try it!
-
I agree, its a bit messy. I could merge vertices in a 2nd pass but I think it'll be a bit slow - or maybe it could be done in one pass as I create the vertices... but Surface Nets should make better geometry because the vertices should be relative evenly spaced, and there will be less triangles too. I'm working on it now so should have some results soon.
-
-
Found this. The normals here don't look too amazing. I think they're smooth shading, kind of looks like it.
-
Love the Model::Save() method.
In blender I confirmed there is no double up on verts, all triangles are sharing what they should be. These are the exported normals. Using blender to recalculate smooth shading gave no visual difference. I thought they should look better than this? Maybe this is another pitfall of marching cubes. Too many small thin triangles!
-
I've decided I will write a method that saves a voxel terrains component as a mesh so I can do some more testing on it in a separate program. I'll upload some results and hopefully find what I'm doing wrong.
-
-
Issues disappears when I delete the directional light.
-
I wonder if it's too much to ask for a temporary solution for this? Just the ability to get the index the material is stored in the shader is enough, I can do the rest and send it to my shader. I'd like to get a nice material up and running for the voxel terrain. I'm just guessing at what the material index is in the shader. It changes though as the game grows though.
-
On 3/7/2023 at 5:44 PM, Josh said:
Or maybe you are seeing some shadow acne. What happens if you increase the light's shadow map size?
https://www.ultraengine.com/learn/Light_SetShadowMapSize?lang=cpp
I just tried it and it made no difference. I tried a size of 32 and 8192.
-
-
Thanks for you help too Josh. Your pointing out what should have been obvious to me pushed me in the right direction.
Shader Master (Node Editor for Custom Shaders)
in Showcase
Posted
Thought I'd show off my node editor for Ultra Engine Shaders. Currently I'm developing it as I develop my game, so features get added as I need them. But I'd love to hear your feedback and if you'd like me to add something I'm sure I can oblige.
Discord for ShaderMaster
ShaderMaster_v1.3.zip
Before use, you need to set the path to UltraEngine like this so it can find the tools and shaders. You will also need to copy 'FragmentCustom.glsl' to 'UltraEngine\Templates\Common\Source\Shaders\PBR' in order to use the fragment shader nodes.
Then to create a new project go to File->New Project and enter in a name. PBR is the only available at the moment and you can choose PostEffect from the right drop down - but this has not been tested in some time! Feel free to explore it though.
Add a file to the project by clicking the file icon with the '+'. Below are the files associated with one of my projects. Macros are also visible when the checkbox is checked. Macros are functions that can be used between projects. Create a function, right click the function file and choose 'Convert to Macro'. The function will be removed the current project and added to the macro folder.
Choose a file type, this is either a shader stage or a function or definition. I've used the fragment shader extensively. I have used the vertex and geometry shaders though there may be bugs here. Please let me know. Tessellation and Compute stages aren't working yet.
Select a file from the list on the right to open it and right click in the node area to get a menu of all the available nodes.
I'll make in depth tutorials on this later if any one is interested as there's a lot more to cover. Right now it's there to play with.
An example of the fragment shader for my voxel terrain.