Jump to content
  • Advertisement

YannikLambert

Member
  • Content Count

    12
  • Joined

  • Last visited

Community Reputation

104 Neutral

About YannikLambert

  • Rank
    Member
  1. YannikLambert

    Convert Euler Rotation

      Many thanks Norman, tested and approved, in fact, with your solution it was really simple ;-)   You can see these kind of rotations for example in unreal engine, skyrim,...
  2. YannikLambert

    Convert Euler Rotation

    Hi, I'm trying to convert rotations from one code to another. Input: rotations: xyz axes: x right, y forward et z up rotation sequence: xyz Output: axes: y right, x forward et z up rotation sequence zyx rotations: ?   Looking for help to achieve this ;-) Thanks in advance for your help.
  3. Hi,in XNA, it seems it's better to clone effect (material = effect) instead of sharing an effect instance and having material setting continuously the different parameters. Question 1: Can i clone effect to avoid setting parameters like textures etc everytime, and sharing the instance between meshparts, but when drawing the part setting only the world matrix..........or do you thing changing the world matrice it too costly too and if two parts do not use the same world matrice i should also clone the effect..... So, it seems the defaut of the content pipeline processor, will share the same effect instance among meshpart that use the same material and world matrice when loading a model. With this you can draw your model meshparts by material order to limit states change..... do the content importer share same instance of the same effect among meshpart of different loaded models or do it only share the instance between parts of ONE model...... if it is the case do you thing it would be better if i separate loading model geometry and creating material instance (wood, blue eye, rock, white skin) and affecting the same materiel instance among all meshparts of all models composing my scene and then having a render loop looking like that: foreach (material in allMaterials) { foreach (meshpart in allMeshpartFromAllModelsUsingThisMaterials) { material.World = ...; Draw(meshpart) } } This aproach is different than the standard xna where the render loop look like this: foreach (model) { foreach (effect in model) { effect.World = ...; } foreach (meshpart in model) { Draw(meshpart) } } Many thanks in advance for your advices....
  4. YannikLambert

    Should Specular RV be clamped?

    I'm agree with this to reject negatives values......but my question was if i also should set to 0 values less than 0.7 Imagine in 2d xy my last scenario, to have a realistic comportment, i should reject values at left of y (negatives x => r.v between 0 and 0.7), because they represent a ray of light coming somewhere from x[-1...0],y[0...1] and having specular reflecting to x[-1...0],y[0...1] => since my normal is up vector all ray of light should have specular reflectance to x[0...1],y[0...1]? It's hard to explain :-) There is an image in attachment. It seems ok to see specular if camera is in orange area, but is it normal to have some in green area? It look nrealistic...... [/quote] Nobody has an idea?
  5. YannikLambert

    Light pre-pass renderer + shadow map

    I find my error: [color="#880000"]// Transform position from screen space to world space position [color="#666600"]= mul[color="#666600"](position[color="#666600"], [color="#660066"]InverseViewProjection[color="#666600"]); position[color="#666600"].xyz [color="#666600"]/= position[color="#666600"].w[color="#666600"]; After that i had forgotten to set position[color="#666600"].w to 1. Now all work fine :-) Thank you all ;-)
  6. Hi, I know this is an old topics but.... You present the best way you have find to create vpos...... But i wandered if you could explain the best way you have find to reonstruct the world position from this vpos and how you store your depth (linear, nonlinear,....). Many thanks in advance for your help.
  7. YannikLambert

    Light pre-pass renderer + shadow map

    Yes the problem is no shadow at all. Light pre-pass is a a deffered rendering. Phase1 : Render Normal and depth map Phase 2-1 : Render shadows maps for every lights Phase 2-2 : Render the light map (here i try to merge with shadow map: if a vertex is occluded in shadow map, it should not recieve lighting) Phase 3 : Render materials using light map [/quote] Is the shadow's "DEPTH DATA" written to the shadow map at all? Or is the depth comparison where you're failing? [/quote] It's depth comparison that fail.....i think i lost too many presision when storing shadow depth. For the depth map i store: { VertexShaderOutput output; float4x4 viewProjection = mul(View, Projection); float4x4 worldViewProjection = mul(World, viewProjection); output.Position = mul(input.Position, worldViewProjection); output.Depth.xy = output.Position.zw; return output; } PixelShaderOutput PixelShaderFunction(VertexShaderOutput input) { PixelShaderOutput output; // Depth is stored as distance from camera / far plane distance // to get value between 0 and 1 output.Depth = input.Depth.x / input.Depth.y; return output; } and for the shadow map: VertexShaderOutput VertexShaderFunction(VertexShaderInput input) { VertexShaderOutput output; float4 worldPosition = mul(input.Position, World); float4 viewPosition = mul(worldPosition, View); output.Position = mul(viewPosition, Projection); output.Depth = output.Position.z; return output; } float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 { // Depth is stored as distance from camera / far plane distance // to get value between 0 and 1 float depth = input.Depth / FarPlane; return depth; } Maybe i should have a look at another depth storing/reconstruction method......i ear about linear ones...... In my code i even don't understand the difference between z/w and z/FarPlane......
  8. YannikLambert

    Should Specular RV be clamped?

    [attachment=4622:Specular.png] I'm agree with this to reject negatives values......but my question was if i also should set to 0 values less than 0.7 Imagine in 2d xy my last scenario, to have a realistic comportment, i should reject values at left of y (negatives x => r.v between 0 and 0.7), because they represent a ray of light coming somewhere from x[-1...0],y[0...1] and having specular reflecting to x[-1...0],y[0...1] => since my normal is up vector all ray of light should have specular reflectance to x[0...1],y[0...1]? It's hard to explain :-) There is an image in attachment. It seems ok to see specular if camera is in orange area, but is it normal to have some in green area? It look nrealistic......
  9. Hi, I have a question about specular calculation (R.V). Imagine a light at -1,1,0 => the reflected vector V will be 1,1,0. A camera placed at 1,1,0 will have R.V = 0.9 => ok full specular. A camera placed at 0,1,0 will have R.V = 0.7 => ok less specular. A camera placed at -1,1,0 will have R.V = 0 => ok no specular. But a camera placed at -0.5,1,0 will have R.V = 0.3 => this is ok since i am in a range of +-45 of reflection angle but it seems to be a non sence since this means i have specular reflectance backward........ Should i reject RV that are not between 0.7 and 1? Thanks in advance for your help.
  10. YannikLambert

    Light pre-pass renderer + shadow map

    Yes the problem is no shadow at all. Light pre-pass is a a deffered rendering. Phase1 : Render Normal and depth map Phase 2-1 : Render shadows maps for every lights Phase 2-2 : Render the light map (here i try to merge with shadow map: if a vertex is occluded in shadow map, it should not recieve lighting) Phase 3 : Render materials using light map
  11. YannikLambert

    Light pre-pass renderer + shadow map

    Sorry, i have reformatted the code ;-)
  12. Hi, I'm having troubles for integrating shadows in LightMap generation phase. I'm using a cone mesh for generating lighting from SpotLight and i'm adding a ShadowMap generated from SpotLight point of view. Lighting work like a charm.....but not shadows Here is the code i'm using: // Calculate the 2D screenposition of a position vectorefloat2 PostProjToScreen(float4 position) { float2 screenPos = position.xy / position.w; return 0.5f * (float2(screenPos.x, -screenPos.y) + 1); } // Calculate the size of one half of a pixel, to convert // between texels and pixelsfloat2 HalfPixel() { return 0.5f / float2(ViewportWidth, ViewportHeight); } float SampleShadowDepthMap(float2 UV) { if (UV.x < 0 || UV.x > 1 || UV.y < 0 || UV.y > 1) return 1; return tex2D(ShadowDepthSampler, UV).r; } VertexShaderOutput SpotLightVertexShaderFunction(VertexShaderInput input) { VertexShaderOutput output; float4 worldPosition = mul(input.Position, World); float4x4 viewProjection = mul(View, Projection); output.Position = mul(worldPosition, viewProjection); output.Position3D = output.Position; return output; } float4 SpotLightPixelShaderFunction(VertexShaderOutput input) : COLOR0 { // Find the pixel coordinates of the input position in the depth // and normal textures float2 texCoord = PostProjToScreen(input.Position3D) + HalfPixel(); // Extract the depth for this pixel from the depth map float4 depth = tex2D(DepthSampler, texCoord); // Recreate the position with the UV coordinates and depth value float4 position; position.x = texCoord.x * 2 - 1; position.y = (1 - texCoord.y) * 2 - 1; position.z = depth.r; position.w = 1.0f; // Transform position from screen space to world space position = mul(position, InverseViewProjection); position.xyz /= position.w; // Extract the normal from the normal map and move from // 0 to 1 range to -1 to 1 range float4 normal = (tex2D(NormalSampler, texCoord) - .5) * 2; // Compute the attenuation float atten = ... // Compute the spot attenuation factor float spotAtten = ... // Get shadow float4x4 shadowViewProjection = mul(ShadowView, ShadowProjection); float4 ShadowPosition = mul(position, shadowViewProjection); float2 shadowTexCoord = PostProjToScreen(ShadowPosition) + ( 0.5f / float2(2048, 2048)); // 2048 is the sizr of she shadow texture float mapDepth = SampleShadowDepthMap(shadowTexCoord); // Depth of the position in shadow map float realDepth = ShadowPosition.z / 5000; // 5000 is the far plane of shadow map view // Depth of position from spot light view float shadow = 1; if (realDepth > mapDepth) shadow = 0; return SpotLightDiffuseColor * nDotl * atten * spotAtten * shadow; } =======> sorry for the previous post where formatting was lost ;-) I suspect the error coming from shadowTexCoord that i think i do njot well reconstruct... Do someone have any idea? Thanks in advance for your help.
  • 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!