kultys

Members
  • Content count

    11
  • Joined

  • Last visited

Community Reputation

122 Neutral

About kultys

  • Rank
    Member
  1. Shadow Mapping

    THX i try
  2. Shadow Mapping

    For now is better, i change this value effect.SetValue("xMaxDepth", 60) to 20. I use this format: A16B16G16R16F Now effect is good: [url="http://desmond.imageshack.us/Himg696/scaled.php?server=696&filename=screenjwf.jpg&res=landing"]http://desmond.image...jpg&res=landing[/url] How to implement PCF ? Thanx for help.
  3. Shadow Mapping

    * What is the surface format of the depth map from the light source? X8R8G8B8 If i change to R16F dont see another shadows for lights (1 and 2): [url="http://desmond.imageshack.us/Himg521/scaled.php?server=521&filename=screentz.jpg&res=landing"]http://desmond.imageshack.us/Himg521/scaled.php?server=521&filename=screentz.jpg&res=landing[/url] * How far is the light “camera” from the objects? Object: Flor is 0F Boy is 0F Light is: [code] LightPos(0) = New Vector3(-12.0F, 10.0F, 3.0F) LightPos(1) = New Vector3(-5, 5, 11.5F) LightPos(2) = New Vector3(-5, 35, 11.5F)[/code] and send to effect this: [code]LightViewProjection(0) = Matrix.LookAtLH(LightPos(0), New Vector3(2, 10, 0), New Vector3(0, 0, 1)) * Matrix.PerspectiveFovLH(CSng(Math.PI) / 2, Me.Width / Me.Height, 1.0F, 100.0F) LightViewProjection(1) = Matrix.LookAtLH(LightPos(1), New Vector3(-5, 5, 0), New Vector3(0, 1, 0)) * Matrix.PerspectiveFovLH(CSng(Math.PI) / 1.9F, Me.Width / Me.Height, 0.3F, 100.0F) LightViewProjection(2) = Matrix.LookAtLH(LightPos(2), New Vector3(-5, 35, 0), New Vector3(0, 1, 0)) * Matrix.PerspectiveFovLH(CSng(Math.PI) / 1.9F, Me.Width / Me.Height, 0.3F, 100.0F)[/code] Camera: [code]Matrix.PerspectiveFovLH((CType(Math.PI, Single) / 4), (Me.Width / Me.Height), 1.0F, 1024.0F)[/code]
  4. Shadow Mapping

    I changed the size of texture and light setting. No have this result: [img]http://img855.imageshack.us/img855/166/screenxe.jpg[/img] This problem exist only light 0 ([font=Arial][size=2][color="#030752"]direction light).[/color][/size][/font] Please help. What is bad in my code ?
  5. Shadow Mapping

    Hi, i implemante im my framework this shadow mapping: [url="http://www.riemers.net/eng/Tutorials/DirectX/Csharp/Series3/Finishing_touch.php"]http://www.riemers.n...shing_touch.php[/url]. Screen show results: [img]http://img259.imageshack.us/img259/1796/screenio.jpg[/img] This shadow is very bad ? How too implemant blur shadow mapps ? Please help me. THX for all. This is code to HLSL VS/PS : [code]struct SMapVertexToPixel { float4 Position : POSITION; float3 Position2D : TEXCOORD0; }; struct SMapPixelToFrame { float4 Color : COLOR0; float Depth : DEPTH; }; struct SSceneVertexToPixel { float4 Position : POSITION; float4 ShadowMapSamplingPos : TEXCOORD0; float4 RealDistance : TEXCOORD1; float2 TexCoords : TEXCOORD2; float3 Normal : TEXCOORD3; float3 Position3D : TEXCOORD4; }; struct SScenePixelToFrame { float4 Color : COLOR0; }; struct AmbientVertexToPixel { float4 Position : POSITION; float2 TexCoords : TEXCOORD0; float4 Position2D : TEXCOORD1; }; struct AmbientPixelToFrame { float4 Color : COLOR0; }; //------- Constants -------- float4x4 xCameraViewProjection; float4x4 xLightViewProjection[3]; float4x4 xRotate; float4x4 xTranslateAndScale; float4 xLightPos[3]; float4 xCameraPos; float xLightPower[3]; float xMaxDepth; float xAmbient; //------- Texture Samplers -------- Texture xColoredTexture; sampler ColoredTextureSampler = sampler_state { texture = <xColoredTexture> ; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = mirror; AddressV = mirror;}; Texture xShadowMap; sampler ShadowMapSampler = sampler_state { texture = <xShadowMap> ; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = clamp; AddressV = clamp;}; Texture xCarLightTexture; sampler CarLightSampler = sampler_state { texture = <xCarLightTexture> ; magfilter = LINEAR; minfilter=LINEAR; mipfilter = LINEAR; AddressU = clamp; AddressV = clamp;}; Texture xSpotLightTexture; sampler SpotLightSampler = sampler_state { texture = <xSpotLightTexture> ; magfilter = LINEAR; minfilter=LINEAR; mipfilter = LINEAR; AddressU = clamp; AddressV = clamp;}; //------- Vertex Shaders -------- SMapVertexToPixel ShadowMapVertexShader( float4 inPos : POSITION, uniform int CurrentLight) { SMapVertexToPixel Output = (SMapVertexToPixel)0; float4x4 preWorld = mul(xRotate, xTranslateAndScale); float4x4 preLightWorldViewProjection = mul (preWorld, xLightViewProjection[CurrentLight]); Output.Position = mul(inPos, preLightWorldViewProjection); Output.Position2D = Output.Position; return Output; } SSceneVertexToPixel ShadowedSceneVertexShader( float4 inPos : POSITION, float2 inTexCoords : TEXCOORD0, float3 inNormal : NORMAL, uniform int CurrentLight) { SSceneVertexToPixel Output = (SSceneVertexToPixel)0; float4x4 preWorld = mul(xRotate, xTranslateAndScale); float4x4 preCameraWorldViewProjection = mul (preWorld, xCameraViewProjection); float4x4 preLightWorldViewProjection = mul (preWorld, xLightViewProjection[CurrentLight]); Output.Position = mul(inPos, preCameraWorldViewProjection); Output.ShadowMapSamplingPos = mul(inPos, preLightWorldViewProjection); Output.RealDistance = Output.ShadowMapSamplingPos.z/xMaxDepth; Output.TexCoords = inTexCoords; Output.Normal = mul(inNormal, xRotate); Output.Position3D = inPos; return Output; } AmbientVertexToPixel AmbientVertexShader( float4 inPos : POSITION, float4 inTexCoords : TEXCOORD0) { AmbientVertexToPixel Output = (AmbientVertexToPixel)0; float4x4 preWorld = mul(xRotate, xTranslateAndScale); float4x4 preCameraWorldViewProjection = mul (preWorld, xCameraViewProjection); Output.Position = mul(inPos, preCameraWorldViewProjection); Output.Position2D = Output.Position; Output.TexCoords = inTexCoords; return Output; } //------- Pixel Shaders -------- float DotProduct(float4 LightPos, float3 Pos3D, float3 Normal) { float3 LightDir = normalize(LightPos - Pos3D); return dot(LightDir, Normal); } SMapPixelToFrame ShadowMapPixelShader(SMapVertexToPixel PSIn, uniform int CurrentLight) { SMapPixelToFrame Output = (SMapPixelToFrame)0; Output.Color[CurrentLight] = PSIn.Position2D.z/xMaxDepth; Output.Depth = Output.Color[CurrentLight]/3.0f + (2-CurrentLight)*0.33f; return Output; } SScenePixelToFrame ShadowedScenePixelShader(SSceneVertexToPixel PSIn, uniform int CurrentLight) { SScenePixelToFrame Output = (SScenePixelToFrame)0; float2 ProjectedTexCoords; ProjectedTexCoords[0] = PSIn.ShadowMapSamplingPos.x/PSIn.ShadowMapSamplingPos.w/2.0f +0.5f; ProjectedTexCoords[1] = -PSIn.ShadowMapSamplingPos.y/PSIn.ShadowMapSamplingPos.w/2.0f +0.5f; if ((saturate(ProjectedTexCoords.x) == ProjectedTexCoords.x) && (saturate(ProjectedTexCoords.y) == ProjectedTexCoords.y)) { float StoredDepthInShadowMap = tex2D(ShadowMapSampler, ProjectedTexCoords)[CurrentLight]; if ((PSIn.RealDistance.x - 1.0f/100.0f) <= StoredDepthInShadowMap) { float LightTextureFactor; if (CurrentLight == 0) { LightTextureFactor = tex2D(CarLightSampler, ProjectedTexCoords).r; }else{ LightTextureFactor = tex2D(SpotLightSampler, ProjectedTexCoords).r; } float DiffuseLightingFactor = DotProduct(xLightPos[CurrentLight], PSIn.Position3D, PSIn.Normal); float4 ColorComponent = tex2D(ColoredTextureSampler, PSIn.TexCoords); Output.Color = ColorComponent*LightTextureFactor*DiffuseLightingFactor*xLightPower[CurrentLight]; } } return Output; } AmbientPixelToFrame AmbientPixelShader(AmbientVertexToPixel PSIn) { AmbientPixelToFrame Output = (AmbientPixelToFrame)0; Output.Color = tex2D(ColoredTextureSampler, PSIn.TexCoords)*xAmbient; float2 ScreenPos; ScreenPos[0] = PSIn.Position2D.x/PSIn.Position2D.w/2.0f +0.5f; ScreenPos[1] = -PSIn.Position2D.y/PSIn.Position2D.w/2.0f +0.5f; for (int CurrentLight=1; CurrentLight<3; CurrentLight++) { float4 Light3DPos = mul(xLightPos[CurrentLight],xCameraViewProjection); float2 LightScreenPos; LightScreenPos[0] = Light3DPos.x/Light3DPos.w/2.0f +0.5f; LightScreenPos[1] = -Light3DPos.y/Light3DPos.w/2.0f +0.5f; float dist = distance(ScreenPos, LightScreenPos); float radius = 3.5f/distance(xCameraPos, xLightPos[CurrentLight]); if (dist < radius) { Output.Color.rgb += (radius-dist)*8.0f; } } return Output; } //------- Techniques -------- technique ShadowMap { pass Pass0 { cullmode = ccw; colorwriteenable = red; VertexShader = compile vs_2_0 ShadowMapVertexShader(0); PixelShader = compile ps_2_0 ShadowMapPixelShader(0); } pass Pass1 { colorwriteenable = green; VertexShader = compile vs_2_0 ShadowMapVertexShader(1); PixelShader = compile ps_2_0 ShadowMapPixelShader(1); } pass Pass2 { colorwriteenable = blue; VertexShader = compile vs_2_0 ShadowMapVertexShader(2); PixelShader = compile ps_2_0 ShadowMapPixelShader(2); } } technique ShadowedScene { pass Pass0 { VertexShader = compile vs_2_0 ShadowedSceneVertexShader(0); PixelShader = compile ps_2_0 ShadowedScenePixelShader(0); } pass Pass1 { SRCBLEND = ONE; DESTBLEND = ONE; ALPHABLENDENABLE = true; VertexShader = compile vs_2_0 ShadowedSceneVertexShader(1); PixelShader = compile ps_2_0 ShadowedScenePixelShader(1); } pass Pass2 { VertexShader = compile vs_2_0 ShadowedSceneVertexShader(2); PixelShader = compile ps_2_0 ShadowedScenePixelShader(2); } pass Pass3 { VertexShader = compile vs_2_0 AmbientVertexShader(); PixelShader = compile ps_2_0 AmbientPixelShader(); } }[/code]
  6. Sorry for stupid question... I have my code which displays objects: Dim newZStencil As Surface = Device.GetBackBuffer(0, 0, BackBufferType.Mono) Do While brun = True Device.SetRenderTarget(0, newZStencil) Device.Clear(ClearFlags.Target Or ClearFlags.ZBuffer, Color.Black, 1.0F, 0) Device.BeginScene() ' First object Device.Transform.World = Matrix.Translation(New Vector3(0,0,0)) For i = 0 To matObject1.Length - 1 'Device.Material = materials3(i) Device.SetTexture(0, texObject1(i)) objObject1.DrawSubset(i) Next ' Second object Device.Transform.World = Matrix.Translation(New Vector3(0,0,0)) For i = 0 To matObject2.Length - 1 'Device.Material = materials3(i) Device.SetTexture(0, texObject2(i)) objObject2.DrawSubset(i) Next Device.EndScene() Device.Present() Application.DoEvents() Loop And i need add for this 2 object effect blur from .FX file (Shader). Please help me, i dont now where and what i must add for this code. VERY VERY thanks for help.
  7. DirectX (VB.NET+shader blur)

    Plase heeeelp ;]
  8. I am beginner. I have my code which displays objects: Dim newZStencil As Surface = Device.GetBackBuffer(0, 0, BackBufferType.Mono) Do While brun = True Device.SetRenderTarget(0, newZStencil) Device.Clear(ClearFlags.Target Or ClearFlags.ZBuffer, Color.Black, 1.0F, 0) Device.BeginScene() ' First object Device.Transform.World = Matrix.Translation(New Vector3(0,0,0)) For i = 0 To matObject1.Length - 1 'Device.Material = materials3(i) Device.SetTexture(0, texObject1(i)) objObject1.DrawSubset(i) Next ' Second object Device.Transform.World = Matrix.Translation(New Vector3(0,0,0)) For i = 0 To matObject2.Length - 1 'Device.Material = materials3(i) Device.SetTexture(0, texObject2(i)) objObject2.DrawSubset(i) Next Device.EndScene() Device.Present() Application.DoEvents() Loop And i need add for this 2 object effect blur from .FX file (Shader). Please help me, i dont now where and what i must add for this code. VERY VERY thanks for help. [Edited by - kultys on September 4, 2008 5:43:44 AM]