simples Bumpmapping (Dot3)

Übersicht BlitzBasic Codearchiv

Neue Antwort erstellen

Hakkai

Betreff: simples Bumpmapping (Dot3)

BeitragSo, Jul 01, 2012 15:29
Antworten mit Zitat
Benutzer-Profile anzeigen
Hier ein kleines Beispiel zum Dot3 Bumpmapping (simpel)

ohne Bump:
user posted image

normales Bump:
user posted image

übertriebenes Bump:
user posted image

Archiv:
http://www2.htw-dresden.de/~s6...teBump.rar

Würde mich um Rückmeldung freuen ob mit Blitz3D in der Richtung noch mehr geht, bei akzeptabler Geschwindigkeit. Specular Lights oder der gleichen wären ganz gut.

Der Code noch:
BlitzBasic: [AUSKLAPPEN]
Const screenW = 1024, screenH = 768, screenD = 32, screenM = 2

Graphics3D screenW, screenH, screenD, screenM
SetBuffer BackBuffer()
AppTitle "Weltkarte Bump"
Local Timer = CreateTimer(60)

;Globals
Global CenterPivotLight = CreatePivot() ;für LichtRotation
Global CenterPivotCamRotY = CreatePivot() ;für CameraRotation um X
Global CenterPivotCamRotX= CreatePivot(CenterPivotCamRotY) ;für CameraRotation um Y
Global RadiusPivotCam = CreatePivot(CenterPivotCamRotX) ;für OrbitBewegung der Cam
MoveEntity RadiusPivotCam, 0, 0, -10 ;Entfernung Erde <-> Cam

Local Light=CreateLight(1, CenterPivotLight) ;Sonne
MoveEntity Light, 0, 0, -5 ;Entfernung Sonne <-> Erde

Local Camera=CreateCamera(RadiusPivotCam)
Global switchTextures = 0, switchBump, switchColor, switchTagNachtWechsel = 0

;IMGs
Local ImgWelt = LoadImage("136054main_bm1024_072004.bmp")
Local ImgBump = LoadImage("136054main_bm1024bump_072004.bmp")
Local TexWelt = LoadTexture("136054main_bm1024_072004.bmp")
Local TexBump = LoadTexture("136054main_bm1024bump_072004.bmp")
ResizeImage ImgWelt, 100, 100
ResizeImage ImgBump, 100, 100

;Meshes
Local Welt = CreateSphere(20)
ScaleEntity Welt, 5, 5, 5
EntityTexture Welt, TexBump, 0, 0 ;Zeichne Bump zuerst
EntityTexture Welt, TexWelt, 0, 1 ;Zeichne dannach das Farbbild
TextureBlend TexBump, 4 ;dot3
TextureBlend TexWelt, 2 ;multiply

;Initials
HidePointer

Repeat
If KeyHit(2) Then
switchTextures = (switchTextures +1) Mod 5

Select switchTextures
Case 0: switchBump = 4: switchColor = 5
Case 1: switchBump = 5: switchColor = 2
Case 2: switchBump = 1: switchColor = 0
Case 3: switchBump = 0: switchColor = 1
Case 4: switchBump = 4: switchColor = 2
End Select

TextureBlend TexBump, switchBump
TextureBlend TexWelt, switchColor
EndIf

If KeyHit(3) Then
switchTagNachtWechsel = Abs(switchTagNachtWechsel - 1)
If switchTagNachtWechsel = 0 Then PositionEntity Light, 0, 0, 0, 1: RotateEntity CenterPivotLight, 0, 0, 0 Else RotateEntity Light, 0, 0, 0
EndIf
If switchTagNachtWechsel = 1 Then
TurnEntity CenterPivotLight, 0, .5, 0
Else
PositionEntity Light, EntityX(RadiusPivotCam,1), EntityY(RadiusPivotCam,1), EntityZ(RadiusPivotCam,1), 1
PointEntity Light, Welt
EndIf

;3D
PositionEntity Welt,0,0,0
TurnEntity Welt,0,.1,0

TurnEntity CenterPivotCamRotX, MouseYSpeed(), 0, 0
TurnEntity CenterPivotCamRotY, 0, -MouseXSpeed(), 0
MoveMouse screenW/2, screenH/2

UpdateWorld()
RenderWorld()

;2D
DrawImage ImgBump, screenW-100, 0
DrawImage ImgWelt, screenW-100, 100
Color 250, 10, 200
Text screenW-StringWidth("mode: X "), 0, "mode: " + switchBump
Text screenW-StringWidth("mode: X "), 100, "mode: " + switchColor
Text 0, 0, "1 - BlendStatusWechsel: " + switchTextures
Text 0, 10, "2 - TagNachtWechsel: " + switchTagNachtWechsel

Color 255,255,255

WaitTimer(Timer)
Flip(0)
Cls
Until KeyHit(1)
End

aMul

Sieger des Minimalist Compo 01/13

BeitragSo, Jul 01, 2012 16:20
Antworten mit Zitat
Benutzer-Profile anzeigen
Specular light gibt es in B3D in der Tat: EntityShininess
(In meinen Test kein Einfluss auf Performance.)

Ansonsten gibt es natürlich noch viele Tricks/Hacks die man benutzen kann.
Zum Beispiel sowas: *werbung*
https://www.blitzforum.de/foru...hp?t=28298

Gibt sicher noch einige andere Sachen die man machen kann, mit ein bisschen innovativem out-of-the-box Denken.
Panic Pong - ultimate action mashup of Pong and Breakout <= aktives Spiele-Projekt, Downloads mit vielen bunten Farben!
advASCIIdraw - the advanced ASCII art program <= aktives nicht-Spiele-Projekt, must-have für ASCII/roguelike/dungeon-crawler fans!
Alter BB-Kram: ThroughTheAsteroidBelt - mit Quelltext! | RGB-Palette in 32²-Textur / Farbige Beleuchtung mit Dot3 | Stereoskopie in Blitz3D | Teleport-Animation Screensaver

Neue Antwort erstellen


Übersicht BlitzBasic Codearchiv

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group