Shader handling in 1.8 has changed?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Shader handling in 1.8 has changed?

Post 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?
Granyte
Posts: 848
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: Shader handling in 1.8 has changed?

Post by Granyte »

i have many shader failing in 1.8 to especialy with transparency enabeled
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Shader handling in 1.8 has changed?

Post 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.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Granyte
Posts: 848
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: Shader handling in 1.8 has changed?

Post 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
Granyte
Posts: 848
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: Shader handling in 1.8 has changed?

Post 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
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: Shader handling in 1.8 has changed?

Post by christianclavet »

Thanks Nadro, I'll check this method and try.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Shader handling in 1.8 has changed?

Post by hybrid »

Please post complete code, at least shader, callbacks and base material setup.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Shader handling in 1.8 has changed?

Post by Nadro »

Which driver did You use? This will be a helpfull info.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Granyte
Posts: 848
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: Shader handling in 1.8 has changed?

Post 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;

}
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: Shader handling in 1.8 has changed?

Post by christianclavet »

Hi, Nadro thanks. Changed the float to int in the shader callback and it fixed the problem! Thanks!
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Shader handling in 1.8 has changed?

Post 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?
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Granyte
Posts: 848
Joined: Tue Jan 25, 2011 11:07 pm
Contact:

Re: Shader handling in 1.8 has changed?

Post 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
Post Reply