Johan and/or Ivan:
It’s driving me insane… I can’t seem to figure out what I’m doing wrong…
I have my material called Background.material
name: “BackgroundMaterial”
tags: “tile”
vertex_program: “/builtins/materials/sprite.vp”
fragment_program: “/main/Background/Background.fp”
vertex_constants {
name: “view_proj”
type: CONSTANT_TYPE_VIEWPROJ
}
vertex_constants {
name: “world”
type: CONSTANT_TYPE_WORLD
}
fragment_constants {
name: “tint”
type: CONSTANT_TYPE_USER
value {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
}
fragment_constants {
name: “offset”
type: CONSTANT_TYPE_USER
}
As you can see, it has the “tile” tag
I have my render_script with the following on_message (when invoqued it does print in the console the “debugging” text)
function on_message(self, message_id, message)
if message_id == hash(“clear_color”) then
self.clear_color = message.color
elseif message_id == hash(“set_view_projection”) then
self.view = message.view
elseif message_id == hash(“bgColor”) then
local constants = render.constant_buffer()
constants.offset = vmath.vector4(-0.1171875,0.0390625,-0.78125,0)
render.draw(self.tile_pred, constants)
print(“It’s getting here”);
end
end
and “/main/Background/Background.fp” does the following:
varying mediump vec4 position;
varying mediump vec2 var_texcoord0;
uniform lowp sampler2D DIFFUSE_TEXTURE;
uniform lowp vec4 tint;
uniform lowp vec4 offset;
void main()
{
//Verde
//lowp vec4 offset_pm = vec4(-0.1171875,0.0390625,-0.78125,0);
//Azul
//lowp vec4 offset_pm = vec4(-0.546875,-0.078125,0.0390625,0);
//Violeta
//lowp vec4 offset_pm = vec4(-0.0390625,-0.3125,-0.15625,0);
//Rojo
//lowp vec4 offset_pm = vec4(0.1953125,-0.390625,-0.5859375,0);
//Naranja
//lowp vec4 offset_pm = vec4(0.3125,-0.15625,-0.546875,0);
//Amarillo
//lowp vec4 offset_pm = vec4(0.1171875,0.078125,-0.6640625,0);
lowp vec4 offset_pm = vec4(offset.xyz,0);
gl_FragColor = texture2D(DIFFUSE_TEXTURE, var_texcoord0.xy) + offset_pm;
}
If I uncomment any of the “lowp vec4 offset_pm =” hardcoded lines, it works just fine… bue when I send them as constants it does nothing…
I can’t seem to find what I’m doing wrong… I’ve been digging into documentation the past 2 days but… well no result.
Thanks