Godot Version
4.2.2
Question
How does one correctly sample a cubemap ? Just, if i wanted to simply have a spatial shader display a cubemap, nothing more, how would one do this ?
There seems to be utterly no documentation on correctly projecting it, and even examples found online are either outdated or non-functional at all.
You can use godot’s texture
with a samplerCube, same with GLSL
gvec4_type texture (gsampler2D s, vec2 p [, float bias])
gvec4_type texture (gsampler2DArray s, vec3 p [, float bias])
gvec4_type texture (gsampler3D s, vec3 p [, float bias])
vec4 texture (samplerCube s, vec3 p [, float bias])
vec4 texture (samplerCubeArray s, vec4 p [, float bias])
Oh unless you mean a cubemap like this, which is a normal 2D texture

It only requires UV coordinates, could be packed better.
This shader for example, packes the 6 sides much tigher and creates a fake room out of the sides
Mhm, mean cubemap like that, since it’s probably the most common type.
And no matter what I plug in, it never seems to UV coherently at all, know that it can be sampled with a texture, just no UV, involving depth or otherwise seems to project it correctly. So it’s never quite clear to me what to plug in for UV to project it correctly at all.
Especially since can’t find what godot expects for a cubemap from the docs
Though suppose, just knowing how to use UV for that arrangement would resolve my issue largely ;;
Yeah this sounds more like a 3D modeling issue, blender can set UV coordinates, I wouldn’t try to do that in Godot. "Cubemap"s aren’t special, sometimes used for skyboxes.
Here’s a in-depth article I found, it involves cutting the texture into 6 textures for each side anyways. You could probably plug this into a Godot shader material for a skybox too.
yeah, just need to now figure out how to add a uv from a model into a shader ;;
Thank you for help though~
in godot it’s the UV
builtin for spatial shaders
uniform sampler2D my_texture: source_color;
void fragment() {
ALBEDO = texture(my_texture, UV)
}
yes, I know where to put the UV, just need to figure out how to get it into the shader from the outside, so to say
since didn’t find much about it, basically how to take it out of a modeled cube, and then have shader access it from there
when the shader is attached to a model UV
is automatically filled in with the model’s UV coordinates.
Are you trying to access UV coordinates without a model? You could hard code them or use a shader parameter/uniform, but the big benefit for a UV is spatial association and linear interpolation between points which you won’t get with uniforms or hard coded numbers.
is there a way to pass in another model’s UV through a uniform ?Or even just get the necessary UV data out of it to then just paste it into the shader code directly ?
Specifically the issue here is that i need a cubemap UV for a screenspace shader, (for sky reasons, as godot doesn’t allow any access to a sky from spacial shaders themselves)
so need a cubemap UV, that Ive been having trouble getting to work at all, for projecting a cubemap in worldspace, most following the doc’s suggestion of making a screenspace shader in its setup.