Page 32 of 56

Posted: Sat Dec 19, 2009 7:15 pm
by Insomniacp
the zombie is b3d, I downloaded it from a site... http://www.psionic3d.co.uk/?s=zombie&x=0&y=0 It is down at the bottom.

if I do non ref then I get the transparency issue again.

It seems that when I remove the shaders from the leaves it work fine, so I guess its something in the shader code for them?

leaves.frag

Code: Select all

uniform sampler2D Texture;

varying vec4 Color;

void main()
{
	gl_FragColor = texture2D( Texture, gl_TexCoord[0].xy ) * Color;
}
leaves.vert

Code: Select all

varying vec4 Color;

void main()
{
	Color = gl_Color;
	gl_TexCoord[0] = gl_MultiTexCoord0;
	gl_Position = ftransform();
}
shader creation with irrlicht

Code: Select all

    leafMaterialType = (video::E_MATERIAL_TYPE) driver->getGPUProgrammingServices()->addHighLevelShaderMaterialFromFiles(
        "shaders/trees/leaves.vert",
        "main",
        EVST_VS_2_0,
        "shaders/trees/leaves.frag",
        "main",
        EPST_PS_2_0,
        0,
        EMT_TRANSPARENT_ALPHA_CHANNEL_REF,
        0);
I don't know if it is anything I can change in those that will fix the issue. I would prefer to have the shader on the leaves since they look better but if I remove the shader and just put EMT_TRANSPARENT_ALPHA_CHANNEL_REF then it works fine so something in the shader is making the lighting look bad and I don't know much about shaders. The game is in opengl, maybe that is the issue?


EDIT
I looked at the fire in example one and it does have the same issue, it is excluded but it lights up the wall behind it
Image

I set the ambient color to black to show that the wall is not black behind the excluded fire.

Posted: Sat Dec 19, 2009 11:01 pm
by BlindSide
No it doesn't have the same issue, your issue was the square shaped brightness around the leaves due to the transparent part not getting affectd by light. You can see in the particles that only the visible particle area is bright and also the fire is TRANSPARENT_ADD so it's supposed to light up it's background a little bit.

Btw the technique I'm implementing for the Irrlicht shadow maps doesn't draw a full screen overlay for lighting so it won't suffer from these issues.

Cheers

Posted: Sat Dec 19, 2009 11:35 pm
by Insomniacp
So I decided I can just do EMT_TRANSPARENT_ALPHA_CHANNEL_REF and then just use XEffects for lighting, This works great with ESM_CAST it shows the leaves as shadows how it should be but when I do both i get the issue with the shadows on the whole image not just the leaves in it. So any thoughts on why that happens?

Posted: Sun Dec 20, 2009 9:01 am
by BlindSide
Well the first post clearly reads:
UPDATE: V 1.2 includes added support for EMT_TRANSPARENT_ALPHA_REF materials for shadow mode ESM_CAST only. Check the first example.
I'm sure that's related somehow. :P

Posted: Sun Dec 20, 2009 2:21 pm
by Insomniacp
ah, okie, thanks.

Posted: Wed Dec 23, 2009 12:34 am
by stefbuet
Hi,
Is there a way to let not visible a node when we call node->setVisible(false) ?
Because actually when I use setVisible(false), I can still see the mesh :
even if :
-I call : effect->excludeNodeFromLightingCalculations(node);
-I call, or not : effect->addShadowToNode(node);

When using excludeNodeFromLightingCalculations method, my mesh is transparent, but there is no shadow where it should be. I mean no shadow on other meshs behind the transparent node.

When using addShadowToNode or not (but not the previous method) then the mesh is transparent but I can see its shadow (on the mesh)

Also is it normal that when activating shadows on a child node which is translated from its parent I can see shadow at the child node position instead of its (child+parent) position ?

In fact, with any node, when its visibility is set to false, we can see its self shadow at its init position (translation are not handled) :( even if the node is not visible.
I'll try to make/destroy nodes, keeping only the mesh, to simulate setVisible behavior...

Thanks

Posted: Wed Dec 23, 2009 7:23 am
by devsh
insomniac your shader is bound to be wrong because you multiply the alpha by the col meaning that the alpha value will gently caress up the correct syntax would be

Code: Select all

uniform sampler2D Texture; 

varying vec4 Color; 

void main() 
{ 
   vec4 texlookup = texture2D( Texture, gl_TexCoord[0].xy );
   gl_FragColor = vec4(texlookup.rgb*Color.rgb, texlookup.a); 
}
and secondly why are you even using a varying to pass on vertex col

Code: Select all

void main() 
{ 
   gl_FrontColor = gl_Color; 
   gl_TexCoord[0] = gl_MultiTexCoord0; 
   gl_Position = ftransform(); 
} 

Code: Select all

uniform sampler2D Texture; 

varying vec4 Color; 

void main() 
{ 
   vec4 texlookup = texture2D( Texture, gl_TexCoord[0].xy );
   gl_FragColor = vec4(texlookup.rgb*gl_Color.rgb, texlookup.a); 
}

Posted: Wed Dec 23, 2009 7:09 pm
by Insomniacp
uhhh, those aren't my shaders. Those were included in either the grass scene node or tree node projects that i downloaded and implemented so I can't answer your question as I did not make them. Thanks for the correction though.

Posted: Wed Dec 30, 2009 1:20 pm
by 3D Ace
I'm not too good with shaders and could use some help. I find the water from the screenwater shader a little too transparent for my purposes, how can i change its transperency?

Posted: Thu Jan 07, 2010 9:44 am
by 3D Ace
Ok Ignore that previous post. I learned some shader programming and wrote my own water scene node. :D

Posted: Thu Jan 07, 2010 1:26 pm
by devsh
very nice... now you could eliminate back/front rendering bugs (when objects above water are refracted as if they are underwater

Posted: Sun Jan 10, 2010 12:43 pm
by Barratator
Wow! Nice lib :-)

But...how can i add the Phong-Effect to a SceneNode?
I can't find the function addEffectToNode in the current version :(


Thanks!


Bastian

Posted: Wed Jan 13, 2010 12:45 pm
by 3D Ace
Hey i was trying to cast shadows on a Terrain Scenenode, however nomatter what i did the terrain always ended up totally black. Im certain the code is right. Does Xeffects actually support casting shadows on terrain scenenodes?

Posted: Thu Jan 14, 2010 6:08 am
by BlindSide
It should cast shadows on practically any scene node that can render to a depth buffer, that includes terrain. The issue is that the terrain scene node might be culled from the main camera's point of view and so some parts can be missing from the shadow camera's vision, this will create lack of shadows rather than black shadows though.

Posted: Thu Jan 14, 2010 12:17 pm
by 3D Ace
I got my new gpu today.(ATi 5970) and wierdly the terrain shadows now work perfectly. No idea why, but it works. :?
EDIT: I previously had a Nvidia 8800GT.