Grai Engine
HomeCrowdfundCommunitiesFreelanceStore
Sign inSign up
Grai Engine

A unified platform for game developers — crowdfunding, communities, freelance, and marketplace all in one place.

Platform

  • Crowdfund
  • Communities
  • Freelance
  • Store

Company

  • About
  • Blog
  • Careers
  • Contact

Support

  • Help Center
  • Platform Terms
  • Content Policy
  • Refund Policy
  • Dispute Policy

© 2026 Grai Engine. All rights reserved.

Platform TermsContent PolicyRefunds
Grai Engine DevshelpHow to implement custom shaders in Grai Engine?

How to implement custom shaders in Grai Engine?

Pinned
shaderhelpbeginner
PI
PixelPioneerJan 14, 2025 at 09:00 AM

I'm trying to create a custom water shader but I can't figure out how to pass uniforms from GDScript. Has anyone done this before?

I've tried using ShaderMaterial but the documentation is sparse. Any help would be appreciated!

Accepted Answer
CO
CodeCrafterAcceptedJan 14, 2025 at 10:15 AM

Building on what ModeratorMax said, for water shaders specifically you'll want to use TIME built-in and combine it with noise textures. Here's a complete water shader:

shader_type spatial;
uniform float wave_speed : hint_range(0.0, 5.0) = 1.0;
uniform sampler2D noise_tex;

void fragment() {
vec2 uv = UV + TIME wave_speed 0.01;
float noise = texture(noise_tex, uv).r;
ALBEDO = vec3(0.0, 0.3 + noise * 0.2, 0.8);
ALPHA = 0.8;
}

This gives you a basic animated water effect. You can extend it with reflection and refraction.

4 Replies

MO
ModeratorMaxModJan 14, 2025 at 09:30 AM

You need to use set_shader_parameter() on the ShaderMaterial. Here's a quick example:

var mat = ShaderMaterial.new()
mat.shader = preload("res://shaders/water.gdshader")
mat.set_shader_parameter("wave_speed", 2.0)
PI
PixelPioneerJan 14, 2025 at 11:00 AM

This is exactly what I needed! The noise texture approach works perfectly. Thanks @CodeCrafter!

IN
IndieDev42Jan 15, 2025 at 04:30 PM

For anyone else looking at this, I'd also recommend checking out the Grai Engine shader tutorial series on the docs site. It covers advanced techniques like screen-space reflections.

Post a Reply