Jump to content
  • Advertisement

zonozz

Member
  • Content Count

    40
  • Joined

  • Last visited

Community Reputation

169 Neutral

About zonozz

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hi guys:   I've done all steps as RasterTek tutorial 36 said. And I found a weird part in my scene, please look at the picture below:   [attachment=24375:Weird picture.bmp]   P.S: Guys how to stick a picture into my topic? I've been uploading a picture as an attachment. : (   Thanks !
  2. Hi everyone:   I'm doing a effect like when I click in then window somewhere, there will be a explosion effect. But, here is a requirement : When I continually click on different position, the previous explosion effect should not disappear immediately, I mean they should be work on there own life span.   The first of my solution is that I build a render queue and a position queue. However, it doesn't work. Because it cannot render the current mouse position explosion effect when previous explosion effect is still working.   So I tried to create a thread when I click. And I hope each thread could finish one explosion effects. But there must something wrong when I call the Draw() function, because Draw() is also called by gluDisplayFunc(Draw);   Does anyone have solution ? Thank you very much. 
  3. Hi everyone:   I tried to use the following code for translate screen coordinates to a fixed-z in OpenGL 3D world: Point3D Get_3D_Pos(int x, int y) { Point3D glpt; GLint viewport[4]; GLdouble modelview[16]; GLdouble projection[16]; GLfloat winX, winY, winZ; GLdouble posX, posY, posZ; GLdouble last_posX, last_posY, last_posZ; glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glPushMatrix(); glGetIntegerv(GL_VIEWPORT, viewport); glGetDoublev(GL_MODELVIEW_MATRIX, modelview); glGetDoublev(GL_PROJECTION_MATRIX, projection); glPopMatrix(); winX = x; winY = viewport[3] - (float)y; glReadPixels((int)winX, (int)winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ); gluUnProject(winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ); glpt.x = posX; glpt.y = posY; glpt.z = posZ; return glpt; } What I'm trying to implement is that I want users to click somewhere in the window and the position will show a explosion effects, just like a fireworks, but I need to fix the Z coordinates, and the effects only works on X & Y axis.   Now I think maybe the results of the function above is wrong. See picture below: [attachment=24215:Wrong position.bmp]   The explosion's position is not where I click.   Could you guys give me an idea?
  4. Hello, everyone:   I've googled how to draw a line which like the paint brush, but I'm going to let the line behind gradually disappearing along with the mouse move. Do you guys have some ideas?   Thanks.
  5. Hi, sorry, I will make sense about it.   I try to scale the texture down, but the result of the texture were looked weird. I used a smaller texture ( screenwidth / 2, screenheight / 2 ) for scaling down. but finally ,I got 1 of 4 , a part of original texture (I mean I got only left-top part of the original texture, not the whole scene). I don't know how to fix it in DirectX 11, because the scaling down procedure was totally handled by DirectX.
  6. Hi everybody:   I'm doing the Blur tutorial which is from RasterTek( It seems has been shutdown at present ). I create a little window for seeing if the last stage's (Render To Texture) result is correct. But I even don't know what should be correct for those results? Could you guys have a look on the following pictures and tell me if the result is correct or not?   In the little window, it is the result of down sampled texture [attachment=24133:DownSampling.bmp]   In the little window, it is the result of horizontal blured texture [attachment=24134:Horizontal.bmp]   I'm very curious why the position of the picture in little window is that weird?  
  7. Hi everbody:   I'm doing the Blur in DirectX11 tutorial which is from previous website called RasterTek (Now it seems has been shutdown). I've some trouble about down sampling and two types bluring (Horizontal & Vertical). I use a little window for monitoring if the "render to texture"'s result is correct. I have some pictures you may interested in. I don't know whether it is a correct look or not. Could you guys give me some ideas?     The small window shows a downsampling result from the last stage. [attachment=24131:DownSampling.bmp]   The small window shows a horizontal blured result from the last stage [attachment=24132:Horizontal.bmp]   Thank you guys.
  8. You mean that different fluids, like difference between ocean and a cup of water, will be simulated in different methods( I think maybe it's just a something detail in equation's item, is that right ?) ? I'm stopped at surface-reconstruction, that's very hard to me. I try to read a lot of opensource and thesis, then I can do next.
  9. Thank you, I already had saved his site
  10. Hi, everyone !   I'm newer to do fluid simulation, and find that really hard to implement, I try to make that physical theory more clear, so I can do next. Please tell me if I had some comprehension problems :   I divide this tech into 2 steps - 1st is physical motion equation solving I called. And 2nd is surface reconstruction. Right ?   As learning going, I gradually find that the most difficult for me is step 2 - surface reconstruction. I cant imagine how those particles reconstructed by position data (or something else data ?), a algorithm to find surfaces ? or iso-surface ?    Digression - Are there something can be improved of fluid simulation for movies or games ? (The movies I saw, which had gorgeous fluid effects.)  
  11. zonozz

    Tangent Binormal Normal

    Oh, guys, thank you all !   I think I've remind the reason about that, I read the old book just now, and the 1st chapter is about physical wave. There is information about tangent & binormal theory.   Book - GPU Gem 1 By nVIDIA
  12. Hi Everyone !   I review the code written before, I just forgot one theory of  "normal mapping" tech.   From lighting theory point, When I need to lighting a object, object must has normal information, that's enough.   But in "normal mapping" tech, why I need tangent and binormal ? If I caculate lighting using normal map's data straight, is that really wrong ?    I make a water demo with high light, that is using 2 normal map, I using those data for lighting straight, the vision result I cant see something wierd ? Is that wrong in theory ?
  13. zonozz

    About water refraction

    Can anyone help me please ?   1. Why I need to calculate refraction & reflection vector ? Use reflection & refraction render texture for water plane will contribute some visual error ?   2. I debugged today, and another problem here, the whole water plane rocked when I turn my camera, I always feel that the surface of the water there is a delay. ( It means the water plane will dislocated with the bath. )
  14. zonozz

    About water refraction

      OK?But I'll post HLSL's code, but I dont know Why I need reflection vector and refraction vector ? I already render the final effect (Combine reflection & refraction).   Here is my code in Vertex Shader & Pixel Shader : /* * File name - Water.vs * Author - CuiXue * Updated date - 2013.4.21 * Desc - * */ cbuffer MatrixBuffer { matrix world; matrix view; matrix proj; }; cbuffer ReflectionBuffer { matrix reflectionMatrix; }; cbuffer CameraBuffer { float3 cameraPosition; float padding; }; struct VS_INPUT { float4 position : POSITION; float2 tex : TEXCOORD0; float3 normal : NORMAL; float3 tangent : TANGENT; float3 binormal : BINORMAL; }; struct PS_INPUT { float4 position : SV_POSITION; float2 tex1 : TEXCOORD0; float2 tex2 : TEXCOORD4; float4 reflectionPos : TEXCOORD1; float4 refractionPos : TEXCOORD2; float3 viewDirection : TEXCOORD3; float3 normal : NORMAL; float3 tangent : TANGENT; float3 binormal : BINORMAL; }; PS_INPUT WaterVS(VS_INPUT input) { PS_INPUT output = (PS_INPUT)0; float4 worldPos; matrix reflectionProjWorld; matrix viewProjWorld; input.position.w = 1.0f; output.position = mul(input.position, world); output.position = mul(output.position, view); output.position = mul(output.position, proj); output.normal = mul(input.normal, (float3x3)world); output.normal = normalize(output.normal); output.tangent = mul(input.tangent, (float3x3)world); output.tangent = normalize(output.tangent); output.binormal = mul(input.binormal, (float3x3)world); output.binormal = normalize(output.binormal); reflectionProjWorld = mul(reflectionMatrix, proj); reflectionProjWorld = mul(world, reflectionProjWorld); output.reflectionPos = mul(input.position, reflectionProjWorld); viewProjWorld = mul(view, proj); viewProjWorld = mul(world, viewProjWorld); output.refractionPos = mul(input.position, viewProjWorld); worldPos = mul(input.position, world); output.viewDirection = cameraPosition.xyz - worldPos.xyz; output.viewDirection = normalize(output.viewDirection); output.tex1 = input.tex / 1.0f; output.tex2 = input.tex / 0.5f; return output; }       Pixel Shader : /* * File name - Water.ps * Author - CuiXue * Updated date - 2013.4.21 * Desc - * */ SamplerState samplerState; Texture2D reflectionTex; Texture2D refractionTex; Texture2D normalTex; cbuffer WaterBuffer { float reflection_refraction_scale; float water_translation; float2 padding; }; cbuffer LightBuffer { float4 ambientColor; float4 diffuseColor; float3 direction; float specularPower; float4 specularColor; }; struct PS_INPUT { float4 position : SV_POSITION; float2 tex1 : TEXCOORD0; float2 tex2 : TEXCOORD4; float4 reflectionPos : TEXCOORD1; float4 refractionPos : TEXCOORD2; float3 viewDirection : TEXCOORD3; float3 normal : NORMAL; float3 tangent : TANGENT; float3 binormal : BINORMAL; }; float4 WaterPS(PS_INPUT input) : SV_TARGET { // Water params float fresnel; float specular; float r; float2 reflection_sample_coord; float2 refraction_sample_coord; float3 normal1; float3 normal2; float3 normal; float3 reflection; float3 heightView; float4 reflectionColor; float4 refractionColor; float4 refl_refr_lerpColor; float4 normalMap1; float4 normalMap2; float4 outputColor; float4 water_refl_color = float4( 0.7f, 0.9f, 0.7f, 1.0 ); float4 water_refr_color = float4( 0.6f, 1.0f, 0.6f, 1.0 ); input.tex1.y = input.tex1.y - water_translation; input.tex2.x = input.tex2.x + water_translation; heightView.x = input.viewDirection.y; heightView.y = input.viewDirection.y; heightView.z = input.viewDirection.y; reflection_sample_coord.x = input.reflectionPos.x / input.reflectionPos.w / 2.0f + 0.5f; reflection_sample_coord.y = -input.reflectionPos.y / input.reflectionPos.w / 2.0f + 0.5f; refraction_sample_coord.x = input.refractionPos.x / input.refractionPos.w / 2.0f + 0.5f; refraction_sample_coord.y = -input.refractionPos.y / input.refractionPos.w / 2.0f + 0.5f; // Sample normal map normalMap1 = normalTex.Sample(samplerState, input.tex1); normalMap2 = normalTex.Sample(samplerState, input.tex2); normal1 = (normalMap1.rgb * 2.0f) - 1.0f; normal2 = (normalMap2.rgb * 2.0f) - 1.0f; normal = normalize(normal1 + normal2); reflection_sample_coord = reflection_sample_coord + (normal.xy * reflection_refraction_scale); refraction_sample_coord = refraction_sample_coord + (normal.xy * reflection_refraction_scale); reflectionColor = reflectionTex.Sample(samplerState, reflection_sample_coord); refractionColor = refractionTex.Sample(samplerState, refraction_sample_coord); reflectionColor *= water_refl_color; refractionColor *= water_refr_color; // Calculate fresnel r = pow((1.0 - 1.0 / 1.3), 2) / pow((1.0 + 1.0/1.3), 2); // r = pow((1.3f - 1.0f), 2) / pow((1.3f + 1.0f), 2); fresnel = max(0.0f, min(1.0f, r + (1.0f - r) * pow(1.0f - dot(normal, heightView), 5.0))); refl_refr_lerpColor = lerp(reflectionColor, refractionColor, fresnel); reflection = -reflect(normalize(direction), normal); specular = dot(normalize(reflection), normalize(input.viewDirection)); if( specular > 0.0f ) { specular = pow(specular, specularPower); refl_refr_lerpColor = saturate(refl_refr_lerpColor + specular * specularColor); } outputColor = refl_refr_lerpColor; return outputColor; }     I just sample the reflection texture & refraction texture. and combine these 2 pictures to water plane.
  15. Hi everyone !   I'm doing 2D water simulation, and there is a problem in my program.   Figure : [attachment=15216:Problem.jpg]   Just as you see, I render the clip plane below to texture and over it to another texture, eventually to combine 2 texture to water plane.   Question :   1. I dont understand why my friends told me I should calculate reflection & refraction vector ? Why I need these vectors ? ( I already finish render the reflection & refraction effect ? ).   2. As you see the picture above, there is a obvious visual error in water plane, when I turn the camera, the goddess body teared ! How does it occurred ? How to fix it ?   Thanks.
  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!