Hi. I currently busy with making a Intro for my game project. My idea is to show a text in the beginning thats blurred and slowly becomes sharper until it’s not blurred anymore. Just like this:
Make a video in internal(or cycles) and playing it using a video texture or make the blur variable use property as result(float maxblur = own[“blur”] or something like that and than make the property always add value. The bigger value it adds, the faster it fades in…
make the blur variable use property as result(float maxblur = own[“blur”]
If I replace float maxblur = 16.0 with float maxblur = own[“blur”] the filter doesn’t work anymore… (and yes, i have a property called blur)
Does anyone know ??
<b>import</b> bge
cont = bge.logic.getCurrentController()
VertexShader = """
uniform mat4 viewMatrixInverse; // view to world
// transformation (the view matrix corresponds to the
// world to view transformation; thus, the inverse
// matrix corresponds to the view to world trafo)
varying vec4 position_in_world_space;
void main()
{
vec4 position_in_view_space =
gl_ModelViewMatrix * gl_Vertex;
// transformation of gl_Vertex from object coordinates
// to view coordinates;
position_in_world_space = viewMatrixInverse *
position_in_view_space;
// transformation of gl_Vertex from view coordinates
// to world coordinates;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
"""
FragmentShader = """
varying vec4 position_in_world_space;
void main()
{
float dist = distance(position_in_world_space,
vec4(0.0, 0.0, 0.0, 1.0));
// computes the distance between the fragment position
// and the origin (the 4th coordinate should always
// be 1 for points).
if (dist < 5.0)
{
gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
// color near origin
}
else
{
gl_FragColor = vec4(0.3, 0.3, 0.3, 1.0);
// color far from origin
}
}
"""
mesh = cont.owner.meshes[0]
<b>for</b> mat <b>in</b> mesh.materials:
shader = mat.getShader()
<b>if</b> shader != None:
<b>if</b> <b>not</b> shader.isValid():
shader.setSource(VertexShader, FragmentShader, 1)
value_of_uniform = \
bge.logic.getCurrentScene().active_camera.camera_to_world shader.setUniformMatrix4('viewMatrixInverse', value_of_uniform) # this is sent
Could you post the shader as I can’t tell if it is a material shader or filter.
The first post was about material shader.
The filter basically the same, but maybe easier to change:
Just specify a variable as ‘uniform’ in the shader’s script, and create an object property (not a script variable) of the same name in the object that runs the 2D filter (i.e. if the Camera runs the 2D filter, make sure it has an object property (in the Game Logic’s Properties panel) that has the same name as the uniform variable that you’re using in the GLSL script).
Basically what I understand:
Add the word ‘uniform’ before your variable.
Have a property of same name.