Jump to content

Control post-processing effects parameters via code


Lunarovich
 Share

Recommended Posts

Hello! I know how to attach post-processing effects to a camera via editor as well as programmatically. However, I do not know how to control post-processing shader parameters dynamically.

 

For example, Shadmar's pixelate shader has this variable:

 

const int downgrade = 6; //at original 1920x1080, 6 yields 320x180

 

Now, how can I change downgrade value via Lua code?

 

Thank you!

Link to comment
Share on other sites

You would have to make this into a uniform

 

uniform int downgrade = 6;

 

and can then set it via Shader:SetInt().

 

I see the point. However, if you look at the API, you'll see that Camera:AddPostEffect accepts only string. That said, I cannot first load a shader and send a reference to the shader as a parameter to the camera. Rather, I send a string and never get the reference to the shader back from camera (at least in Lua and as far as I can see).

 

 

 

 

That would probably be the way to control Shadmar's shaders? But can you control stock shaders (ones that come with LE) in the same way?

Link to comment
Share on other sites

I see the point. However, if you look at the API, you'll see that Camera:AddPostEffect accepts only string. That said, I cannot first load a shader and send a reference to the shader as a parameter to the camera. Rather, I send a string and never get the reference to the shader back from camera (at least in Lua and as far as I can see).

 

The path parameter for Camera:AddPostEffect also accepts a Lua script which does the shader handling. I have no access to Leadwerks right now, but iirc the Bloom effect uses this approach (have a look at Shaders/PostProcess).

  • Upvote 1
Link to comment
Share on other sites

The path parameter for Camera:AddPostEffect also accepts a Lua script which does the shader handling. I have no access to Leadwerks right now, but iirc the Bloom effect uses this approach (have a look at Shaders/PostProcess).

 

Thanks! It occured to me to use also this approach. However, I wanted to see if there is a more direct approach. I'm asking all this because I have an idea of a gameplay based on various postprocessing parameter manipulations - different types of subjectivities manifested via different types of vision.

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...