mirror of
https://github.com/aap/librw.git
synced 2025-12-20 01:19:51 +00:00
add modulate flag check for material rendering
This commit is contained in:
@@ -34,14 +34,14 @@ static int32 u_fxparams;
|
||||
static int32 u_colorClamp;
|
||||
|
||||
void
|
||||
matfxDefaultRender(InstanceDataHeader *header, InstanceData *inst)
|
||||
matfxDefaultRender(InstanceDataHeader *header, InstanceData *inst, uint32 flags)
|
||||
{
|
||||
Material *m;
|
||||
m = inst->material;
|
||||
|
||||
defaultShader->use();
|
||||
|
||||
setMaterial(m->color, m->surfaceProps);
|
||||
setMaterial(flags, m->color, m->surfaceProps);
|
||||
|
||||
setTexture(0, m->texture);
|
||||
|
||||
@@ -83,13 +83,13 @@ uploadEnvMatrix(Frame *frame)
|
||||
}
|
||||
|
||||
void
|
||||
matfxEnvRender(InstanceDataHeader *header, InstanceData *inst, MatFX::Env *env)
|
||||
matfxEnvRender(InstanceDataHeader *header, InstanceData *inst, uint32 flags, MatFX::Env *env)
|
||||
{
|
||||
Material *m;
|
||||
m = inst->material;
|
||||
|
||||
if(env->tex == nil || env->coefficient == 0.0f){
|
||||
matfxDefaultRender(header, inst);
|
||||
matfxDefaultRender(header, inst, flags);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ matfxEnvRender(InstanceDataHeader *header, InstanceData *inst, MatFX::Env *env)
|
||||
setTexture(1, env->tex);
|
||||
uploadEnvMatrix(env->frame);
|
||||
|
||||
setMaterial(m->color, m->surfaceProps);
|
||||
setMaterial(flags, m->color, m->surfaceProps);
|
||||
|
||||
float fxparams[2];
|
||||
fxparams[0] = env->coefficient;
|
||||
@@ -125,6 +125,7 @@ matfxEnvRender(InstanceDataHeader *header, InstanceData *inst, MatFX::Env *env)
|
||||
void
|
||||
matfxRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
{
|
||||
uint32 flags = atomic->geometry->flags;
|
||||
setWorldMatrix(atomic->getFrame()->getLTM());
|
||||
lightingCB(atomic);
|
||||
|
||||
@@ -145,13 +146,13 @@ matfxRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
MatFX *matfx = MatFX::get(inst->material);
|
||||
|
||||
if(matfx == nil)
|
||||
matfxDefaultRender(header, inst);
|
||||
matfxDefaultRender(header, inst, flags);
|
||||
else switch(matfx->type){
|
||||
case MatFX::ENVMAP:
|
||||
matfxEnvRender(header, inst, &matfx->fx[0].env);
|
||||
matfxEnvRender(header, inst, flags, &matfx->fx[0].env);
|
||||
break;
|
||||
default:
|
||||
matfxDefaultRender(header, inst);
|
||||
matfxDefaultRender(header, inst, flags);
|
||||
break;
|
||||
}
|
||||
inst++;
|
||||
|
||||
@@ -123,6 +123,7 @@ defaultRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
{
|
||||
Material *m;
|
||||
|
||||
uint32 flags = atomic->geometry->flags;
|
||||
setWorldMatrix(atomic->getFrame()->getLTM());
|
||||
lightingCB(atomic);
|
||||
|
||||
@@ -142,7 +143,7 @@ defaultRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
while(n--){
|
||||
m = inst->material;
|
||||
|
||||
setMaterial(m->color, m->surfaceProps);
|
||||
setMaterial(flags, m->color, m->surfaceProps);
|
||||
|
||||
setTexture(0, m->texture);
|
||||
|
||||
|
||||
@@ -257,6 +257,7 @@ skinRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
{
|
||||
Material *m;
|
||||
|
||||
uint32 flags = atomic->geometry->flags;
|
||||
setWorldMatrix(atomic->getFrame()->getLTM());
|
||||
lightingCB(atomic);
|
||||
|
||||
@@ -278,7 +279,7 @@ skinRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
while(n--){
|
||||
m = inst->material;
|
||||
|
||||
setMaterial(m->color, m->surfaceProps);
|
||||
setMaterial(flags, m->color, m->surfaceProps);
|
||||
|
||||
setTexture(0, m->texture);
|
||||
|
||||
|
||||
@@ -181,6 +181,14 @@ int32 setLights(WorldLights *lightData);
|
||||
// per Mesh
|
||||
void setTexture(int32 n, Texture *tex);
|
||||
void setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops, float extraSurfProp = 0.0f);
|
||||
inline void setMaterial(uint32 flags, const RGBA &color, const SurfaceProperties &surfaceprops, float extraSurfProp = 0.0f)
|
||||
{
|
||||
static RGBA white = { 255, 255, 255, 255 };
|
||||
if(flags & Geometry::MODULATE)
|
||||
setMaterial(color, surfaceprops, extraSurfProp);
|
||||
else
|
||||
setMaterial(white, surfaceprops, extraSurfProp);
|
||||
}
|
||||
|
||||
void setAlphaBlend(bool32 enable);
|
||||
bool32 getAlphaBlend(void);
|
||||
|
||||
Reference in New Issue
Block a user