#How to achieve a circular crop?
31 messages · Page 1 of 1 (latest)
Right on let me try 🙂
Where do I get TEXCOORD0 from?
I'm sorry; could you provide the code? I'm clueless with shaders.
uniform sampler2D texture;
uniform vec2 texture_size;
uniform vec2 uv_offset;
uniform vec2 uv_scale;
void fragment() {
// UV coords offset and scale calc
vec2 uv = (TEXCOORD0.xy * uv_scale) + uv_offset;
// texture sampling modified UV coordinates
vec4 color = texture(texture, uv);
// output
COLOR = color;
}```
I need to be passing in:
uniform vec2 texture_size;
uniform vec2 uv_offset;
uniform vec2 uv_scale;
Somehow right?
look at the right side
of the screen
you can set the variable there
its like export variabls
Hmm, I'm setting the shader via code:
var shader_material = ShaderMaterial.new()
shader_material.shader = load("res://shaders/CircleCropShader.gdshader")
shader_material.set_shader_parameter('texture', texture)
okie
Thanks again for the help
gotcha ❤️
What should I pass in for these?
just input some random floats
and work your way to accuracy 😄
texture_size is prolly 1080x1920
Can you show me an example? I'm clueless on what to pass, sorry 😦
like this:
uniform vec2 texture_size = vec2(1024.0, 1024.0);
uniform vec2 uv_offset = vec2(0.0, 0.0);
uniform vec2 uv_scale = vec2(0.5, 0.5);
as you like to do things by code
@warm thunder I actually managed to somehow do it using a parent texturerect and clip only under visability
I can't thank you enough for your help though, you've inspired me to learn shaders 🙂
OMG nice!
Only took 11 or so hours.
lets goooooooooooooooooo