Textures Map

Blitz3D Forums/Blitz3D Beginners Area/Textures Map

Mr. Slat(Posted 2010) [#1]
Ok so this could be usefull to a lot of developers here...
I'm now Trying to give that little "extra" to my game, so I Have these textures "s_COLOR.Png","s_Normal.Png","s_OCC.Png","s_SPEC.Png","s_DISP.Png" made by CrazyBump, and I'm trying to put them all together to give me those really nice looking models.

the s_DISP.png no question
the s_Color.Png is the diffuse texture no question there
I've already rewriten a code on normal bump maps, so no problem here. My question is, What exactly am I supposed to do with the other textures? And how to properly used them....


Oiduts Studios(Posted 2010) [#2]
I've already rewriten a code on normal bump maps


I'm guessing you have Fast extension then because that is one of the only ways to this in Blitz.

The OCC is for ambient occlusion, there is some code in the archives (http://www.blitzbasic.com/codearcs/codearcs.php?code=2517)
but I am not sure how to apply them exactly,(probably with blend modes).

The SPEC is for Specular bump mapping,shiny stuff. (http://www.blitzbasic.com/Community/posts.php?topic=84519). Go down to post 17 and Vonderman has a good example

You are kind of limited with DirectX 7 though, you won't get those amazing results as in modern games because that requires shaders. But you can achieve something close to it.


Mr. Slat(Posted 2010) [#3]
no

Type DLight
Field Entity,Intensity#,x#,y#,z#,Pitch#,Yaw#,Roll#
Field LightType
End Type

Type TextureMap
Field Entity
Field Diffuse,Normal
End Type

Function CreateTextureMap(Entity,DiffuseTex$,NormalTex$)
TM.TextureMap=New TextureMap
TM\Entity=Entity:TM\Diffuse=LoadTexture(DiffuseTex$,1+8):TM\Normal=LoadTexture(NormalTex$,1+8)
EntityFX(TM\Entity,1+2):TextureBlend(TM\Normal,4)
EntityTexture(TM\Entity,TM\Normal,0,0):EntityTexture(TM\Entity,TM\Diffuse,0,1)
End Function

Function UpdateBumpNormals(mesh,light,lighttype=0)
EP=GetParent(mesh):n_surf=CountSurfaces(mesh)
For srf=1 To n_surf
surf=GetSurface(mesh,srf):n_vert=CountVertices(surf)-1
For v=0 To n_vert
red2#=0:grn2#=0:blu2#=0
For d3l.DLight=Each DLight
lx#=EntityX(d3l\Entity,True):ly#=EntityY(d3l\Entity,True):lz#=EntityZ(d3l\Entity,True)
If(d3l\LightType=1)Then;Directional light
TFormVector 0,0,1,d3l\Entity,0
nx#=TFormedX():ny#=TFormedY():nz#=TFormedZ()
TFormNormal VertexNX(surf,v),VertexNY(surf,v),VertexNZ(surf,v),mesh,0
red#=TFormedX():grn#=TFormedY():blu#=TFormedZ()
ElseIf(d3l\LightType=2)Then;Point light
TFormNormal VertexNX(surf,v),VertexNY(surf,v),VertexNZ(surf,v),mesh,0
Vnx#=TFormedX():Vny#=TFormedY():Vnz#=TFormedZ()
TFormPoint VertexX(surf,v),VertexY(surf,v),VertexZ(surf,v),mesh,0
Lvx#=lx-TFormedX():Lvy#=ly-TFormedY():Lvz#=lz-TFormedZ()
d#=Sqr(Lvx*Lvx+Lvy*Lvy+Lvz*Lvz):Lvx=Lvx/d:Lvy=Lvy/d:Lvz=Lvz/d
End If:dot#=(Lvx*Vnx + Lvy*Vny + Lvz*Vnz)
If(dot<0.0)Then dot#=0
If(EP)Then
TFormNormal Lvx,Lvy,Lvz,0,EP:Lvx#=TFormedX():Lvy#=TFormedY():Lvz#=TFormedZ()
End If:red#=((1.1+(Lvx*dot))*127)*d3l\Intensity#:grn#=((1.1+(Lvy*dot))*120)*d3l\Intensity#:blu#=((1.1+(-Lvz*dot))*127)*d3l\Intensity#:red2#=red2+red:grn2#=grn2+grn:blu2#=blu2+blu
Next:VertexColor surf,v,red2,grn2,blu2
Next
Next
End Function

Function DCreateLight(LightType=1,parent=0,Intensity#=1.0,real=True)
d3l.DLight=New DLight:If(real)Then
d3l\Entity=CreateLight(LightType,parent):LightRange d3l\Entity,50
Else:d3l\Entity=CreatePivot(parent):End If
d3l\LightType=LightType:d3l\Intensity#=Intensity#:NameEntity(d3l\Entity,Handle(d3l)):Return d3l\Entity
End Function

Function DLightRange(Entity,range#)
If((Entity)<>0)Then:d3l.Dlight=Object.DLight(EntityName(Entity))
If(Handle(d3l))Then
If Lower$(EntityClass(d3l\Entity))="light"
LightRange d3l\Entity,range
EndIf
EndIf
EndIf
End Function

Function DLightIntensity(Entity,Intensity#)
If((Entity)<>0)Then:d3l.Dlight=Object.DLight(EntityName(Entity))
If(Handle(d3l))Then
d3l\Intensity#=Intensity:If Lower$(EntityClass(d3l\Entity))="light"
LightColor d3l\Entity,d3l\Intensity#*255.0,d3l\Intensity#*255.0,d3l\Intensity#*255.0
EndIf
EndIf
EndIf
End Function

Function PositionDLight(Entity,x#,y#,z#)
If((Entity)<>0)Then
d3l.Dlight=Object.DLight(EntityName(Entity))
If(Handle(d3l))Then
If Lower$(EntityClass(d3l\Entity))="light"
d3l\x#=x#:d3l\y#=y#:d3l\z#=z#:PositionEntity(d3l\Entity,d3l\x#,d3l\y#,d3l\z#)
EndIf
EndIf
EndIf
End Function

Function RotateDLight(Entity,Pitch#,Yaw#,Roll#)
If((Entity)<>0)Then
d3l.Dlight=Object.DLight(EntityName(Entity))
If(Handle(d3l))Then
If Lower$(EntityClass(d3l\Entity))="light"
d3l\Pitch#=Pitch#:d3l\Yaw#=Yaw#:d3l\Roll#=Roll#:RotateEntity(d3l\Entity,d3l\Pitch#,d3l\Yaw#,d3l\Roll#)
EndIf
EndIf
EndIf
End Function

Function DeleteDLight(Entity)
If((Entity)<>0)Then
d3l.Dlight=Object.DLight(EntityName(Entity))
If(Handle(d3l))Then
FreeEntity d3l\Entity:Delete d3l
EndIf
EndIf
End Function

Function DeleteDLights()
For d3l.DLight=Each DLight
FreeEntity d3l\Entity:Delete D3l
Next:Delete Each DLight
End Function





I wanted to make all texture coding here like I have this one...
any help?