Jump to content

How to use Stipple shader?


Dreikblack
 Share

Go to solution Solved by Josh,

Recommended Posts

Model just became invisible with it. What am i doing wrong?

#include "UltraEngine.h"

using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    //Get the displays
    auto displays = GetDisplays();

    //Create a window
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);

    //Create a world
    auto world = CreateWorld();

    //Create a framebuffer
    auto framebuffer = CreateFramebuffer(window);

    //Create a camera
    auto camera = CreateCamera(world);
    camera->SetClearColor(0.125);
    camera->SetPosition(0, 0, -4);

    //Create a light
    auto light = CreateBoxLight(world);
    light->SetRotation(45, 35, 0);
    light->SetRange(-10, 10);
    light->SetColor(2);

    //Create a model
    auto model = CreateBox(world);
    model->SetColor(0, 0, 1, 0.5f);
    auto strippleMaterial = CreateMaterial();
    ChangeDir(AppDir());
    auto strippleShader = LoadShaderFamily("Shaders/Editor/Stipple.fam");
    strippleMaterial->SetShaderFamily(strippleShader);
    model->SetMaterial(strippleMaterial);

    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

Link to comment
Share on other sites

  • Solution

If you add this inside the shaderfamily structure in the file, it will behave like a standard shader:

"root": "Shaders/PBR.fam"

Note that this shader is not really line stippling, it just discards pixels in a grid pattern.

image.thumb.png.534f201986e9a55577074c4bb4bed866.png

  • Like 2

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

8 minutes ago, SpiderPig said:

Maybe the shader needs to be applied to the mask section of the shader family as well?

Same result. Not sure if i did it right tho
 

{
	"shaderfamily":
	{
		"root": "Shaders/PBR.fam",
		"static":
		{
			"float": {
				"opaque": {
					"default": {
						"base": {
							"vertex": "Shaders/PBR/PBR.vert",
							"fragment": "Shaders/Editor/Stipple.frag"
						}
					}
				},
				"mask": {
					"default": {
						"base": {
							"vertex": "Shaders/PBR/PBR.vert",
							"fragment": "Shaders/Editor/Stipple.frag"
						}
					}
				}
			}
		}
	}
}

 

Link to comment
Share on other sites

You could also use alpha masking, and define a fragment shader in the depth pass settings.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Keep in mind, if you have 45 degree lines they will hit some spots where they appear completely solid, and in some positions they will disappear, because it's a checker pattern.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...