Custom Shaders discussion

Plug-in related stuff can be discussed here.

Moderator: Plugin Moderators

User avatar
Lobby
Developer
Reactions:
Posts: 3705
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

Custom Shaders discussion

#1

Post by Lobby »

For better overview I moved discussions about custom shaders to here. Here you can also suggest changes to the tutorial.

To go to the tutorial: The Custom Shaders documentation
User avatar
Bevise
Micy's Assistant
Reactions:
Posts: 502
Joined: 27 Feb 2020, 15:39
Location: Phu Quoc Island, Vietnam
Plugins: Showcase Store
Version: Beta
Contact:

Plugin Creator

Platform

[1.10.50] Custom Shaders

#2

Post by Bevise »

I don't comprehend it at all. Maybe I should try out the plugin. ._.
User avatar
Simon142
Small-town resident
Reactions:
Posts: 35
Joined: 05 Feb 2020, 14:13
Plugins: Showcase Store

Plugin Creator

Platform

Re: Custom Shaders discussion

#3

Post by Simon142 »

YOOOO nice. I kinda know glsl, imma make my first shader plugin!
User avatar
PixelDubs
TheoTown Veteran in Pension
Reactions:
Posts: 554
Joined: 02 Nov 2020, 20:14
Location: Telford, England
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Custom Shaders discussion

#4

Post by PixelDubs »

To be honest probably won't be using this, can't use GLSL, when I start developing BetterTT I will not be using shaders as the project would take forever as it is.
User avatar
PixelDubs
TheoTown Veteran in Pension
Reactions:
Posts: 554
Joined: 02 Nov 2020, 20:14
Location: Telford, England
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Custom Shaders discussion

#5

Post by PixelDubs »

I also think shaders won't be used much too.
User avatar
Simon142
Small-town resident
Reactions:
Posts: 35
Joined: 05 Feb 2020, 14:13
Plugins: Showcase Store

Plugin Creator

Platform

Re: Custom Shaders discussion

#6

Post by Simon142 »

Does the existence of type IDs shader imply there is a way to get pixel's type (part of GUI, text, or tile)? If so, how can I make something similar too? I'd like to make it so my shaders don't affect game UI.

Also, is/will there be the source code reveal of fancy/X fancy shaders?
User avatar
Bearbear76
Former Bearbear65
Reactions:
Posts: 5730
Joined: 10 Feb 2017, 14:53
Location: L2 cache
Plugins: Showcase Store

Plugin Creator

Platform

Re: Custom Shaders discussion

#7

Post by Bearbear76 »

Simon142 wrote: 02 Oct 2022, 18:46 Does the existence of type IDs shader imply there is a way to get pixel's type (part of GUI, text, or tile)? If so, how can I make something similar too? I'd like to make it so my shaders don't affect game UI.

Also, is/will there be the source code reveal of fancy/X fancy shaders?
True the game UI was bearly visible with your plugin if I remember correctly.
User avatar
IlikeBurgerHam
Villager
Reactions:
Posts: 10
Joined: 08 Jun 2020, 04:11
Location: Philippines
Plugins: Showcase Store

Platform

Re: Custom Shaders discussion

#8

Post by IlikeBurgerHam »

How do you recreate the LOL shader that's in-game? Like what's the code?
User avatar
Simon142
Small-town resident
Reactions:
Posts: 35
Joined: 05 Feb 2020, 14:13
Plugins: Showcase Store

Plugin Creator

Platform

Re: Custom Shaders discussion

#9

Post by Simon142 »

Bearbear76 wrote: 03 Oct 2022, 01:31
Simon142 wrote: 02 Oct 2022, 18:46 Does the existence of type IDs shader imply there is a way to get pixel's type (part of GUI, text, or tile)? If so, how can I make something similar too? I'd like to make it so my shaders don't affect game UI.

Also, is/will there be the source code reveal of fancy/X fancy shaders?
True the game UI was bearly visible with your plugin if I remember correctly.
I think most UI was visible, but only some light grey text in settings wasn't
User avatar
Simon142
Small-town resident
Reactions:
Posts: 35
Joined: 05 Feb 2020, 14:13
Plugins: Showcase Store

Plugin Creator

Platform

Re: Custom Shaders discussion

#10

Post by Simon142 »

Bearbear76 wrote: 03 Oct 2022, 01:31
Simon142 wrote: 02 Oct 2022, 18:46 Does the existence of type IDs shader imply there is a way to get pixel's type (part of GUI, text, or tile)? If so, how can I make something similar too? I'd like to make it so my shaders don't affect game UI.

Also, is/will there be the source code reveal of fancy/X fancy shaders?
True the game UI was bearly visible with your plugin if I remember correctly.
Fixed now :)
User avatar
Hadestia
Inhabitant of a Megalopolis
Reactions:
Posts: 727
Joined: 17 Jul 2017, 16:16
Location: Philippines
Plugins: Showcase Store
Contact:

Plugin Creator

Platform

Re: Custom Shaders discussion

#11

Post by Hadestia »

What's the uniform type for night animations
User avatar
Hadestia
Inhabitant of a Megalopolis
Reactions:
Posts: 727
Joined: 17 Jul 2017, 16:16
Location: Philippines
Plugins: Showcase Store
Contact:

Plugin Creator

Platform

Re: Custom Shaders discussion

#12

Post by Hadestia »

Here I provided some alternative function from glsl that the game doesn't have
Show
step()
step generates a step function by comparing x to edge

Code: Select all

float step(float x, float edge) {
	return (x < edge) ? 0.0 : 1.0;
}
Show
simple fract()
returns the fractional part of x.

Code: Select all

float fract(float x) {
	return (x - floor(x));
}
Show
mix()
mix performs a linear interpolation between x and y using a to weight between them

Code: Select all

//@param A Vector3
//@param B Vector3
//@param a Alpha
//@return Vector3
vec3 mix(vec3 A, vec3 B, float a) {
	return vec3(A * (1.0 - a) + B * a);
}
Show
overlay()
overlay a foreground color from background color

Code: Select all

//@param base Vector3 background color
//@param blend Vector3 foreground color
//@return Vector3
vec3 overlay(vec3 base, vec3 blend) {
    return vec3(
         base.r < 0.5 ? (2.0 * base.r * blend.r) : (1.0 - 2.0 * (1.0 - base.r) * (1.0 - blend.r)),
         base.g < 0.5 ? (2.0 * base.g * blend.g) : (1.0 - 2.0 * (1.0 - base.g) * (1.0 - blend.g)),
         base.b < 0.5 ? (2.0 * base.b * blend.b) : (1.0 - 2.0 * (1.0 - base.b) * (1.0 - blend.b))
    );
}
Show
using screen resolution
Since 1.10.83 Drawing.setUniform() was available, we could just include this on our script:
uniform.lua

Code: Select all    Reset

local w, h = Drawing.getSize() Drawing.setUniform('Resolution', (w + .0), (h + .0)) -- we need to ensure that our values are in float format
Interactive Lua editor
Run
However user Resolution change over time depending on user choice in game settings, so I don't think this would be updated in runtime, Anyway our fragment shader will look like to use our uniform.

Code: Select all

... 
uniform vec2 Resolution; //Drawing.getSize()  returns 2 values so our uniform would be vec2
... 

void main()  {
    // use our uniform as example: 
    // Resolution.x = screen width or Resources.r
    // Resolution.y = screen height or Resolution.g
    if (Resolution.x >= 10.0 || Resolution.y <= 10.0)  {
        //your code
    }
}
Feel free to correct me if you nnotice something wrong. :)
User avatar
GreenKeldeo
Settler
Reactions:
Posts: 1
Joined: 16 May 2016, 23:44
Plugins: Showcase Store

Re: Custom Shaders discussion

#13

Post by GreenKeldeo »

It's been a *very* long time since I last did anything with TheoTown, but I'm pleased to see at least some graphical scripting support available. Does the game process a depth buffer when rendering? If so, I might try my hand at scripting a PBR handler when I eventually have some spare time.
Post Reply Previous topicNext topic

Return to “Plug-In Discussion”