42 lines
		
	
	
		
			832 B
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			42 lines
		
	
	
		
			832 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| 
								 | 
							
								package uniform
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import (
							 | 
						||
| 
								 | 
							
									"fmt"
							 | 
						||
| 
								 | 
							
									"unsafe"
							 | 
						||
| 
								 | 
							
									"zworld/engine/renderapi/color"
							 | 
						||
| 
								 | 
							
									"zworld/plugins/math/mat4"
							 | 
						||
| 
								 | 
							
									"zworld/plugins/math/vec4"
							 | 
						||
| 
								 | 
							
								)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								type Light struct {
							 | 
						||
| 
								 | 
							
									ViewProj  [4]mat4.T
							 | 
						||
| 
								 | 
							
									Shadowmap [4]uint32
							 | 
						||
| 
								 | 
							
									Distance  [4]float32
							 | 
						||
| 
								 | 
							
									Color     color.T
							 | 
						||
| 
								 | 
							
									Position  vec4.T
							 | 
						||
| 
								 | 
							
									Type      uint32
							 | 
						||
| 
								 | 
							
									Intensity float32
							 | 
						||
| 
								 | 
							
									Range     float32
							 | 
						||
| 
								 | 
							
									Falloff   float32
							 | 
						||
| 
								 | 
							
									_padding  float32
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								type LightSettings struct {
							 | 
						||
| 
								 | 
							
									AmbientColor       color.T
							 | 
						||
| 
								 | 
							
									AmbientIntensity   float32
							 | 
						||
| 
								 | 
							
									Count              int32
							 | 
						||
| 
								 | 
							
									ShadowSamples      int32
							 | 
						||
| 
								 | 
							
									ShadowSampleRadius float32
							 | 
						||
| 
								 | 
							
									ShadowBias         float32
							 | 
						||
| 
								 | 
							
									NormalOffset       float32
							 | 
						||
| 
								 | 
							
									_padding           [75]float32
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								func init() {
							 | 
						||
| 
								 | 
							
									lightSz := unsafe.Sizeof(Light{})
							 | 
						||
| 
								 | 
							
									settingSz := unsafe.Sizeof(LightSettings{})
							 | 
						||
| 
								 | 
							
									if lightSz != settingSz {
							 | 
						||
| 
								 | 
							
										panic(fmt.Sprintf("Light (%d) and LightSetting (%d) must have equal size", lightSz, settingSz))
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								}
							 |