Author Topic: Custom FLSLfilter in MeshBatch3D  (Read 748 times)

Björn Lilleike   «   on: June 07, 2016, 06:51:38 AM »
I have problems with using a custom FLSLfilter in the MeshBatch3D.
All parameters and all seems to be fine, but it is just not rendering.

I rebuild it from the material in the batch but that still does not help.
The filter itself works when used directly on the mesh used to create the batch.

The filtercode is this:
Code: [Select]

use namespace flare;
use namespace flare.transforms;
use namespace flare.filters;
use namespace flare.blendMode;

param float2 objectOffset = float2(0, 0);
param float2 objectRepeat = float2(1, 1);
param float2 colorOffset = float2(0, 0);
param float2 colorRepeat = float2(1, 1);
param float4 primaryRed = float4( 0.5, 0.5, 0.5, 0 );
param float4 secondaryGreen = float4( 0.5, 0.5, 0.5, 0 );
param float4 tertiaryBlue = float4( 0.5, 0.5, 0.5, 0 );
param float4 displaymodeColor = float4( 0.0, 0.8, 0.9, 1 );
param float alphaClipping = 0.6;
param float4 condition = 1.0;

sampler2D objectTexture<format = FORMAT_COMPRESSED_ALPHA, mip = MIP_NONE>;
sampler2D colorTexture<format = FORMAT_COMPRESSED_ALPHA, mip = MIP_NONE>;
sampler2D perlinTexture;


float4 getSkinnedVertex()
{
return transform();
}


float grayscale(float4 color) {
    return (color.r+color.g+color.b)/3;
}

float4 basicTexture()
{
float4 objectColor = textureMap(objectTexture, objectRepeat, objectOffset);
kill(objectColor.a - alphaClipping);
return objectColor;
}

float4 tintedColor ( )
{
float4 objectColor = textureMap(objectTexture, objectRepeat, objectOffset);
kill(objectColor.a - alphaClipping);
float4 mask = textureMap(colorTexture, colorRepeat, colorOffset);
float t = mask.r * primaryRed.a + mask.g * secondaryGreen.a + mask.b * tertiaryBlue.a;
float4 maskColor = (primaryRed * mask.r + secondaryGreen * mask.g + tertiaryBlue * mask.b);

// neutral maskColor is float4( 0.5, 0.5, 0.5, 0 ); to avoid effect on overlay
return overlay(maskColor, float4(float3(grayscale(objectColor)), objectColor.a)) * t + objectColor * (1 - t);
}

float4 displayMode ( )
{
float4 objectColor = textureMap(objectTexture, objectRepeat, objectOffset);
kill(objectColor.a - alphaClipping);
return overlay(displaymodeColor, float4(float3(grayscale(objectColor)), displaymodeColor.a));
}

float4 dirtEffect(float4 objectPixel)
{
float4 perlin = textureMap(perlinTexture, objectRepeat * 2, objectOffset);
float4 dirt = mix(objectPixel, overlay(objectPixel, perlin), max(condition, perlin));
float4 perlinHighlight = textureMap(perlinTexture, objectRepeat * 2, objectOffset)
return mix(dirt, hardlight(dirt, perlinHighlight), max(condition, perlinHighlight));
}


technique basic
{
output vertex = getSkinnedVertex();
output fragment = basicTexture();
}

technique dirt
{
output vertex = getSkinnedVertex();
output fragment = dirtEffect(basicTexture());
}

technique color
{
output vertex = getSkinnedVertex();
output fragment = tintedColor();
}

technique colorAndDirt
{
output vertex = getSkinnedVertex();
output fragment = dirtEffect(tintedColor());
}

technique displaymode
{
output vertex = getSkinnedVertex();
output fragment = displayMode();
}

technique displaymodeAndDirt
{
output vertex = getSkinnedVertex();
output fragment = dirtEffect(displayMode());
}


and I still get those unnerving SkinModifier.as nullpointer at random and really would appreciate to can have a look into the source to easier debug this error.

Thanks, Björn

Björn Lilleike   «   Reply #1 on: June 10, 2016, 01:21:08 AM »
I have no idea how to debug this problem without the sources of the MeshBatch and what it changes.

It is really frustrating to not be able to get support on technical issues.

Björn Lilleike   «   Reply #2 on: June 20, 2016, 10:37:53 AM »
After another hours I omitted the vertex-output and then it worked.

Tags: