mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
vertex colors
This commit is contained in:
parent
9bd888d9a1
commit
8e683c2e05
4 changed files with 36 additions and 6 deletions
|
@ -226,7 +226,7 @@ void NIFLoader::createMaterial(const String &name,
|
|||
const Vector &emissive,
|
||||
float glossiness, float alpha,
|
||||
int alphaFlags, float alphaTest,
|
||||
const String &texName)
|
||||
const String &texName, bool vertexColor)
|
||||
{
|
||||
if (texName.empty())
|
||||
return;
|
||||
|
@ -246,6 +246,9 @@ void NIFLoader::createMaterial(const String &name,
|
|||
|
||||
instance->setProperty ("diffuseMap", sh::makeProperty(texName));
|
||||
|
||||
if (vertexColor)
|
||||
instance->setProperty ("has_vertex_colour", sh::makeProperty<sh::BooleanValue>(new sh::BooleanValue(true)));
|
||||
|
||||
// Add transparency if NiAlphaProperty was present
|
||||
if (alphaFlags != -1)
|
||||
{
|
||||
|
@ -272,7 +275,6 @@ void NIFLoader::createMaterial(const String &name,
|
|||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
if (!texName.empty())
|
||||
{
|
||||
|
@ -668,6 +670,8 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou
|
|||
NiTexturingProperty *t = NULL;
|
||||
NiMaterialProperty *m = NULL;
|
||||
NiAlphaProperty *a = NULL;
|
||||
// can't make any sense of these values, so ignoring them for now
|
||||
//NiVertexColorProperty *v = NULL;
|
||||
|
||||
// Scan the property list for material information
|
||||
PropertyList &list = shape->props;
|
||||
|
@ -685,6 +689,8 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou
|
|||
m = static_cast<NiMaterialProperty*>(pr);
|
||||
else if (pr->recType == RC_NiAlphaProperty)
|
||||
a = static_cast<NiAlphaProperty*>(pr);
|
||||
//else if (pr->recType == RC_NiVertexColorProperty)
|
||||
//v = static_cast<NiVertexColorProperty*>(pr);
|
||||
}
|
||||
|
||||
// Texture
|
||||
|
@ -755,7 +761,7 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou
|
|||
{
|
||||
//std::cout << "new";
|
||||
createMaterial(material, d->ambient, d->diffuse, d->specular, d->emissive,
|
||||
d->glossiness, d->alpha, alphaFlags, alphaTest, texName);
|
||||
d->glossiness, d->alpha, alphaFlags, alphaTest, texName, shape->data->colors.length != 0);
|
||||
MaterialMap.insert(std::make_pair(texName,material));
|
||||
}
|
||||
}
|
||||
|
@ -771,7 +777,7 @@ void NIFLoader::handleNiTriShape(NiTriShape *shape, int flags, BoundsFinder &bou
|
|||
}
|
||||
|
||||
createMaterial(material, one, one, zero, zero, 0.0, 1.0,
|
||||
alphaFlags, alphaTest, texName);
|
||||
alphaFlags, alphaTest, texName, shape->data->colors.length != 0);
|
||||
}
|
||||
}
|
||||
} // End of material block, if(!hidden) ...
|
||||
|
|
|
@ -142,7 +142,8 @@ class NIFLoader : Ogre::ManualResourceLoader
|
|||
const Nif::Vector &emissive,
|
||||
float glossiness, float alpha,
|
||||
int alphaFlags, float alphaTest,
|
||||
const Ogre::String &texName);
|
||||
const Ogre::String &texName,
|
||||
bool vertexColor);
|
||||
|
||||
void findRealTexture(Ogre::String &texName);
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#define shOutput(type, name) , out type name : TEXCOORD@shCounter(2)
|
||||
|
||||
#define shNormalInput(type) , in type normal : NORMAL
|
||||
|
||||
#define shColourInput(type) , in type colour : COLOR
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
|
@ -40,7 +42,7 @@
|
|||
|
||||
#define SH_BEGIN_PROGRAM \
|
||||
void main( \
|
||||
out float4 oColor : COLOR
|
||||
out float4 oColor0 : COLOR
|
||||
|
||||
#define SH_START_PROGRAM \
|
||||
) \
|
||||
|
@ -69,7 +71,9 @@
|
|||
|
||||
#define shMatrixMult(m, v) m * v
|
||||
|
||||
// automatically recognized by ogre when the input name equals this
|
||||
#define shInputPosition vertex
|
||||
|
||||
#define shOutputPosition gl_Position
|
||||
#define shOutputColor(num) oColor##num
|
||||
|
||||
|
@ -78,7 +82,9 @@
|
|||
#define shInput(type, name) in type name;
|
||||
#define shOutput(type, name) out type name;
|
||||
|
||||
// automatically recognized by ogre when the input name equals this
|
||||
#define shNormalInput(type) in type normal;
|
||||
#define shColourInput(type) in type colour;
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#define NEED_DEPTH
|
||||
#endif
|
||||
|
||||
#define HAS_VERTEXCOLOR @shPropertyBool(has_vertex_colour)
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
|
@ -22,6 +24,10 @@
|
|||
shOutput(float4, normalPassthrough)
|
||||
#ifdef NEED_DEPTH
|
||||
shOutput(float, depthPassthrough)
|
||||
#endif
|
||||
#if HAS_VERTEXCOLOR
|
||||
shColourInput(float4)
|
||||
shOutput(float4, colorPassthrough)
|
||||
#endif
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
|
@ -31,6 +37,10 @@
|
|||
#ifdef NEED_DEPTH
|
||||
depthPassthrough = shOutputPosition.z;
|
||||
#endif
|
||||
|
||||
#if HAS_VERTEXCOLOR
|
||||
colorPassthrough = colour;
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -50,13 +60,20 @@
|
|||
#if FOG
|
||||
shUniform(float3 fogColor) @shAutoConstant(fogColor, fog_colour)
|
||||
shUniform(float4 fogParams) @shAutoConstant(fogParams, fog_params)
|
||||
#endif
|
||||
|
||||
#ifdef HAS_VERTEXCOLOR
|
||||
shInput(float4, colorPassthrough)
|
||||
#endif
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
//shOutputColor(0) = float4((normalize(normalPassthrough.xyz)+float3(1.0,1.0,1.0)) / 2.f, 1.0);
|
||||
shOutputColor(0) = shSample(diffuseMap, UV);
|
||||
|
||||
#if HAS_VERTEXCOLOR
|
||||
shOutputColor(0).xyz *= colorPassthrough.xyz;
|
||||
#endif
|
||||
|
||||
#if FOG
|
||||
float fogValue = shSaturate((depthPassthrough - fogParams.y) * fogParams.w);
|
||||
shOutputColor(0).xyz = shLerp (shOutputColor(0).xyz, fogColor, fogValue);
|
||||
|
|
Loading…
Reference in a new issue