float rough_q = roughness * roughness;
rough_q *= rough_q;
float denom = n_dot_h*n_dot_h*(rough_q-1)+1;
- // Scale by pi to get a result per steradian, suitable for integration
+ /* Scale by pi to normalize the total area of the microfacets as projected
+ to the macrosurface */
return rough_q/(PI*denom*denom);
}
};
inline unsigned get_type_size(DataType t) { return t&0xFF; }
-inline bool is_matrix(DataType t) { return (t>>14)&3; }
-inline bool is_vector(DataType t) { return !is_matrix(t) && ((t>>12)&3); }
+inline bool is_matrix(DataType t) { return t&0xC000; }
+inline bool is_vector(DataType t) { return !is_matrix(t) && (t&0x3000); }
GLenum get_gl_type(DataType);
DataType from_gl_type(GLenum);
compiler.compile(SL::Compiler::MODULE);
prepared_source = compiler.get_combined_glsl();
source_map = compiler.get_source_map();
+
#ifdef DEBUG
string diagnostics = compiler.get_diagnostics();
if(!diagnostics.empty())
add("weight", static_cast<void (Loader::*)(float, float, float)>(&Loader::weight));
add("weight", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::weight));
+ // Deprecated
add("vertex2", static_cast<void (Loader::*)(float, float)>(&Loader::vertex));
add("vertex3", static_cast<void (Loader::*)(float, float, float)>(&Loader::vertex));
add("vertex4", static_cast<void (Loader::*)(float, float, float, float)>(&Loader::vertex));
namespace Msp {
namespace GL {
-class Renderable;
class Resources;
/**
class Light;
class Resources;
-class Scene;
/**
-Creates shadows on a Scene through a shadow map texture. In the preparation
+Creates shadows on a renderable through a shadow map texture. In the setup
phase, the scene is rendered to a depth texture from the point of view of the
lightsource. This texture is then used in the rendering phase together with
texture coordinate generation to determine whether each fragment is lit.
#include <msp/io/seekable.h>
#include "builtin.h"
#include "parser.h"
-#include "visitor.h"
using namespace std;
-#ifndef MSP_GL_SL_COMPATIBILITY_H_
-#define MSP_GL_SL_COMPATIBILITY_H_
+#ifndef MSP_GL_SL_FINALIZE_H_
+#define MSP_GL_SL_FINALIZE_H_
#include <string>
#include "visitor.h"
namespace GL {
namespace SL {
+/** Assigns location and binding layout qualifiers to interface variables and
+blocks. */
class LocationAllocator: private TraversingVisitor
{
private:
namespace GL {
namespace SL {
+/** Determines the number of interface locations required by a variable. */
class LocationCounter: private NodeVisitor
{
private:
namespace GL {
namespace SL {
+/** Base class for validators. Contains some utilities for adding diagnostic
+messages. */
class Validator: protected TraversingVisitor
{
protected:
void add_info(Node &, const std::string &);
};
+/** Verifies that declarations are valid in isolation. */
class DeclarationValidator: private Validator
{
private:
virtual void visit(FunctionDeclaration &);
};
+/** Verifies that identifiers are unique or, in the case of functions, are
+overloaded only in valid ways. */
class IdentifierValidator: private Validator
{
private:
virtual void visit(FunctionDeclaration &);
};
+/** Verifies that there are no unresolved references. */
class ReferenceValidator: private Validator
{
public:
virtual void visit(FunctionDeclaration &);
};
+/** Verifies that expressions are valid. In most cases an invalid expression
+is indicated by a null result type. */
class ExpressionValidator: private Validator
{
private:
virtual void visit(Return &);
};
+/** Verifies that stage input and output interfaces are valid. Linked
+variables must have matching types and locations and there must not be any
+overlap in locations. */
class StageInterfaceValidator: private Validator
{
private:
virtual void visit(FunctionDeclaration &) { }
};
+/** Verifies that uniform interfaces are valid across the entire module.
+Variables declared with the same binding must have the same name and type. */
class GlobalInterfaceValidator: private Validator
{
private:
Represents a single instance of an Object. Thanks to being derived from
Placeable in can be positioned without additional effort. Other instance
parameters can be set by overriding the hook functions.
-
-ObjectInstances can benefit from being put in an InstanceScene, which will
-render all instances of the same object consecutively.
*/
class ObjectInstance: public PlacedRenderable
{
mutable ProgramMap programs;
mutable UniformBlock *last_block;
mutable Buffer *buffer;
- mutable unsigned dirty;
+ mutable Mask dirty;
public:
ProgramData(const Program * = 0);