• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

242 Neutral

About Nyocia

  • Rank
  1. I been looking around for some source code and theories about this mather for a time now. (source code to experiment with and learn - i find it easier that way) The most fit implementation for my work seem to be Preetham's "A Practical Analytic Model for Daylight" and out of some researching regarding his theroies i found a shader source at this homepage.(very good job by s.Wickens by the way). I tried to use the effect file in fxComposer2 - first timer using that program though. The resason why it aint working is with my mathemathical lack of wisdom i think, so the thing i need explained is the values needed to start exploring the effects of the light and aerial perspective. so lets begin, from below code the shader needs some variables. and if i have understand everything so far - some are constants and some are varying values. the thing im asking for is a brief very newbie explonation of below variables - which values are constants and which isn't. the only thing i want out of this exploring and playing with the shader is to recreate the haze vision you automaticly get from this theory. (so i can have a static sun, and everything - but the haze must appear on the terrain). I dont need to understand the mathemathical formulas either, i simply want to know how to set up this in fXcomposer (is it possible?, the only thing is to set symanthics right - where?) and from there i can develop something out of my needs. tnx for some basic information and some pointing towards right directions, and maybe even a little clue on what values i need to define in fxComposer to get a vision at all) (plane only black now ofcourse with no values set except the matrices). - well look at the bright side i can rotate the plane :). The fx file i try to use on that plane in fxComposer2. all code here below is not mine!, it is pasted from site mentioned above i reclaim none of this code and use it in learning purpouse only. float4x4 world, worldViewProj; float3 zenith; //x, y, Y format float perez_x[5]; float perez_y[5]; float perez_Y[5]; float3 eye, dir; float3 sunDir; float thetaS; //sun angle from zenith float Perez(float perez[5], float gamma, float theta, float luminance) { float cg = cos(gamma), cs = cos(thetaS); float num = (1 + perez[0]*exp(perez[1]/cos(theta))) * (1 + perez[2]*exp(perez[3]*gamma) + perez[4]*cg*cg); //eq 3 F(theta, gamma) float den = (1 + perez[0]*exp(perez[1])) * (1 + perez[2]*exp(perez[3]*thetaS) + perez[4]*cs*cs); //eq 3 F(0, thetaSun) return luminance*num/den; //eq 4 } struct vsIn { float3 pos: POSITION; float2 uv: TEXCOORD0; }; struct vsOut { float4 final: POSITION; float3 pos: TEXCOORD0; float2 uv: TEXCOORD1; }; void VS(in vsIn input, out vsOut output) { output.pos = mul(float4(input.pos, 1.0), world).xyz; output.final = mul(float4(input.pos, 1.0), worldViewProj); output.uv = input.uv; } struct psIn { float3 pos: TEXCOORD0; float2 uv: TEXCOORD1; }; float4 PS(in psIn input) : COLOR { float3 v = input.pos - eye; float ex = exp(-length(v)*0.0001); v = normalize(input.pos); //angle to the sun from this point float gamma = acos(dot(v, sunDir)); //angle from y axis to this point float theta = acos(v.y); float x = Perez(perez_x, gamma, theta, zenith.x); float y = Perez(perez_y, gamma, theta, zenith.y); float Y = Perez(perez_Y, gamma, theta, zenith.z); //convert xyY -> XYZ float X = x*Y/y; float Z = (1.0f - x - y)*Y/y; //convert XYZ -> RGB float3 inscatter; inscatter.r = 1.0 - exp(-0.00006*(3.240479*X - 1.53715*Y - 0.49853*Z)); inscatter.g = 1.0 - exp(-0.00006*(-0.969256*X + 1.875991*Y + 0.041556*Z)); inscatter.b = 1.0 - exp(-0.00006*(0.055648*X - 0.204043*Y + 1.057311*Z)); // float3 colour = tex2D(detailMapSampler, input.uv); float3 colour = {0.1, 0.1, 0.1}; return float4(colour*ex + inscatter*(1.0 - ex), 1.0); } technique shader { pass P0 { VertexShader = compile vs_1_1 VS(); PixelShader = compile ps_3_0 PS(); } } [Edited by - Nyocia on February 28, 2008 5:11:49 AM]
  2. Quote:Original post by V-man I suggest you create your texture first. Check to see what your depth precision is first. Use glGetIntegerv(GL_DEPTH_BIT, ...) I think If it is 24 bit, *** Source Snippet Removed *** and then use *** Source Snippet Removed *** so it will be a direct copy. Okey, do you think this can be a improvement compared to glReadPixels, which is "optimized" to read one single pixel , while this rendertotexture thingy is what i understand optimized to read whole pixelbuffers. what do you think V-man? PS: how do i post source like you did?, what is the specific snippet for it?
  3. Quote:Original post by RobbieS Quote:Original post by Ravuya You could try using an FBO and then using the depth information later through a shader. This is the best solution IMO. Have you tried setting up an FBO? You could render your scene and/or depth to textures, and then you have all that information quite handily. Especially if you just plan on piping it back into the GPU. The problem is the data has to be tranfered back to the cpu , the shader cannot help me at this point.
  4. by the way if i use glCopyTexImage2D can it lead to a improvement ?, i looked at the parameters that you can send into this function and i cant find anything that i can use to store the depth data ? is there any other function that may help me to this in the same way as glReadPixels? (but faster) GL_ALPHA, GL_ALPHA4, GL_ALPHA8, GL_ALPHA12, GL_ALPHA16, GL_LUMINANCE, GL_LUMINANCE4, GL_LUMINANCE8, GL_LUMINANCE12, GL_LUMINANCE16, GL_LUMINANCE_ALPHA, GL_LUMINANCE4_ALPHA4, GL_LUMINANCE6_ALPHA2, GL_LUMINANCE8_ALPHA8, GL_LUMINANCE12_ALPHA4, GL_LUMINANCE12_ALPHA12, GL_LUMINANCE16_ALPHA16, GL_INTENSITY, GL_INTENSITY4, GL_INTENSITY8, GL_INTENSITY12, GL_INTENSITY16, GL_RGB, GL_R3_G3_B2, GL_RGB4, GL_RGB5, GL_RGB8, GL_RGB10, GL_RGB12, GL_RGB16, GL_RGBA, GL_RGBA2, GL_RGBA4, GL_RGB5_A1, GL_RGBA8, GL_RGB10_A2, GL_RGBA12, or GL_RGBA16.
  5. okey, here's the thing: I want to read the pixels depth somehow and then perform a light algorithm on it, so i may use the wrong way to do so by using the glReadPixels. i looked at deffered shading and think thats the way to go. Now i need to know if there is any fast and reliable way to render the pixels on the screen to a texture, where i later on for example in a shader read the depth of a specific pixel?, if - how? and what method do i preferably use? I also posted a topic about this deffered lightning shader mather that can be found at forum under OpenGL -> deffered lightning/shading. Maybe just reply on that topic instead where it is of relevance, i now understand that glReadPixels is to slow for my mather and moving on to next discussion.. follow :). http://www.gamedev.net/community/forums/topic.asp?topic_id=473948
  6. Searched for a good deffered lightning/shading shader tutorial or article (a tutorial whould be preferable) but can't fint anything good out there. The thing i want to do is, to render the pixel into a texture (this to store the depth) , and then in the second pass of the shader i want to do my deffered lightning on those pixels that need it (refer to depthtexture). Im using OpenGL and GLSL, whould be awsome if anyone have any suggestions of article or tut, about this whole topic. Tnx for your answers , and keep the good code up !
  7. Hey guys ! I am reading the GL_DEPTH_COMPONENT from the screen using the glReadPixel call, and the project im working on is to big to use this function, and realising it becomes one of the biggest bottleneck in the project i have to do something about it. <code> glReadPixels(win.x(), win.y(), 1, 1, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT_8_8_8_8_REV, &bufferZ); </code> (the <code> snippet dont seem to work how do i attach code correctly in this forum? :S) someone have any ideas of what i can do to speed this up, do we have some betetr solutions , like writing it to a texture and then read in with another functioncall that is faster? Tnx for help , appriciated.
  8. Hey !, I work on a project that needs foam after a boat. The current implementation is with a particlesystem, and dont look very well imo. Do anyone have some ideas of a easy solution (i have very limited time). I tought of a shader , maybe a shader ?, but how do i write sucha shader easiest way ?, ... is there anyway to get the particlesystem nicer, any trix? well ty for any fast advices
  9. Untitled

    i got very much in school atm, so therefore a update is impossible at this time. be patient tho, it will be updated and i havent forgoten you :) cheers!
  10. Pause

    Hello, i have been on a vaccation and is still on it.. Therefore the bad update rate of this journal.
  11. update

    thanks :) actually its awsome !
  12. update

    Hello ! today i installed XNA and gamestudio. with c# visual express. lets see how it goes. over and out !

    Thats sounds very interesting mate. You definitly got a point here. Keep going dude.
  14. projects

    Soon there will be a update here with my 3d stuff as promised. i am currently working on multithreading a networksupported real time game (pong) so im rather busy trying to learn mutexes and such. thread one: c ya alter thread two: later dude
  15. Dissapointed

    Well Stalker was a really nice game, thats all ,, nice and i felt comfortable looking at it.. but where is the gameplay ?
  • Advertisement