To run this simple example you'll need two images:
(Place them inside a folder named 'texture')
protuberance.jpg - Search the net for streaks
sun.jpg - search the net for a round image of the sun.
Now save the following script to a folder named 'scripts'
filename: sunmaterial.material
Edit: changed the script and code a bit.
Code: Select all
material wobbleFlare
{
technique
{
pass
{
ambient 1 1 1
diffuse 0.9 0.9 1.0
scene_blend add
texture_unit
{
texture sun.jpg
colour_op replace
}
texture_unit
{
texture protuberance.jpg
colour_op add
wave_xform scale_x sine 0.99 0.07 0.09 0.8
wave_xform scale_y sine 0.9 0.05 0.05 0.89
wave_xform rotate sine 0.8 0.01 0.01 0.2
}
texture_unit
{
texture protuberance.jpg
rotate 60
colour_op add
wave_xform scale_x sine 0.9 0.08 0.02 0.9
wave_xform scale_y sine 0.85 0.07 0.03 0.8
wave_xform rotate sine 0.9 -0.01 -0.01 0.2
}
}
}
}
Code: Select all
;Simulate the sun and stars using billboards
;I thought I'd show you an easy way to simulate the sun with active protuberances.
;Example by DK_Peter
InitEngine3D()
InitSprite()
InitMouse()
InitKeyboard()
UseJPEGImageDecoder()
Procedure.f RandomF(min.f, Max.f, Res.i = 100000)
ProcedureReturn (Min + (Max - Min) * Random(Res) / Res)
EndProcedure
Global Quit.i = 0
OpenWindow(0, 0, 0, 1024, 768, "Simulate the sun", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0), 0, 0, 1024, 768, #False, 0, 0)
Add3DArchive("texture", #PB_3DArchive_FileSystem)
Add3DArchive("scripts", #PB_3DArchive_FileSystem)
Parse3DScripts()
CreateCamera(0, 0, 0, 100, 100)
;alternative to skybox()
CreateTexture(0, 7, 7)
StartDrawing(TextureOutput(0))
Circle(3, 3, 2, $FFFFFF)
StopDrawing()
CreateMaterial(0, TextureID(0))
MaterialBlendingMode(0, #PB_Material_Add)
DisableMaterialLighting(0, #True)
CreateBillboardGroup(0, MaterialID(0), 6, 6, 0, 0, -1000)
For p = 0 To 3000
AddBillboard(0, RandomF(-10000, 10000), RandomF(-10000, 10000), RandomF(-10000, 10000))
Next p
;sun
GetScriptMaterial(1, "wobbleFlare")
CreateBillboardGroup(1, MaterialID(1), 400, 400, 0, 0, 0)
AddBillboard(1, 0, 20, -3000)
Repeat
Repeat
ev = WindowEvent()
If ev = #PB_Event_CloseWindow : Quit = 1 : EndIf
Until ev = 0
ExamineMouse()
RotateCamera(0, MouseDeltaY() * 0.03, -MouseDeltaX() * 0.03, 0, #PB_Relative)
RenderWorld()
ExamineKeyboard()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
