Pages: 1 ... 26 27 28 29 [30]   Go Down
  Print  
Author Topic: "Outdoor shadows solution for Quest3D" (source code available for purchase)  (Read 104984 times)
March 04, 2013, 12:27:41 pm
I don't think the problem is related to those camera settings because the original sample project works perfectly fine in q3d4.3.2. It is some kind of compatibility issue.

Also, the flickering isn't the kind you get with too little updates per frame.
The whole scene (shadowed and non-shadow areas) are flashing randomly between textured and
total blackout.

You described what I am seeing in you earlier post:
"If i open v24_4_3_OSSfQ3D_Skinned_character_nature_painter project directly in Q3D 5 shadow is flickering and it looks totally black."
March 04, 2013, 12:44:50 pm
Well. Setup is a bit complicated. What i did was to bring them all in one place, then diagnose any issue while i could see the whole pipeline at once. Shadow have a very simple setup but this example is complicated as hell. I guess you call that sky rt somewhere wrong.

ali-rahimi.net
June 08, 2013, 11:48:04 am
Is this Solution possible to intigrate in Q3d 5?
Thx
June 08, 2013, 01:39:48 pm
Is this Solution possible to intigrate in Q3d 5?
Thx

Sure. I already did.

ali-rahimi.net
June 08, 2013, 10:51:07 pm
Oh pervect! good news since a long time. Grin
September 12, 2013, 01:35:53 am
I was try to use this shader with the Shadow solution
but it is so hard for me to add the second technique to render deph and shadows!  Frustrated

Plz if someone could help me, I would be very grateful.

Code:
/*** Generated through Lumonix shaderFX  by: Maximilian Witsch in 3dsmax at: 28.08.2013 00:18:23  ***/

// This FX shader was built to support the Quest3D engine.
// Tell the app that we want tangets
int UseTangent : UseTangent;
int UseBiNormal : UseBiNormal;
 
float dummy : DisableObjectClipping;

float UIVector_976x :CHANNELVALUE0
<
string UIWidget = "Slider";
float UIMin = -999.0;
float UIMax = 999.0;
float UIStep = 0.1;
string UIName = "World PosX";
> = 0.0;
 
float UIVector_976y :CHANNELVALUE1
<
string UIWidget = "Slider";
float UIMin = -999.0;
float UIMax = 999.0;
float UIStep = 0.1;
string UIName = "World PosY";
> = 0.0;
 
float UIVector_976z :CHANNELVALUE2
<
string UIWidget = "Slider";
float UIMin = -999.0;
float UIMax = 999.0;
float UIStep = 0.1;
string UIName = "World PosZ";
> = 0.0;
 
float UIConst_4927 :CHANNELVALUE3
<
string UIWidget = "Slider";
float UIMin = 10.0;
float UIMax = 0.0;
float UIStep = 0.01;
string UIName = "Highmap scale";
> = 0.01;
 
texture NormalMap_1285 : TEXTURE0
<
string ResourceType = "2D";
>;
 
sampler2D NormalMap_1285Sampler = sampler_state
{
Texture = <NormalMap_1285>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = LINEAR;
AddressU = WRAP;
AddressV = WRAP;
};
 
float UIConst_9949 :CHANNELVALUE4
<
string UIWidget = "Slider";
float UIMin = -10.0;
float UIMax = 10.0;
float UIStep = 0.1;
string UIName = "Blend Offset";
> = -10.0;
 
float UIConst_5925 :CHANNELVALUE5
<
string UIWidget = "Slider";
float UIMin = 0.0;
float UIMax = 100.0;
float UIStep = 0.1;
string UIName = "Blend Softness";
> = 25.0;
 
texture TextureMap_322 : TEXTURE1
<
string ResourceType = "2D";
>;
 
sampler2D TextureMap_322Sampler = sampler_state
{
Texture = <TextureMap_322>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = LINEAR;
AddressU = WRAP;
AddressV = WRAP;
};
 
texture TextureMap_8331 : TEXTURE2
<
string ResourceType = "2D";
>;
 
sampler2D TextureMap_8331Sampler = sampler_state
{
Texture = <TextureMap_8331>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = LINEAR;
AddressU = WRAP;
AddressV = WRAP;
};
 
texture TextureMap_5118 : TEXTURE3
<
string ResourceType = "2D";
>;
 
sampler2D TextureMap_5118Sampler = sampler_state
{
Texture = <TextureMap_5118>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = LINEAR;
AddressU = WRAP;
AddressV = WRAP;
};
 
texture TextureMap_6453 : TEXTURE4
<
string ResourceType = "2D";
>;
 
sampler2D TextureMap_6453Sampler = sampler_state
{
Texture = <TextureMap_6453>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = LINEAR;
AddressU = WRAP;
AddressV = WRAP;
};
 
float UIConst_2821 :CHANNELVALUE6
<
string UIWidget = "Slider";
float UIMin = 0.0;
float UIMax = 1.0;
float UIStep = 0.1;
string UIName = "Light";
> = 0.8;
 
texture TextureMap_1019 : TEXTURE5
<
string ResourceType = "2D";
>;
 
sampler2D TextureMap_1019Sampler = sampler_state
{
Texture = <TextureMap_1019>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = LINEAR;
AddressU = WRAP;
AddressV = WRAP;
};
 
float UIConst_6115 :CHANNELVALUE7
<
string UIWidget = "Slider";
float UIMin = -30.0;
float UIMax = 30.0;
float UIStep = 0.1;
string UIName = "High";
> = 80.0;
 

// this function does the different types of light attenuation
float attenuation_func(int lightattenType, float4 lightAttenuation, float3 lightVec)
{
float att = 1.0;
return att;
}

// this function does the different types of cone angle
float coneangle_func(int lightconeType, float lightHotspot, float lightFalloff, float3 lightVec, float3 lightDir)
{
float cone = 1.0;
return cone;
}

/************** light info **************/

#define MAX_LIGHTCOUNT 8
float NLIGHTS = 1;
#define LIGHT_TYPE_NONE 0
#define LIGHT_TYPE_POINT 1
#define LIGHT_TYPE_SPOT 2
#define LIGHT_TYPE_DIRECTIONAL 3
 
float3 light_dir[MAX_LIGHTCOUNT] : LIGHTDIR;
float3 light_pos[MAX_LIGHTCOUNT] : LIGHTPOS;
float4 light_color[MAX_LIGHTCOUNT] : LIGHTCOLOR;
float light_atten1[MAX_LIGHTCOUNT] : LIGHTATT1;
float light_atten2[MAX_LIGHTCOUNT] : LIGHTATT2;
float light_atten3[MAX_LIGHTCOUNT] : LIGHTATT3;
float light_hotspot[MAX_LIGHTCOUNT] : LIGHTPHI;
float light_falloff[MAX_LIGHTCOUNT] : LIGHTTHETA;
float light_type[MAX_LIGHTCOUNT] : LIGHTTYPE;
#define light1attenType 0
#define light1coneType 0
#define light1CastShadows false

//----------------------------------

float4x4 wvp : WorldViewProjection < string UIWidget = "None"; >; 
float4x4 worldI : WorldInverse < string UIWidget = "None"; >; 
float4x4 worldIT : WorldInverseTranspose < string UIWidget = "None"; >; 
float4x4 viewInv : ViewInverse < string UIWidget = "None"; >; 
float4x4 world : World < string UIWidget = "None"; >; 
// create the light vector
float3 lightVec_func(float3 worldSpacePos, float3 lightVector, int lightType)
{
float3 lightVec = lightVector - worldSpacePos;
return lightVec;
}



// input from application
struct a2v {
float4 position : POSITION;

float4 tangent : TANGENT;
float4 binormal : BINORMAL;
float4 normal : NORMAL;
float2 texCoord1 : TEXCOORD1;

};

// output to fragment program
struct v2f {
        float4 position    : POSITION;
        float4 worldNormal    : TEXCOORD0;

        float4 wposition     : TEXCOORD1;
        float4 worldBinormal : TEXCOORD2;
float2 texCoord1 : TEXCOORD3;

};

//Ambient and Self-Illum Pass Vertex Shader
v2f av(a2v In, uniform float3 lightPos, uniform int lightType, uniform float3 lightDir)
{
    v2f Out = (v2f)0;

/*============================= Custom Vertex Shader Code =============================*/
float3 INVertPos_4896 = In.position.xyz;
float3 INVertPos_3565 = mul(In.position, world);
float3 MathVecConstuct_3073 = float3(INVertPos_3565.x, INVertPos_3565.z, INVertPos_3565.y);
float3 UIVector_976 = float3(UIVector_976x, UIVector_976y, UIVector_976z);
float3 MathOperator_8008 = MathVecConstuct_3073 + UIVector_976;
float4 TextureMap_1019 = tex2Dlod(TextureMap_1019Sampler, float4((MathOperator_8008 * UIConst_4927).xy,0,0) );
float3 MathVecConstuct_9664 = float3(INVertPos_4896.x, (INVertPos_4896.y + (TextureMap_1019.g * UIConst_6115)), INVertPos_4896.z);
In.position.xyz = MathVecConstuct_9664;
/*=====================================================================================*/


Out.position = mul(In.position, wvp); //transform vert position to homogeneous clip space

//this code was added by the Vertex Position Node
Out.wposition = mul(In.position, world); //world space vertex position passed out
//this code was added by the Texture Map Node
Out.worldNormal = float4( mul(In.normal, worldIT).xyz, In.normal.w ); //compute world space normal
Out.worldBinormal = float4(mul(In.binormal, worldIT).xyz, 1); //compute world space binormal
if (dot(cross(In.binormal, In.normal), In.tangent) < 0.0) Out.worldBinormal.w = -1; //detect mirrored UV space
Out.texCoord1 = In.texCoord1; //pass through texture coordinates from channel 2

return Out;
}

//Ambient and Self-Illum Pass Pixel Shader
float4 af(v2f In, uniform float3 lightDir, uniform float4 lightColor, uniform float4 lightAttenuation, uniform float lightHotspot, uniform float lightFalloff, uniform int lightType, uniform int lightattenType, uniform int lightconeType, uniform bool lightCastShadows, uniform int shadowPassCount) : COLOR
{

float3 INVertPos_3565 = In.wposition.xyz; //Incoming vertex position in world space
float3 MathVecConstuct_3073 = float3(INVertPos_3565.x, INVertPos_3565.z, INVertPos_3565.y);
float3 UIVector_976 = float3(UIVector_976x, UIVector_976y, UIVector_976z);
float3 MathOperator_8008 = MathVecConstuct_3073 + UIVector_976;
float3 MathOperator_7529 = MathOperator_8008 * UIConst_4927;
float4 NormalMap_1285 = tex2D(NormalMap_1285Sampler, MathOperator_7529.xy);
NormalMap_1285.xyz = NormalMap_1285.xyz * 2 - 1; //expand to -1 to 1 range
NormalMap_1285 = float4(mul(NormalMap_1285, worldIT).xyz, NormalMap_1285.w); //put object space normal in world space
NormalMap_1285.rgb = normalize(NormalMap_1285.rgb); //normalized the normal vector
float3 MathBrightnessContrast_3348 = (NormalMap_1285.rgb - 0.5) * UIConst_5925 + 0.5 + UIConst_9949;
float3 MathVecConstuct_7226 = MathBrightnessContrast_3348;
float UIConst_8297 = 0.0;
float UIConst_1683 = 1.0;
float MathClamp_4849 = clamp(MathVecConstuct_7226.b, UIConst_8297, UIConst_1683);
float2 INUV_7051 = In.texCoord1.xy;
float4 TextureMap_322 = tex2D(TextureMap_322Sampler, INUV_7051.xy);
float3 UIColor_7483 = float3(1.0f, 1.0f, 1.0f );
float3 MathVecConstuct_7587 = (UIColor_7483.rgb - MathBrightnessContrast_3348);
float MathClamp_3333 = clamp(MathVecConstuct_7587.b, UIConst_8297, UIConst_1683);
float4 TextureMap_8331 = tex2D(TextureMap_8331Sampler, INUV_7051.xy);
float4 TextureMap_5118 = tex2D(TextureMap_5118Sampler, MathOperator_7529.xy);
float4 TextureMap_6453 = tex2D(TextureMap_6453Sampler, MathOperator_7529.xy);
float3 UIColor_186 = float3(1.0f, 1.0f, 1.0f );
float3 MathLerp_9814 = lerp(TextureMap_6453.rgb, UIColor_186.rgb, UIConst_2821);
float3 MathColorBlend_9432;
MathColorBlend_9432 = (((MathClamp_4849 * TextureMap_322.rgb) + (MathClamp_3333 * TextureMap_8331.rgb)) + TextureMap_5118.rgb) * MathLerp_9814; //Multiply Color Blend
float3 input1 = MathColorBlend_9432;

float4 ret =  float4(0,0,0,1);
ret = float4(input1, 1);
return ret;
}

// Pixel shader input structure
struct in_depth_ps {
float4 clip_pos : POSITION;
float view_depth : TEXCOORD0;
float3 normal : TEXCOORD1;
};

struct in_hw_shadow_ps {
float4 clip_pos : POSITION;
};

struct in_sw_shadow_ps {
float4 clip_pos : POSITION;
float clip_pos_depth : TEXCOORD0;
};

//---------------------------------------------------------------

float4 depth_ps(in_depth_ps input) : COLOR {
return float4(input.view_depth, input.normal);
}

float4 hw_shadow_map_ps(in_hw_shadow_ps input) : COLOR {
return 1;
}

float4 sw_shadow_map_ps(in_sw_shadow_ps input) : COLOR {
return float4(input.clip_pos_depth.xxx, 0);
}

//---------------------------------------------------------------


technique Complete 

pass ambient 
    {
VertexShader = compile vs_3_0 av(light_pos[0], light_type[0], light_dir[0]);
ZEnable = true;
ZWriteEnable = true;
CullMode = ccw;
ShadeMode = Gouraud;
AlphaBlendEnable = false;
AlphaTestEnable = FALSE;
PixelShader = compile ps_3_0 af(light_dir[0], light_color[0], float4(light_atten1[0], light_atten2[0], light_atten3[0], 1.0), light_hotspot[0], light_falloff[0], light_type[0], light1attenType, light1coneType, light1CastShadows, 1);


}

technique depth_render { //Tech #1
pass P0 {

ZEnable = TRUE;
ZWriteEnable = TRUE;
ZFunc = LESS;
StencilEnable = TRUE;
stencilfunc = ALWAYS;
StencilPass = REPLACE;
StencilFail = KEEP;
StencilZFail = KEEP;
StencilRef = 1;

PixelShader = compile ps_3_0 depth_ps();
}
}
November 15, 2013, 10:51:21 am
I really like this shadow solution, it is fast and gives a clean AO & shadow! Is it possible to add lights with shadows (f.e. for a spotlight like in qframework) to use this solution for indoor lighting situations, too?
Pages: 1 ... 26 27 28 29 [30]   Go Down
  Print  
 
Jump to: