mifth
November 22, 2011, 6:21am
81
Thanks! It was one of my first shader… i missed it. Fixed in the mercurial repository.
I have 2 questions:
about uniforms:
I did simple fog in my lightblow.frag
gl_FragColor.rgb = mix(fogColor.rgb,gl_FragColor.rgb,vec3(fogFactor));
Is it allowed to make such operations with gl_FragColor?
@normen , can you test my shaders in the mercurial repository to fix all bugs?
hg clone https://paulgeraskin@code.google.com/p/jme-glsl-shaders/ - Mercurial repository.
There is a JMP project with java examples. Simply, run all examples. They all should work.
You are the only one person who has Mac (which I know).
Thanks a lot beforehand.
nehon
November 22, 2011, 7:31am
82
@mifth said:
1) about uniforms:
I did simple fog in my lightblow.frag
gl_FragColor.rgb = mix(fogColor.rgb,gl_FragColor.rgb,vec3(fogFactor));
Is it allowed to make such operations with gl_FragColor?
gl_FragColor is not an uniform, it's a build in output parameter. So yes it's allowed, i'd say it's the very purpose of this variable.
mifth
November 22, 2011, 8:11am
83
Nice! Thank you @nehon !
Another question:
I have a post processor Cartoon edges. It makes additional geometry. It copies mesh and shift polygons.
When I switch this cartoon edge processor on, it creates additional geometry to all objects (which have this processor in MatDef).
Can I specify to some objects not to use this processor even if these objects have the processor in MatDef?
MatDef - http://code.google.com/p/jme-glsl-shaders/source/browse/assets/MatDefs/MatCap/MatCap.j3md
The processor is called CartoonEdge.
nehon
November 22, 2011, 8:26am
84
No you can’t, a PostProcessor is applied on a viewport, not on a scene.
You could put the objects you don’t want the effect on in another viewport.
mifth
November 22, 2011, 8:43am
85
Nice! That’s cool. THANK YOU!
Is it possible to place objects to another viewport when game started? I mean dynamically.
nehon
November 22, 2011, 9:26am
86
Yes create your new viewport in your simpleInit .
Each viewport will have a scene (rootNode for the main viewport and whatever for your second viewport)
You just have to switch objects from the rootNode to the other node.
Don’t forget to call updateLogicalState and updateGeometricState int he update loop^on the other node as it won’t be called automatically on it.
1 Like
mifth
November 23, 2011, 1:16pm
87
@nehon , just another question about g_Time.
In FakeParticleBlow.vert I have such operation:
[java]
float thisTime = g_Time * m_TimeSpeed;
texCoordAni.y += thisTime;
[/java]
But what if texCoordAni.y will be equal more than allowed value for “float”? Will I get crush?
Should I add something to avoid it?
normen
November 23, 2011, 1:34pm
88
I guess like in any system you just get an overflow (going from max value to min value in one step). Since this looks like some constant movement thing it should be OK I think.
mifth
November 23, 2011, 1:47pm
89
nehon
November 23, 2011, 1:54pm
90
@mifth said:
@nehon , just another question about g_Time.
In FakeParticleBlow.vert I have such operation:
[java]
float thisTime = g_Time * m_TimeSpeed;
texCoordAni.y += thisTime;
[/java]
But what if texCoordAni.y will be equal more than allowed value for "float"? Will I get crush?
Should I add something to avoid it?
I don't know for sure, but...when you think about it....
g_Time is the time in seconds since your process started.
There are around 31,5 million seconds in a year (which is 31,5 * 10 exp 6).
The max float capacity is 10 exp 308 on a 64 bit system (according to wikipedia).
So event at speed =10 I guess your process would have to run for millenniums before reaching the float maximum range.
Even if your shader rocks... There is a slight chance that it won't be used anymore in several millenniums ;)
normen
November 23, 2011, 1:59pm
91
I think this float is 32bit no? Anyway it shouldn’t be a problem I guess ^^
mifth
November 23, 2011, 2:01pm
92
Even if I have such an operation:
[java]selectedTile += g_Time*m_Speed;
// the "1 - " bit is because otherwise it goes from right to left
texCoordAni.x = -(1 - ((texCoordAni.x + selectedTile % iNumTilesU) / iNumTilesU)); ///selectedTile;
texCoordAni.y = ((-texCoordAni.y - selectedTile / iNumTilesU) / iNumTilesV); ///selectedTile;
[/java]
m_Speed = 24;
Vertex shder is here: http://code.google.com/p/jme-glsl-shaders/source/browse/assets/Shaders/SimpleSprite/SimpleSprite.vert?r=ecf224d6f57665c78fc9d9805132d14a0f46db10
Thanks!
nehon
November 23, 2011, 2:41pm
93
Well i guess it’s safe too, it’s just milleniums/24…
zzuegg
November 27, 2011, 5:47pm
94
@mifth : i have downloaded the shadercollection_05, LightBlow works fine, but i get an error with the FakeParticleBlow, see image below:
this is the .vert file:
[java]
uniform mat4 g_WorldViewProjectionMatrix;
uniform float g_Time;
#if defined (ANY_DIR_Y) || defined (ANY_DIR_X)
uniform float m_TimeSpeed;
#endif
attribute vec3 inPosition;
attribute vec2 inTexCoord;
varying vec2 texCoord;
varying vec2 texCoordAni;
#ifdef FOG
varying float fog_z;
#endif
#if defined(FOG_SKY)
varying vec3 I;
uniform vec3 g_CameraPosition;
uniform mat4 g_WorldMatrix;
#endif
void main(){
gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1.0);
float thisTime = g_Time * m_TimeSpeed;
texCoord = inTexCoord;
texCoordAni = inTexCoord;
#if defined (ANY_DIR_Y) && !defined (CHANGE_DIR)
texCoordAni.y += thisTime;
#elif defined (ANY_DIR_Y) && defined (CHANGE_DIR)
texCoordAni.y -= thisTime;
#endif
#if defined (ANY_DIR_X) && !defined (CHANGE_DIR)
texCoordAni.x += thisTime;
#elif defined (ANY_DIR_X) && defined (CHANGE_DIR)
texCoordAni.x -= thisTime;
#endif
#if defined(FOG_SKY)
vec3 worldPos = (g_WorldMatrix * pos).xyz;
I = normalize( g_CameraPosition - worldPos ).xyz;
#endif
#ifdef FOG
fog_z = gl_Position.z;
#endif
}
[/java]
zzuegg
November 27, 2011, 5:56pm
95
@zzuegg said:
@mifth : i have downloaded the shadercollection_05, LightBlow works fine, but i get an error with the FakeParticleBlow, see image below:
I tracked the issue down, when both, Animation_X and Animation_Y are unchecked the shader will fail since m_TimeSpeed is not instanced.
mifth
November 27, 2011, 8:13pm
96
mifth
December 21, 2011, 8:07am
97
ShaderBlow_06 is out.
LightBlow - uniforms optimization. Simple_IBL feature and example is added is added. Fixes for ATI video cards.
FakeParticleBlow fixes.
http://code.google.com/p/jme-glsl-shaders/downloads/detail?name=JME_ShaderBlow_06.zip&can=2&q=
mifth
December 21, 2011, 8:30am
98
And another good news - ShaderBlow library will be used in this project:
http://code.google.com/p/rise-of-mutants/
YAHOOOO!!!
mifth
February 16, 2012, 2:45pm
99
1 Like
Hi,
(i don’t know if i can post this here, if not, please let me know …)
can someone give out a code example to use the toon shader
I have setup the material correctly and i use this code
Code:
Material mat = assetManager.loadMaterial("Materials/LightBlow/Toon_System/Toon_Base.j3m");
thing.setMaterial(mat);
as i try to have an object outline (with no toon shading), the material is setup this way :
Code:
Material toon : MatDefs/LightBlow/LightBlow.j3md {
MaterialParameters {
Toon : false
EdgesColor : 1.0 0.2 0.2 1.0
EdgeSize : 5.5099998
FogColor : 0.8 0.8 0.8 17.0
Fog_Edges : true
DiffuseMap : Textures/machine_texture.png
SpecularMap : Textures/machine_gloss.png
NormalMap : Textures/machine_normals.png
Shininess : 1.2
}
AdditionalRenderState {
}
}
but it does not show any outline :(
btw : why "Fog_Edges" ? why not "Edges" ?
thx