Author Topic: [REQ] Skies  (Read 1428 times)

0 Members and 1 Guest are viewing this topic.

Offline JayFoxRox

  • Posts: 2221
    • View Profile
    • Homepage
[REQ] Skies
« on: November 10, 2007, 01:36:22 PM »
Howdie!

I just wrote some absolutly PWNGE skydome code, and it looks fucking realistic - even on the PSP (Just take a look at the screens and you'll see: this can keep up with most commercial software)!
I will definatly stick to this technique, however, I have problems with finding a good texture

 .

Would be great if any of you do such things or know someone doing this. I wasn't sure where to post this, but I think this is some kind of expression and most artists will look here.


Oh yeh, if anyone wants to use my code for the skydome in vegas or w/e, heres the code to generate the buffer:

Types:

Code: [Select]
Private Type iVertex
    X As Single
    Y As Single
    Z As Single
    U As Single
    V As Single
End Type
Dim vr_Sky() As iVertex

Generating:

Code: [Select]
sn_Radius = 100
in_Columns = 64
in_Rows = 10

ReDim vr_Sky(in_Rows * 2 * in_Columns * 3 - 1)
For in_Column = 0 To in_Columns - 1
    For in_Row = 0 To in_Rows - 1
        Dim in_Address As Integer
        in_Address = 0 + in_Row * 2 * in_Columns * 3 'Go to row
        in_Address = in_Address + in_Column * 2 * 3 'Go to object
                        
        vr_Sky(in_Address + 0).Y = Sin(RD(90 / in_Rows * (in_Row + 1))) * sn_Radius
        vr_Sky(in_Address + 1).Y = Sin(RD(90 / in_Rows * (in_Row + 0))) * sn_Radius
        vr_Sky(in_Address + 2).Y = Sin(RD(90 / in_Rows * (in_Row + 0))) * sn_Radius
        vr_Sky(in_Address + 3).Y = Sin(RD(90 / in_Rows * (in_Row + 1))) * sn_Radius
        vr_Sky(in_Address + 4).Y = Sin(RD(90 / in_Rows * (in_Row + 1))) * sn_Radius
        vr_Sky(in_Address + 5).Y = Sin(RD(90 / in_Rows * (in_Row + 0))) * sn_Radius
        
        vr_Sky(in_Address + 0).U = 1 / in_Columns * (in_Column + 0)
        vr_Sky(in_Address + 0).V = 1 - (1 / in_Rows * (in_Row + 1))
        vr_Sky(in_Address + 1).U = 1 / in_Columns * (in_Column + 0)
        vr_Sky(in_Address + 1).V = 1 - (1 / in_Rows * (in_Row + 0))
        vr_Sky(in_Address + 2).U = 1 / in_Columns * (in_Column + 1)
        vr_Sky(in_Address + 2).V = 1 - (1 / in_Rows * (in_Row + 0))
        vr_Sky(in_Address + 3).U = 1 / in_Columns * (in_Column + 0)
        vr_Sky(in_Address + 3).V = 1 - (1 / in_Rows * (in_Row + 1))
        vr_Sky(in_Address + 4).U = 1 / in_Columns * (in_Column + 1)
        vr_Sky(in_Address + 4).V = 1 - (1 / in_Rows * (in_Row + 1))
        vr_Sky(in_Address + 5).U = 1 / in_Columns * (in_Column + 1)
        vr_Sky(in_Address + 5).V = 1 - (1 / in_Rows * (in_Row + 0))
        
        vr_Sky(in_Address + 0).X = Sin(RD(360 / in_Columns * (in_Column + 0))) * sn_Radius / in_Rows * (in_Rows - in_Row - 1)
        vr_Sky(in_Address + 0).Z = Cos(RD(360 / in_Columns * (in_Column + 0))) * sn_Radius / in_Rows * (in_Rows - in_Row - 1)
        
        vr_Sky(in_Address + 1).X = Sin(RD(360 / in_Columns * (in_Column + 0))) * sn_Radius / in_Rows * (in_Rows - in_Row - 0)
        vr_Sky(in_Address + 1).Z = Cos(RD(360 / in_Columns * (in_Column + 0))) * sn_Radius / in_Rows * (in_Rows - in_Row - 0)
        
        vr_Sky(in_Address + 2).X = Sin(RD(360 / in_Columns * (in_Column + 1))) * sn_Radius / in_Rows * (in_Rows - in_Row - 0)
        vr_Sky(in_Address + 2).Z = Cos(RD(360 / in_Columns * (in_Column + 1))) * sn_Radius / in_Rows * (in_Rows - in_Row - 0)
                
        vr_Sky(in_Address + 3).X = Sin(RD(360 / in_Columns * (in_Column + 0))) * sn_Radius / in_Rows * (in_Rows - in_Row - 1)
        vr_Sky(in_Address + 3).Z = Cos(RD(360 / in_Columns * (in_Column + 0))) * sn_Radius / in_Rows * (in_Rows - in_Row - 1)
        
        vr_Sky(in_Address + 4).X = Sin(RD(360 / in_Columns * (in_Column + 1))) * sn_Radius / in_Rows * (in_Rows - in_Row - 1)
        vr_Sky(in_Address + 4).Z = Cos(RD(360 / in_Columns * (in_Column + 1))) * sn_Radius / in_Rows * (in_Rows - in_Row - 1)
    
        vr_Sky(in_Address + 5).X = Sin(RD(360 / in_Columns * (in_Column + 1))) * sn_Radius / in_Rows * (in_Rows - in_Row - 0)
        vr_Sky(in_Address + 5).Z = Cos(RD(360 / in_Columns * (in_Column + 1))) * sn_Radius / in_Rows * (in_Rows - in_Row - 0)

    Next in_Row
Next in_Column
Set dx_Sky = dx_Direct3DX.CreateTextureFromFile(dx_Device3D, "sky/day.bmp")

Rendering:

Code: [Select]
dx_Device3D.SetRenderState D3DRS_ZENABLE, 1
dx_Device3D.SetRenderState D3DRS_ZWRITEENABLE, 0
dx_Device3D.SetRenderState D3DRS_CULLMODE, D3DCULL_NONE
dx_Device3D.SetRenderState D3DRS_CLIPPING, 0
dx_Device3D.SetRenderState D3DRS_LIGHTING, 0
dx_Device3D.SetRenderState D3DRS_FILLMODE, D3DFILL_SOLID

dx_Device3D.SetTexture 0, dx_Sky

dx_Device3D.SetVertexShader D3DFVF_XYZ Or D3DFVF_TEX1
dx_Device3D.DrawPrimitiveUP D3DPT_TRIANGLELIST, (UBound(vr_Sky) + 1) / 3, vr_Sky(0), Len(vr_Sky(0))

dx_Device3D.SetRenderState D3DRS_ZWRITEENABLE, 1

dx_Device3D.SetTexture 0, Nothing

Other:

- dx_Device3D is the Direct3DDevice8
- dx_Direct3DX is the D3DX8
- RD makes a Radian from Degree (RD(x) = x * atn(1) * 4 / 180
- Sky might be mirrored on vertical axis
« Last Edit: November 10, 2007, 01:40:53 PM by Fox »

Offline Shifftee

  • Shiff
  • SASL 2014 Judges
  • *
  • Posts: 14076
  • Retired.
    • View Profile
[REQ] Skies
« Reply #1 on: November 10, 2007, 01:42:47 PM »
than those skys isnt real?
e.: i think my english suck a little bit
« Last Edit: November 10, 2007, 01:43:08 PM by SORT »

Offline Daffy

  • V.I.P. Member
  • Posts: 13506
  • WH & NU Founder
    • View Profile
[REQ] Skies
« Reply #2 on: November 10, 2007, 10:22:45 PM »
Could it be possible to have skies like that in VC/SA?

Offline jessrocked

  • Veteran Member
  • Posts: 3360
  • Victory Loves Preparation
    • View Profile
    • http://www.friendster.com/jessrocked
[REQ] Skies
« Reply #3 on: November 10, 2007, 10:29:25 PM »
Quote from: Daffy
Could it be possible to have skies like that in VC/SA?

x2

Offline GT-7

  • Posts: 3402
  • Old fart from the past
    • View Profile
[REQ] Skies
« Reply #4 on: November 11, 2007, 12:47:26 AM »
Woahw awesome =)

Offline JayFoxRox

  • Posts: 2221
    • View Profile
    • Homepage
[REQ] Skies
« Reply #5 on: November 11, 2007, 02:01:46 AM »
yes it is possible to have such skies in VC and SA - modelingman has some of his work in his sig. You have to write a SCM which places an selfmade sphere around the cam, or even better, hook the direct3d call for rendering the sky (its the only one with zwriteenable = false, and inject your own code)

However, this was meant as a request... :'(
Anyways, I found some new one myself:

http://www.philohome.com/skycollec/skycollec.htm (A bit wrong colored and sun on the sky isn't too good)
http://blenderartists.org/forum/showthread.php?t=24038 (No photos, good anyways)
http://www.marlinstudios.com/samples/samppano.htm (not free, but maybe I can get this one for christmas or something   )
« Last Edit: November 11, 2007, 02:03:33 AM by Fox »

Offline jessrocked

  • Veteran Member
  • Posts: 3360
  • Victory Loves Preparation
    • View Profile
    • http://www.friendster.com/jessrocked
[REQ] Skies
« Reply #6 on: November 11, 2007, 04:24:39 AM »
can you simplify things up


what should we add/replace/w/e in the vc files? the gta3.img?

Offline JayFoxRox

  • Posts: 2221
    • View Profile
    • Homepage
[REQ] Skies
« Reply #7 on: November 11, 2007, 07:35:19 AM »
Nah, its more complex, either make a dff from the dome and load it using object.dat and the SCM so its around the camera object all the time or create a loaded binary (*.dll, *.asi) which is injected into GTA's render engine (thats what I would do). Read Spookys Speedo tutorial/source and you'll get what I mean.

Offline jessrocked

  • Veteran Member
  • Posts: 3360
  • Victory Loves Preparation
    • View Profile
    • http://www.friendster.com/jessrocked
[REQ] Skies
« Reply #8 on: November 11, 2007, 06:06:41 PM »
Quote from: Fox
Nah, its more complex, either make a dff from the dome and load it using object.dat and the SCM so its around the camera object all the time or create a loaded binary (*.dll, *.asi) which is injected into GTA's render engine (thats what I would do). Read Spookys Speedo tutorial/source and you'll get what I mean.

i see... i think i get it somehow...

are u saying, the sky is only available inside the dome?
or ur saying, a dff file like a dome would be carried through out the game.. or is there?

well anyways, good luck... and share it to us once its done

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal