Sets 4-component vector parameter (float4/vec4 uniform) for entity shader (RGBA colors, full vectors, quaternions).
Takes shader (shader handle from b3dLoadEntityShader, positive integer), name (parameter name, string matching HLSL CustomShaderParams cbuffer field), x (first component, float), y (second component, float), z (third component, float), w (fourth component, float).
Returns nothing.
Shaders
Parameters & Returns
Parameters
shaderInt
nameString
xDouble
yDouble
zDouble
wDouble
Returns
Void
Quick Summary
Sets 4-component vector parameter (float4/vec4 uniform) for entity shader (RGBA colors, full vectors, quaternions).
Takes shader (shader handle from b3dLoadEntityShader, positive integer), name (parameter name, string matching HLSL CustomShaderParams cbuffer field), x (first component, float), y (second component, float), z (third component, float), w (fourth component, float).
Returns nothing.
Technical Exegesis...
Sets 4-component vector parameter (float4/vec4 uniform) for entity shader (RGBA colors, full vectors, quaternions). Takes shader (shader handle from b3dLoadEntityShader, positive integer), name (parameter name, string matching HLSL CustomShaderParams cbuffer field), x (first component, float), y (second component, float), z (third component, float), w (fourth component, float). Returns nothing. Stores components in shader.floatParams map as name.x, name.y, name.z, name.
Sets 4-component vector parameter (float4/vec4 uniform) for entity shader (RGBA colors, full vectors, quaternions). Takes shader (shader handle from b3dLoadEntityShader, positive integer), name (parameter name, string matching HLSL CustomShaderParams cbuffer field), x (first component, float), y (second component, float), z (third component, float), w (fourth component, float). Returns nothing. Stores components in shader.floatParams map as name.x, name.y, name.z, name.w (four separate float entries, persists until changed). Use to pass RGBA colors (tint color with alpha, rim color with intensity), full vectors (quaternion rotation, plane equation), or 4D parameters (color+strength, position+radius, packed data). Storage behavior: components stored separately (name.x stores x, name.y stores y, name.z stores z, name.w stores w in floatParams map), shader reads as float4 (HLSL shader accesses as single vec4, engine packs components automatically), persists until changed (call again with same name to update, survives across frames), shared by all entities (shader's parameters used by all entities referencing this shader, not per-entity). Use cases: (1) RGBA tint (b3dSetEntityShaderFloat4(shader, "tintColor", 1.0, 0.5, 0.2, 0.8) orange tint with 80% opacity), (2) Color+intensity (b3dSetEntityShaderFloat4(shader, "rimColor", 0.0, 1.0, 1.0, 2.0) cyan rim with 2x intensity), (3) Outline RGBA (b3dSetEntityShaderFloat4(shader, "outlineColor", 0.0, 0.0, 0.0, 1.0) black opaque outline), (4) Emission+strength (b3dSetEntityShaderFloat4(shader, "emissive", r, g, b, strength) glow color and power), (5) Packed parameters (b3dSetEntityShaderFloat4(shader, "params", roughness, metalness, ao, height) PBR properties). Common patterns: set = b3dSetEntityShaderFloat4(shader, "paramName", x, y, z, w) configure vector; rgba = b3dSetEntityShaderFloat4(shader, "color", r/255.0, g/255.0, b/255.0, a/255.0) RGBA normalized 0-1. Typical workflow: load shader (shader = b3dLoadEntityShader("toon.hlsl")), set vector (this function for 4D values), assign to entity (b3dEntityShader(entity, shader) activate), render (b3dRenderWorld applies shader with parameters), update vector (call SetEntityShaderFloat4 again to animate). HLSL shader access: declare in CustomShaderParams cbuffer (cbuffer CustomShaderParams : register(b3) { float4 tintColor; float4 rimColor; float4 emissive; }), read in pixel shader (finalColor *= tintColor; float4 rimParams = rimColor; float rimIntensity = rimColor.w; finalColor.rgb += rimColor.rgb * rimFactor * rimIntensity;), match parameter name (C++ "tintColor" must match HLSL "tintColor" exactly, case-sensitive), access components (tintColor.x/y/z/w or tintColor.rgba or tintColor.xyzw for swizzling). Common parameter names: "tintColor" or "color" (RGBA tint with alpha, 0.0-1.0 normalized), "rimColor" (RGB rim color + W intensity/power), "outlineColor" (RGBA outline with alpha), "emissive" or "emissionColor" (RGB emission + W strength/multiplier), "params" or "properties" (packed parameters, roughness/metalness/ao/height), "colorCorrect" (RGBA adjustment multipliers). Typical values: RGBA color 0.0-1.0 (normalized, 1.0=full intensity, 0.0=none, for tint/rim/outline), RGBA color 0-255 divide by 255 (convert from integer RGBA to float 0-1), intensity/strength in W component (0.0-5.0 typical, multiplier for RGB), emissive RGB >1.0 allowed (HDR bloom/glow effects), packed parameters 0.0-1.0 (normalized PBR properties). Performance: set cost zero (four map insertions/updates, trivial CPU operation), parameter read cost zero (constant buffer upload once per entity draw, GPU reads efficiently), vector packing automatic (engine combines name.x/y/z/w into float4 for shader), no performance difference vs four SetEntityShaderFloat calls (same storage, just convenience function). Component storage: x component stored as "name.x" key (floatParams["color.x"] = 1.0), y component stored as "name.y" key (floatParams["color.y"] = 0.5), z component stored as "name.z" key (floatParams["color.z"] = 0.2), w component stored as "name.w" key (floatParams["color.w"] = 0.8), shader reads combined (HLSL sees float4 color = {1.0, 0.5, 0.2, 0.8}), can mix with SetEntityShaderFloat (can overwrite individual components with SetEntityShaderFloat, components independent). Validation: ignores if shader <= 0 (invalid handle, silent no-op), ignores if name null (null pointer, early return), ignores if shader not found (not in g_entityShaders map, silent no-op), accepts any values (no range validation, user responsible for sensible values). No return value: void function (doesn't indicate success/failure), assumes success (parameters set if shader valid, nothing if invalid), silent operation (no error messages, no confirmation prints). Parameter lifetime: persists until changed (call SetEntityShaderFloat4 again with same name overwrites all components), survives entity changes (shader parameters independent of entity assignments), freed on shader free (b3dFreeEntityShader removes entire shader including all parameters), individual components persist (name.x/y/z/w stored separately, can overwrite with SetEntityShaderFloat if needed). RGBA color conversion: integer RGBA to float (r/255.0, g/255.0, b/255.0, a/255.0 for 0-255 -> 0.0-1.0), HDR colors allowed (RGB values > 1.0 for bloom/glow effects, alpha typically 0-1), premultiplied alpha shader responsibility (pass straight or premultiplied as needed, shader handles blending). Common uses: RGBA tint (multiply entity color by tint, alpha for blend amount), color+intensity (RGB color + W multiplier, convenient packaging), packed properties (roughness/metalness/ao/height in single vector, efficient parameter passing), outline/rim colors (RGBA for full color control with alpha). Related: b3dSetEntityShaderFloat sets single float (for scalar values, intensity, time), b3dSetEntityShaderInt sets integer parameter (for discrete values, flags), b3dSetEntityShaderFloat2 sets 2-component vector (vec2 in HLSL, UV offsets), b3dSetEntityShaderFloat3 sets 3-component vector (vec3 in HLSL, RGB colors without alpha), b3dSetEntityShaderTexture sets shader texture (custom texture binding), b3dLoadEntityShader loads shader (creates shader configured by this function), b3dEntityShader applies shader to entity (activates shader that uses parameters set here).