llOffsetTexture for PBR Materials?
Log In
Allegory Malaprop
Yes. It's clunky and built into PRIM_GLTF_BASE_COLOR in llSet(Link)PrimitiveParams. Refer to texture UUID as "" to use the one set in the material, you can llGet(Link)PrimitiveParams for the rest of the variables to keep them at those values and just replace selective variables. Similar functions exist for variables for normal, orm, and emissive.
Tech Robonaught
Allegory Malaprop it would be great if people in the know would post some examples ... I live on the examples. LOL
Allegory Malaprop
Tech Robonaught The wiki has a page on it- https://wiki.secondlife.com/wiki/GLTF_Overrides This is an overly complicated script example- it goes through all faces and slices things up into multiple lists- but it has the reasoning etc. behind what is going on as well. Honestly it probably explains it better than I will, because it's not just a simple scripting function you need. GLTF scripting is complicated, to say the least.
What you need is to a) GET the PRIM_GLTF_BASE_COLOR attributes you want to keep from the current texture (unless you always know what it's all going to be and can hard code it) and then b) SET all of the attributes. ALL of the attributes are required (with the exception of texture), so you're going to need to know what you want everything else set to every time you offset a texture.
Quick and dirty:
integer face = 0; //your face number here
touch_end(integer i) {
list params = llGetPrimitiveParams([PRIM_GLTF_BASE_COLOR, face]);
llSetPrimitiveParams([PRIM_GLTF_BASE_COLOR, face, "", llList2Vector(params, 1), <0.5, 0.5, 0.0>] + llList2List(params, 3, -1));
}
The actual offsetting is done with llSetPrimitiveParams([PRIM_GLTF_BASE_COLOR,
face number
, "texture UUID"
, <texture repeats>
, <TEXTURE OFFSETS>
, texture rotation
, <tint color>
, alpha amount
, PRIM_GLTF_ALPHA_MODE_mode
, alpha mask cutoff
, 0]); (Note: 1 is a valid option for the last variable instead of 0. DO NOT USE 1. 1 doubles your mesh with back faces, and it's no better than doubling the backfaces you need and uploading the mesh with them, in load time or LI, etc. When in doubt, do it manually, you'll get more consistent and correct results.)llSetLinkPrimitiveParams and llGetLinkPrimitiveParams, with the addition of the link number, make this work for any objects in a link set (and of course llSetLinkPrimitiveParamsFast without the delay).
Allegory Malaprop
These functions don't work exactly the same as texture setting functions do in general: setting the texture to "" doesn't replace it with null, it instead replaces it with the texture that exists already IN the GLTF Material you have applied, so you do not need to actually get it (so at least it's possible at all without having to hard code everything if you transfer ownership). This means you must create a full material, not just make it on the fly on the object (it has to be saved as an asset and dragged back onto the object, or applied by the material asset's UUID). Alternately, you can hard code the UUID for the texture into the PRIM_GLTF_BASE_COLOR call (this is probably not advisable for multiple reasons, but sometimes might be the right choice).
You also set transparency with this convoluted....thing (
alpha amount
in the above, also set the alpha mode to BLEND...or possibly MASK with appropriate cutoff), so hiding parts of objects, or entire objects, in PBR materials is also more of a pain than the much simpler set alpha options for Blinn-Phong textures.