Page 1 of 1

Shader handling in 1.8 has changed?

Posted: Fri Nov 09, 2012 12:45 am
by christianclavet
Hi, I had my terrain and water shader working ok on 1.7.3.

Just switched to 1.8.0 Today, the code compile ok, and run, but the shader rendering is completely corrupted (GLSL)
If the view change (zoom, move, etc) the black lines (should be the terrain) change patterns.
Image

Is there new methods? I don't see any message on the console that the shader crashed (compiled the debug dll)

What do I have to do?

Re: Shader handling in 1.8 has changed?

Posted: Fri Nov 09, 2012 1:08 am
by Granyte
i have many shader failing in 1.8 to especialy with transparency enabeled

Re: Shader handling in 1.8 has changed?

Posted: Fri Nov 09, 2012 2:38 am
by Nadro
@Christian
In v1.8 we added an int interface in IShaderConstantCallBack. Please use this interface to send a textures as int data instead of float.

@Granyte
In this release we fixed many problems with material rendering (mainly in D3D drivers), thats why old methods can work not properly. More info would be helpfull.

Re: Shader handling in 1.8 has changed?

Posted: Fri Nov 09, 2012 3:06 am
by Granyte
Il post a video later i just don't know how to explain it anymore

many of my materials flickers betwen opac and transparent depending on the position you are

Re: Shader handling in 1.8 has changed?

Posted: Fri Nov 09, 2012 4:44 am
by Granyte
this

http://www.youtube.com/watch?v=g2GyXVn9 ... tube_gdata

i mess around alot befor finding the precise spot but at the end the issue is clearly visible

Re: Shader handling in 1.8 has changed?

Posted: Fri Nov 09, 2012 1:30 pm
by christianclavet
Thanks Nadro, I'll check this method and try.

Re: Shader handling in 1.8 has changed?

Posted: Fri Nov 09, 2012 10:07 pm
by hybrid
Please post complete code, at least shader, callbacks and base material setup.

Re: Shader handling in 1.8 has changed?

Posted: Sat Nov 10, 2012 12:31 am
by Nadro
Which driver did You use? This will be a helpfull info.

Re: Shader handling in 1.8 has changed?

Posted: Sat Nov 10, 2012 1:23 am
by Granyte
dx9 using alpha blending with a verry basic shader

here is the content

float4x4 mWorldViewProj; // World * View * Projection transformation
float3 fvCameraPos;
float4x4 World;
float3 mLightPos[3];
sampler2D tex0 : register(s0);
sampler2D tex1 : register(s1);
sampler2D tex2 : register(s2);
sampler2D tex3 : register(s3);
sampler2D tex4 : register(s4);
sampler2D tex5 : register(s5);


// Vertex shader output structure
struct VS_OUTPUT
{
float4 Position : POSITION; // vertex position
float2 TexCoord : TEXCOORD0; // tex coords
float4 pos : TEXCOORD1; // The Mie color
float3 WorldView : TEXCOORD2;
float4 Diffuse : TEXCOORD3;
float3x3 TBN : TEXCOORD4;
float3x3 fvLightPos : TEXCOORD7;

};
VS_OUTPUT vertexMain( in float4 vPosition : POSITION,
in float3 vNormal : NORMAL,
float2 texCoord : TEXCOORD0,
float3 vBinorm : BINORMAL0,
float3 vTangent : TANGENT0
)
{
VS_OUTPUT Output;



Output.Position = mul(vPosition,mWorldViewProj);
Output.Diffuse = Output.Position;
Output.pos = (vPosition);
// transform normal

// renormalize normal
Output.TBN[0] = mul(normalize(vTangent), World);
Output.TBN[1] = mul(normalize(vBinorm), World);
Output.TBN[2] = mul(normalize(vNormal), World);


Output.fvLightPos[0] = normalize(mLightPos[0]-vPosition.xyz);
Output.fvLightPos[1] = normalize(mLightPos[1]-vPosition.xyz);
Output.fvLightPos[2] = normalize(mLightPos[2]-vPosition.xyz);
Output.TexCoord = texCoord;
Output.WorldView = fvCameraPos -vPosition.xyz;





return Output;
}


float4 pixelMain(VS_OUTPUT Inputs // vertex position
) :COLOR0
{
float4 ringdensity = tex2D(tex0,Inputs.TexCoord);
float4 ringNormaldensity = tex2D(tex1,Inputs.TexCoord);

float4 Noise = tex2D(tex2,Inputs.pos.xz*0.05);
float4 NoiseNormal = tex2D(tex3,Inputs.pos.xz*0.05);

Noise *= tex2D(tex2,Inputs.pos.xz*0.01);
NoiseNormal += tex2D(tex3,Inputs.pos.xz*0.01);

Noise *= tex2D(tex2,Inputs.pos.xz*0.002);
NoiseNormal += tex2D(tex3,Inputs.pos.xz*0.002);


float4 Color = tex2D(tex4,Inputs.pos.xz);


return ringdensity.a*Noise.a*Color*5;

}

Re: Shader handling in 1.8 has changed?

Posted: Sat Nov 10, 2012 2:14 am
by christianclavet
Hi, Nadro thanks. Changed the float to int in the shader callback and it fixed the problem! Thanks!

Re: Shader handling in 1.8 has changed?

Posted: Sat Nov 10, 2012 2:59 am
by Nadro
@christianclavet
I am glad it solved Your issues. Float interface for a textures was very unsafe (it worked on some platforms, but on other no) and this was one of the most important thing for adding int interface.

@Granyte
Do You have the same effect when You would use eg 1 or 2 textures?

Re: Shader handling in 1.8 has changed?

Posted: Sat Nov 10, 2012 3:39 am
by Granyte
I have the same effect with just my atmosphere shader that use no texture you can see in the background that there is a black ring around the planet well that's what was my atmospheric shader