Seite 1 von 1

Schattenarten funktionieren nicht alle auf "einmal"

Verfasst: 23.07.2013 14:40
von Chimorin
Hey,

kennt jemand von euch auch das Phänomen, dass wenn die Schattenarten Modulative und Additive funktionieren, eine Umstellung auf TextureAdditive keine Schatten zur Folge hat? Anders herum habe ich es auch in einem Code (Welcher aber viel zu lang ist, um ihn zu posten).
Liegt das vllt an der unterschiedlichen Erstellungsreihenfolge Lichter, Entities, Schatten, Physik,... (Dürfte doch eig egal sein)?

Was micht auch stört, ist, dass man Schatten nicht abstellen kann. Ich werde demnächst für obiges Problem einen Code posten.

Re: Schattenarten funktionieren nicht alle auf "einmal"

Verfasst: 24.07.2013 11:45
von Chimorin
Kann mir jemand helfen? Ich komme nicht darauf, warum in diesem Beispiel gar kein Schatten angezeigt wird... Ich habe doch alles richtig gemacht?!

Das sollte eigentlich ein Beispiel werden, in dem entweder Modulative und Additive oder TextureAdditive Schatten funktionieren. Naja, es funktioniert nichts von allem.

Code: Alles auswählen

EnableExplicit

Define.i cube, light, cam, ground, cube_mesh, ground_mesh

InitEngine3D()
InitSprite()
InitKeyboard()

OpenScreen(1920, 1080, 32, "Test_0", #PB_Screen_SmartSynchronization)

cam = CreateCamera(#PB_Any, 0, 0, 100, 100)
MoveCamera(cam, 0, 20, 0, #PB_Absolute)
CameraLookAt(cam, 10, 0, 10)

;WorldShadows(#PB_Shadow_TextureAdditive, 100, RGB(255 * 0.2, 255 * 0.2, 255 * 0.2), 4096)
WorldShadows(#PB_Shadow_TextureAdditive, 100, RGB(0, 0, 0), 4096)

light = CreateLight(#PB_Any, RGB(255, 255, 255), 20, 10, 20, #PB_Light_Point)
AmbientColor(RGB(85,85,85))

cube_mesh = CreateCube(#PB_Any, 2)
BuildMeshShadowVolume(cube_mesh)
cube = CreateEntity(#PB_Any, MeshID(cube_mesh), 0, 10, 1, 10)

ground_mesh = CreatePlane(#PB_Any, 20, 20, 1, 1, 1, 1)
BuildMeshShadowVolume(ground_mesh)
ground = CreateEntity(#PB_Any, MeshID(ground_mesh), 0, 10, 0, 10)

Repeat
  ClearScreen(RGB(0, 0, 0))
  
  ExamineKeyboard()
  
  RenderWorld()
  FlipBuffers()
Until KeyboardReleased(#PB_Key_Escape)

End

Re: Schattenarten funktionieren nicht alle auf "einmal"

Verfasst: 25.07.2013 23:09
von Makke
Mit dem Punkt-Licht hatte ich auch immer Probleme. Probier mal das
Richtungs-Licht.

Re: Schattenarten funktionieren nicht alle auf "einmal"

Verfasst: 26.07.2013 10:18
von Chimorin
Funktioniert leider genauso wenig :D
Hast du schon einen Wunschthread im Englischen Forum bezüglich dem Ein und Ausschalten der Schatten erstellt?

Code: Alles auswählen

EnableExplicit

Define.i cube, light, cam, ground, cube_mesh, ground_mesh

InitEngine3D()
InitSprite()
InitKeyboard()

OpenScreen(1920, 1080, 32, "Test_0", #PB_Screen_SmartSynchronization)

cam = CreateCamera(#PB_Any, 0, 0, 100, 100)
MoveCamera(cam, 0, 20, 0, #PB_Absolute)
CameraLookAt(cam, 10, 0, 10)

;WorldShadows(#PB_Shadow_TextureAdditive, 100, RGB(255 * 0.2, 255 * 0.2, 255 * 0.2), 4096)
WorldShadows(#PB_Shadow_TextureAdditive, 100, RGB(0, 0, 0), 4096)

light = CreateLight(#PB_Any, RGB(255, 255, 255), 20, 10, 20, #PB_Light_Directional)
LightDirection(light, 0.4, -1, 0.2)
AmbientColor(RGB(85,85,85))

cube_mesh = CreateCube(#PB_Any, 2)
BuildMeshShadowVolume(cube_mesh)
cube = CreateEntity(#PB_Any, MeshID(cube_mesh), 0, 10, 1, 10)

ground_mesh = CreatePlane(#PB_Any, 20, 20, 1, 1, 1, 1)
BuildMeshShadowVolume(ground_mesh)
ground = CreateEntity(#PB_Any, MeshID(ground_mesh), 0, 10, 0, 10)

Repeat
  ClearScreen(RGB(0, 0, 0))
  
  ExamineKeyboard()
  
  RenderWorld()
  FlipBuffers()
Until KeyboardReleased(#PB_Key_Escape)

End

Re: Schattenarten funktionieren nicht alle auf "einmal"

Verfasst: 28.07.2013 09:10
von Makke
Hi,

ich habe Dein Bespiel mal erweitert, also die Entities werfen immer Schatten (siehe Beispiel) ausser anscheinend bei Texture-Additive, das wirft keinen Schatten. Die Funktion #PB_Entity_CastShadow ist also unnütz. Im englischen Forum habe ich das aber noch nicht geschrieben.

Hier das Beispiel, mit F1 die Schattenarten durchgehen:

Code: Alles auswählen

EnableExplicit

Define.f degree
Define.i x, y, tempTexture, tempMaterial, tempMesh, camera, light, entLight, entGround, entBall1, entCube1, entBall2, entCube2, shadowType = #PB_Shadow_Modulative

; init
InitEngine3D()
InitSprite()
InitKeyboard()

OpenWindow(0,0,0,1024,768,"Schatten - Modulative",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0), WindowHeight(0), 0, 0, 0, #PB_Screen_WaitSynchronization)

WorldShadows(shadowType, 500, RGB(32, 32, 32), 1024)
MaterialFilteringMode(#PB_Default, #PB_Material_Anisotropic, 8)

; create entity for light position
tempTexture = CreateTexture(#PB_Any, 1, 1)
StartDrawing(TextureOutput(tempTexture))
Plot(0,0,RGB(255,0,255))
StopDrawing()
tempMaterial = CreateMaterial(#PB_Any, TextureID(tempTexture))
MaterialBlendingMode(tempMaterial, #PB_Material_Phong)
tempMesh = CreateSphere(#PB_Any, 1)
entLight = CreateEntity(#PB_Any, MeshID(tempMesh), MaterialID(tempMaterial))

; create ground entity
tempTexture = CreateTexture(#PB_Any, 32, 32)
StartDrawing(TextureOutput(tempTexture))
Box(0,0,16,16,RGB(128,128,128))
Box(0,16,16,16,RGB(225,225,225))
Box(16,0,16,16,RGB(225,225,225))
Box(16,16,16,16,RGB(128,128,128))
For y = 0 To 31 Step 4
  For x = 0 To 31 Step 4
    If Random(1)
      Plot(x, y, RGB(128,128,128))
    EndIf
  Next
Next
For y = 0 To 31 Step 4
  For x = 0 To 31 Step 4
    If Random(1)
      Plot(x, y, RGB(225,225,225))
    EndIf
  Next
Next
StopDrawing()
tempMaterial = CreateMaterial(#PB_Any, TextureID(tempTexture))
MaterialShadingMode(tempMaterial, #PB_Material_Phong)
tempMesh = CreatePlane(#PB_Any, 100, 100, 1, 1, 1, 1)
entGround = CreateEntity(#PB_Any, MeshID(tempMesh), MaterialID(tempMaterial), 0, 0, 0)

; create shadowcaster entities
tempTexture = CreateTexture(#PB_Any, 32, 32)
StartDrawing(TextureOutput(tempTexture))
Box(0,0,8,32,RGB(154,205,50))
Box(8,0,8,32,RGB(255,215,0))
Box(16,0,8,32,RGB(154,205,50))
Box(24,0,8,32,RGB(255,215,0))
StopDrawing()
tempMaterial = CreateMaterial(#PB_Any, TextureID(tempTexture))
MaterialShadingMode(tempMaterial, #PB_Material_Phong)
tempMesh = CreateSphere(#PB_Any, 5)
entBall1 = CreateEntity(#PB_Any, MeshID(tempMesh), MaterialID(tempMaterial), -20, 10, -20)
entBall2 = CreateEntity(#PB_Any, MeshID(tempMesh), MaterialID(tempMaterial), 20, 10, 20)
EntityRenderMode(entBall2, #PB_Entity_CastShadow)

tempTexture = CreateTexture(#PB_Any, 32, 32)
StartDrawing(TextureOutput(tempTexture))
Box(0,0,16,16,RGB(70,130,180))
Box(0,15,16,16,RGB(255,69,0))
Box(15,0,16,16,RGB(70,130,180))
Box(15,15,16,16,RGB(255,69,0))
StopDrawing()
tempMaterial = CreateMaterial(#PB_Any, TextureID(tempTexture))
MaterialShadingMode(tempMaterial, #PB_Material_Phong)
tempMesh = CreateCube(#PB_Any, 10)
entCube1 = CreateEntity(#PB_Any, MeshID(tempMesh), MaterialID(tempMaterial), -20, 10, 20)
entCube2 = CreateEntity(#PB_Any, MeshID(tempMesh), MaterialID(tempMaterial), 20, 10, -20)
EntityRenderMode(entCube2, #PB_Entity_CastShadow)

; create light
light = CreateLight(#PB_Any, RGB(225, 225, 225), 0, 100, 50, #PB_Light_Directional)
LightLookAt(light, 0,0,0)

; create camera
camera = CreateCamera(#PB_Any, 0, 0, 100, 100)
MoveCamera(camera, 0, 75, 50, #PB_Absolute)
CameraLookAt(camera, 0, 0, 0)

AmbientColor(RGB(64,64,64))

FreeMesh(tempMesh)
FreeMaterial(tempMaterial)
FreeTexture(tempTexture)

Repeat
  
  While WindowEvent() : Wend
  
  ExamineKeyboard()
  
  ; switch shadow type
  If KeyboardReleased(#PB_Key_F1)
    If shadowType = #PB_Shadow_Modulative
      shadowType = #PB_Shadow_Additive
      SetWindowTitle(0, "Schatten - Additive")
    ElseIf shadowType = #PB_Shadow_Additive
      shadowType = #PB_Shadow_TextureAdditive
      SetWindowTitle(0, "Schatten - TextureAdditive")
    ElseIf shadowType = #PB_Shadow_TextureAdditive
      shadowType = #PB_Shadow_None
      SetWindowTitle(0, "Schatten - None")
    ElseIf shadowType = #PB_Shadow_None
      shadowType = #PB_Shadow_Modulative
      SetWindowTitle(0, "Schatten - Modulative")
    EndIf
    WorldShadows(shadowType, 500, RGB(32, 32, 32), 1024)
  EndIf
  
  ; move light
  degree + 0.5
  If degree >= 360
    degree - 360
  EndIf
  x = 40 * Cos(Radian(degree))
  y = 40 * Sin(Radian(degree))
  MoveLight(light, x, 30, y, #PB_Absolute)
  LightLookAt(light, 0,0,0)
  MoveEntity(entLight, LightX(light), LightY(light), LightZ(light), #PB_Absolute)
  
  RenderWorld()
  FlipBuffers()
  
Until KeyboardReleased(#PB_Key_Escape)

End

Re: Schattenarten funktionieren nicht alle auf "einmal"

Verfasst: 28.07.2013 09:11
von Chimorin
Es gibt eine Konstante, welche den Wert "0" trägt. Diese steht für sowas wie: #PB_Entity_ReceiveShadow (Einfach 0 in EntityRenderMode() rein)

PointLights funktionieren nicht so gut mit TextureAdditive Schatten, liegt an OGRE.

Die restlichen Schattenbugs sind schon gefixt worden.