I try your hint, but get no appreciable results.
tomorrow, if I have time, I'll send you a image of the rendering, but consider view only the surrounding box that track the current brick under mouse cursor and the grid if you click on a brick (or part)
this means that positioning calculation is correct but something goes wrong probably in matrices.
here is a the part of my code that performs rendering:
have a look. hope is not too complex...
--------------------------------------------------
F = Effect.FromFile(DV, AppPath & "\BFL3.txt", Nothing, "", ShaderFlags.SkipValidation Or ShaderFlags.PreferFlowControl, EP, s)
If s <> "" Then
MsgBox("Effect Shader Compilation ERROR:" & s, MsgBoxStyle.Critical, AppName)
End
End If
hW = F.GetParameter(Nothing, "mWorld")
hWP = F.GetParameter(Nothing, "mWorldP")
hC = F.GetParameter(Nothing, "CameraPos")
hD = F.GetParameter(Nothing, "Diffuse")
SP = F.GetParameter(Nothing, "Specular")
SH = F.GetParameter(Nothing, "Shiness")
Tec1 = F.GetTechnique("TAndLV")
F.Technique = Tec1
F.CommitChanges()
--------------------------------------------------
If IsRendering Then Exit Sub
IsRendering = True
If Environment.TickCount - T > 1000 Then
If FrameRT > 0 Then RaiseEvent FPSChange(FrameRT / (Environment.TickCount - T) * 1000)
T = Environment.TickCount
FrameRT = 0
End If
DV.Clear(ClearFlags.ZBuffer + ClearFlags.Target, BCKc, 1.0F, 1)
'mW = World Transformation Matrix
'mWIT = Inverse-Transposed of M (for Normal Management)
F.SetValue(hC, vLookFrom4)
'Begin Scene
F.Begin(FX.None)
F.BeginPass(0)
DV.BeginScene()
'Render all bricks/block - First Solid...
For j = UBound(Block) To 0 Step -1
If Block(j).NBrick > 0 Then
mWIT = Matrix.Multiply(Block(j).mTrans, mWorld)
mWIT.Multiply(mView)
mW = Matrix.Multiply(mWIT, mProj)
mWIT.Invert()
mWIT.Transpose(mWIT)
F.SetValue(hWP, mW)
F.SetValue(hW, mWIT)
F.CommitChanges()
RenderSolid(j)
End If
Next
DV.EndScene()
F.EndPass()
F.End()
DV.Present()
FrameRT += 1
IsRendering = False
--------------------------------------------------
Private Sub RenderSolid(ByVal j As Integer)
Dim i As Integer
For i = 0 To UBound(Block(j).SubBl)
With Block(j).SubBl(i)
If .Color > -1 And Not IsNothing(.VB) Then
If (ColArr(.Color).Col.Alpha = 1 And j > 0) Then
F.SetValue(SH, ColArr(.Color).Shiness)
F.SetValue(SP, ColArr(.Color).Specular)
F.SetValue(hD, ColArr(.Color).Col)
F.CommitChanges()
#If Debug And shw Then
If i = 0 Then
If .N4.Length > 1 Then
DV.SetStreamSource(0, .NB, 0, sV3)
DV.DrawPrimitives(PrimitiveType.LineList, 0, (.N4.Length - 1) / 2)
End If
End If
#End If
If .iasVB.Length > 1 Then
DV.SetStreamSource(0, .sVB, 0, sCV)
DV.Indices = .isVB
DV.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, .iasVB.Length - 1, 0, (.iasVB.Length - 1) / 3)
End If
If .iaVB.Length > 1 Then
DV.SetStreamSource(0, .VB, 0, sCV)
DV.Indices = .iVB
DV.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, (.iaVB.Length - 1), 0, (.iaVB.Length - 1) / 3)
End If
ElseIf j = 0 And Block(0).NBrick = 1 And ColArr(.Color).Col.Alpha <> 1 Then
DV.RenderState.AlphaBlendEnable = True
F.SetValue(SH, ColArr(.Color).Shiness)
F.SetValue(SP, ColArr(.Color).Specular)
F.SetValue(hD, ColArr(.Color).Col)
F.CommitChanges()
#If Debug And shw Then
If i = 0 Then
If .N4.Length > 1 Then
DV.SetStreamSource(0, .NB, 0, sV3)
DV.DrawPrimitives(PrimitiveType.LineList, 0, (.N4.Length - 1) / 2)
End If
End If
#End If
If .iasVB.Length > 1 Then
DV.SetStreamSource(0, .sVB, 0, sCV)
DV.Indices = .isVB
DV.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, .iasVB.Length - 1, 0, (.iasVB.Length - 1) / 3)
End If
If .iaVB.Length > 1 Then
DV.SetStreamSource(0, .VB, 0, sCV)
DV.Indices = .iVB
DV.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, (.iaVB.Length - 1), 0, (.iaVB.Length - 1) / 3)
End If
DV.RenderState.AlphaBlendEnable = False
End If
End If
End With
Next
End Sub
--------------------------------------------------
[quote="gads"]
Sorry about the confusion!
When I said "Error" I mean the incorrect rendering. I was asking for a screenshot that shows the problem you are describing
For example, you have
OUT.DL = Diffuse * LightDColor * dot(N, LightDir);
Try instead
OUT.DL = Diffuse * LightDColor * float4(dot(N, LightDir), 1);
It's a long shot, but at least this way you confirm that alpha it's correct.
[/quote]