Jump to content
  • Advertisement

AriusMyst

Member
  • Content Count

    66
  • Joined

  • Last visited

Community Reputation

130 Neutral

About AriusMyst

  • Rank
    Member
  1. AriusMyst

    Geometry Instancing API

    I can't believe I forgot the shader. float4x4 w; //World. float4x4 v; //View. float4x4 p; //Projection. texture d; //Diffuse/Colour texture map. sampler2D ds = sampler_state { Texture = (d); MIPFILTER = LINEAR; MAGFILTER = LINEAR; MINFILTER = LINEAR; }; struct a2v { //Stream 0. Vertex information. float4 p : POSITION0; float2 uv: TEXCOORD0; float3 n : NORMAL; //Stream 1. Instance information. float4 Pos: COLOR1; }; struct v2f { float4 p : POSITION; float2 uv : TEXCOORD0; }; void vp(in a2v a2vin, out v2f v2fout) { float4 newPosition = mul(a2vin.p, w); float4 InstPosition = mul(a2vin.Pos, w); newPosition.x += InstPosition.x; newPosition.y += InstPosition.y; newPosition.z += InstPosition.z; v2fout.p = mul(newPosition, mul(v, p)); v2fout.uv = a2vin.uv; } float4 fp(in v2f v2fin): COLOR0 { float4 pixel = tex2D(ds, v2fin.uv); return pixel; } technique render { pass pass0 { //ZENABLE = TRUE; //ZWRITEENABLE = TRUE; //CULLMODE = NONE; vertexshader = compile vs_3_0 vp(); pixelshader = compile ps_3_0 fp(); } }
  2. AriusMyst

    Obama or McCain?

    All I heard tonight was "You suck." - "No, you suck.". Which at least made a welcome change from 2004's "You suck." - "Well, you may have a point, but you don't need to say it so often *sob* *sob*". I don't really know much about US domestic policy, and their foriegn policy is up to them imo, so it would be wrong of me to say who I thought gave the better answers. But in truth, not sure if I could pick one out anyway. They both seemed kind of flat really. Although, I would say I found McCain's implication that Obama wants to invade Pakistan amusing - not sure anybody fell for that but it was funny to see him try.
  3. AriusMyst

    Unresolved external symbol.. ?

    That works, guess I'm going to have read up on creating .libs. Thanks deadstar. :)
  4. AriusMyst

    how much does endorphine/euphoria cost?

    http://www.naturalmotion.com/sales.php You can download free learning editions here: http://www.naturalmotion.com/downloads.htm
  5. AriusMyst

    D3D10 Semantic debug error

    Quote:Original post by Adam_42 Just spotted something else with that data. The tangent is wrapped in round brackets while the other lines are in curly ones. That will make a big mess of the tangent data as it will combine it all into one with the comma operator! Did it not produce any compiler warnings? You sir are a genius and I am a fool. I have no idea why I had () instead of {}. Compiles and runs now, thank you very much for your help. :D
  6. AriusMyst

    D3D10 Semantic debug error

    Well spotted. Unfortunately it hasn't solved my problem, nor has D3D10_APPEND_ALIGNED_ELEMENT. It works if I don't attempt to pass tangent information so I'm pretty sure the shader itself is clean, but I'll post just in case. matrix World; matrix View; matrix Projection; matrix wvp; float3 LightPos = (0, 0, 5); Texture2D Diffuse; SamplerState sampleLinear { Filter = MIN_MAG_MIP_LINEAR; AddressU = Wrap; AddressV = Wrap; }; struct HOSTtoVERTEX { float4 PosOfVertex: POSITION; float3 Normal : NORMAL; // float3 Tangent : TANGENT; float2 UV : TEXCOORD; }; struct VERTEXtoFRAGMENT { float4 PosOfVertex: SV_POSITION; float3 Norm : TEXCOORD0; float3 LV : TEXCOORD1; float2 UV : TEXCOORD2; }; void VertexProgram(in HOSTtoVERTEX IN, out VERTEXtoFRAGMENT OUT) { float4 Pos = mul(IN.PosOfVertex, World); float4 PosWorld = mul(IN.PosOfVertex, World); Pos = mul(Pos, View); OUT.PosOfVertex = mul(Pos, Projection); OUT.LV = (PosWorld - LightPos); OUT.Norm = mul(IN.Normal, World); OUT.UV = IN.UV; } float4 FragmentProgram(in VERTEXtoFRAGMENT IN): SV_Target { float3 L = normalize(IN.LV); float3 N = IN.Norm; float D = dot(N, L); float3 C = Diffuse.Sample(sampleLinear, IN.UV); return D * float4(C, 1); // return float4(N, 1); } technique10 Render { pass pass0 { SetVertexShader(CompileShader(vs_4_0, VertexProgram())); SetGeometryShader(NULL); SetPixelShader(CompileShader(ps_4_0, FragmentProgram())); } }
  7. Just as a sidenote. You will need express 2005 and not 2008( unless you use XNA3 which I beleive is still in beta ). I kind of like using XNA with my 360, my only complaint is that the internet connection must be maintained( not the network connection, but the inet link ). I understand why this is, but it can be a little tedious if you're running Vista and like me you have those weird days where it simply refuses to maintain the connection. This can make debugging highly frustrating.
  8. AriusMyst

    Another SSAO thread.

    Yes, you shouldn't be texturing anything( apart from your quad ). It's post-processing shader. Here is the 4 that I have. Although, I still don't have the bias in. Depth: float4x4 World : WORLDVIEW; float4x4 wViewProj: WORLDVIEWPROJ; struct a2v { float4 Position: POSITION0; float3 Normal : NORMAL; }; struct v2f { float4 Position: POSITION0; float Test : TEXCOORD0; float3 Normal : TEXCOORD1; }; struct f2s { float4 Colour : COLOR0; }; void vp(in a2v IN, out v2f OUT) { OUT.Position = mul(IN.Position, World); OUT.Test = length(OUT.Position.xyz); OUT.Position = mul(IN.Position, wViewProj); OUT.Normal = IN.Normal; } void fp(in v2f IN, out f2s OUT) { float Deep = IN.Test; float3 N = normalize(IN.Normal); OUT.Colour = float4(N.r, N.g, N.b, Deep); } technique { pass Pass0 { VertexShader = compile vs_1_1 vp(); PixelShader = compile ps_2_0 fp(); } } SSAO: float4x4 Projection: PROJECTION; texture Deepa; texture Rand; float SampleRadius = 0.84; float DistanceScale = 3.5; float OccludeDist = 7.5; float3 Direction; sampler2D DeepSample = sampler_state { Texture = (Deepa); MIPFILTER = LINEAR; MAGFILTER = LINEAR; MINFILTER = LINEAR; }; sampler2D RandSample = sampler_state { Texture = (Rand); MIPFILTER = LINEAR; MAGFILTER = LINEAR; MINFILTER = LINEAR; }; struct app2vp { float4 Position: POSITION; float2 UV : TEXCOORD0; }; struct vp2fp { float4 Position: POSITION; float2 UV : TEXCOORD0; float3 Corner : TEXCOORD1; }; struct fp2s { float4 Colour : COLOR0; }; void vp( in app2vp IN, out vp2fp OUT ) { OUT.Position = IN.Position; OUT.UV = IN.UV; float2 ScreenPos = IN.UV; ScreenPos.y = 1.0f - ScreenPos.y; ScreenPos = ScreenPos * 2 - 1; OUT.Corner = float3(IN.Position.xy, 1.0f) * Direction; } void fp( in vp2fp IN, out fp2s OUT ) { float4 Samples[16] = { float4(0.355512, -0.709318, -0.102371, 0.0 ), float4(0.534186, 0.71511, -0.115167, 0.0 ), float4(-0.87866, 0.157139, -0.115167, 0.0 ), float4(0.140679, -0.475516, -0.0639818, 0.0 ), float4(-0.0796121, 0.158842, -0.677075, 0.0 ), float4(-0.0759516, -0.101676, -0.483625, 0.0 ), float4(0.12493, -0.0223423, -0.483625, 0.0 ), float4(-0.0720074, 0.243395, -0.967251, 0.0 ), float4(-0.207641, 0.414286, 0.187755, 0.0 ), float4(-0.277332, -0.371262, 0.187755, 0.0 ), float4(0.63864, -0.114214, 0.262857, 0.0 ), float4(-0.184051, 0.622119, 0.262857, 0.0 ), float4(0.110007, -0.219486, 0.435574, 0.0 ), float4(0.235085, 0.314707, 0.696918, 0.0 ), float4(-0.290012, 0.0518654, 0.522688, 0.0 ), float4(0.0975089, -0.329594, 0.609803, 0.0 ) }; float fColour = 0.0f; float2 nUV = IN.UV; float Deep = tex2D(DeepSample, nUV).a; float3 Norm = tex2D(RandSample, IN.UV * 200).rgb; float3 SE = (normalize(IN.Corner) * Deep); for(int i = 0; i < 16; i++) { float3 Ray = reflect(Samples.xyz, Norm) * SampleRadius; float4 Sample = float4(Ray + SE, 1); float4 SS = mul(Sample, Projection); float2 sUV = 0.5 * (SS.xy/SS.w) + float2(0.5, 0.5); sUV.y = 1-sUV.y; float sDeep = tex2D(DeepSample, sUV).a; //this check is hacky, change it when you have time. if(length(Deep - sDeep) > OccludeDist) { fColour++; } else { float Occlude = DistanceScale * max(Deep - sDeep, 0); fColour += 1 / (1 + (Occlude * Occlude) * 0.1); } } fColour = fColour/16; OUT.Colour = float4(fColour, fColour, fColour, 1); } technique null { pass Pass0 { VertexShader = compile vs_3_0 vp(); PixelShader = compile ps_3_0 fp(); } } Blur: float2 Direction = float2(1.0f/1024.0f, 0); texture Deepa; texture SSAO; sampler2D DeepSample = sampler_state { Texture = (Deepa); MIPFILTER = LINEAR; MAGFILTER = LINEAR; MINFILTER = LINEAR; }; sampler2D SSAOSample = sampler_state { Texture = (SSAO); MIPFILTER = LINEAR; MAGFILTER = LINEAR; MINFILTER = LINEAR; }; struct a2v { float4 Position: POSITION0; float2 UV : TEXCOORD0; }; struct v2f { float4 Position: POSITION0; float2 UV : TEXCOORD0; }; void vp(in a2v IN, out v2f OUT) { OUT.Position = IN.Position; OUT.UV = IN.UV; } float4 fp(in v2f IN): COLOR0 { float Deep = tex2D(DeepSample, IN.UV).r; float3 Norm = tex2D(DeepSample, IN.UV).rgb; float AO = tex2D(SSAOSample, IN.UV).r; float Num = 1; int Sam = 32; for(int i = -Sam/2; i <= Sam/2; i+=1) { float2 nUV = float2(IN.UV + i * Direction.xy); float Sample = tex2D(SSAOSample, nUV).r; float3 sNorm = tex2D(DeepSample, nUV).rgb; if(dot(Norm, sNorm) > 0.99) { Num += (Sam/2 - abs(i)); AO += Sample * (Sam/2 - abs(i)); } } return AO / Num; } Composite: texture SSAOTex; texture SceneTexture; float2 PixelOffset = float2( 0.001953125, 0.001953125 ); sampler2D ScreenSampler: TEXUNIT0 = sampler_state { Texture = (SceneTexture); }; sampler2D SSAOSampler: TEXUNIT0 = sampler_state { Texture = (SSAOTex); }; struct a2v { float4 Position: POSITION; float2 UV : TEXCOORD0; }; struct v2p { float4 Position: POSITION; float2 UV : TEXCOORD0; }; struct p2s { float4 Colour : COLOR0; }; void vp( in a2v IN, out v2p OUT ) { OUT.Position = IN.Position; OUT.UV = IN.UV; } void fp( in v2p IN, out p2s OUT ) { float4 Scene = tex2D(ScreenSampler, IN.UV); float4 SSAO = tex2D(SSAOSampler, IN.UV); float4 Grin = SSAO.r * Scene; OUT.Colour = Grin; OUT.Colour.a = 1; } technique null { pass Pass0 { VertexShader = compile vs_1_1 vp(); PixelShader = compile ps_2_0 fp(); } } Edit: Forgot to add. For these shaders, I had no need to modify the co-ords because the engine I am using for this sample does it for me. You may very well need to do this yourself. Anyway, I hope the code helps somewhat. I had a bitch of a time getting it up, it seems a twitchy technique. Good luck. :) [Edited by - AriusMyst on June 14, 2008 9:29:28 AM]
  9. AriusMyst

    Another SSAO thread.

    Well, you're doing it differently to me. But if you notice in the one I posted, I am grabbing the depth from world space - not world view projection space. Maybe there is something in that. Good luck :D.
  10. AriusMyst

    Another SSAO thread.

    Ahh yes, I understand now. I was being dense. Thanks again Agi, you've been very helpful :).
  11. AriusMyst

    Another SSAO thread.

    Actually, scrap that. The higher the resolution the worse the walls get: http://azazeldev.org/ssao/planes.jpg I'm not sure what you mean by the bias, I've tried doing this: float Deep = tex2D(DeepSample, nUV).a; float3 Bias = tex2D(DeepSample, nUV).rgb; float3 Norm = tex2D(RandSample, IN.UV * 200).rgb * Bias; I figured that was wrong, but thought I'd give it a shot anyway. I tried reading your thread here( http://www.gamedev.net/community/forums/topic.asp?topic_id=497072 ) but not sure if that is the thread you meant.
  12. AriusMyst

    Another SSAO thread.

    The method I'm using for the blur is pretty simple, though, at first I just used my HDRR blurring - but that looked awful. Here is what I'm doing. float2 Direction = float2(1.0f/1024.0f, 0); texture Deepa; texture SSAO; sampler2D DeepSample = sampler_state { Texture = (Deepa); }; sampler2D SSAOSample = sampler_state { Texture = (SSAO); }; struct a2v { float4 Position: POSITION0; float2 UV : TEXCOORD0; }; struct v2f { float4 Position: POSITION0; float2 UV : TEXCOORD0; }; void vp(in a2v IN, out v2f OUT) { OUT.Position = IN.Position; OUT.UV = IN.UV; } float4 fp(in v2f IN): COLOR0 { float Deep = tex2D(DeepSample, IN.UV).r; float3 Norm = tex2D(DeepSample, IN.UV).rgb; float AO = tex2D(SSAOSample, IN.UV).r; float Num = 1; int Sam = 32; for(int i = -Sam/2; i <= Sam/2; i+=1) { float2 nUV = float2(IN.UV + i * Direction.xy); float Sample = tex2D(SSAOSample, nUV).r; float3 sNorm = tex2D(DeepSample, nUV).rgb; if(dot(Norm, sNorm) > 0.99) { Num += (Sam/2 - abs(i)); AO += Sample * (Sam/2 - abs(i)); } } return AO / Num; } technique Blur { pass p0 { VertexShader = compile vs_3_0 vp(); PixelShader = compile ps_3_0 fp(); } } Obviously I run it twice, once for each direction. I also have one with less samples for SM2( I'm writing this for the TV3D community and some of them need the lower quality version ). I included a simple depth check that seems to work well: http://azazeldev.org/ssao/depth.avi I'm still not sure about the self-occlusion you're mentioning. The walls are annoying, but they don't seem so bad now this depth check is in play.
  13. AriusMyst

    Another SSAO thread.

    Ok, I have the blurring done: http://azazeldev.org/ssao/3.jpg Agi, I do still have something I don't understand however. The bias you mentioned for example, but also, if you look at the above screenshot. If I move that man in to the centre of the box-room, there is still occlusion on the walls from him. I'm guessing I need to check the depth, but I'm not sure how to go about doing that.. any ideas?
  14. AriusMyst

    Another SSAO thread.

    Well, I can show you mine, maybe that will help. :). Ignore the normals dump, I'm doing that for my blur shader( which is weird atm, but heh :D ). float4x4 World : WORLDVIEW; float4x4 wViewProj: WORLDVIEWPROJ; struct a2v { float4 Position: POSITION0; float3 Normal : NORMAL; }; struct v2f { float4 Position: POSITION0; float Test : TEXCOORD0; float3 Normal : TEXCOORD1; }; struct f2s { float4 Colour : COLOR0; }; void vp(in a2v IN, out v2f OUT) { OUT.Position = mul(IN.Position, World); OUT.Test = length(OUT.Position.xyz); OUT.Position = mul(IN.Position, wViewProj); OUT.Normal = IN.Normal; } void fp(in v2f IN, out f2s OUT) { float Deep = IN.Test; float3 N = normalize(IN.Normal); OUT.Colour = float4(N.r, N.g, N.b, Deep); } technique { pass Pass0 { VertexShader = compile vs_1_1 vp(); PixelShader = compile ps_2_0 fp(); } }
  15. AriusMyst

    Another SSAO thread.

    Wow, 6 days now. Well, it turned out I had a few things wrong - but the major thing was the corner. Thanks Agi, once we had that breakthrough everyone on IRC rallied together and started throwing out idea. The other things wrong were, in my calculation I was using tanf - but with degrees!( dumb thing I know, didn't even give it a thought ) and also the sample V co-ord needed a 1- :). The result is a little odd, I need to flip the colouring I think. But I think there is definite occlusion here: http://azazeldev.org/ssao/new.jpg Thanks guys, I was going out of my mind trying to get this to work. :) Edit: fixed the colouration, see: http://azazeldev.org/ssao/yay_yay_yay.jpg Thanks again guys.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!