Ogre Version: : 1 13 5 6:
Operating System: :Linux Tumbleweed:
Render System: :OpenGL3+
Hello, I try to add simple setCustomParam for my Instancing Entities.
I did reserve a "slot" for custom parameter :
Code: Select all
mInstanceManagerDirt = mSceneManager->createInstanceManager(
"InstanceManagerMeshDirt",
"FogOfWarDirt.mesh",
"Graphics",
Ogre::InstanceManager::HWInstancingBasic,
128,
Ogre::IM_USEALL,
0);
mInstanceManagerCloud = mSceneManager->createInstanceManager(
"InstanceManagerMeshCloud2",
"FogOfWarCloud2.mesh",
"Graphics",
Ogre::InstanceManager::HWInstancingBasic,
64,
Ogre::IM_USEALL,
0);
mInstanceManagerDirt->setNumCustomParams(1); // Number of vec4 custom params
mInstanceManagerDirt->defragmentBatches(true);
mInstanceManagerCloud->defragmentBatches(true);and then I setup it : like that :
mFogOfWarDirtMesh->setCustomParam(0, Ogre::Vector4(1.0f, 0.0f, 0.0f, 0.0f)); // Example: RGBA color
Example header for vertex shader program look like that :
Code: Select all
#version 330 core
#extension GL_ARB_explicit_uniform_location : enable
#extension GL_ARB_shading_language_include : enable
#include <OgreUnifiedShader.h>
#include "PerlinNoise.glsl"
#include "FFPLib_Transform.glsl"
uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;
uniform mat4 worldMatrix;
uniform mat4 lightMatrix;
layout (location = 0) in vec4 position;
layout (location = 2) in vec3 normal;
/* layout (location = 3) in mat3x4 uv1; */
layout (location = 8) in vec2 uv_0;
layout (location = 8) in vec2 uv_1;
layout (location = 12) in vec4 color;
layout (location = 14) in vec3 tangent;
IN(mat3x4 uv1, TEXCOORD1)
out vec2 out_UV0;
out vec2 out_UV1;
out vec3 FragPos;
out vec4 VertexPos;
out vec4 outputColor;
out mat3 TBN;In the manual I read :
Custom parameters
Some instancing techniques allow passing custom parameters to vertex shaders. For example a custom colour in an RTS game to identify player units; a single value for randomly colouring vegetation, light parameters for rendering deferred shading's light volumes (diffuse colour, specular colour, etc)
At the time of writing only HW Basic supports passing the custom parameters. All other techniques will ignore it.[8]
To use custom parameters, call InstanceManager::setNumCustomParams to tell the number of custom parameters the user will need. This number cannot be changed after creating the first batch (call createInstancedEntity)
Afterwards, it's just a matter of calling InstancedEntity::setCustomParam with the param you wish to send.
For HW Basic techniques, the vertex shader will receive the custom param in an extra TEXCOORD.
So is the choice layout (location = 12) in vec4 color; ( as chatgpt suggested ) right ?
Or what layout location I should choose for passing the color of a Tile from the c++ code side ?
So far I get LSD-checkboard pattern when it comes to color , so the choice for sure is wrong ..........